2000-12-08 03:42:29 +01:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* cffload.c */
|
|
|
|
/* */
|
2001-12-05 02:22:05 +01:00
|
|
|
/* OpenType and CFF data/program tables loader (body). */
|
2000-12-08 03:42:29 +01:00
|
|
|
/* */
|
2016-01-13 11:54:10 +01:00
|
|
|
/* Copyright 1996-2016 by */
|
2000-12-08 03:42:29 +01:00
|
|
|
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
|
|
|
/* */
|
|
|
|
/* This file is part of the FreeType project, and may only be used, */
|
* builds/win32/detekt.mk: Fix .PHONY target for Intel compiler.
Renamed "ftnames.h" to "ftsnames.h", and FT_NAMES_H to
FT_SFNT_NAMES_H.
* docs/docmaker.py: Added generation of INDEX link in table of
contents.
* INSTALL, docs/BUILD: Updated documentation to indicate that the
compilation process has changed slightly (no more `src' required in
* builds/*/*-def.mk: Changed the objects directory from "obj" to
"objs".
* include/freetype/config/ftheader.h: Removed obsolete macros like
FT_SOURCE_FILE, etc. and added cache-specific macro definitions that
were previously defined in <freetype/ftcache.h>. Added comments to
be included in a new API Reference section.
* src/*/*: Removed the use of FT_SOURCE_FILE, etc. Now, each
component needs to add its own directory to the include path at
compile time. Modified all "rules.mk" and "descrip.mms"
accordingly.
* src/cid/cidobjs.c, src/cid/cidload.c, src/pcf/pcfread.c,
src/type1/t1load.c, src/type1/t1objs.c: Added a few casts to remove
compiler warnings in pedantic modes.
* include/config/ft2build.h, include/config/ftheader.h: The file
top-level <ft2build.h>.
* include/config/ftheader.h: Added new section describing the #include
macros.
the Type 2 glyph charstring (used by conversion programs).
* docs/docmaker.py: Added cross-references generation as well as
seac emulation provided by the Type 2 endchar operator.
* src/cid/cidafm.c, src/cid/cidafm.h: removed un-needed files,
Added support for clipped direct rendering in the smooth renderer.
* src/cff/t2objs.c (T2_Init_Face): For pure CFF fonts, set
2001-03-20 23:58:56 +01:00
|
|
|
/* modified, and distributed under the terms of the FreeType project */
|
2000-12-08 03:42:29 +01:00
|
|
|
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
|
|
|
/* this file you indicate that you have read the license and */
|
|
|
|
/* understand and accept it fully. */
|
|
|
|
/* */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
#include <ft2build.h>
|
|
|
|
#include FT_INTERNAL_DEBUG_H
|
|
|
|
#include FT_INTERNAL_OBJECTS_H
|
|
|
|
#include FT_INTERNAL_STREAM_H
|
|
|
|
#include FT_TRUETYPE_TAGS_H
|
2007-01-13 15:01:36 +01:00
|
|
|
#include FT_TYPE1_TABLES_H
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2016-12-16 11:15:17 +01:00
|
|
|
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
|
|
|
|
#include FT_MULTIPLE_MASTERS_H
|
|
|
|
#include FT_SERVICE_MULTIPLE_MASTERS_H
|
|
|
|
#endif
|
|
|
|
|
2001-03-20 12:14:24 +01:00
|
|
|
#include "cffload.h"
|
|
|
|
#include "cffparse.h"
|
2000-12-08 03:42:29 +01:00
|
|
|
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
#include "cfferrs.h"
|
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
#define FT_FIXED_ONE ( (FT_Fixed)0x10000 )
|
|
|
|
|
|
|
|
|
2001-12-20 14:14:18 +01:00
|
|
|
#if 1
|
2008-04-13 07:55:36 +02:00
|
|
|
|
2001-12-20 14:14:18 +01:00
|
|
|
static const FT_UShort cff_isoadobe_charset[229] =
|
|
|
|
{
|
2007-01-05 11:51:56 +01:00
|
|
|
0, 1, 2, 3, 4, 5, 6, 7,
|
|
|
|
8, 9, 10, 11, 12, 13, 14, 15,
|
|
|
|
16, 17, 18, 19, 20, 21, 22, 23,
|
|
|
|
24, 25, 26, 27, 28, 29, 30, 31,
|
|
|
|
32, 33, 34, 35, 36, 37, 38, 39,
|
|
|
|
40, 41, 42, 43, 44, 45, 46, 47,
|
|
|
|
48, 49, 50, 51, 52, 53, 54, 55,
|
|
|
|
56, 57, 58, 59, 60, 61, 62, 63,
|
|
|
|
64, 65, 66, 67, 68, 69, 70, 71,
|
|
|
|
72, 73, 74, 75, 76, 77, 78, 79,
|
|
|
|
80, 81, 82, 83, 84, 85, 86, 87,
|
|
|
|
88, 89, 90, 91, 92, 93, 94, 95,
|
|
|
|
96, 97, 98, 99, 100, 101, 102, 103,
|
|
|
|
104, 105, 106, 107, 108, 109, 110, 111,
|
|
|
|
112, 113, 114, 115, 116, 117, 118, 119,
|
|
|
|
120, 121, 122, 123, 124, 125, 126, 127,
|
|
|
|
128, 129, 130, 131, 132, 133, 134, 135,
|
|
|
|
136, 137, 138, 139, 140, 141, 142, 143,
|
|
|
|
144, 145, 146, 147, 148, 149, 150, 151,
|
|
|
|
152, 153, 154, 155, 156, 157, 158, 159,
|
|
|
|
160, 161, 162, 163, 164, 165, 166, 167,
|
|
|
|
168, 169, 170, 171, 172, 173, 174, 175,
|
|
|
|
176, 177, 178, 179, 180, 181, 182, 183,
|
|
|
|
184, 185, 186, 187, 188, 189, 190, 191,
|
|
|
|
192, 193, 194, 195, 196, 197, 198, 199,
|
|
|
|
200, 201, 202, 203, 204, 205, 206, 207,
|
|
|
|
208, 209, 210, 211, 212, 213, 214, 215,
|
|
|
|
216, 217, 218, 219, 220, 221, 222, 223,
|
|
|
|
224, 225, 226, 227, 228
|
2001-12-20 14:14:18 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static const FT_UShort cff_expert_charset[166] =
|
|
|
|
{
|
2007-01-05 11:51:56 +01:00
|
|
|
0, 1, 229, 230, 231, 232, 233, 234,
|
|
|
|
235, 236, 237, 238, 13, 14, 15, 99,
|
|
|
|
239, 240, 241, 242, 243, 244, 245, 246,
|
|
|
|
247, 248, 27, 28, 249, 250, 251, 252,
|
|
|
|
253, 254, 255, 256, 257, 258, 259, 260,
|
|
|
|
261, 262, 263, 264, 265, 266, 109, 110,
|
|
|
|
267, 268, 269, 270, 271, 272, 273, 274,
|
|
|
|
275, 276, 277, 278, 279, 280, 281, 282,
|
|
|
|
283, 284, 285, 286, 287, 288, 289, 290,
|
|
|
|
291, 292, 293, 294, 295, 296, 297, 298,
|
|
|
|
299, 300, 301, 302, 303, 304, 305, 306,
|
|
|
|
307, 308, 309, 310, 311, 312, 313, 314,
|
|
|
|
315, 316, 317, 318, 158, 155, 163, 319,
|
|
|
|
320, 321, 322, 323, 324, 325, 326, 150,
|
|
|
|
164, 169, 327, 328, 329, 330, 331, 332,
|
|
|
|
333, 334, 335, 336, 337, 338, 339, 340,
|
|
|
|
341, 342, 343, 344, 345, 346, 347, 348,
|
|
|
|
349, 350, 351, 352, 353, 354, 355, 356,
|
|
|
|
357, 358, 359, 360, 361, 362, 363, 364,
|
|
|
|
365, 366, 367, 368, 369, 370, 371, 372,
|
|
|
|
373, 374, 375, 376, 377, 378
|
2001-12-20 14:14:18 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static const FT_UShort cff_expertsubset_charset[87] =
|
|
|
|
{
|
2007-01-05 11:51:56 +01:00
|
|
|
0, 1, 231, 232, 235, 236, 237, 238,
|
|
|
|
13, 14, 15, 99, 239, 240, 241, 242,
|
|
|
|
243, 244, 245, 246, 247, 248, 27, 28,
|
|
|
|
249, 250, 251, 253, 254, 255, 256, 257,
|
|
|
|
258, 259, 260, 261, 262, 263, 264, 265,
|
|
|
|
266, 109, 110, 267, 268, 269, 270, 272,
|
|
|
|
300, 301, 302, 305, 314, 315, 158, 155,
|
|
|
|
163, 320, 321, 322, 323, 324, 325, 326,
|
|
|
|
150, 164, 169, 327, 328, 329, 330, 331,
|
|
|
|
332, 333, 334, 335, 336, 337, 338, 339,
|
|
|
|
340, 341, 342, 343, 344, 345, 346
|
2001-12-20 14:14:18 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static const FT_UShort cff_standard_encoding[256] =
|
|
|
|
{
|
2007-01-05 11:51:56 +01:00
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
1, 2, 3, 4, 5, 6, 7, 8,
|
|
|
|
9, 10, 11, 12, 13, 14, 15, 16,
|
|
|
|
17, 18, 19, 20, 21, 22, 23, 24,
|
|
|
|
25, 26, 27, 28, 29, 30, 31, 32,
|
|
|
|
33, 34, 35, 36, 37, 38, 39, 40,
|
|
|
|
41, 42, 43, 44, 45, 46, 47, 48,
|
|
|
|
49, 50, 51, 52, 53, 54, 55, 56,
|
|
|
|
57, 58, 59, 60, 61, 62, 63, 64,
|
|
|
|
65, 66, 67, 68, 69, 70, 71, 72,
|
|
|
|
73, 74, 75, 76, 77, 78, 79, 80,
|
|
|
|
81, 82, 83, 84, 85, 86, 87, 88,
|
|
|
|
89, 90, 91, 92, 93, 94, 95, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 96, 97, 98, 99, 100, 101, 102,
|
|
|
|
103, 104, 105, 106, 107, 108, 109, 110,
|
|
|
|
0, 111, 112, 113, 114, 0, 115, 116,
|
|
|
|
117, 118, 119, 120, 121, 122, 0, 123,
|
|
|
|
0, 124, 125, 126, 127, 128, 129, 130,
|
|
|
|
131, 0, 132, 133, 0, 134, 135, 136,
|
|
|
|
137, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 138, 0, 139, 0, 0, 0, 0,
|
|
|
|
140, 141, 142, 143, 0, 0, 0, 0,
|
|
|
|
0, 144, 0, 0, 0, 145, 0, 0,
|
|
|
|
146, 147, 148, 149, 0, 0, 0, 0
|
2001-12-20 14:14:18 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static const FT_UShort cff_expert_encoding[256] =
|
|
|
|
{
|
2007-01-05 11:51:56 +01:00
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
1, 229, 230, 0, 231, 232, 233, 234,
|
|
|
|
235, 236, 237, 238, 13, 14, 15, 99,
|
|
|
|
239, 240, 241, 242, 243, 244, 245, 246,
|
|
|
|
247, 248, 27, 28, 249, 250, 251, 252,
|
|
|
|
0, 253, 254, 255, 256, 257, 0, 0,
|
|
|
|
0, 258, 0, 0, 259, 260, 261, 262,
|
|
|
|
0, 0, 263, 264, 265, 0, 266, 109,
|
|
|
|
110, 267, 268, 269, 0, 270, 271, 272,
|
|
|
|
273, 274, 275, 276, 277, 278, 279, 280,
|
|
|
|
281, 282, 283, 284, 285, 286, 287, 288,
|
|
|
|
289, 290, 291, 292, 293, 294, 295, 296,
|
|
|
|
297, 298, 299, 300, 301, 302, 303, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 304, 305, 306, 0, 0, 307, 308,
|
|
|
|
309, 310, 311, 0, 312, 0, 0, 312,
|
|
|
|
0, 0, 314, 315, 0, 0, 316, 317,
|
|
|
|
318, 0, 0, 0, 158, 155, 163, 319,
|
|
|
|
320, 321, 322, 323, 324, 325, 0, 0,
|
|
|
|
326, 150, 164, 169, 327, 328, 329, 330,
|
|
|
|
331, 332, 333, 334, 335, 336, 337, 338,
|
|
|
|
339, 340, 341, 342, 343, 344, 345, 346,
|
|
|
|
347, 348, 349, 350, 351, 352, 353, 354,
|
|
|
|
355, 356, 357, 358, 359, 360, 361, 362,
|
|
|
|
363, 364, 365, 366, 367, 368, 369, 370,
|
|
|
|
371, 372, 373, 374, 375, 376, 377, 378
|
2001-12-20 14:14:18 +01:00
|
|
|
};
|
2008-04-13 07:55:36 +02:00
|
|
|
|
|
|
|
#endif /* 1 */
|
2001-12-20 14:14:18 +01:00
|
|
|
|
|
|
|
|
2002-03-01 03:26:22 +01:00
|
|
|
FT_LOCAL_DEF( FT_UShort )
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
cff_get_standard_encoding( FT_UInt charcode )
|
2001-12-20 14:14:18 +01:00
|
|
|
{
|
2008-04-13 07:55:36 +02:00
|
|
|
return (FT_UShort)( charcode < 256 ? cff_standard_encoding[charcode]
|
|
|
|
: 0 );
|
2001-12-20 14:14:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
|
|
|
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
|
|
|
/* messages during execution. */
|
|
|
|
/* */
|
|
|
|
#undef FT_COMPONENT
|
2001-01-03 01:21:59 +01:00
|
|
|
#define FT_COMPONENT trace_cffload
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2007-01-06 08:47:45 +01:00
|
|
|
|
2007-01-05 14:14:08 +01:00
|
|
|
/* read an offset from the index's stream current position */
|
|
|
|
static FT_ULong
|
|
|
|
cff_index_read_offset( CFF_Index idx,
|
2007-01-06 08:51:48 +01:00
|
|
|
FT_Error *errorp )
|
2007-01-05 14:14:08 +01:00
|
|
|
{
|
|
|
|
FT_Error error;
|
|
|
|
FT_Stream stream = idx->stream;
|
|
|
|
FT_Byte tmp[4];
|
|
|
|
FT_ULong result = 0;
|
|
|
|
|
2007-01-06 08:47:45 +01:00
|
|
|
|
2007-01-05 14:14:08 +01:00
|
|
|
if ( !FT_STREAM_READ( tmp, idx->off_size ) )
|
|
|
|
{
|
|
|
|
FT_Int nn;
|
|
|
|
|
2007-01-06 08:47:45 +01:00
|
|
|
|
2007-01-05 14:14:08 +01:00
|
|
|
for ( nn = 0; nn < idx->off_size; nn++ )
|
2007-01-06 08:47:45 +01:00
|
|
|
result = ( result << 8 ) | tmp[nn];
|
2007-01-05 14:14:08 +01:00
|
|
|
}
|
|
|
|
|
2007-01-06 08:51:48 +01:00
|
|
|
*errorp = error;
|
2007-01-05 14:14:08 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2001-10-21 17:41:11 +02:00
|
|
|
|
2001-06-27 21:46:12 +02:00
|
|
|
static FT_Error
|
2007-01-05 14:14:08 +01:00
|
|
|
cff_index_init( CFF_Index idx,
|
|
|
|
FT_Stream stream,
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
FT_Bool load,
|
|
|
|
FT_Bool cff2 )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2000-12-08 17:17:16 +01:00
|
|
|
FT_Error error;
|
|
|
|
FT_Memory memory = stream->memory;
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
FT_UInt count;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
|
2016-09-28 19:06:21 +02:00
|
|
|
FT_ZERO( idx );
|
2000-12-08 03:42:29 +01:00
|
|
|
|
* src/base/ftdbgmem.c (ft_mem_table_resize, ft_mem_table_new,
ft_mem_table_set, ft_mem_debug_alloc, ft_mem_debug_free,
ft_mem_debug_realloc, ft_mem_debug_done, FT_Alloc_Debug,
FT_Realloc_Debug, FT_Free_Debug): Fix compiler warnings.
* src/base/ftcalc.c (FT_MulFix): Ditto.
* src/cff/cffdrivr.c (cff_get_name_index): Ditto.
* src/cff/cffobjs.c (CFF_Size_Get_Global_Funcs, CFF_Size_Init,
CFF_GlyphSlot_Init): Ditto.
* src/cid/cidobjs.c (CID_GlyphSlot_Init,
CID_Size_Get_Globals_Funcs): Ditto.
* src/type1/t1objs.c (T1_Size_Get_Globals_Funcs, T1_GlyphSlot_Init):
Ditto.
* src/pshinter/pshmod.c (pshinter_interface): Use `static const'.
* src/winfonts/winfnt.c (FNT_Get_Next_Char): Remove unused
variables.
* include/freetype/internal/psaux.h (T1_Builder_Funcs): Renamed
to...
(T1_Builder_FuncsRec): This.
(T1_Builder_Funcs): New typedef.
(PSAux_Interface): Remove compiler warnings.
* src/psaux/psauxmod.c (t1_builder_funcs), src/psaux/psobjs.h
(t1_builder_funcs): Updated.
* src/pshinter/pshglob.h (PSH_Blue_Align): Replaced with ...
(PSH_BLUE_ALIGN_{NONE,TOP,BOT}): New defines.
(PSH_AlignmentRec): Updated.
* include/freetype/internal/ftstream.h (GET_Char, GET_Byte): Fix
typo.
* include/freetype/internal/ftgloadr.h (FT_SubGlyph): Ditto.
* src/base/ftstream (FT_Get_Char): Rename to...
(FT_Stream_Get_Char): This.
* src/base/ftnames.c (FT_Get_Sfnt_Name): s/index/idx/ -- `index' is
a built-in function in gcc, causing warning messages with gcc 3.0.
* src/autohint/ahglyph.c (ah_outline_load): Ditto.
* src/autohint/ahglobal.c (ah_hinter_compute_blues): Ditto.
* src/cache/ftcmanag.c (ftc_family_table_alloc,
ftc_family_table_free, FTC_Manager_Done, FTC_Manager_Register_Cache):
Ditto.
* src/cff/cffload.c (cff_new_index, cff_done_index,
cff_explicit_index, CFF_Access_Element, CFF_Forget_Element,
CFF_Get_Name, CFF_Get_String, CFF_Load_SubFont, CFF_Load_Font,
CFF_Done_Font): Ditto.
* src/psaux/psobjs.c (PS_Table_Add, PS_Parser_LoadField): Ditto.
* src/psaux/t1decode.c (T1_Decoder_Parse_Charstrings): Ditto.
* src/pshinter/pshrec.c (ps_mask_test_bit, ps_mask_clear_bit,
ps_mask_set_bit, ps_dimension_add_t1stem, ps_hints_t1stem3,
* src/pshinter/pshalgo1.c (psh1_hint_table_record,
psh1_hint_table_record_mask, psh1_hint_table_activate_mask): Ditto.
* src/pshinter/pshalgo2.c (psh2_hint_table_record,
psh2_hint_table_record_mask, psh2_hint_table_activate_mask): Ditto.
* src/sfnt/ttpost.c (Load_Format_20, Load_Format_25,
TT_Get_PS_Name): Ditto.
* src/truetype/ttgload.c (TT_Get_Metrics, Get_HMetrics,
load_truetype_glyph): Ditto.
* src/type1/t1load.c (parse_subrs, T1_Open_Face): Ditto.
* src/type1/t1afm.c (T1_Get_Kerning): Ditto.
* include/freetype/cache/ftcmanag.h (ftc_family_table_free): Ditto.
2002-03-07 22:59:59 +01:00
|
|
|
idx->stream = stream;
|
2007-01-05 14:14:08 +01:00
|
|
|
idx->start = FT_STREAM_POS();
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
|
|
|
|
if ( cff2 )
|
|
|
|
{
|
|
|
|
if ( FT_READ_ULONG( count ) )
|
|
|
|
goto Exit;
|
|
|
|
idx->hdr_size = 5;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( FT_READ_USHORT( count ) )
|
|
|
|
goto Exit;
|
|
|
|
idx->hdr_size = 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( count > 0 )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2007-01-06 08:47:45 +01:00
|
|
|
FT_Byte offsize;
|
2007-01-06 08:51:48 +01:00
|
|
|
FT_ULong size;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* there is at least one element; read the offset size, */
|
|
|
|
/* then access the offset table to compute the index's total size */
|
* include/freetype/internal/ftstream.h,
src/base/ftstream.c, src/cff/cffload.c, src/pcf/pcfread.c,
src/sfnt/ttcmap.c, src/sfnt/ttcmap0.c, src/sfnt/ttload.c,
src/sfnt/ttpost.c, src/sfnt/ttsbit.c,
src/truetype/ttgload.c, src/truetype/ttpload.c,
src/winfonts/winfnt.c:
changed the definitions of stream macros. Examples:
NEXT_Byte => FT_NEXT_BYTE
NEXT_Short => FT_NEXT_SHORT
NEXT_UShortLE => FT_NEXT_USHORT_LE
READ_Short => FT_READ_SHORT
GET_Long => FT_GET_LONG
etc..
also introduced the FT_PEEK_XXXX functions..
2002-03-22 13:55:23 +01:00
|
|
|
if ( FT_READ_BYTE( offsize ) )
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
|
|
|
|
2006-10-23 12:23:17 +02:00
|
|
|
if ( offsize < 1 || offsize > 4 )
|
|
|
|
{
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_Table );
|
2006-10-23 12:23:17 +02:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
* src/base/ftdbgmem.c (ft_mem_table_resize, ft_mem_table_new,
ft_mem_table_set, ft_mem_debug_alloc, ft_mem_debug_free,
ft_mem_debug_realloc, ft_mem_debug_done, FT_Alloc_Debug,
FT_Realloc_Debug, FT_Free_Debug): Fix compiler warnings.
* src/base/ftcalc.c (FT_MulFix): Ditto.
* src/cff/cffdrivr.c (cff_get_name_index): Ditto.
* src/cff/cffobjs.c (CFF_Size_Get_Global_Funcs, CFF_Size_Init,
CFF_GlyphSlot_Init): Ditto.
* src/cid/cidobjs.c (CID_GlyphSlot_Init,
CID_Size_Get_Globals_Funcs): Ditto.
* src/type1/t1objs.c (T1_Size_Get_Globals_Funcs, T1_GlyphSlot_Init):
Ditto.
* src/pshinter/pshmod.c (pshinter_interface): Use `static const'.
* src/winfonts/winfnt.c (FNT_Get_Next_Char): Remove unused
variables.
* include/freetype/internal/psaux.h (T1_Builder_Funcs): Renamed
to...
(T1_Builder_FuncsRec): This.
(T1_Builder_Funcs): New typedef.
(PSAux_Interface): Remove compiler warnings.
* src/psaux/psauxmod.c (t1_builder_funcs), src/psaux/psobjs.h
(t1_builder_funcs): Updated.
* src/pshinter/pshglob.h (PSH_Blue_Align): Replaced with ...
(PSH_BLUE_ALIGN_{NONE,TOP,BOT}): New defines.
(PSH_AlignmentRec): Updated.
* include/freetype/internal/ftstream.h (GET_Char, GET_Byte): Fix
typo.
* include/freetype/internal/ftgloadr.h (FT_SubGlyph): Ditto.
* src/base/ftstream (FT_Get_Char): Rename to...
(FT_Stream_Get_Char): This.
* src/base/ftnames.c (FT_Get_Sfnt_Name): s/index/idx/ -- `index' is
a built-in function in gcc, causing warning messages with gcc 3.0.
* src/autohint/ahglyph.c (ah_outline_load): Ditto.
* src/autohint/ahglobal.c (ah_hinter_compute_blues): Ditto.
* src/cache/ftcmanag.c (ftc_family_table_alloc,
ftc_family_table_free, FTC_Manager_Done, FTC_Manager_Register_Cache):
Ditto.
* src/cff/cffload.c (cff_new_index, cff_done_index,
cff_explicit_index, CFF_Access_Element, CFF_Forget_Element,
CFF_Get_Name, CFF_Get_String, CFF_Load_SubFont, CFF_Load_Font,
CFF_Done_Font): Ditto.
* src/psaux/psobjs.c (PS_Table_Add, PS_Parser_LoadField): Ditto.
* src/psaux/t1decode.c (T1_Decoder_Parse_Charstrings): Ditto.
* src/pshinter/pshrec.c (ps_mask_test_bit, ps_mask_clear_bit,
ps_mask_set_bit, ps_dimension_add_t1stem, ps_hints_t1stem3,
* src/pshinter/pshalgo1.c (psh1_hint_table_record,
psh1_hint_table_record_mask, psh1_hint_table_activate_mask): Ditto.
* src/pshinter/pshalgo2.c (psh2_hint_table_record,
psh2_hint_table_record_mask, psh2_hint_table_activate_mask): Ditto.
* src/sfnt/ttpost.c (Load_Format_20, Load_Format_25,
TT_Get_PS_Name): Ditto.
* src/truetype/ttgload.c (TT_Get_Metrics, Get_HMetrics,
load_truetype_glyph): Ditto.
* src/type1/t1load.c (parse_subrs, T1_Open_Face): Ditto.
* src/type1/t1afm.c (T1_Get_Kerning): Ditto.
* include/freetype/cache/ftcmanag.h (ftc_family_table_free): Ditto.
2002-03-07 22:59:59 +01:00
|
|
|
idx->count = count;
|
|
|
|
idx->off_size = offsize;
|
2007-01-05 14:14:08 +01:00
|
|
|
size = (FT_ULong)( count + 1 ) * offsize;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
idx->data_offset = idx->start + idx->hdr_size + size;
|
2007-01-05 14:14:08 +01:00
|
|
|
|
|
|
|
if ( FT_STREAM_SKIP( size - offsize ) )
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
|
|
|
|
2007-01-05 14:14:08 +01:00
|
|
|
size = cff_index_read_offset( idx, &error );
|
2007-01-06 08:47:45 +01:00
|
|
|
if ( error )
|
2007-01-05 14:14:08 +01:00
|
|
|
goto Exit;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2007-01-05 14:14:08 +01:00
|
|
|
if ( size == 0 )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_Table );
|
2007-01-05 14:14:08 +01:00
|
|
|
goto Exit;
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
2007-01-05 14:14:08 +01:00
|
|
|
idx->data_size = --size;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
if ( load )
|
|
|
|
{
|
|
|
|
/* load the data */
|
2007-01-05 14:14:08 +01:00
|
|
|
if ( FT_FRAME_EXTRACT( size, idx->bytes ) )
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* skip the data */
|
2007-01-05 14:14:08 +01:00
|
|
|
if ( FT_STREAM_SKIP( size ) )
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
if ( error )
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( idx->offsets );
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-27 21:46:12 +02:00
|
|
|
static void
|
2007-01-05 14:14:08 +01:00
|
|
|
cff_index_done( CFF_Index idx )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
* src/base/ftdbgmem.c (ft_mem_table_resize, ft_mem_table_new,
ft_mem_table_set, ft_mem_debug_alloc, ft_mem_debug_free,
ft_mem_debug_realloc, ft_mem_debug_done, FT_Alloc_Debug,
FT_Realloc_Debug, FT_Free_Debug): Fix compiler warnings.
* src/base/ftcalc.c (FT_MulFix): Ditto.
* src/cff/cffdrivr.c (cff_get_name_index): Ditto.
* src/cff/cffobjs.c (CFF_Size_Get_Global_Funcs, CFF_Size_Init,
CFF_GlyphSlot_Init): Ditto.
* src/cid/cidobjs.c (CID_GlyphSlot_Init,
CID_Size_Get_Globals_Funcs): Ditto.
* src/type1/t1objs.c (T1_Size_Get_Globals_Funcs, T1_GlyphSlot_Init):
Ditto.
* src/pshinter/pshmod.c (pshinter_interface): Use `static const'.
* src/winfonts/winfnt.c (FNT_Get_Next_Char): Remove unused
variables.
* include/freetype/internal/psaux.h (T1_Builder_Funcs): Renamed
to...
(T1_Builder_FuncsRec): This.
(T1_Builder_Funcs): New typedef.
(PSAux_Interface): Remove compiler warnings.
* src/psaux/psauxmod.c (t1_builder_funcs), src/psaux/psobjs.h
(t1_builder_funcs): Updated.
* src/pshinter/pshglob.h (PSH_Blue_Align): Replaced with ...
(PSH_BLUE_ALIGN_{NONE,TOP,BOT}): New defines.
(PSH_AlignmentRec): Updated.
* include/freetype/internal/ftstream.h (GET_Char, GET_Byte): Fix
typo.
* include/freetype/internal/ftgloadr.h (FT_SubGlyph): Ditto.
* src/base/ftstream (FT_Get_Char): Rename to...
(FT_Stream_Get_Char): This.
* src/base/ftnames.c (FT_Get_Sfnt_Name): s/index/idx/ -- `index' is
a built-in function in gcc, causing warning messages with gcc 3.0.
* src/autohint/ahglyph.c (ah_outline_load): Ditto.
* src/autohint/ahglobal.c (ah_hinter_compute_blues): Ditto.
* src/cache/ftcmanag.c (ftc_family_table_alloc,
ftc_family_table_free, FTC_Manager_Done, FTC_Manager_Register_Cache):
Ditto.
* src/cff/cffload.c (cff_new_index, cff_done_index,
cff_explicit_index, CFF_Access_Element, CFF_Forget_Element,
CFF_Get_Name, CFF_Get_String, CFF_Load_SubFont, CFF_Load_Font,
CFF_Done_Font): Ditto.
* src/psaux/psobjs.c (PS_Table_Add, PS_Parser_LoadField): Ditto.
* src/psaux/t1decode.c (T1_Decoder_Parse_Charstrings): Ditto.
* src/pshinter/pshrec.c (ps_mask_test_bit, ps_mask_clear_bit,
ps_mask_set_bit, ps_dimension_add_t1stem, ps_hints_t1stem3,
* src/pshinter/pshalgo1.c (psh1_hint_table_record,
psh1_hint_table_record_mask, psh1_hint_table_activate_mask): Ditto.
* src/pshinter/pshalgo2.c (psh2_hint_table_record,
psh2_hint_table_record_mask, psh2_hint_table_activate_mask): Ditto.
* src/sfnt/ttpost.c (Load_Format_20, Load_Format_25,
TT_Get_PS_Name): Ditto.
* src/truetype/ttgload.c (TT_Get_Metrics, Get_HMetrics,
load_truetype_glyph): Ditto.
* src/type1/t1load.c (parse_subrs, T1_Open_Face): Ditto.
* src/type1/t1afm.c (T1_Get_Kerning): Ditto.
* include/freetype/cache/ftcmanag.h (ftc_family_table_free): Ditto.
2002-03-07 22:59:59 +01:00
|
|
|
if ( idx->stream )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
* src/base/ftdbgmem.c (ft_mem_table_resize, ft_mem_table_new,
ft_mem_table_set, ft_mem_debug_alloc, ft_mem_debug_free,
ft_mem_debug_realloc, ft_mem_debug_done, FT_Alloc_Debug,
FT_Realloc_Debug, FT_Free_Debug): Fix compiler warnings.
* src/base/ftcalc.c (FT_MulFix): Ditto.
* src/cff/cffdrivr.c (cff_get_name_index): Ditto.
* src/cff/cffobjs.c (CFF_Size_Get_Global_Funcs, CFF_Size_Init,
CFF_GlyphSlot_Init): Ditto.
* src/cid/cidobjs.c (CID_GlyphSlot_Init,
CID_Size_Get_Globals_Funcs): Ditto.
* src/type1/t1objs.c (T1_Size_Get_Globals_Funcs, T1_GlyphSlot_Init):
Ditto.
* src/pshinter/pshmod.c (pshinter_interface): Use `static const'.
* src/winfonts/winfnt.c (FNT_Get_Next_Char): Remove unused
variables.
* include/freetype/internal/psaux.h (T1_Builder_Funcs): Renamed
to...
(T1_Builder_FuncsRec): This.
(T1_Builder_Funcs): New typedef.
(PSAux_Interface): Remove compiler warnings.
* src/psaux/psauxmod.c (t1_builder_funcs), src/psaux/psobjs.h
(t1_builder_funcs): Updated.
* src/pshinter/pshglob.h (PSH_Blue_Align): Replaced with ...
(PSH_BLUE_ALIGN_{NONE,TOP,BOT}): New defines.
(PSH_AlignmentRec): Updated.
* include/freetype/internal/ftstream.h (GET_Char, GET_Byte): Fix
typo.
* include/freetype/internal/ftgloadr.h (FT_SubGlyph): Ditto.
* src/base/ftstream (FT_Get_Char): Rename to...
(FT_Stream_Get_Char): This.
* src/base/ftnames.c (FT_Get_Sfnt_Name): s/index/idx/ -- `index' is
a built-in function in gcc, causing warning messages with gcc 3.0.
* src/autohint/ahglyph.c (ah_outline_load): Ditto.
* src/autohint/ahglobal.c (ah_hinter_compute_blues): Ditto.
* src/cache/ftcmanag.c (ftc_family_table_alloc,
ftc_family_table_free, FTC_Manager_Done, FTC_Manager_Register_Cache):
Ditto.
* src/cff/cffload.c (cff_new_index, cff_done_index,
cff_explicit_index, CFF_Access_Element, CFF_Forget_Element,
CFF_Get_Name, CFF_Get_String, CFF_Load_SubFont, CFF_Load_Font,
CFF_Done_Font): Ditto.
* src/psaux/psobjs.c (PS_Table_Add, PS_Parser_LoadField): Ditto.
* src/psaux/t1decode.c (T1_Decoder_Parse_Charstrings): Ditto.
* src/pshinter/pshrec.c (ps_mask_test_bit, ps_mask_clear_bit,
ps_mask_set_bit, ps_dimension_add_t1stem, ps_hints_t1stem3,
* src/pshinter/pshalgo1.c (psh1_hint_table_record,
psh1_hint_table_record_mask, psh1_hint_table_activate_mask): Ditto.
* src/pshinter/pshalgo2.c (psh2_hint_table_record,
psh2_hint_table_record_mask, psh2_hint_table_activate_mask): Ditto.
* src/sfnt/ttpost.c (Load_Format_20, Load_Format_25,
TT_Get_PS_Name): Ditto.
* src/truetype/ttgload.c (TT_Get_Metrics, Get_HMetrics,
load_truetype_glyph): Ditto.
* src/type1/t1load.c (parse_subrs, T1_Open_Face): Ditto.
* src/type1/t1afm.c (T1_Get_Kerning): Ditto.
* include/freetype/cache/ftcmanag.h (ftc_family_table_free): Ditto.
2002-03-07 22:59:59 +01:00
|
|
|
FT_Stream stream = idx->stream;
|
2000-12-08 03:42:29 +01:00
|
|
|
FT_Memory memory = stream->memory;
|
|
|
|
|
|
|
|
|
* src/base/ftdbgmem.c (ft_mem_table_resize, ft_mem_table_new,
ft_mem_table_set, ft_mem_debug_alloc, ft_mem_debug_free,
ft_mem_debug_realloc, ft_mem_debug_done, FT_Alloc_Debug,
FT_Realloc_Debug, FT_Free_Debug): Fix compiler warnings.
* src/base/ftcalc.c (FT_MulFix): Ditto.
* src/cff/cffdrivr.c (cff_get_name_index): Ditto.
* src/cff/cffobjs.c (CFF_Size_Get_Global_Funcs, CFF_Size_Init,
CFF_GlyphSlot_Init): Ditto.
* src/cid/cidobjs.c (CID_GlyphSlot_Init,
CID_Size_Get_Globals_Funcs): Ditto.
* src/type1/t1objs.c (T1_Size_Get_Globals_Funcs, T1_GlyphSlot_Init):
Ditto.
* src/pshinter/pshmod.c (pshinter_interface): Use `static const'.
* src/winfonts/winfnt.c (FNT_Get_Next_Char): Remove unused
variables.
* include/freetype/internal/psaux.h (T1_Builder_Funcs): Renamed
to...
(T1_Builder_FuncsRec): This.
(T1_Builder_Funcs): New typedef.
(PSAux_Interface): Remove compiler warnings.
* src/psaux/psauxmod.c (t1_builder_funcs), src/psaux/psobjs.h
(t1_builder_funcs): Updated.
* src/pshinter/pshglob.h (PSH_Blue_Align): Replaced with ...
(PSH_BLUE_ALIGN_{NONE,TOP,BOT}): New defines.
(PSH_AlignmentRec): Updated.
* include/freetype/internal/ftstream.h (GET_Char, GET_Byte): Fix
typo.
* include/freetype/internal/ftgloadr.h (FT_SubGlyph): Ditto.
* src/base/ftstream (FT_Get_Char): Rename to...
(FT_Stream_Get_Char): This.
* src/base/ftnames.c (FT_Get_Sfnt_Name): s/index/idx/ -- `index' is
a built-in function in gcc, causing warning messages with gcc 3.0.
* src/autohint/ahglyph.c (ah_outline_load): Ditto.
* src/autohint/ahglobal.c (ah_hinter_compute_blues): Ditto.
* src/cache/ftcmanag.c (ftc_family_table_alloc,
ftc_family_table_free, FTC_Manager_Done, FTC_Manager_Register_Cache):
Ditto.
* src/cff/cffload.c (cff_new_index, cff_done_index,
cff_explicit_index, CFF_Access_Element, CFF_Forget_Element,
CFF_Get_Name, CFF_Get_String, CFF_Load_SubFont, CFF_Load_Font,
CFF_Done_Font): Ditto.
* src/psaux/psobjs.c (PS_Table_Add, PS_Parser_LoadField): Ditto.
* src/psaux/t1decode.c (T1_Decoder_Parse_Charstrings): Ditto.
* src/pshinter/pshrec.c (ps_mask_test_bit, ps_mask_clear_bit,
ps_mask_set_bit, ps_dimension_add_t1stem, ps_hints_t1stem3,
* src/pshinter/pshalgo1.c (psh1_hint_table_record,
psh1_hint_table_record_mask, psh1_hint_table_activate_mask): Ditto.
* src/pshinter/pshalgo2.c (psh2_hint_table_record,
psh2_hint_table_record_mask, psh2_hint_table_activate_mask): Ditto.
* src/sfnt/ttpost.c (Load_Format_20, Load_Format_25,
TT_Get_PS_Name): Ditto.
* src/truetype/ttgload.c (TT_Get_Metrics, Get_HMetrics,
load_truetype_glyph): Ditto.
* src/type1/t1load.c (parse_subrs, T1_Open_Face): Ditto.
* src/type1/t1afm.c (T1_Get_Kerning): Ditto.
* include/freetype/cache/ftcmanag.h (ftc_family_table_free): Ditto.
2002-03-07 22:59:59 +01:00
|
|
|
if ( idx->bytes )
|
2002-03-20 11:49:31 +01:00
|
|
|
FT_FRAME_RELEASE( idx->bytes );
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( idx->offsets );
|
2016-09-28 19:06:21 +02:00
|
|
|
FT_ZERO( idx );
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-01-05 14:14:08 +01:00
|
|
|
static FT_Error
|
|
|
|
cff_index_load_offsets( CFF_Index idx )
|
|
|
|
{
|
2013-03-14 11:21:17 +01:00
|
|
|
FT_Error error = FT_Err_Ok;
|
2007-01-05 14:14:08 +01:00
|
|
|
FT_Stream stream = idx->stream;
|
|
|
|
FT_Memory memory = stream->memory;
|
|
|
|
|
2007-01-06 08:47:45 +01:00
|
|
|
|
2007-01-16 07:11:27 +01:00
|
|
|
if ( idx->count > 0 && idx->offsets == NULL )
|
2007-01-05 14:14:08 +01:00
|
|
|
{
|
|
|
|
FT_Byte offsize = idx->off_size;
|
|
|
|
FT_ULong data_size;
|
|
|
|
FT_Byte* p;
|
|
|
|
FT_Byte* p_end;
|
|
|
|
FT_ULong* poff;
|
|
|
|
|
2007-01-06 08:47:45 +01:00
|
|
|
|
|
|
|
data_size = (FT_ULong)( idx->count + 1 ) * offsize;
|
2007-01-05 14:14:08 +01:00
|
|
|
|
|
|
|
if ( FT_NEW_ARRAY( idx->offsets, idx->count + 1 ) ||
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
FT_STREAM_SEEK( idx->start + idx->hdr_size ) ||
|
2007-01-06 08:47:45 +01:00
|
|
|
FT_FRAME_ENTER( data_size ) )
|
2007-01-05 14:14:08 +01:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
poff = idx->offsets;
|
|
|
|
p = (FT_Byte*)stream->cursor;
|
|
|
|
p_end = p + data_size;
|
|
|
|
|
|
|
|
switch ( offsize )
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
for ( ; p < p_end; p++, poff++ )
|
|
|
|
poff[0] = p[0];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
for ( ; p < p_end; p += 2, poff++ )
|
|
|
|
poff[0] = FT_PEEK_USHORT( p );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
for ( ; p < p_end; p += 3, poff++ )
|
2015-02-20 08:35:32 +01:00
|
|
|
poff[0] = FT_PEEK_UOFF3( p );
|
2007-01-05 14:14:08 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
for ( ; p < p_end; p += 4, poff++ )
|
|
|
|
poff[0] = FT_PEEK_ULONG( p );
|
|
|
|
}
|
|
|
|
|
|
|
|
FT_FRAME_EXIT();
|
|
|
|
}
|
|
|
|
|
|
|
|
Exit:
|
2007-01-06 08:47:45 +01:00
|
|
|
if ( error )
|
2007-01-05 14:14:08 +01:00
|
|
|
FT_FREE( idx->offsets );
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Improve CFF string (especially glyphname) lookup performance.
We do this by avoiding memory allocation and file I/O. This is
Savannah patch #7104.
* src/cff/cfftypes.h: Include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(CFF_SubFontRec): Remove `num_local_subrs'.
(CFF_FontRec): Add `num_strings', `strings', and `string_pool'
fields.
Remove `string_index' and `num_global_subrs' fields.
Use real types instead of `void' for `pshinter' and `psnames' fields.
* src/cff/cffload.c: Don't include PS cmaps service.
(cff_index_get_pointers): Add `pool' parameter which allows to
insert an extra NUL character for each String INDEX entry.
(cff_index_get_name): Make it a local function.
(cff_index_get_string): New function.
(cff_subfont_load): Updated.
(cff_font_load): Initialize `num_strings', `strings', and
`string_pool' fields in the `CFF_FontRec' structure.
(cff_index_get_sid_string): Use `cff_index_get_string' instead of
`cff_index_get_name'.
(cff_font_done): Updated.
* src/cff/cffload.h: Don't include PS cmaps service.
(cff_index_get_string): Added.
(cff_index_get_sid_string): Updated.
* src/cff/cffobjs.c: Don't include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_size_get_globals_funcs, cff_slot_init): Updated.
(cff_face_init): Follow `cff_index_get_name',
`cff_index_get_string', and `cff_index_get_sid_string' changes.
* src/cff/cffcmap.c (cff_sid_free_glyph_name): Removed.
(cff_sid_to_glyph_name): Use `cff_index_get_cid_string'.
(cff_cmap_unicode_init): Updated.
* src/cff/cffdrivr.c: Don't include PS cmap service.
(cff_get_glyph_name): Avoid unnecessary lookup for POSTSCRIPT_CMAPS
service.
(cff_get_glyph_name, cff_ps_get_font_info, cff_get_ros): Follow API
`cff_index_get_sid_string' change.
(cff_get_name_index): Use `cff_index_get_string' instead of
`cff_index_get_name'.
* src/cff/cffgload.c: Don't include FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_decoder_init, cff_decoder_prepare): Updated.
2010-03-02 13:00:55 +01:00
|
|
|
/* Allocate a table containing pointers to an index's elements. */
|
|
|
|
/* The `pool' argument makes this function convert the index */
|
|
|
|
/* entries to C-style strings (this is, NULL-terminated). */
|
2001-06-27 21:46:12 +02:00
|
|
|
static FT_Error
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
cff_index_get_pointers( CFF_Index idx,
|
Improve CFF string (especially glyphname) lookup performance.
We do this by avoiding memory allocation and file I/O. This is
Savannah patch #7104.
* src/cff/cfftypes.h: Include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(CFF_SubFontRec): Remove `num_local_subrs'.
(CFF_FontRec): Add `num_strings', `strings', and `string_pool'
fields.
Remove `string_index' and `num_global_subrs' fields.
Use real types instead of `void' for `pshinter' and `psnames' fields.
* src/cff/cffload.c: Don't include PS cmaps service.
(cff_index_get_pointers): Add `pool' parameter which allows to
insert an extra NUL character for each String INDEX entry.
(cff_index_get_name): Make it a local function.
(cff_index_get_string): New function.
(cff_subfont_load): Updated.
(cff_font_load): Initialize `num_strings', `strings', and
`string_pool' fields in the `CFF_FontRec' structure.
(cff_index_get_sid_string): Use `cff_index_get_string' instead of
`cff_index_get_name'.
(cff_font_done): Updated.
* src/cff/cffload.h: Don't include PS cmaps service.
(cff_index_get_string): Added.
(cff_index_get_sid_string): Updated.
* src/cff/cffobjs.c: Don't include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_size_get_globals_funcs, cff_slot_init): Updated.
(cff_face_init): Follow `cff_index_get_name',
`cff_index_get_string', and `cff_index_get_sid_string' changes.
* src/cff/cffcmap.c (cff_sid_free_glyph_name): Removed.
(cff_sid_to_glyph_name): Use `cff_index_get_cid_string'.
(cff_cmap_unicode_init): Updated.
* src/cff/cffdrivr.c: Don't include PS cmap service.
(cff_get_glyph_name): Avoid unnecessary lookup for POSTSCRIPT_CMAPS
service.
(cff_get_glyph_name, cff_ps_get_font_info, cff_get_ros): Follow API
`cff_index_get_sid_string' change.
(cff_get_name_index): Use `cff_index_get_string' instead of
`cff_index_get_name'.
* src/cff/cffgload.c: Don't include FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_decoder_init, cff_decoder_prepare): Updated.
2010-03-02 13:00:55 +01:00
|
|
|
FT_Byte*** table,
|
2016-02-15 14:28:28 +01:00
|
|
|
FT_Byte** pool,
|
|
|
|
FT_ULong* pool_size )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2013-03-14 11:21:17 +01:00
|
|
|
FT_Error error = FT_Err_Ok;
|
2010-07-06 10:44:56 +02:00
|
|
|
FT_Memory memory = idx->stream->memory;
|
2013-03-14 10:27:35 +01:00
|
|
|
|
|
|
|
FT_Byte** t = NULL;
|
2010-07-06 10:44:56 +02:00
|
|
|
FT_Byte* new_bytes = NULL;
|
2016-02-15 14:28:28 +01:00
|
|
|
FT_ULong new_size;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
|
Improve CFF string (especially glyphname) lookup performance.
We do this by avoiding memory allocation and file I/O. This is
Savannah patch #7104.
* src/cff/cfftypes.h: Include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(CFF_SubFontRec): Remove `num_local_subrs'.
(CFF_FontRec): Add `num_strings', `strings', and `string_pool'
fields.
Remove `string_index' and `num_global_subrs' fields.
Use real types instead of `void' for `pshinter' and `psnames' fields.
* src/cff/cffload.c: Don't include PS cmaps service.
(cff_index_get_pointers): Add `pool' parameter which allows to
insert an extra NUL character for each String INDEX entry.
(cff_index_get_name): Make it a local function.
(cff_index_get_string): New function.
(cff_subfont_load): Updated.
(cff_font_load): Initialize `num_strings', `strings', and
`string_pool' fields in the `CFF_FontRec' structure.
(cff_index_get_sid_string): Use `cff_index_get_string' instead of
`cff_index_get_name'.
(cff_font_done): Updated.
* src/cff/cffload.h: Don't include PS cmaps service.
(cff_index_get_string): Added.
(cff_index_get_sid_string): Updated.
* src/cff/cffobjs.c: Don't include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_size_get_globals_funcs, cff_slot_init): Updated.
(cff_face_init): Follow `cff_index_get_name',
`cff_index_get_string', and `cff_index_get_sid_string' changes.
* src/cff/cffcmap.c (cff_sid_free_glyph_name): Removed.
(cff_sid_to_glyph_name): Use `cff_index_get_cid_string'.
(cff_cmap_unicode_init): Updated.
* src/cff/cffdrivr.c: Don't include PS cmap service.
(cff_get_glyph_name): Avoid unnecessary lookup for POSTSCRIPT_CMAPS
service.
(cff_get_glyph_name, cff_ps_get_font_info, cff_get_ros): Follow API
`cff_index_get_sid_string' change.
(cff_get_name_index): Use `cff_index_get_string' instead of
`cff_index_get_name'.
* src/cff/cffgload.c: Don't include FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_decoder_init, cff_decoder_prepare): Updated.
2010-03-02 13:00:55 +01:00
|
|
|
*table = NULL;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2007-01-05 14:14:08 +01:00
|
|
|
if ( idx->offsets == NULL )
|
|
|
|
{
|
|
|
|
error = cff_index_load_offsets( idx );
|
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2016-02-15 14:28:28 +01:00
|
|
|
new_size = idx->data_size + idx->count;
|
|
|
|
|
|
|
|
if ( idx->count > 0 &&
|
|
|
|
!FT_NEW_ARRAY( t, idx->count + 1 ) &&
|
|
|
|
( !pool || !FT_ALLOC( new_bytes, new_size ) ) )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
Improve CFF string (especially glyphname) lookup performance.
We do this by avoiding memory allocation and file I/O. This is
Savannah patch #7104.
* src/cff/cfftypes.h: Include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(CFF_SubFontRec): Remove `num_local_subrs'.
(CFF_FontRec): Add `num_strings', `strings', and `string_pool'
fields.
Remove `string_index' and `num_global_subrs' fields.
Use real types instead of `void' for `pshinter' and `psnames' fields.
* src/cff/cffload.c: Don't include PS cmaps service.
(cff_index_get_pointers): Add `pool' parameter which allows to
insert an extra NUL character for each String INDEX entry.
(cff_index_get_name): Make it a local function.
(cff_index_get_string): New function.
(cff_subfont_load): Updated.
(cff_font_load): Initialize `num_strings', `strings', and
`string_pool' fields in the `CFF_FontRec' structure.
(cff_index_get_sid_string): Use `cff_index_get_string' instead of
`cff_index_get_name'.
(cff_font_done): Updated.
* src/cff/cffload.h: Don't include PS cmaps service.
(cff_index_get_string): Added.
(cff_index_get_sid_string): Updated.
* src/cff/cffobjs.c: Don't include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_size_get_globals_funcs, cff_slot_init): Updated.
(cff_face_init): Follow `cff_index_get_name',
`cff_index_get_string', and `cff_index_get_sid_string' changes.
* src/cff/cffcmap.c (cff_sid_free_glyph_name): Removed.
(cff_sid_to_glyph_name): Use `cff_index_get_cid_string'.
(cff_cmap_unicode_init): Updated.
* src/cff/cffdrivr.c: Don't include PS cmap service.
(cff_get_glyph_name): Avoid unnecessary lookup for POSTSCRIPT_CMAPS
service.
(cff_get_glyph_name, cff_ps_get_font_info, cff_get_ros): Follow API
`cff_index_get_sid_string' change.
(cff_get_name_index): Use `cff_index_get_string' instead of
`cff_index_get_name'.
* src/cff/cffgload.c: Don't include FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_decoder_init, cff_decoder_prepare): Updated.
2010-03-02 13:00:55 +01:00
|
|
|
FT_ULong n, cur_offset;
|
|
|
|
FT_ULong extra = 0;
|
|
|
|
FT_Byte* org_bytes = idx->bytes;
|
|
|
|
|
|
|
|
|
|
|
|
/* at this point, `idx->offsets' can't be NULL */
|
|
|
|
cur_offset = idx->offsets[0] - 1;
|
|
|
|
|
2010-06-25 21:55:14 +02:00
|
|
|
/* sanity check */
|
2013-08-06 08:55:19 +02:00
|
|
|
if ( cur_offset != 0 )
|
2010-06-25 21:55:14 +02:00
|
|
|
{
|
|
|
|
FT_TRACE0(( "cff_index_get_pointers:"
|
|
|
|
" invalid first offset value %d set to zero\n",
|
|
|
|
cur_offset ));
|
|
|
|
cur_offset = 0;
|
|
|
|
}
|
|
|
|
|
Improve CFF string (especially glyphname) lookup performance.
We do this by avoiding memory allocation and file I/O. This is
Savannah patch #7104.
* src/cff/cfftypes.h: Include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(CFF_SubFontRec): Remove `num_local_subrs'.
(CFF_FontRec): Add `num_strings', `strings', and `string_pool'
fields.
Remove `string_index' and `num_global_subrs' fields.
Use real types instead of `void' for `pshinter' and `psnames' fields.
* src/cff/cffload.c: Don't include PS cmaps service.
(cff_index_get_pointers): Add `pool' parameter which allows to
insert an extra NUL character for each String INDEX entry.
(cff_index_get_name): Make it a local function.
(cff_index_get_string): New function.
(cff_subfont_load): Updated.
(cff_font_load): Initialize `num_strings', `strings', and
`string_pool' fields in the `CFF_FontRec' structure.
(cff_index_get_sid_string): Use `cff_index_get_string' instead of
`cff_index_get_name'.
(cff_font_done): Updated.
* src/cff/cffload.h: Don't include PS cmaps service.
(cff_index_get_string): Added.
(cff_index_get_sid_string): Updated.
* src/cff/cffobjs.c: Don't include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_size_get_globals_funcs, cff_slot_init): Updated.
(cff_face_init): Follow `cff_index_get_name',
`cff_index_get_string', and `cff_index_get_sid_string' changes.
* src/cff/cffcmap.c (cff_sid_free_glyph_name): Removed.
(cff_sid_to_glyph_name): Use `cff_index_get_cid_string'.
(cff_cmap_unicode_init): Updated.
* src/cff/cffdrivr.c: Don't include PS cmap service.
(cff_get_glyph_name): Avoid unnecessary lookup for POSTSCRIPT_CMAPS
service.
(cff_get_glyph_name, cff_ps_get_font_info, cff_get_ros): Follow API
`cff_index_get_sid_string' change.
(cff_get_name_index): Use `cff_index_get_string' instead of
`cff_index_get_name'.
* src/cff/cffgload.c: Don't include FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_decoder_init, cff_decoder_prepare): Updated.
2010-03-02 13:00:55 +01:00
|
|
|
if ( !pool )
|
|
|
|
t[0] = org_bytes + cur_offset;
|
|
|
|
else
|
|
|
|
t[0] = new_bytes + cur_offset;
|
|
|
|
|
|
|
|
for ( n = 1; n <= idx->count; n++ )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
Improve CFF string (especially glyphname) lookup performance.
We do this by avoiding memory allocation and file I/O. This is
Savannah patch #7104.
* src/cff/cfftypes.h: Include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(CFF_SubFontRec): Remove `num_local_subrs'.
(CFF_FontRec): Add `num_strings', `strings', and `string_pool'
fields.
Remove `string_index' and `num_global_subrs' fields.
Use real types instead of `void' for `pshinter' and `psnames' fields.
* src/cff/cffload.c: Don't include PS cmaps service.
(cff_index_get_pointers): Add `pool' parameter which allows to
insert an extra NUL character for each String INDEX entry.
(cff_index_get_name): Make it a local function.
(cff_index_get_string): New function.
(cff_subfont_load): Updated.
(cff_font_load): Initialize `num_strings', `strings', and
`string_pool' fields in the `CFF_FontRec' structure.
(cff_index_get_sid_string): Use `cff_index_get_string' instead of
`cff_index_get_name'.
(cff_font_done): Updated.
* src/cff/cffload.h: Don't include PS cmaps service.
(cff_index_get_string): Added.
(cff_index_get_sid_string): Updated.
* src/cff/cffobjs.c: Don't include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_size_get_globals_funcs, cff_slot_init): Updated.
(cff_face_init): Follow `cff_index_get_name',
`cff_index_get_string', and `cff_index_get_sid_string' changes.
* src/cff/cffcmap.c (cff_sid_free_glyph_name): Removed.
(cff_sid_to_glyph_name): Use `cff_index_get_cid_string'.
(cff_cmap_unicode_init): Updated.
* src/cff/cffdrivr.c: Don't include PS cmap service.
(cff_get_glyph_name): Avoid unnecessary lookup for POSTSCRIPT_CMAPS
service.
(cff_get_glyph_name, cff_ps_get_font_info, cff_get_ros): Follow API
`cff_index_get_sid_string' change.
(cff_get_name_index): Use `cff_index_get_string' instead of
`cff_index_get_name'.
* src/cff/cffgload.c: Don't include FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_decoder_init, cff_decoder_prepare): Updated.
2010-03-02 13:00:55 +01:00
|
|
|
FT_ULong next_offset = idx->offsets[n] - 1;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2007-01-05 14:14:08 +01:00
|
|
|
|
2013-08-06 08:55:19 +02:00
|
|
|
/* two sanity checks for invalid offset tables */
|
|
|
|
if ( next_offset < cur_offset )
|
Improve CFF string (especially glyphname) lookup performance.
We do this by avoiding memory allocation and file I/O. This is
Savannah patch #7104.
* src/cff/cfftypes.h: Include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(CFF_SubFontRec): Remove `num_local_subrs'.
(CFF_FontRec): Add `num_strings', `strings', and `string_pool'
fields.
Remove `string_index' and `num_global_subrs' fields.
Use real types instead of `void' for `pshinter' and `psnames' fields.
* src/cff/cffload.c: Don't include PS cmaps service.
(cff_index_get_pointers): Add `pool' parameter which allows to
insert an extra NUL character for each String INDEX entry.
(cff_index_get_name): Make it a local function.
(cff_index_get_string): New function.
(cff_subfont_load): Updated.
(cff_font_load): Initialize `num_strings', `strings', and
`string_pool' fields in the `CFF_FontRec' structure.
(cff_index_get_sid_string): Use `cff_index_get_string' instead of
`cff_index_get_name'.
(cff_font_done): Updated.
* src/cff/cffload.h: Don't include PS cmaps service.
(cff_index_get_string): Added.
(cff_index_get_sid_string): Updated.
* src/cff/cffobjs.c: Don't include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_size_get_globals_funcs, cff_slot_init): Updated.
(cff_face_init): Follow `cff_index_get_name',
`cff_index_get_string', and `cff_index_get_sid_string' changes.
* src/cff/cffcmap.c (cff_sid_free_glyph_name): Removed.
(cff_sid_to_glyph_name): Use `cff_index_get_cid_string'.
(cff_cmap_unicode_init): Updated.
* src/cff/cffdrivr.c: Don't include PS cmap service.
(cff_get_glyph_name): Avoid unnecessary lookup for POSTSCRIPT_CMAPS
service.
(cff_get_glyph_name, cff_ps_get_font_info, cff_get_ros): Follow API
`cff_index_get_sid_string' change.
(cff_get_name_index): Use `cff_index_get_string' instead of
`cff_index_get_name'.
* src/cff/cffgload.c: Don't include FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_decoder_init, cff_decoder_prepare): Updated.
2010-03-02 13:00:55 +01:00
|
|
|
next_offset = cur_offset;
|
2013-08-06 08:55:19 +02:00
|
|
|
else if ( next_offset > idx->data_size )
|
|
|
|
next_offset = idx->data_size;
|
2007-01-25 14:53:56 +01:00
|
|
|
|
Improve CFF string (especially glyphname) lookup performance.
We do this by avoiding memory allocation and file I/O. This is
Savannah patch #7104.
* src/cff/cfftypes.h: Include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(CFF_SubFontRec): Remove `num_local_subrs'.
(CFF_FontRec): Add `num_strings', `strings', and `string_pool'
fields.
Remove `string_index' and `num_global_subrs' fields.
Use real types instead of `void' for `pshinter' and `psnames' fields.
* src/cff/cffload.c: Don't include PS cmaps service.
(cff_index_get_pointers): Add `pool' parameter which allows to
insert an extra NUL character for each String INDEX entry.
(cff_index_get_name): Make it a local function.
(cff_index_get_string): New function.
(cff_subfont_load): Updated.
(cff_font_load): Initialize `num_strings', `strings', and
`string_pool' fields in the `CFF_FontRec' structure.
(cff_index_get_sid_string): Use `cff_index_get_string' instead of
`cff_index_get_name'.
(cff_font_done): Updated.
* src/cff/cffload.h: Don't include PS cmaps service.
(cff_index_get_string): Added.
(cff_index_get_sid_string): Updated.
* src/cff/cffobjs.c: Don't include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_size_get_globals_funcs, cff_slot_init): Updated.
(cff_face_init): Follow `cff_index_get_name',
`cff_index_get_string', and `cff_index_get_sid_string' changes.
* src/cff/cffcmap.c (cff_sid_free_glyph_name): Removed.
(cff_sid_to_glyph_name): Use `cff_index_get_cid_string'.
(cff_cmap_unicode_init): Updated.
* src/cff/cffdrivr.c: Don't include PS cmap service.
(cff_get_glyph_name): Avoid unnecessary lookup for POSTSCRIPT_CMAPS
service.
(cff_get_glyph_name, cff_ps_get_font_info, cff_get_ros): Follow API
`cff_index_get_sid_string' change.
(cff_get_name_index): Use `cff_index_get_string' instead of
`cff_index_get_name'.
* src/cff/cffgload.c: Don't include FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_decoder_init, cff_decoder_prepare): Updated.
2010-03-02 13:00:55 +01:00
|
|
|
if ( !pool )
|
|
|
|
t[n] = org_bytes + next_offset;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
t[n] = new_bytes + next_offset + extra;
|
|
|
|
|
|
|
|
if ( next_offset != cur_offset )
|
|
|
|
{
|
|
|
|
FT_MEM_COPY( t[n - 1], org_bytes + cur_offset, t[n] - t[n - 1] );
|
|
|
|
t[n][0] = '\0';
|
|
|
|
t[n] += 1;
|
|
|
|
extra++;
|
|
|
|
}
|
|
|
|
}
|
2000-12-08 03:42:29 +01:00
|
|
|
|
Improve CFF string (especially glyphname) lookup performance.
We do this by avoiding memory allocation and file I/O. This is
Savannah patch #7104.
* src/cff/cfftypes.h: Include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(CFF_SubFontRec): Remove `num_local_subrs'.
(CFF_FontRec): Add `num_strings', `strings', and `string_pool'
fields.
Remove `string_index' and `num_global_subrs' fields.
Use real types instead of `void' for `pshinter' and `psnames' fields.
* src/cff/cffload.c: Don't include PS cmaps service.
(cff_index_get_pointers): Add `pool' parameter which allows to
insert an extra NUL character for each String INDEX entry.
(cff_index_get_name): Make it a local function.
(cff_index_get_string): New function.
(cff_subfont_load): Updated.
(cff_font_load): Initialize `num_strings', `strings', and
`string_pool' fields in the `CFF_FontRec' structure.
(cff_index_get_sid_string): Use `cff_index_get_string' instead of
`cff_index_get_name'.
(cff_font_done): Updated.
* src/cff/cffload.h: Don't include PS cmaps service.
(cff_index_get_string): Added.
(cff_index_get_sid_string): Updated.
* src/cff/cffobjs.c: Don't include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_size_get_globals_funcs, cff_slot_init): Updated.
(cff_face_init): Follow `cff_index_get_name',
`cff_index_get_string', and `cff_index_get_sid_string' changes.
* src/cff/cffcmap.c (cff_sid_free_glyph_name): Removed.
(cff_sid_to_glyph_name): Use `cff_index_get_cid_string'.
(cff_cmap_unicode_init): Updated.
* src/cff/cffdrivr.c: Don't include PS cmap service.
(cff_get_glyph_name): Avoid unnecessary lookup for POSTSCRIPT_CMAPS
service.
(cff_get_glyph_name, cff_ps_get_font_info, cff_get_ros): Follow API
`cff_index_get_sid_string' change.
(cff_get_name_index): Use `cff_index_get_string' instead of
`cff_index_get_name'.
* src/cff/cffgload.c: Don't include FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_decoder_init, cff_decoder_prepare): Updated.
2010-03-02 13:00:55 +01:00
|
|
|
cur_offset = next_offset;
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
*table = t;
|
Improve CFF string (especially glyphname) lookup performance.
We do this by avoiding memory allocation and file I/O. This is
Savannah patch #7104.
* src/cff/cfftypes.h: Include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(CFF_SubFontRec): Remove `num_local_subrs'.
(CFF_FontRec): Add `num_strings', `strings', and `string_pool'
fields.
Remove `string_index' and `num_global_subrs' fields.
Use real types instead of `void' for `pshinter' and `psnames' fields.
* src/cff/cffload.c: Don't include PS cmaps service.
(cff_index_get_pointers): Add `pool' parameter which allows to
insert an extra NUL character for each String INDEX entry.
(cff_index_get_name): Make it a local function.
(cff_index_get_string): New function.
(cff_subfont_load): Updated.
(cff_font_load): Initialize `num_strings', `strings', and
`string_pool' fields in the `CFF_FontRec' structure.
(cff_index_get_sid_string): Use `cff_index_get_string' instead of
`cff_index_get_name'.
(cff_font_done): Updated.
* src/cff/cffload.h: Don't include PS cmaps service.
(cff_index_get_string): Added.
(cff_index_get_sid_string): Updated.
* src/cff/cffobjs.c: Don't include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_size_get_globals_funcs, cff_slot_init): Updated.
(cff_face_init): Follow `cff_index_get_name',
`cff_index_get_string', and `cff_index_get_sid_string' changes.
* src/cff/cffcmap.c (cff_sid_free_glyph_name): Removed.
(cff_sid_to_glyph_name): Use `cff_index_get_cid_string'.
(cff_cmap_unicode_init): Updated.
* src/cff/cffdrivr.c: Don't include PS cmap service.
(cff_get_glyph_name): Avoid unnecessary lookup for POSTSCRIPT_CMAPS
service.
(cff_get_glyph_name, cff_ps_get_font_info, cff_get_ros): Follow API
`cff_index_get_sid_string' change.
(cff_get_name_index): Use `cff_index_get_string' instead of
`cff_index_get_name'.
* src/cff/cffgload.c: Don't include FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_decoder_init, cff_decoder_prepare): Updated.
2010-03-02 13:00:55 +01:00
|
|
|
|
|
|
|
if ( pool )
|
|
|
|
*pool = new_bytes;
|
2016-02-15 14:28:28 +01:00
|
|
|
if ( pool_size )
|
|
|
|
*pool_size = new_size;
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
2007-01-05 14:14:08 +01:00
|
|
|
Exit:
|
2000-12-08 03:42:29 +01:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-01 03:26:22 +01:00
|
|
|
FT_LOCAL_DEF( FT_Error )
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
cff_index_access_element( CFF_Index idx,
|
|
|
|
FT_UInt element,
|
|
|
|
FT_Byte** pbytes,
|
|
|
|
FT_ULong* pbyte_len )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2013-03-14 11:21:17 +01:00
|
|
|
FT_Error error = FT_Err_Ok;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
|
* src/base/ftdbgmem.c (ft_mem_table_resize, ft_mem_table_new,
ft_mem_table_set, ft_mem_debug_alloc, ft_mem_debug_free,
ft_mem_debug_realloc, ft_mem_debug_done, FT_Alloc_Debug,
FT_Realloc_Debug, FT_Free_Debug): Fix compiler warnings.
* src/base/ftcalc.c (FT_MulFix): Ditto.
* src/cff/cffdrivr.c (cff_get_name_index): Ditto.
* src/cff/cffobjs.c (CFF_Size_Get_Global_Funcs, CFF_Size_Init,
CFF_GlyphSlot_Init): Ditto.
* src/cid/cidobjs.c (CID_GlyphSlot_Init,
CID_Size_Get_Globals_Funcs): Ditto.
* src/type1/t1objs.c (T1_Size_Get_Globals_Funcs, T1_GlyphSlot_Init):
Ditto.
* src/pshinter/pshmod.c (pshinter_interface): Use `static const'.
* src/winfonts/winfnt.c (FNT_Get_Next_Char): Remove unused
variables.
* include/freetype/internal/psaux.h (T1_Builder_Funcs): Renamed
to...
(T1_Builder_FuncsRec): This.
(T1_Builder_Funcs): New typedef.
(PSAux_Interface): Remove compiler warnings.
* src/psaux/psauxmod.c (t1_builder_funcs), src/psaux/psobjs.h
(t1_builder_funcs): Updated.
* src/pshinter/pshglob.h (PSH_Blue_Align): Replaced with ...
(PSH_BLUE_ALIGN_{NONE,TOP,BOT}): New defines.
(PSH_AlignmentRec): Updated.
* include/freetype/internal/ftstream.h (GET_Char, GET_Byte): Fix
typo.
* include/freetype/internal/ftgloadr.h (FT_SubGlyph): Ditto.
* src/base/ftstream (FT_Get_Char): Rename to...
(FT_Stream_Get_Char): This.
* src/base/ftnames.c (FT_Get_Sfnt_Name): s/index/idx/ -- `index' is
a built-in function in gcc, causing warning messages with gcc 3.0.
* src/autohint/ahglyph.c (ah_outline_load): Ditto.
* src/autohint/ahglobal.c (ah_hinter_compute_blues): Ditto.
* src/cache/ftcmanag.c (ftc_family_table_alloc,
ftc_family_table_free, FTC_Manager_Done, FTC_Manager_Register_Cache):
Ditto.
* src/cff/cffload.c (cff_new_index, cff_done_index,
cff_explicit_index, CFF_Access_Element, CFF_Forget_Element,
CFF_Get_Name, CFF_Get_String, CFF_Load_SubFont, CFF_Load_Font,
CFF_Done_Font): Ditto.
* src/psaux/psobjs.c (PS_Table_Add, PS_Parser_LoadField): Ditto.
* src/psaux/t1decode.c (T1_Decoder_Parse_Charstrings): Ditto.
* src/pshinter/pshrec.c (ps_mask_test_bit, ps_mask_clear_bit,
ps_mask_set_bit, ps_dimension_add_t1stem, ps_hints_t1stem3,
* src/pshinter/pshalgo1.c (psh1_hint_table_record,
psh1_hint_table_record_mask, psh1_hint_table_activate_mask): Ditto.
* src/pshinter/pshalgo2.c (psh2_hint_table_record,
psh2_hint_table_record_mask, psh2_hint_table_activate_mask): Ditto.
* src/sfnt/ttpost.c (Load_Format_20, Load_Format_25,
TT_Get_PS_Name): Ditto.
* src/truetype/ttgload.c (TT_Get_Metrics, Get_HMetrics,
load_truetype_glyph): Ditto.
* src/type1/t1load.c (parse_subrs, T1_Open_Face): Ditto.
* src/type1/t1afm.c (T1_Get_Kerning): Ditto.
* include/freetype/cache/ftcmanag.h (ftc_family_table_free): Ditto.
2002-03-07 22:59:59 +01:00
|
|
|
if ( idx && idx->count > element )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
|
|
|
/* compute start and end offsets */
|
2007-01-05 14:14:08 +01:00
|
|
|
FT_Stream stream = idx->stream;
|
|
|
|
FT_ULong off1, off2 = 0;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
|
2007-01-05 14:14:08 +01:00
|
|
|
/* load offsets from file or the offset table */
|
|
|
|
if ( !idx->offsets )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2007-01-06 08:47:45 +01:00
|
|
|
FT_ULong pos = element * idx->off_size;
|
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
if ( FT_STREAM_SEEK( idx->start + idx->hdr_size + pos ) )
|
2007-01-05 14:14:08 +01:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
off1 = cff_index_read_offset( idx, &error );
|
2007-01-06 08:47:45 +01:00
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
2007-01-05 14:14:08 +01:00
|
|
|
|
|
|
|
if ( off1 != 0 )
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
element++;
|
|
|
|
off2 = cff_index_read_offset( idx, &error );
|
2016-02-07 11:43:03 +01:00
|
|
|
|
|
|
|
} while ( off2 == 0 && element < idx->count );
|
2007-01-05 14:14:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* use offsets table */
|
|
|
|
{
|
|
|
|
off1 = idx->offsets[element];
|
|
|
|
if ( off1 )
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
element++;
|
|
|
|
off2 = idx->offsets[element];
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2007-01-05 14:14:08 +01:00
|
|
|
} while ( off2 == 0 && element < idx->count );
|
|
|
|
}
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
2010-09-19 20:51:19 +02:00
|
|
|
/* XXX: should check off2 does not exceed the end of this entry; */
|
|
|
|
/* at present, only truncate off2 at the end of this stream */
|
|
|
|
if ( off2 > stream->size + 1 ||
|
|
|
|
idx->data_offset > stream->size - off2 + 1 )
|
2010-09-19 18:30:38 +02:00
|
|
|
{
|
|
|
|
FT_ERROR(( "cff_index_access_element:"
|
|
|
|
" offset to next entry (%d)"
|
|
|
|
" exceeds the end of stream (%d)\n",
|
|
|
|
off2, stream->size - idx->data_offset + 1 ));
|
|
|
|
off2 = stream->size - idx->data_offset + 1;
|
|
|
|
}
|
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
/* access element */
|
2006-02-27 14:14:42 +01:00
|
|
|
if ( off1 && off2 > off1 )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
|
|
|
*pbyte_len = off2 - off1;
|
|
|
|
|
* src/base/ftdbgmem.c (ft_mem_table_resize, ft_mem_table_new,
ft_mem_table_set, ft_mem_debug_alloc, ft_mem_debug_free,
ft_mem_debug_realloc, ft_mem_debug_done, FT_Alloc_Debug,
FT_Realloc_Debug, FT_Free_Debug): Fix compiler warnings.
* src/base/ftcalc.c (FT_MulFix): Ditto.
* src/cff/cffdrivr.c (cff_get_name_index): Ditto.
* src/cff/cffobjs.c (CFF_Size_Get_Global_Funcs, CFF_Size_Init,
CFF_GlyphSlot_Init): Ditto.
* src/cid/cidobjs.c (CID_GlyphSlot_Init,
CID_Size_Get_Globals_Funcs): Ditto.
* src/type1/t1objs.c (T1_Size_Get_Globals_Funcs, T1_GlyphSlot_Init):
Ditto.
* src/pshinter/pshmod.c (pshinter_interface): Use `static const'.
* src/winfonts/winfnt.c (FNT_Get_Next_Char): Remove unused
variables.
* include/freetype/internal/psaux.h (T1_Builder_Funcs): Renamed
to...
(T1_Builder_FuncsRec): This.
(T1_Builder_Funcs): New typedef.
(PSAux_Interface): Remove compiler warnings.
* src/psaux/psauxmod.c (t1_builder_funcs), src/psaux/psobjs.h
(t1_builder_funcs): Updated.
* src/pshinter/pshglob.h (PSH_Blue_Align): Replaced with ...
(PSH_BLUE_ALIGN_{NONE,TOP,BOT}): New defines.
(PSH_AlignmentRec): Updated.
* include/freetype/internal/ftstream.h (GET_Char, GET_Byte): Fix
typo.
* include/freetype/internal/ftgloadr.h (FT_SubGlyph): Ditto.
* src/base/ftstream (FT_Get_Char): Rename to...
(FT_Stream_Get_Char): This.
* src/base/ftnames.c (FT_Get_Sfnt_Name): s/index/idx/ -- `index' is
a built-in function in gcc, causing warning messages with gcc 3.0.
* src/autohint/ahglyph.c (ah_outline_load): Ditto.
* src/autohint/ahglobal.c (ah_hinter_compute_blues): Ditto.
* src/cache/ftcmanag.c (ftc_family_table_alloc,
ftc_family_table_free, FTC_Manager_Done, FTC_Manager_Register_Cache):
Ditto.
* src/cff/cffload.c (cff_new_index, cff_done_index,
cff_explicit_index, CFF_Access_Element, CFF_Forget_Element,
CFF_Get_Name, CFF_Get_String, CFF_Load_SubFont, CFF_Load_Font,
CFF_Done_Font): Ditto.
* src/psaux/psobjs.c (PS_Table_Add, PS_Parser_LoadField): Ditto.
* src/psaux/t1decode.c (T1_Decoder_Parse_Charstrings): Ditto.
* src/pshinter/pshrec.c (ps_mask_test_bit, ps_mask_clear_bit,
ps_mask_set_bit, ps_dimension_add_t1stem, ps_hints_t1stem3,
* src/pshinter/pshalgo1.c (psh1_hint_table_record,
psh1_hint_table_record_mask, psh1_hint_table_activate_mask): Ditto.
* src/pshinter/pshalgo2.c (psh2_hint_table_record,
psh2_hint_table_record_mask, psh2_hint_table_activate_mask): Ditto.
* src/sfnt/ttpost.c (Load_Format_20, Load_Format_25,
TT_Get_PS_Name): Ditto.
* src/truetype/ttgload.c (TT_Get_Metrics, Get_HMetrics,
load_truetype_glyph): Ditto.
* src/type1/t1load.c (parse_subrs, T1_Open_Face): Ditto.
* src/type1/t1afm.c (T1_Get_Kerning): Ditto.
* include/freetype/cache/ftcmanag.h (ftc_family_table_free): Ditto.
2002-03-07 22:59:59 +01:00
|
|
|
if ( idx->bytes )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
|
|
|
/* this index was completely loaded in memory, that's easy */
|
* src/base/ftdbgmem.c (ft_mem_table_resize, ft_mem_table_new,
ft_mem_table_set, ft_mem_debug_alloc, ft_mem_debug_free,
ft_mem_debug_realloc, ft_mem_debug_done, FT_Alloc_Debug,
FT_Realloc_Debug, FT_Free_Debug): Fix compiler warnings.
* src/base/ftcalc.c (FT_MulFix): Ditto.
* src/cff/cffdrivr.c (cff_get_name_index): Ditto.
* src/cff/cffobjs.c (CFF_Size_Get_Global_Funcs, CFF_Size_Init,
CFF_GlyphSlot_Init): Ditto.
* src/cid/cidobjs.c (CID_GlyphSlot_Init,
CID_Size_Get_Globals_Funcs): Ditto.
* src/type1/t1objs.c (T1_Size_Get_Globals_Funcs, T1_GlyphSlot_Init):
Ditto.
* src/pshinter/pshmod.c (pshinter_interface): Use `static const'.
* src/winfonts/winfnt.c (FNT_Get_Next_Char): Remove unused
variables.
* include/freetype/internal/psaux.h (T1_Builder_Funcs): Renamed
to...
(T1_Builder_FuncsRec): This.
(T1_Builder_Funcs): New typedef.
(PSAux_Interface): Remove compiler warnings.
* src/psaux/psauxmod.c (t1_builder_funcs), src/psaux/psobjs.h
(t1_builder_funcs): Updated.
* src/pshinter/pshglob.h (PSH_Blue_Align): Replaced with ...
(PSH_BLUE_ALIGN_{NONE,TOP,BOT}): New defines.
(PSH_AlignmentRec): Updated.
* include/freetype/internal/ftstream.h (GET_Char, GET_Byte): Fix
typo.
* include/freetype/internal/ftgloadr.h (FT_SubGlyph): Ditto.
* src/base/ftstream (FT_Get_Char): Rename to...
(FT_Stream_Get_Char): This.
* src/base/ftnames.c (FT_Get_Sfnt_Name): s/index/idx/ -- `index' is
a built-in function in gcc, causing warning messages with gcc 3.0.
* src/autohint/ahglyph.c (ah_outline_load): Ditto.
* src/autohint/ahglobal.c (ah_hinter_compute_blues): Ditto.
* src/cache/ftcmanag.c (ftc_family_table_alloc,
ftc_family_table_free, FTC_Manager_Done, FTC_Manager_Register_Cache):
Ditto.
* src/cff/cffload.c (cff_new_index, cff_done_index,
cff_explicit_index, CFF_Access_Element, CFF_Forget_Element,
CFF_Get_Name, CFF_Get_String, CFF_Load_SubFont, CFF_Load_Font,
CFF_Done_Font): Ditto.
* src/psaux/psobjs.c (PS_Table_Add, PS_Parser_LoadField): Ditto.
* src/psaux/t1decode.c (T1_Decoder_Parse_Charstrings): Ditto.
* src/pshinter/pshrec.c (ps_mask_test_bit, ps_mask_clear_bit,
ps_mask_set_bit, ps_dimension_add_t1stem, ps_hints_t1stem3,
* src/pshinter/pshalgo1.c (psh1_hint_table_record,
psh1_hint_table_record_mask, psh1_hint_table_activate_mask): Ditto.
* src/pshinter/pshalgo2.c (psh2_hint_table_record,
psh2_hint_table_record_mask, psh2_hint_table_activate_mask): Ditto.
* src/sfnt/ttpost.c (Load_Format_20, Load_Format_25,
TT_Get_PS_Name): Ditto.
* src/truetype/ttgload.c (TT_Get_Metrics, Get_HMetrics,
load_truetype_glyph): Ditto.
* src/type1/t1load.c (parse_subrs, T1_Open_Face): Ditto.
* src/type1/t1afm.c (T1_Get_Kerning): Ditto.
* include/freetype/cache/ftcmanag.h (ftc_family_table_free): Ditto.
2002-03-07 22:59:59 +01:00
|
|
|
*pbytes = idx->bytes + off1 - 1;
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* this index is still on disk/file, access it through a frame */
|
2002-03-20 11:49:31 +01:00
|
|
|
if ( FT_STREAM_SEEK( idx->data_offset + off1 - 1 ) ||
|
|
|
|
FT_FRAME_EXTRACT( off2 - off1, *pbytes ) )
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* empty index element */
|
|
|
|
*pbytes = 0;
|
|
|
|
*pbyte_len = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_Argument );
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-01 03:26:22 +01:00
|
|
|
FT_LOCAL_DEF( void )
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
cff_index_forget_element( CFF_Index idx,
|
|
|
|
FT_Byte** pbytes )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
* src/base/ftdbgmem.c (ft_mem_table_resize, ft_mem_table_new,
ft_mem_table_set, ft_mem_debug_alloc, ft_mem_debug_free,
ft_mem_debug_realloc, ft_mem_debug_done, FT_Alloc_Debug,
FT_Realloc_Debug, FT_Free_Debug): Fix compiler warnings.
* src/base/ftcalc.c (FT_MulFix): Ditto.
* src/cff/cffdrivr.c (cff_get_name_index): Ditto.
* src/cff/cffobjs.c (CFF_Size_Get_Global_Funcs, CFF_Size_Init,
CFF_GlyphSlot_Init): Ditto.
* src/cid/cidobjs.c (CID_GlyphSlot_Init,
CID_Size_Get_Globals_Funcs): Ditto.
* src/type1/t1objs.c (T1_Size_Get_Globals_Funcs, T1_GlyphSlot_Init):
Ditto.
* src/pshinter/pshmod.c (pshinter_interface): Use `static const'.
* src/winfonts/winfnt.c (FNT_Get_Next_Char): Remove unused
variables.
* include/freetype/internal/psaux.h (T1_Builder_Funcs): Renamed
to...
(T1_Builder_FuncsRec): This.
(T1_Builder_Funcs): New typedef.
(PSAux_Interface): Remove compiler warnings.
* src/psaux/psauxmod.c (t1_builder_funcs), src/psaux/psobjs.h
(t1_builder_funcs): Updated.
* src/pshinter/pshglob.h (PSH_Blue_Align): Replaced with ...
(PSH_BLUE_ALIGN_{NONE,TOP,BOT}): New defines.
(PSH_AlignmentRec): Updated.
* include/freetype/internal/ftstream.h (GET_Char, GET_Byte): Fix
typo.
* include/freetype/internal/ftgloadr.h (FT_SubGlyph): Ditto.
* src/base/ftstream (FT_Get_Char): Rename to...
(FT_Stream_Get_Char): This.
* src/base/ftnames.c (FT_Get_Sfnt_Name): s/index/idx/ -- `index' is
a built-in function in gcc, causing warning messages with gcc 3.0.
* src/autohint/ahglyph.c (ah_outline_load): Ditto.
* src/autohint/ahglobal.c (ah_hinter_compute_blues): Ditto.
* src/cache/ftcmanag.c (ftc_family_table_alloc,
ftc_family_table_free, FTC_Manager_Done, FTC_Manager_Register_Cache):
Ditto.
* src/cff/cffload.c (cff_new_index, cff_done_index,
cff_explicit_index, CFF_Access_Element, CFF_Forget_Element,
CFF_Get_Name, CFF_Get_String, CFF_Load_SubFont, CFF_Load_Font,
CFF_Done_Font): Ditto.
* src/psaux/psobjs.c (PS_Table_Add, PS_Parser_LoadField): Ditto.
* src/psaux/t1decode.c (T1_Decoder_Parse_Charstrings): Ditto.
* src/pshinter/pshrec.c (ps_mask_test_bit, ps_mask_clear_bit,
ps_mask_set_bit, ps_dimension_add_t1stem, ps_hints_t1stem3,
* src/pshinter/pshalgo1.c (psh1_hint_table_record,
psh1_hint_table_record_mask, psh1_hint_table_activate_mask): Ditto.
* src/pshinter/pshalgo2.c (psh2_hint_table_record,
psh2_hint_table_record_mask, psh2_hint_table_activate_mask): Ditto.
* src/sfnt/ttpost.c (Load_Format_20, Load_Format_25,
TT_Get_PS_Name): Ditto.
* src/truetype/ttgload.c (TT_Get_Metrics, Get_HMetrics,
load_truetype_glyph): Ditto.
* src/type1/t1load.c (parse_subrs, T1_Open_Face): Ditto.
* src/type1/t1afm.c (T1_Get_Kerning): Ditto.
* include/freetype/cache/ftcmanag.h (ftc_family_table_free): Ditto.
2002-03-07 22:59:59 +01:00
|
|
|
if ( idx->bytes == 0 )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
* src/base/ftdbgmem.c (ft_mem_table_resize, ft_mem_table_new,
ft_mem_table_set, ft_mem_debug_alloc, ft_mem_debug_free,
ft_mem_debug_realloc, ft_mem_debug_done, FT_Alloc_Debug,
FT_Realloc_Debug, FT_Free_Debug): Fix compiler warnings.
* src/base/ftcalc.c (FT_MulFix): Ditto.
* src/cff/cffdrivr.c (cff_get_name_index): Ditto.
* src/cff/cffobjs.c (CFF_Size_Get_Global_Funcs, CFF_Size_Init,
CFF_GlyphSlot_Init): Ditto.
* src/cid/cidobjs.c (CID_GlyphSlot_Init,
CID_Size_Get_Globals_Funcs): Ditto.
* src/type1/t1objs.c (T1_Size_Get_Globals_Funcs, T1_GlyphSlot_Init):
Ditto.
* src/pshinter/pshmod.c (pshinter_interface): Use `static const'.
* src/winfonts/winfnt.c (FNT_Get_Next_Char): Remove unused
variables.
* include/freetype/internal/psaux.h (T1_Builder_Funcs): Renamed
to...
(T1_Builder_FuncsRec): This.
(T1_Builder_Funcs): New typedef.
(PSAux_Interface): Remove compiler warnings.
* src/psaux/psauxmod.c (t1_builder_funcs), src/psaux/psobjs.h
(t1_builder_funcs): Updated.
* src/pshinter/pshglob.h (PSH_Blue_Align): Replaced with ...
(PSH_BLUE_ALIGN_{NONE,TOP,BOT}): New defines.
(PSH_AlignmentRec): Updated.
* include/freetype/internal/ftstream.h (GET_Char, GET_Byte): Fix
typo.
* include/freetype/internal/ftgloadr.h (FT_SubGlyph): Ditto.
* src/base/ftstream (FT_Get_Char): Rename to...
(FT_Stream_Get_Char): This.
* src/base/ftnames.c (FT_Get_Sfnt_Name): s/index/idx/ -- `index' is
a built-in function in gcc, causing warning messages with gcc 3.0.
* src/autohint/ahglyph.c (ah_outline_load): Ditto.
* src/autohint/ahglobal.c (ah_hinter_compute_blues): Ditto.
* src/cache/ftcmanag.c (ftc_family_table_alloc,
ftc_family_table_free, FTC_Manager_Done, FTC_Manager_Register_Cache):
Ditto.
* src/cff/cffload.c (cff_new_index, cff_done_index,
cff_explicit_index, CFF_Access_Element, CFF_Forget_Element,
CFF_Get_Name, CFF_Get_String, CFF_Load_SubFont, CFF_Load_Font,
CFF_Done_Font): Ditto.
* src/psaux/psobjs.c (PS_Table_Add, PS_Parser_LoadField): Ditto.
* src/psaux/t1decode.c (T1_Decoder_Parse_Charstrings): Ditto.
* src/pshinter/pshrec.c (ps_mask_test_bit, ps_mask_clear_bit,
ps_mask_set_bit, ps_dimension_add_t1stem, ps_hints_t1stem3,
* src/pshinter/pshalgo1.c (psh1_hint_table_record,
psh1_hint_table_record_mask, psh1_hint_table_activate_mask): Ditto.
* src/pshinter/pshalgo2.c (psh2_hint_table_record,
psh2_hint_table_record_mask, psh2_hint_table_activate_mask): Ditto.
* src/sfnt/ttpost.c (Load_Format_20, Load_Format_25,
TT_Get_PS_Name): Ditto.
* src/truetype/ttgload.c (TT_Get_Metrics, Get_HMetrics,
load_truetype_glyph): Ditto.
* src/type1/t1load.c (parse_subrs, T1_Open_Face): Ditto.
* src/type1/t1afm.c (T1_Get_Kerning): Ditto.
* include/freetype/cache/ftcmanag.h (ftc_family_table_free): Ditto.
2002-03-07 22:59:59 +01:00
|
|
|
FT_Stream stream = idx->stream;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
|
2002-03-20 11:49:31 +01:00
|
|
|
FT_FRAME_RELEASE( *pbytes );
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Improve CFF string (especially glyphname) lookup performance.
We do this by avoiding memory allocation and file I/O. This is
Savannah patch #7104.
* src/cff/cfftypes.h: Include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(CFF_SubFontRec): Remove `num_local_subrs'.
(CFF_FontRec): Add `num_strings', `strings', and `string_pool'
fields.
Remove `string_index' and `num_global_subrs' fields.
Use real types instead of `void' for `pshinter' and `psnames' fields.
* src/cff/cffload.c: Don't include PS cmaps service.
(cff_index_get_pointers): Add `pool' parameter which allows to
insert an extra NUL character for each String INDEX entry.
(cff_index_get_name): Make it a local function.
(cff_index_get_string): New function.
(cff_subfont_load): Updated.
(cff_font_load): Initialize `num_strings', `strings', and
`string_pool' fields in the `CFF_FontRec' structure.
(cff_index_get_sid_string): Use `cff_index_get_string' instead of
`cff_index_get_name'.
(cff_font_done): Updated.
* src/cff/cffload.h: Don't include PS cmaps service.
(cff_index_get_string): Added.
(cff_index_get_sid_string): Updated.
* src/cff/cffobjs.c: Don't include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_size_get_globals_funcs, cff_slot_init): Updated.
(cff_face_init): Follow `cff_index_get_name',
`cff_index_get_string', and `cff_index_get_sid_string' changes.
* src/cff/cffcmap.c (cff_sid_free_glyph_name): Removed.
(cff_sid_to_glyph_name): Use `cff_index_get_cid_string'.
(cff_cmap_unicode_init): Updated.
* src/cff/cffdrivr.c: Don't include PS cmap service.
(cff_get_glyph_name): Avoid unnecessary lookup for POSTSCRIPT_CMAPS
service.
(cff_get_glyph_name, cff_ps_get_font_info, cff_get_ros): Follow API
`cff_index_get_sid_string' change.
(cff_get_name_index): Use `cff_index_get_string' instead of
`cff_index_get_name'.
* src/cff/cffgload.c: Don't include FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_decoder_init, cff_decoder_prepare): Updated.
2010-03-02 13:00:55 +01:00
|
|
|
/* get an entry from Name INDEX */
|
2010-03-14 15:12:13 +01:00
|
|
|
FT_LOCAL_DEF( FT_String* )
|
Improve CFF string (especially glyphname) lookup performance.
We do this by avoiding memory allocation and file I/O. This is
Savannah patch #7104.
* src/cff/cfftypes.h: Include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(CFF_SubFontRec): Remove `num_local_subrs'.
(CFF_FontRec): Add `num_strings', `strings', and `string_pool'
fields.
Remove `string_index' and `num_global_subrs' fields.
Use real types instead of `void' for `pshinter' and `psnames' fields.
* src/cff/cffload.c: Don't include PS cmaps service.
(cff_index_get_pointers): Add `pool' parameter which allows to
insert an extra NUL character for each String INDEX entry.
(cff_index_get_name): Make it a local function.
(cff_index_get_string): New function.
(cff_subfont_load): Updated.
(cff_font_load): Initialize `num_strings', `strings', and
`string_pool' fields in the `CFF_FontRec' structure.
(cff_index_get_sid_string): Use `cff_index_get_string' instead of
`cff_index_get_name'.
(cff_font_done): Updated.
* src/cff/cffload.h: Don't include PS cmaps service.
(cff_index_get_string): Added.
(cff_index_get_sid_string): Updated.
* src/cff/cffobjs.c: Don't include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_size_get_globals_funcs, cff_slot_init): Updated.
(cff_face_init): Follow `cff_index_get_name',
`cff_index_get_string', and `cff_index_get_sid_string' changes.
* src/cff/cffcmap.c (cff_sid_free_glyph_name): Removed.
(cff_sid_to_glyph_name): Use `cff_index_get_cid_string'.
(cff_cmap_unicode_init): Updated.
* src/cff/cffdrivr.c: Don't include PS cmap service.
(cff_get_glyph_name): Avoid unnecessary lookup for POSTSCRIPT_CMAPS
service.
(cff_get_glyph_name, cff_ps_get_font_info, cff_get_ros): Follow API
`cff_index_get_sid_string' change.
(cff_get_name_index): Use `cff_index_get_string' instead of
`cff_index_get_name'.
* src/cff/cffgload.c: Don't include FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_decoder_init, cff_decoder_prepare): Updated.
2010-03-02 13:00:55 +01:00
|
|
|
cff_index_get_name( CFF_Font font,
|
|
|
|
FT_UInt element )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
Improve CFF string (especially glyphname) lookup performance.
We do this by avoiding memory allocation and file I/O. This is
Savannah patch #7104.
* src/cff/cfftypes.h: Include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(CFF_SubFontRec): Remove `num_local_subrs'.
(CFF_FontRec): Add `num_strings', `strings', and `string_pool'
fields.
Remove `string_index' and `num_global_subrs' fields.
Use real types instead of `void' for `pshinter' and `psnames' fields.
* src/cff/cffload.c: Don't include PS cmaps service.
(cff_index_get_pointers): Add `pool' parameter which allows to
insert an extra NUL character for each String INDEX entry.
(cff_index_get_name): Make it a local function.
(cff_index_get_string): New function.
(cff_subfont_load): Updated.
(cff_font_load): Initialize `num_strings', `strings', and
`string_pool' fields in the `CFF_FontRec' structure.
(cff_index_get_sid_string): Use `cff_index_get_string' instead of
`cff_index_get_name'.
(cff_font_done): Updated.
* src/cff/cffload.h: Don't include PS cmaps service.
(cff_index_get_string): Added.
(cff_index_get_sid_string): Updated.
* src/cff/cffobjs.c: Don't include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_size_get_globals_funcs, cff_slot_init): Updated.
(cff_face_init): Follow `cff_index_get_name',
`cff_index_get_string', and `cff_index_get_sid_string' changes.
* src/cff/cffcmap.c (cff_sid_free_glyph_name): Removed.
(cff_sid_to_glyph_name): Use `cff_index_get_cid_string'.
(cff_cmap_unicode_init): Updated.
* src/cff/cffdrivr.c: Don't include PS cmap service.
(cff_get_glyph_name): Avoid unnecessary lookup for POSTSCRIPT_CMAPS
service.
(cff_get_glyph_name, cff_ps_get_font_info, cff_get_ros): Follow API
`cff_index_get_sid_string' change.
(cff_get_name_index): Use `cff_index_get_string' instead of
`cff_index_get_name'.
* src/cff/cffgload.c: Don't include FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_decoder_init, cff_decoder_prepare): Updated.
2010-03-02 13:00:55 +01:00
|
|
|
CFF_Index idx = &font->name_index;
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
FT_Memory memory;
|
2000-12-08 03:42:29 +01:00
|
|
|
FT_Byte* bytes;
|
|
|
|
FT_ULong byte_len;
|
|
|
|
FT_Error error;
|
|
|
|
FT_String* name = 0;
|
|
|
|
|
|
|
|
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
if ( !idx->stream ) /* CFF2 does not include a name index */
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
memory = idx->stream->memory;
|
|
|
|
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
error = cff_index_access_element( idx, element, &bytes, &byte_len );
|
2000-12-08 03:42:29 +01:00
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
|
2002-03-22 14:52:37 +01:00
|
|
|
if ( !FT_ALLOC( name, byte_len + 1 ) )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2016-09-03 06:33:36 +02:00
|
|
|
if ( byte_len )
|
|
|
|
FT_MEM_COPY( name, bytes, byte_len );
|
2000-12-08 03:42:29 +01:00
|
|
|
name[byte_len] = 0;
|
|
|
|
}
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
cff_index_forget_element( idx, &bytes );
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
Exit:
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Improve CFF string (especially glyphname) lookup performance.
We do this by avoiding memory allocation and file I/O. This is
Savannah patch #7104.
* src/cff/cfftypes.h: Include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(CFF_SubFontRec): Remove `num_local_subrs'.
(CFF_FontRec): Add `num_strings', `strings', and `string_pool'
fields.
Remove `string_index' and `num_global_subrs' fields.
Use real types instead of `void' for `pshinter' and `psnames' fields.
* src/cff/cffload.c: Don't include PS cmaps service.
(cff_index_get_pointers): Add `pool' parameter which allows to
insert an extra NUL character for each String INDEX entry.
(cff_index_get_name): Make it a local function.
(cff_index_get_string): New function.
(cff_subfont_load): Updated.
(cff_font_load): Initialize `num_strings', `strings', and
`string_pool' fields in the `CFF_FontRec' structure.
(cff_index_get_sid_string): Use `cff_index_get_string' instead of
`cff_index_get_name'.
(cff_font_done): Updated.
* src/cff/cffload.h: Don't include PS cmaps service.
(cff_index_get_string): Added.
(cff_index_get_sid_string): Updated.
* src/cff/cffobjs.c: Don't include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_size_get_globals_funcs, cff_slot_init): Updated.
(cff_face_init): Follow `cff_index_get_name',
`cff_index_get_string', and `cff_index_get_sid_string' changes.
* src/cff/cffcmap.c (cff_sid_free_glyph_name): Removed.
(cff_sid_to_glyph_name): Use `cff_index_get_cid_string'.
(cff_cmap_unicode_init): Updated.
* src/cff/cffdrivr.c: Don't include PS cmap service.
(cff_get_glyph_name): Avoid unnecessary lookup for POSTSCRIPT_CMAPS
service.
(cff_get_glyph_name, cff_ps_get_font_info, cff_get_ros): Follow API
`cff_index_get_sid_string' change.
(cff_get_name_index): Use `cff_index_get_string' instead of
`cff_index_get_name'.
* src/cff/cffgload.c: Don't include FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_decoder_init, cff_decoder_prepare): Updated.
2010-03-02 13:00:55 +01:00
|
|
|
/* get an entry from String INDEX */
|
|
|
|
FT_LOCAL_DEF( FT_String* )
|
|
|
|
cff_index_get_string( CFF_Font font,
|
|
|
|
FT_UInt element )
|
|
|
|
{
|
|
|
|
return ( element < font->num_strings )
|
|
|
|
? (FT_String*)font->strings[element]
|
|
|
|
: NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-01 03:26:22 +01:00
|
|
|
FT_LOCAL_DEF( FT_String* )
|
Improve CFF string (especially glyphname) lookup performance.
We do this by avoiding memory allocation and file I/O. This is
Savannah patch #7104.
* src/cff/cfftypes.h: Include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(CFF_SubFontRec): Remove `num_local_subrs'.
(CFF_FontRec): Add `num_strings', `strings', and `string_pool'
fields.
Remove `string_index' and `num_global_subrs' fields.
Use real types instead of `void' for `pshinter' and `psnames' fields.
* src/cff/cffload.c: Don't include PS cmaps service.
(cff_index_get_pointers): Add `pool' parameter which allows to
insert an extra NUL character for each String INDEX entry.
(cff_index_get_name): Make it a local function.
(cff_index_get_string): New function.
(cff_subfont_load): Updated.
(cff_font_load): Initialize `num_strings', `strings', and
`string_pool' fields in the `CFF_FontRec' structure.
(cff_index_get_sid_string): Use `cff_index_get_string' instead of
`cff_index_get_name'.
(cff_font_done): Updated.
* src/cff/cffload.h: Don't include PS cmaps service.
(cff_index_get_string): Added.
(cff_index_get_sid_string): Updated.
* src/cff/cffobjs.c: Don't include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_size_get_globals_funcs, cff_slot_init): Updated.
(cff_face_init): Follow `cff_index_get_name',
`cff_index_get_string', and `cff_index_get_sid_string' changes.
* src/cff/cffcmap.c (cff_sid_free_glyph_name): Removed.
(cff_sid_to_glyph_name): Use `cff_index_get_cid_string'.
(cff_cmap_unicode_init): Updated.
* src/cff/cffdrivr.c: Don't include PS cmap service.
(cff_get_glyph_name): Avoid unnecessary lookup for POSTSCRIPT_CMAPS
service.
(cff_get_glyph_name, cff_ps_get_font_info, cff_get_ros): Follow API
`cff_index_get_sid_string' change.
(cff_get_name_index): Use `cff_index_get_string' instead of
`cff_index_get_name'.
* src/cff/cffgload.c: Don't include FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_decoder_init, cff_decoder_prepare): Updated.
2010-03-02 13:00:55 +01:00
|
|
|
cff_index_get_sid_string( CFF_Font font,
|
|
|
|
FT_UInt sid )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2003-12-11 18:55:58 +01:00
|
|
|
/* value 0xFFFFU indicates a missing dictionary entry */
|
|
|
|
if ( sid == 0xFFFFU )
|
Improve CFF string (especially glyphname) lookup performance.
We do this by avoiding memory allocation and file I/O. This is
Savannah patch #7104.
* src/cff/cfftypes.h: Include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(CFF_SubFontRec): Remove `num_local_subrs'.
(CFF_FontRec): Add `num_strings', `strings', and `string_pool'
fields.
Remove `string_index' and `num_global_subrs' fields.
Use real types instead of `void' for `pshinter' and `psnames' fields.
* src/cff/cffload.c: Don't include PS cmaps service.
(cff_index_get_pointers): Add `pool' parameter which allows to
insert an extra NUL character for each String INDEX entry.
(cff_index_get_name): Make it a local function.
(cff_index_get_string): New function.
(cff_subfont_load): Updated.
(cff_font_load): Initialize `num_strings', `strings', and
`string_pool' fields in the `CFF_FontRec' structure.
(cff_index_get_sid_string): Use `cff_index_get_string' instead of
`cff_index_get_name'.
(cff_font_done): Updated.
* src/cff/cffload.h: Don't include PS cmaps service.
(cff_index_get_string): Added.
(cff_index_get_sid_string): Updated.
* src/cff/cffobjs.c: Don't include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_size_get_globals_funcs, cff_slot_init): Updated.
(cff_face_init): Follow `cff_index_get_name',
`cff_index_get_string', and `cff_index_get_sid_string' changes.
* src/cff/cffcmap.c (cff_sid_free_glyph_name): Removed.
(cff_sid_to_glyph_name): Use `cff_index_get_cid_string'.
(cff_cmap_unicode_init): Updated.
* src/cff/cffdrivr.c: Don't include PS cmap service.
(cff_get_glyph_name): Avoid unnecessary lookup for POSTSCRIPT_CMAPS
service.
(cff_get_glyph_name, cff_ps_get_font_info, cff_get_ros): Follow API
`cff_index_get_sid_string' change.
(cff_get_name_index): Use `cff_index_get_string' instead of
`cff_index_get_name'.
* src/cff/cffgload.c: Don't include FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_decoder_init, cff_decoder_prepare): Updated.
2010-03-02 13:00:55 +01:00
|
|
|
return NULL;
|
2003-12-11 18:55:58 +01:00
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
/* if it is not a standard string, return it */
|
|
|
|
if ( sid > 390 )
|
Improve CFF string (especially glyphname) lookup performance.
We do this by avoiding memory allocation and file I/O. This is
Savannah patch #7104.
* src/cff/cfftypes.h: Include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(CFF_SubFontRec): Remove `num_local_subrs'.
(CFF_FontRec): Add `num_strings', `strings', and `string_pool'
fields.
Remove `string_index' and `num_global_subrs' fields.
Use real types instead of `void' for `pshinter' and `psnames' fields.
* src/cff/cffload.c: Don't include PS cmaps service.
(cff_index_get_pointers): Add `pool' parameter which allows to
insert an extra NUL character for each String INDEX entry.
(cff_index_get_name): Make it a local function.
(cff_index_get_string): New function.
(cff_subfont_load): Updated.
(cff_font_load): Initialize `num_strings', `strings', and
`string_pool' fields in the `CFF_FontRec' structure.
(cff_index_get_sid_string): Use `cff_index_get_string' instead of
`cff_index_get_name'.
(cff_font_done): Updated.
* src/cff/cffload.h: Don't include PS cmaps service.
(cff_index_get_string): Added.
(cff_index_get_sid_string): Updated.
* src/cff/cffobjs.c: Don't include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_size_get_globals_funcs, cff_slot_init): Updated.
(cff_face_init): Follow `cff_index_get_name',
`cff_index_get_string', and `cff_index_get_sid_string' changes.
* src/cff/cffcmap.c (cff_sid_free_glyph_name): Removed.
(cff_sid_to_glyph_name): Use `cff_index_get_cid_string'.
(cff_cmap_unicode_init): Updated.
* src/cff/cffdrivr.c: Don't include PS cmap service.
(cff_get_glyph_name): Avoid unnecessary lookup for POSTSCRIPT_CMAPS
service.
(cff_get_glyph_name, cff_ps_get_font_info, cff_get_ros): Follow API
`cff_index_get_sid_string' change.
(cff_get_name_index): Use `cff_index_get_string' instead of
`cff_index_get_name'.
* src/cff/cffgload.c: Don't include FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_decoder_init, cff_decoder_prepare): Updated.
2010-03-02 13:00:55 +01:00
|
|
|
return cff_index_get_string( font, sid - 391 );
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2003-12-11 18:55:58 +01:00
|
|
|
/* CID-keyed CFF fonts don't have glyph names */
|
Improve CFF string (especially glyphname) lookup performance.
We do this by avoiding memory allocation and file I/O. This is
Savannah patch #7104.
* src/cff/cfftypes.h: Include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(CFF_SubFontRec): Remove `num_local_subrs'.
(CFF_FontRec): Add `num_strings', `strings', and `string_pool'
fields.
Remove `string_index' and `num_global_subrs' fields.
Use real types instead of `void' for `pshinter' and `psnames' fields.
* src/cff/cffload.c: Don't include PS cmaps service.
(cff_index_get_pointers): Add `pool' parameter which allows to
insert an extra NUL character for each String INDEX entry.
(cff_index_get_name): Make it a local function.
(cff_index_get_string): New function.
(cff_subfont_load): Updated.
(cff_font_load): Initialize `num_strings', `strings', and
`string_pool' fields in the `CFF_FontRec' structure.
(cff_index_get_sid_string): Use `cff_index_get_string' instead of
`cff_index_get_name'.
(cff_font_done): Updated.
* src/cff/cffload.h: Don't include PS cmaps service.
(cff_index_get_string): Added.
(cff_index_get_sid_string): Updated.
* src/cff/cffobjs.c: Don't include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_size_get_globals_funcs, cff_slot_init): Updated.
(cff_face_init): Follow `cff_index_get_name',
`cff_index_get_string', and `cff_index_get_sid_string' changes.
* src/cff/cffcmap.c (cff_sid_free_glyph_name): Removed.
(cff_sid_to_glyph_name): Use `cff_index_get_cid_string'.
(cff_cmap_unicode_init): Updated.
* src/cff/cffdrivr.c: Don't include PS cmap service.
(cff_get_glyph_name): Avoid unnecessary lookup for POSTSCRIPT_CMAPS
service.
(cff_get_glyph_name, cff_ps_get_font_info, cff_get_ros): Follow API
`cff_index_get_sid_string' change.
(cff_get_name_index): Use `cff_index_get_string' instead of
`cff_index_get_name'.
* src/cff/cffgload.c: Don't include FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_decoder_init, cff_decoder_prepare): Updated.
2010-03-02 13:00:55 +01:00
|
|
|
if ( !font->psnames )
|
|
|
|
return NULL;
|
2003-12-11 18:55:58 +01:00
|
|
|
|
Improve CFF string (especially glyphname) lookup performance.
We do this by avoiding memory allocation and file I/O. This is
Savannah patch #7104.
* src/cff/cfftypes.h: Include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(CFF_SubFontRec): Remove `num_local_subrs'.
(CFF_FontRec): Add `num_strings', `strings', and `string_pool'
fields.
Remove `string_index' and `num_global_subrs' fields.
Use real types instead of `void' for `pshinter' and `psnames' fields.
* src/cff/cffload.c: Don't include PS cmaps service.
(cff_index_get_pointers): Add `pool' parameter which allows to
insert an extra NUL character for each String INDEX entry.
(cff_index_get_name): Make it a local function.
(cff_index_get_string): New function.
(cff_subfont_load): Updated.
(cff_font_load): Initialize `num_strings', `strings', and
`string_pool' fields in the `CFF_FontRec' structure.
(cff_index_get_sid_string): Use `cff_index_get_string' instead of
`cff_index_get_name'.
(cff_font_done): Updated.
* src/cff/cffload.h: Don't include PS cmaps service.
(cff_index_get_string): Added.
(cff_index_get_sid_string): Updated.
* src/cff/cffobjs.c: Don't include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_size_get_globals_funcs, cff_slot_init): Updated.
(cff_face_init): Follow `cff_index_get_name',
`cff_index_get_string', and `cff_index_get_sid_string' changes.
* src/cff/cffcmap.c (cff_sid_free_glyph_name): Removed.
(cff_sid_to_glyph_name): Use `cff_index_get_cid_string'.
(cff_cmap_unicode_init): Updated.
* src/cff/cffdrivr.c: Don't include PS cmap service.
(cff_get_glyph_name): Avoid unnecessary lookup for POSTSCRIPT_CMAPS
service.
(cff_get_glyph_name, cff_ps_get_font_info, cff_get_ros): Follow API
`cff_index_get_sid_string' change.
(cff_get_name_index): Use `cff_index_get_string' instead of
`cff_index_get_name'.
* src/cff/cffgload.c: Don't include FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_decoder_init, cff_decoder_prepare): Updated.
2010-03-02 13:00:55 +01:00
|
|
|
/* this is a standard string */
|
|
|
|
return (FT_String *)font->psnames->adobe_std_strings( sid );
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*** ***/
|
|
|
|
/*** FD Select table support ***/
|
|
|
|
/*** ***/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
|
2001-06-27 21:46:12 +02:00
|
|
|
static void
|
2002-08-06 23:47:40 +02:00
|
|
|
CFF_Done_FD_Select( CFF_FDSelect fdselect,
|
2002-03-30 17:41:09 +01:00
|
|
|
FT_Stream stream )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2002-08-06 23:47:40 +02:00
|
|
|
if ( fdselect->data )
|
|
|
|
FT_FRAME_RELEASE( fdselect->data );
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2002-08-06 23:47:40 +02:00
|
|
|
fdselect->data_size = 0;
|
|
|
|
fdselect->format = 0;
|
|
|
|
fdselect->range_count = 0;
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-27 21:46:12 +02:00
|
|
|
static FT_Error
|
2002-08-06 23:47:40 +02:00
|
|
|
CFF_Load_FD_Select( CFF_FDSelect fdselect,
|
2002-03-30 17:41:09 +01:00
|
|
|
FT_UInt num_glyphs,
|
|
|
|
FT_Stream stream,
|
|
|
|
FT_ULong offset )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2000-12-08 17:17:16 +01:00
|
|
|
FT_Error error;
|
|
|
|
FT_Byte format;
|
|
|
|
FT_UInt num_ranges;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* read format */
|
* include/freetype/internal/ftstream.h,
src/base/ftstream.c, src/cff/cffload.c, src/pcf/pcfread.c,
src/sfnt/ttcmap.c, src/sfnt/ttcmap0.c, src/sfnt/ttload.c,
src/sfnt/ttpost.c, src/sfnt/ttsbit.c,
src/truetype/ttgload.c, src/truetype/ttpload.c,
src/winfonts/winfnt.c:
changed the definitions of stream macros. Examples:
NEXT_Byte => FT_NEXT_BYTE
NEXT_Short => FT_NEXT_SHORT
NEXT_UShortLE => FT_NEXT_USHORT_LE
READ_Short => FT_READ_SHORT
GET_Long => FT_GET_LONG
etc..
also introduced the FT_PEEK_XXXX functions..
2002-03-22 13:55:23 +01:00
|
|
|
if ( FT_STREAM_SEEK( offset ) || FT_READ_BYTE( format ) )
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
|
|
|
|
2002-08-06 23:47:40 +02:00
|
|
|
fdselect->format = format;
|
|
|
|
fdselect->cache_count = 0; /* clear cache */
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
switch ( format )
|
|
|
|
{
|
|
|
|
case 0: /* format 0, that's simple */
|
2002-08-06 23:47:40 +02:00
|
|
|
fdselect->data_size = num_glyphs;
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Load_Data;
|
|
|
|
|
|
|
|
case 3: /* format 3, a tad more complex */
|
* include/freetype/internal/ftstream.h,
src/base/ftstream.c, src/cff/cffload.c, src/pcf/pcfread.c,
src/sfnt/ttcmap.c, src/sfnt/ttcmap0.c, src/sfnt/ttload.c,
src/sfnt/ttpost.c, src/sfnt/ttsbit.c,
src/truetype/ttgload.c, src/truetype/ttpload.c,
src/winfonts/winfnt.c:
changed the definitions of stream macros. Examples:
NEXT_Byte => FT_NEXT_BYTE
NEXT_Short => FT_NEXT_SHORT
NEXT_UShortLE => FT_NEXT_USHORT_LE
READ_Short => FT_READ_SHORT
GET_Long => FT_GET_LONG
etc..
also introduced the FT_PEEK_XXXX functions..
2002-03-22 13:55:23 +01:00
|
|
|
if ( FT_READ_USHORT( num_ranges ) )
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
|
|
|
|
2014-02-26 14:18:03 +01:00
|
|
|
if ( !num_ranges )
|
|
|
|
{
|
|
|
|
FT_TRACE0(( "CFF_Load_FD_Select: empty FDSelect array\n" ));
|
|
|
|
error = FT_THROW( Invalid_File_Format );
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2002-08-06 23:47:40 +02:00
|
|
|
fdselect->data_size = num_ranges * 3 + 2;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
Load_Data:
|
2002-08-06 23:47:40 +02:00
|
|
|
if ( FT_FRAME_EXTRACT( fdselect->data_size, fdselect->data ) )
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: /* hmm... that's wrong */
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_File_Format );
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-01 03:26:22 +01:00
|
|
|
FT_LOCAL_DEF( FT_Byte )
|
2002-08-06 23:47:40 +02:00
|
|
|
cff_fd_select_get( CFF_FDSelect fdselect,
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
FT_UInt glyph_index )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
|
|
|
FT_Byte fd = 0;
|
|
|
|
|
2016-12-17 22:52:50 +01:00
|
|
|
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
/* if there is no FDSelect, return zero */
|
|
|
|
/* Note: CFF2 with just one Font Dict has no FDSelect */
|
|
|
|
if ( fdselect->data == NULL )
|
|
|
|
goto Exit;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2002-08-06 23:47:40 +02:00
|
|
|
switch ( fdselect->format )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2002-08-06 23:47:40 +02:00
|
|
|
fd = fdselect->data[glyph_index];
|
2000-12-08 03:42:29 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
2014-02-26 14:18:03 +01:00
|
|
|
/* first, compare to the cache */
|
2002-08-06 23:47:40 +02:00
|
|
|
if ( (FT_UInt)( glyph_index - fdselect->cache_first ) <
|
|
|
|
fdselect->cache_count )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2002-08-06 23:47:40 +02:00
|
|
|
fd = fdselect->cache_fd;
|
2000-12-08 03:42:29 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-02-26 14:18:03 +01:00
|
|
|
/* then, look up the ranges array */
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2002-08-06 23:47:40 +02:00
|
|
|
FT_Byte* p = fdselect->data;
|
|
|
|
FT_Byte* p_limit = p + fdselect->data_size;
|
2000-12-08 03:42:29 +01:00
|
|
|
FT_Byte fd2;
|
|
|
|
FT_UInt first, limit;
|
|
|
|
|
|
|
|
|
* include/freetype/internal/ftstream.h,
src/base/ftstream.c, src/cff/cffload.c, src/pcf/pcfread.c,
src/sfnt/ttcmap.c, src/sfnt/ttcmap0.c, src/sfnt/ttload.c,
src/sfnt/ttpost.c, src/sfnt/ttsbit.c,
src/truetype/ttgload.c, src/truetype/ttpload.c,
src/winfonts/winfnt.c:
changed the definitions of stream macros. Examples:
NEXT_Byte => FT_NEXT_BYTE
NEXT_Short => FT_NEXT_SHORT
NEXT_UShortLE => FT_NEXT_USHORT_LE
READ_Short => FT_READ_SHORT
GET_Long => FT_GET_LONG
etc..
also introduced the FT_PEEK_XXXX functions..
2002-03-22 13:55:23 +01:00
|
|
|
first = FT_NEXT_USHORT( p );
|
2000-12-08 03:42:29 +01:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if ( glyph_index < first )
|
|
|
|
break;
|
|
|
|
|
|
|
|
fd2 = *p++;
|
* include/freetype/internal/ftstream.h,
src/base/ftstream.c, src/cff/cffload.c, src/pcf/pcfread.c,
src/sfnt/ttcmap.c, src/sfnt/ttcmap0.c, src/sfnt/ttload.c,
src/sfnt/ttpost.c, src/sfnt/ttsbit.c,
src/truetype/ttgload.c, src/truetype/ttpload.c,
src/winfonts/winfnt.c:
changed the definitions of stream macros. Examples:
NEXT_Byte => FT_NEXT_BYTE
NEXT_Short => FT_NEXT_SHORT
NEXT_UShortLE => FT_NEXT_USHORT_LE
READ_Short => FT_READ_SHORT
GET_Long => FT_GET_LONG
etc..
also introduced the FT_PEEK_XXXX functions..
2002-03-22 13:55:23 +01:00
|
|
|
limit = FT_NEXT_USHORT( p );
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
if ( glyph_index < limit )
|
|
|
|
{
|
|
|
|
fd = fd2;
|
|
|
|
|
|
|
|
/* update cache */
|
2002-08-06 23:47:40 +02:00
|
|
|
fdselect->cache_first = first;
|
2014-02-26 14:18:03 +01:00
|
|
|
fdselect->cache_count = limit - first;
|
2002-08-06 23:47:40 +02:00
|
|
|
fdselect->cache_fd = fd2;
|
2000-12-08 03:42:29 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
first = limit;
|
|
|
|
|
|
|
|
} while ( p < p_limit );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
Exit:
|
2000-12-08 03:42:29 +01:00
|
|
|
return fd;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*** ***/
|
|
|
|
/*** CFF font support ***/
|
|
|
|
/*** ***/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2006-10-23 12:23:17 +02:00
|
|
|
static FT_Error
|
|
|
|
cff_charset_compute_cids( CFF_Charset charset,
|
|
|
|
FT_UInt num_glyphs,
|
|
|
|
FT_Memory memory )
|
|
|
|
{
|
2013-03-14 11:21:17 +01:00
|
|
|
FT_Error error = FT_Err_Ok;
|
2006-10-23 12:23:17 +02:00
|
|
|
FT_UInt i;
|
2009-07-05 14:54:59 +02:00
|
|
|
FT_Long j;
|
2006-10-23 12:23:17 +02:00
|
|
|
FT_UShort max_cid = 0;
|
|
|
|
|
2006-10-24 07:28:45 +02:00
|
|
|
|
2006-10-23 12:23:17 +02:00
|
|
|
if ( charset->max_cid > 0 )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
for ( i = 0; i < num_glyphs; i++ )
|
2010-09-19 18:28:17 +02:00
|
|
|
{
|
2010-09-19 20:51:19 +02:00
|
|
|
if ( charset->sids[i] > max_cid )
|
2006-10-23 12:23:17 +02:00
|
|
|
max_cid = charset->sids[i];
|
2010-09-19 18:28:17 +02:00
|
|
|
}
|
2006-10-23 12:23:17 +02:00
|
|
|
|
2010-09-19 20:51:19 +02:00
|
|
|
if ( FT_NEW_ARRAY( charset->cids, (FT_ULong)max_cid + 1 ) )
|
2006-10-23 12:23:17 +02:00
|
|
|
goto Exit;
|
|
|
|
|
2009-07-05 14:54:59 +02:00
|
|
|
/* When multiple GIDs map to the same CID, we choose the lowest */
|
|
|
|
/* GID. This is not described in any spec, but it matches the */
|
|
|
|
/* behaviour of recent Acroread versions. */
|
2016-02-15 12:54:40 +01:00
|
|
|
for ( j = (FT_Long)num_glyphs - 1; j >= 0; j-- )
|
2009-07-05 14:54:59 +02:00
|
|
|
charset->cids[charset->sids[j]] = (FT_UShort)j;
|
2006-10-23 12:23:17 +02:00
|
|
|
|
2007-01-05 15:47:08 +01:00
|
|
|
charset->max_cid = max_cid;
|
|
|
|
charset->num_glyphs = num_glyphs;
|
2006-10-23 12:23:17 +02:00
|
|
|
|
|
|
|
Exit:
|
2006-10-24 07:28:45 +02:00
|
|
|
return error;
|
2006-10-23 12:23:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-01-05 14:14:08 +01:00
|
|
|
FT_LOCAL_DEF( FT_UInt )
|
|
|
|
cff_charset_cid_to_gindex( CFF_Charset charset,
|
|
|
|
FT_UInt cid )
|
|
|
|
{
|
|
|
|
FT_UInt result = 0;
|
|
|
|
|
2007-01-06 08:47:45 +01:00
|
|
|
|
2010-09-19 18:22:34 +02:00
|
|
|
if ( cid <= charset->max_cid )
|
2007-01-05 14:14:08 +01:00
|
|
|
result = charset->cids[cid];
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2007-01-06 08:47:45 +01:00
|
|
|
|
2006-10-23 12:23:17 +02:00
|
|
|
static void
|
|
|
|
cff_charset_free_cids( CFF_Charset charset,
|
|
|
|
FT_Memory memory )
|
|
|
|
{
|
|
|
|
FT_FREE( charset->cids );
|
|
|
|
charset->max_cid = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-27 21:46:12 +02:00
|
|
|
static void
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
cff_charset_done( CFF_Charset charset,
|
2002-03-30 17:41:09 +01:00
|
|
|
FT_Stream stream )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
|
|
|
FT_Memory memory = stream->memory;
|
|
|
|
|
2006-10-24 07:28:45 +02:00
|
|
|
|
2006-10-23 12:23:17 +02:00
|
|
|
cff_charset_free_cids( charset, memory );
|
2000-12-30 23:14:58 +01:00
|
|
|
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( charset->sids );
|
2000-12-08 03:42:29 +01:00
|
|
|
charset->format = 0;
|
|
|
|
charset->offset = 0;
|
|
|
|
}
|
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
|
2001-06-27 21:46:12 +02:00
|
|
|
static FT_Error
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
cff_charset_load( CFF_Charset charset,
|
2002-03-20 10:44:20 +01:00
|
|
|
FT_UInt num_glyphs,
|
|
|
|
FT_Stream stream,
|
|
|
|
FT_ULong base_offset,
|
2003-12-12 16:38:39 +01:00
|
|
|
FT_ULong offset,
|
|
|
|
FT_Bool invert )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2003-06-02 23:58:05 +02:00
|
|
|
FT_Memory memory = stream->memory;
|
2013-03-14 11:21:17 +01:00
|
|
|
FT_Error error = FT_Err_Ok;
|
2000-12-30 23:14:58 +01:00
|
|
|
FT_UShort glyph_sid;
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
|
2016-04-09 05:21:34 +02:00
|
|
|
/* If the offset is greater than 2, we have to parse the charset */
|
|
|
|
/* table. */
|
2000-12-08 03:42:29 +01:00
|
|
|
if ( offset > 2 )
|
|
|
|
{
|
2000-12-30 01:37:14 +01:00
|
|
|
FT_UInt j;
|
2000-12-08 17:17:16 +01:00
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
charset->offset = base_offset + offset;
|
|
|
|
|
|
|
|
/* Get the format of the table. */
|
|
|
|
if ( FT_STREAM_SEEK( charset->offset ) ||
|
|
|
|
FT_READ_BYTE( charset->format ) )
|
|
|
|
goto Exit;
|
|
|
|
|
2000-12-30 01:37:14 +01:00
|
|
|
/* Allocate memory for sids. */
|
2002-03-22 14:52:37 +01:00
|
|
|
if ( FT_NEW_ARRAY( charset->sids, num_glyphs ) )
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
|
|
|
|
2000-12-30 01:37:14 +01:00
|
|
|
/* assign the .notdef glyph */
|
|
|
|
charset->sids[0] = 0;
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
switch ( charset->format )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2000-12-08 17:17:16 +01:00
|
|
|
case 0:
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
if ( num_glyphs > 0 )
|
2000-12-08 17:17:16 +01:00
|
|
|
{
|
2002-07-26 11:09:10 +02:00
|
|
|
if ( FT_FRAME_ENTER( ( num_glyphs - 1 ) * 2 ) )
|
2000-12-30 01:37:14 +01:00
|
|
|
goto Exit;
|
2003-01-31 00:24:18 +01:00
|
|
|
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
for ( j = 1; j < num_glyphs; j++ )
|
2010-08-29 10:46:26 +02:00
|
|
|
charset->sids[j] = FT_GET_USHORT();
|
2003-01-31 00:24:18 +01:00
|
|
|
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
FT_FRAME_EXIT();
|
2000-12-08 17:17:16 +01:00
|
|
|
}
|
2000-12-30 01:37:14 +01:00
|
|
|
break;
|
2000-12-08 17:17:16 +01:00
|
|
|
|
2000-12-30 01:37:14 +01:00
|
|
|
case 1:
|
2000-12-08 17:17:16 +01:00
|
|
|
case 2:
|
|
|
|
{
|
2000-12-30 01:37:14 +01:00
|
|
|
FT_UInt nleft;
|
|
|
|
FT_UInt i;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
|
2000-12-30 01:37:14 +01:00
|
|
|
j = 1;
|
2000-12-08 17:17:16 +01:00
|
|
|
|
2000-12-30 01:37:14 +01:00
|
|
|
while ( j < num_glyphs )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2000-12-30 01:37:14 +01:00
|
|
|
/* Read the first glyph sid of the range. */
|
* include/freetype/internal/ftstream.h,
src/base/ftstream.c, src/cff/cffload.c, src/pcf/pcfread.c,
src/sfnt/ttcmap.c, src/sfnt/ttcmap0.c, src/sfnt/ttload.c,
src/sfnt/ttpost.c, src/sfnt/ttsbit.c,
src/truetype/ttgload.c, src/truetype/ttpload.c,
src/winfonts/winfnt.c:
changed the definitions of stream macros. Examples:
NEXT_Byte => FT_NEXT_BYTE
NEXT_Short => FT_NEXT_SHORT
NEXT_UShortLE => FT_NEXT_USHORT_LE
READ_Short => FT_READ_SHORT
GET_Long => FT_GET_LONG
etc..
also introduced the FT_PEEK_XXXX functions..
2002-03-22 13:55:23 +01:00
|
|
|
if ( FT_READ_USHORT( glyph_sid ) )
|
2000-12-08 17:17:16 +01:00
|
|
|
goto Exit;
|
|
|
|
|
2000-12-30 01:37:14 +01:00
|
|
|
/* Read the number of glyphs in the range. */
|
|
|
|
if ( charset->format == 2 )
|
|
|
|
{
|
* include/freetype/internal/ftstream.h,
src/base/ftstream.c, src/cff/cffload.c, src/pcf/pcfread.c,
src/sfnt/ttcmap.c, src/sfnt/ttcmap0.c, src/sfnt/ttload.c,
src/sfnt/ttpost.c, src/sfnt/ttsbit.c,
src/truetype/ttgload.c, src/truetype/ttpload.c,
src/winfonts/winfnt.c:
changed the definitions of stream macros. Examples:
NEXT_Byte => FT_NEXT_BYTE
NEXT_Short => FT_NEXT_SHORT
NEXT_UShortLE => FT_NEXT_USHORT_LE
READ_Short => FT_READ_SHORT
GET_Long => FT_GET_LONG
etc..
also introduced the FT_PEEK_XXXX functions..
2002-03-22 13:55:23 +01:00
|
|
|
if ( FT_READ_USHORT( nleft ) )
|
2000-12-30 01:37:14 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
* include/freetype/internal/ftstream.h,
src/base/ftstream.c, src/cff/cffload.c, src/pcf/pcfread.c,
src/sfnt/ttcmap.c, src/sfnt/ttcmap0.c, src/sfnt/ttload.c,
src/sfnt/ttpost.c, src/sfnt/ttsbit.c,
src/truetype/ttgload.c, src/truetype/ttpload.c,
src/winfonts/winfnt.c:
changed the definitions of stream macros. Examples:
NEXT_Byte => FT_NEXT_BYTE
NEXT_Short => FT_NEXT_SHORT
NEXT_UShortLE => FT_NEXT_USHORT_LE
READ_Short => FT_READ_SHORT
GET_Long => FT_GET_LONG
etc..
also introduced the FT_PEEK_XXXX functions..
2002-03-22 13:55:23 +01:00
|
|
|
if ( FT_READ_BYTE( nleft ) )
|
2000-12-30 01:37:14 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2009-03-20 06:49:10 +01:00
|
|
|
/* try to rescue some of the SIDs if `nleft' is too large */
|
2010-08-29 10:46:26 +02:00
|
|
|
if ( glyph_sid > 0xFFFFL - nleft )
|
2010-06-08 08:37:11 +02:00
|
|
|
{
|
2010-09-19 18:26:56 +02:00
|
|
|
FT_ERROR(( "cff_charset_load: invalid SID range trimmed"
|
|
|
|
" nleft=%d -> %d\n", nleft, 0xFFFFL - glyph_sid ));
|
2010-08-29 10:46:26 +02:00
|
|
|
nleft = ( FT_UInt )( 0xFFFFL - glyph_sid );
|
2009-03-20 06:49:10 +01:00
|
|
|
}
|
|
|
|
|
2000-12-30 01:37:14 +01:00
|
|
|
/* Fill in the range of sids -- `nleft + 1' glyphs. */
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
for ( i = 0; j < num_glyphs && i <= nleft; i++, j++, glyph_sid++ )
|
2000-12-30 01:37:14 +01:00
|
|
|
charset->sids[j] = glyph_sid;
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
2000-12-08 17:17:16 +01:00
|
|
|
}
|
2000-12-30 01:37:14 +01:00
|
|
|
break;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
default:
|
2009-06-26 06:15:41 +02:00
|
|
|
FT_ERROR(( "cff_charset_load: invalid table format\n" ));
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_File_Format );
|
2000-12-08 17:17:16 +01:00
|
|
|
goto Exit;
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
2000-12-30 01:37:14 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Parse default tables corresponding to offset == 0, 1, or 2. */
|
|
|
|
/* CFF specification intimates the following: */
|
|
|
|
/* */
|
|
|
|
/* In order to use a predefined charset, the following must be */
|
2000-12-30 23:14:58 +01:00
|
|
|
/* true: The charset constructed for the glyphs in the font's */
|
2000-12-30 01:37:14 +01:00
|
|
|
/* charstrings dictionary must match the predefined charset in */
|
2003-04-23 08:47:12 +02:00
|
|
|
/* the first num_glyphs. */
|
2000-12-30 01:37:14 +01:00
|
|
|
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
charset->offset = offset; /* record charset type */
|
|
|
|
|
* src/sfnt/ttpost.c (load_post_names, tt_face_free_ps_names,
tt_face_get_ps_name): Replace switch statement with if clauses to
make it more portable.
* src/cff/cffobjs.c (cff_face_init): Ditto.
* include/freetype/ftmodule.h (FT_Module_Class): Use `FT_Long' for
`module_size'.
* include/freetype/ftrender.h (FT_Glyph_Class_): Use `FT_Long' for
`glyph_size'.
* src/base/ftobjs.c (FT_Render_Glyph): Change second parameter to
`FT_Render_Mode'.
(FT_Render_Glyph_Internal): Change third parameter to
`FT_Render_Mode'.
* src/base/ftglyph.c (FT_Glyph_To_Bitmap): Change second parameter
to `FT_Render_Mode'.
* src/raster/ftrend1.c (ft_raster1_render): Change third parameter
to `FT_Render_Mode'.
* src/smooth/ftsmooth.c (ft_smooth_render, ft_smooth_render_lcd,
ft_smooth_render_lcd_v): Ditto.
(ft_smooth_render_generic): Change third and fifth parameter to
`FT_Render_Mode'.
* include/freetype/freetype.h, include/freetype/internal/ftobjs.h,
include/freetype/ftglyph.h: Updated.
* src/cff/cffdrivr.c (Load_Glyph), src/pcf/pcfdriver.c
(PCF_Glyph_Load), src/pfr/pfrobjs.c (pfr_slot_load),
src/winfonts/winfnt.c (FNT_Load_Glyph), src/t42/t42objs.c
(T42_GlyphSlot_Load), src/bdf/bdfdrivr.c (BDF_Glyph_Load): Change
fourth parameter to `FT_Int32'.
* src/pfr/pfrobjs.c (pfr_face_init): Add two missing parameters
and declare them as unused.
* src/cid/cidparse.h (CID_Parser): Use FT_Long for `postscript_len'.
* src/psnames/psnames.h (PS_Unicode_Value_Func): Change return
value to FT_UInt32.
* src/psnames/psmodule.c (ps_unicode_value, ps_build_unicode_table):
Updated accordingly.
* src/cff/cffdrivr.c (Get_Kerning): Use FT_Long for `middle'.
(cff_get_glyph_name): Use cast for result of ft_strlen.
* src/cff/cffparse.c (cff_parse_real): User cast for assigning
`exp'.
* src/cff/cffload.c (cff_index_get_pointers): Use FT_ULong for
some local variables.
(cff_charset_load, cff_encoding_load): Use casts to FT_UInt for some
switch statements.
(cff_font_load): Use cast in call to CFF_Load_FD_Select.
* src/cff/cffobjs.c (cff_size_init): Use more casts.
(cff_face_init): Use FT_Int32 for `flags'.
* src/cff/cffgload.c (cff_operator_seac): Use cast for assigning
`adx' and `ady'.
(cff_decoder_parse_charstrings): Use FT_ULong for third parameter.
Use more casts.
* src/cff/cffcmap.c (cff_cmap_unicode_init): Use cast for `count'.
* src/cid/cidload.c (cid_read_subrs): Use FT_ULong for `len'.
* src/cid/cidgload.c (cid_load_glyph): Add missing cast for
`cid_get_offset'.
* src/psaux/t1decode.c (t1_decoder_parse_charstrings) <18>: Use
cast for `num_points'.
(t1_decoder_init): Use cast for assigning `decoder->num_glyphs'.
* src/base/ftdebug.c (ft_debug_init): Use FT_Int.
* include/freetype/internal/ftdriver.h (FT_Slot_LoadFunc): Use
`FT_Int32' for fourth parameter.
* src/base/ftobjs.c (open_face): Use cast for calling
clazz->init_face.
* src/raster/ftraster.c (Set_High_Precision): Use `1' instead of
`1L'.
(Finalize_Profile_Table, Line_Up, ft_black_init): Use casts.
* src/raster/ftrend1.c (ft_raster1_render): Ditto.
* src/sfnt/sfnt_dir_check: Compare `magic' with unsigned long
constant.
* builds/amiga/include/freetype/config/ftmodule.h: Updated.
2002-09-27 13:09:23 +02:00
|
|
|
switch ( (FT_UInt)offset )
|
2000-12-30 01:37:14 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2002-11-23 16:53:57 +01:00
|
|
|
if ( num_glyphs > 229 )
|
2000-12-30 01:37:14 +01:00
|
|
|
{
|
2003-12-12 16:38:39 +01:00
|
|
|
FT_ERROR(( "cff_charset_load: implicit charset larger than\n"
|
2009-06-26 06:15:41 +02:00
|
|
|
"predefined charset (Adobe ISO-Latin)\n" ));
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_File_Format );
|
2000-12-30 01:37:14 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate memory for sids. */
|
2002-03-22 14:52:37 +01:00
|
|
|
if ( FT_NEW_ARRAY( charset->sids, num_glyphs ) )
|
2000-12-30 01:37:14 +01:00
|
|
|
goto Exit;
|
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
/* Copy the predefined charset into the allocated memory. */
|
2004-01-15 20:07:44 +01:00
|
|
|
FT_ARRAY_COPY( charset->sids, cff_isoadobe_charset, num_glyphs );
|
2000-12-30 01:37:14 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2002-11-23 16:53:57 +01:00
|
|
|
if ( num_glyphs > 166 )
|
2000-12-30 01:37:14 +01:00
|
|
|
{
|
2002-11-23 16:53:57 +01:00
|
|
|
FT_ERROR(( "cff_charset_load: implicit charset larger than\n"
|
2009-06-26 06:15:41 +02:00
|
|
|
"predefined charset (Adobe Expert)\n" ));
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_File_Format );
|
2000-12-30 01:37:14 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate memory for sids. */
|
2002-03-22 14:52:37 +01:00
|
|
|
if ( FT_NEW_ARRAY( charset->sids, num_glyphs ) )
|
2000-12-30 01:37:14 +01:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* Copy the predefined charset into the allocated memory. */
|
2004-01-15 20:07:44 +01:00
|
|
|
FT_ARRAY_COPY( charset->sids, cff_expert_charset, num_glyphs );
|
2000-12-30 01:37:14 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2002-11-23 16:53:57 +01:00
|
|
|
if ( num_glyphs > 87 )
|
2000-12-30 01:37:14 +01:00
|
|
|
{
|
2002-11-23 16:53:57 +01:00
|
|
|
FT_ERROR(( "cff_charset_load: implicit charset larger than\n"
|
2009-06-26 06:15:41 +02:00
|
|
|
"predefined charset (Adobe Expert Subset)\n" ));
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_File_Format );
|
2000-12-30 01:37:14 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate memory for sids. */
|
2002-03-22 14:52:37 +01:00
|
|
|
if ( FT_NEW_ARRAY( charset->sids, num_glyphs ) )
|
2000-12-30 01:37:14 +01:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* Copy the predefined charset into the allocated memory. */
|
2004-01-15 20:07:44 +01:00
|
|
|
FT_ARRAY_COPY( charset->sids, cff_expertsubset_charset, num_glyphs );
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2000-12-30 01:37:14 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_File_Format );
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
2000-12-30 01:37:14 +01:00
|
|
|
}
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
2003-12-18 09:18:37 +01:00
|
|
|
/* we have to invert the `sids' array for subsetted CID-keyed fonts */
|
2003-12-12 16:38:39 +01:00
|
|
|
if ( invert )
|
2006-10-23 12:23:17 +02:00
|
|
|
error = cff_charset_compute_cids( charset, num_glyphs, memory );
|
2003-12-12 16:38:39 +01:00
|
|
|
|
|
|
|
Exit:
|
2000-12-30 01:37:14 +01:00
|
|
|
/* Clean up if there was an error. */
|
|
|
|
if ( error )
|
2003-12-12 16:38:39 +01:00
|
|
|
{
|
|
|
|
FT_FREE( charset->sids );
|
|
|
|
FT_FREE( charset->cids );
|
|
|
|
charset->format = 0;
|
|
|
|
charset->offset = 0;
|
|
|
|
charset->sids = 0;
|
|
|
|
}
|
2000-12-30 01:37:14 +01:00
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
|
[cff] Implement CFF2 support (2/2).
The font variation code. All parts dependent on the GX code in the
`truetype' module are guarded with TT_CONFIG_OPTION_GX_VAR_SUPPORT.
In other words, you can still compile the `cff' module without
defining TT_CONFIG_OPTION_GX_VAR_SUPPORT (which brings you CFF2
support without font variation).
* src/cff/cf2font.c (cf2_font_setup): Add support for font
variation.
* src/cff/cf2font.h (CF2_Font): Add fields for variation data.
* src/cff/cf2ft.c (cf2_free_instance): Free blend data.
(cf2_getVStore, cf2_getNormalizedVector): New functions.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c: Include `cffload.h'.
(cf2_cmdRESERVED_15, cf2_cmdRESERVED_16): Replace with...
(cf2_cmdVSINDEX, cf2_cmdBLEND): ... this new enum values.
(cf2_doBlend): New function.
(cf2_interpT2CharString): Handle `vsindex' and `blend' opcodes.
* src/cff/cffload.c (FT_fdot14ToFixed): New macro.
(cff_vstore_done, cff_vstore_load): New functions.
(cff_blend_clear, cff_blend_doBlend, cff_blend_build_vector,
cff_blend_check_vector): New functions.
(cff_load_private_dict): Add arguments for blend vector.
Handle blend data.
(cff_subfont_load, cff_subfont_done): Updated.
(cff_font_load): Handle CFF2 variation store data.
(cff_font_done): Updated.
* src/cff/cffload.h: Include `cffparse.h'.
Updated.
* src/cff/cffobjs.c (cff_face_done): Updated.
* src/cff/cffparse.c: Include `cffload.h'.
(cff_parse_num): Handle internal value 255.
(cff_parse_vsindex, cff_parse_blend): New functions.
(CFF_FIELD_BLEND): New macro.
(cff_parser_run): Updated.
* src/cff/cffparse.h (cff_kind_blend): New enum value.
* src/cff/cfftoken.h: Handle `vstore', `vsindex', and `blend'
dictionary values.
* src/cff/cfftypes.h (CFF_VarData, CFF_AxisCoords, CFF_VarRegion,
CFF_VStore, CFF_Blend): New structures.
(CFF_FontRecDict): Add `vstore_offset' field.
(CFF_Private): Add `vsindex' field.
(CFF_SubFont): Add fields for blend data.
(CFF_Font): Add `vstore' field.
* src/truetype/ttgxvar.c (TT_Get_MM_Var): `CFF2' is equal to `gvar',
since glyph variation data is directly embedded.
(TT_Set_MM_Blend): Don't load `gvar' table for CFF2 fonts.
2016-12-15 21:56:44 +01:00
|
|
|
static void
|
|
|
|
cff_vstore_done( CFF_VStoreRec* vstore,
|
|
|
|
FT_Memory memory )
|
|
|
|
{
|
|
|
|
FT_UInt i;
|
|
|
|
|
|
|
|
|
|
|
|
/* free regionList and axisLists */
|
|
|
|
if ( vstore->varRegionList )
|
|
|
|
{
|
|
|
|
for ( i = 0; i < vstore->regionCount; i++ )
|
|
|
|
FT_FREE( vstore->varRegionList[i].axisList );
|
|
|
|
}
|
|
|
|
FT_FREE( vstore->varRegionList );
|
|
|
|
|
|
|
|
/* free varData and indices */
|
|
|
|
if ( vstore->varData )
|
|
|
|
{
|
|
|
|
for ( i = 0; i < vstore->dataCount; i++ )
|
|
|
|
FT_FREE( vstore->varData[i].regionIndices );
|
|
|
|
}
|
|
|
|
FT_FREE( vstore->varData );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* convert 2.14 to Fixed */
|
|
|
|
#define FT_fdot14ToFixed( x ) ( ( (FT_Fixed)( (FT_Int16)(x) ) ) << 2 )
|
|
|
|
|
|
|
|
|
|
|
|
static FT_Error
|
|
|
|
cff_vstore_load( CFF_VStoreRec* vstore,
|
|
|
|
FT_Stream stream,
|
|
|
|
FT_ULong base_offset,
|
|
|
|
FT_ULong offset )
|
|
|
|
{
|
|
|
|
FT_Memory memory = stream->memory;
|
|
|
|
FT_Error error = FT_ERR( Invalid_File_Format );
|
|
|
|
|
|
|
|
FT_ULong* dataOffsetArray = NULL;
|
|
|
|
FT_UInt i, j;
|
|
|
|
|
|
|
|
|
|
|
|
/* no offset means no vstore to parse */
|
|
|
|
if ( offset )
|
|
|
|
{
|
|
|
|
FT_UInt vsOffset;
|
|
|
|
FT_UInt format;
|
|
|
|
FT_ULong regionListOffset;
|
|
|
|
|
|
|
|
|
2016-12-16 11:15:17 +01:00
|
|
|
/* we need to parse the table to determine its size; */
|
|
|
|
/* skip table length */
|
[cff] Implement CFF2 support (2/2).
The font variation code. All parts dependent on the GX code in the
`truetype' module are guarded with TT_CONFIG_OPTION_GX_VAR_SUPPORT.
In other words, you can still compile the `cff' module without
defining TT_CONFIG_OPTION_GX_VAR_SUPPORT (which brings you CFF2
support without font variation).
* src/cff/cf2font.c (cf2_font_setup): Add support for font
variation.
* src/cff/cf2font.h (CF2_Font): Add fields for variation data.
* src/cff/cf2ft.c (cf2_free_instance): Free blend data.
(cf2_getVStore, cf2_getNormalizedVector): New functions.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c: Include `cffload.h'.
(cf2_cmdRESERVED_15, cf2_cmdRESERVED_16): Replace with...
(cf2_cmdVSINDEX, cf2_cmdBLEND): ... this new enum values.
(cf2_doBlend): New function.
(cf2_interpT2CharString): Handle `vsindex' and `blend' opcodes.
* src/cff/cffload.c (FT_fdot14ToFixed): New macro.
(cff_vstore_done, cff_vstore_load): New functions.
(cff_blend_clear, cff_blend_doBlend, cff_blend_build_vector,
cff_blend_check_vector): New functions.
(cff_load_private_dict): Add arguments for blend vector.
Handle blend data.
(cff_subfont_load, cff_subfont_done): Updated.
(cff_font_load): Handle CFF2 variation store data.
(cff_font_done): Updated.
* src/cff/cffload.h: Include `cffparse.h'.
Updated.
* src/cff/cffobjs.c (cff_face_done): Updated.
* src/cff/cffparse.c: Include `cffload.h'.
(cff_parse_num): Handle internal value 255.
(cff_parse_vsindex, cff_parse_blend): New functions.
(CFF_FIELD_BLEND): New macro.
(cff_parser_run): Updated.
* src/cff/cffparse.h (cff_kind_blend): New enum value.
* src/cff/cfftoken.h: Handle `vstore', `vsindex', and `blend'
dictionary values.
* src/cff/cfftypes.h (CFF_VarData, CFF_AxisCoords, CFF_VarRegion,
CFF_VStore, CFF_Blend): New structures.
(CFF_FontRecDict): Add `vstore_offset' field.
(CFF_Private): Add `vsindex' field.
(CFF_SubFont): Add fields for blend data.
(CFF_Font): Add `vstore' field.
* src/truetype/ttgxvar.c (TT_Get_MM_Var): `CFF2' is equal to `gvar',
since glyph variation data is directly embedded.
(TT_Set_MM_Blend): Don't load `gvar' table for CFF2 fonts.
2016-12-15 21:56:44 +01:00
|
|
|
if ( FT_STREAM_SEEK( base_offset + offset ) ||
|
2016-12-16 11:15:17 +01:00
|
|
|
FT_STREAM_SKIP( 2 ) )
|
[cff] Implement CFF2 support (2/2).
The font variation code. All parts dependent on the GX code in the
`truetype' module are guarded with TT_CONFIG_OPTION_GX_VAR_SUPPORT.
In other words, you can still compile the `cff' module without
defining TT_CONFIG_OPTION_GX_VAR_SUPPORT (which brings you CFF2
support without font variation).
* src/cff/cf2font.c (cf2_font_setup): Add support for font
variation.
* src/cff/cf2font.h (CF2_Font): Add fields for variation data.
* src/cff/cf2ft.c (cf2_free_instance): Free blend data.
(cf2_getVStore, cf2_getNormalizedVector): New functions.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c: Include `cffload.h'.
(cf2_cmdRESERVED_15, cf2_cmdRESERVED_16): Replace with...
(cf2_cmdVSINDEX, cf2_cmdBLEND): ... this new enum values.
(cf2_doBlend): New function.
(cf2_interpT2CharString): Handle `vsindex' and `blend' opcodes.
* src/cff/cffload.c (FT_fdot14ToFixed): New macro.
(cff_vstore_done, cff_vstore_load): New functions.
(cff_blend_clear, cff_blend_doBlend, cff_blend_build_vector,
cff_blend_check_vector): New functions.
(cff_load_private_dict): Add arguments for blend vector.
Handle blend data.
(cff_subfont_load, cff_subfont_done): Updated.
(cff_font_load): Handle CFF2 variation store data.
(cff_font_done): Updated.
* src/cff/cffload.h: Include `cffparse.h'.
Updated.
* src/cff/cffobjs.c (cff_face_done): Updated.
* src/cff/cffparse.c: Include `cffload.h'.
(cff_parse_num): Handle internal value 255.
(cff_parse_vsindex, cff_parse_blend): New functions.
(CFF_FIELD_BLEND): New macro.
(cff_parser_run): Updated.
* src/cff/cffparse.h (cff_kind_blend): New enum value.
* src/cff/cfftoken.h: Handle `vstore', `vsindex', and `blend'
dictionary values.
* src/cff/cfftypes.h (CFF_VarData, CFF_AxisCoords, CFF_VarRegion,
CFF_VStore, CFF_Blend): New structures.
(CFF_FontRecDict): Add `vstore_offset' field.
(CFF_Private): Add `vsindex' field.
(CFF_SubFont): Add fields for blend data.
(CFF_Font): Add `vstore' field.
* src/truetype/ttgxvar.c (TT_Get_MM_Var): `CFF2' is equal to `gvar',
since glyph variation data is directly embedded.
(TT_Set_MM_Blend): Don't load `gvar' table for CFF2 fonts.
2016-12-15 21:56:44 +01:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* actual variation store begins after the length */
|
|
|
|
vsOffset = FT_STREAM_POS();
|
|
|
|
|
|
|
|
/* check the header */
|
|
|
|
if ( FT_READ_USHORT( format ) )
|
|
|
|
goto Exit;
|
|
|
|
if ( format != 1 )
|
|
|
|
{
|
|
|
|
error = FT_THROW( Invalid_File_Format );
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* read top level fields */
|
|
|
|
if ( FT_READ_ULONG( regionListOffset ) ||
|
|
|
|
FT_READ_USHORT( vstore->dataCount ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* make temporary copy of item variation data offsets; */
|
|
|
|
/* we'll parse region list first, then come back */
|
|
|
|
if ( FT_NEW_ARRAY( dataOffsetArray, vstore->dataCount ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
for ( i = 0; i < vstore->dataCount; i++ )
|
|
|
|
{
|
|
|
|
if ( FT_READ_ULONG( dataOffsetArray[i] ) )
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* parse regionList and axisLists */
|
|
|
|
if ( FT_STREAM_SEEK( vsOffset + regionListOffset ) ||
|
|
|
|
FT_READ_USHORT( vstore->axisCount ) ||
|
|
|
|
FT_READ_USHORT( vstore->regionCount ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
if ( FT_NEW_ARRAY( vstore->varRegionList, vstore->regionCount ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
for ( i = 0; i < vstore->regionCount; i++ )
|
|
|
|
{
|
|
|
|
CFF_VarRegion* region = &vstore->varRegionList[i];
|
|
|
|
|
|
|
|
|
|
|
|
if ( FT_NEW_ARRAY( region->axisList, vstore->axisCount ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
for ( j = 0; j < vstore->axisCount; j++ )
|
|
|
|
{
|
|
|
|
CFF_AxisCoords* axis = ®ion->axisList[j];
|
|
|
|
|
|
|
|
FT_Int16 start14, peak14, end14;
|
|
|
|
|
|
|
|
|
|
|
|
if ( FT_READ_SHORT( start14 ) ||
|
|
|
|
FT_READ_SHORT( peak14 ) ||
|
|
|
|
FT_READ_SHORT( end14 ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
axis->startCoord = FT_fdot14ToFixed( start14 );
|
|
|
|
axis->peakCoord = FT_fdot14ToFixed( peak14 );
|
|
|
|
axis->endCoord = FT_fdot14ToFixed( end14 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* use dataOffsetArray now to parse varData items */
|
|
|
|
if ( FT_NEW_ARRAY( vstore->varData, vstore->dataCount ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
for ( i = 0; i < vstore->dataCount; i++ )
|
|
|
|
{
|
|
|
|
CFF_VarData* data = &vstore->varData[i];
|
|
|
|
|
|
|
|
|
|
|
|
if ( FT_STREAM_SEEK( vsOffset + dataOffsetArray[i] ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* ignore `itemCount' and `shortDeltaCount' */
|
|
|
|
/* because CFF2 has no delta sets */
|
|
|
|
if ( FT_STREAM_SKIP( 4 ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* Note: just record values; consistency is checked later */
|
|
|
|
/* by cff_blend_build_vector when it consumes `vstore' */
|
|
|
|
|
|
|
|
if ( FT_READ_USHORT( data->regionIdxCount ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
if ( FT_NEW_ARRAY( data->regionIndices, data->regionIdxCount ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
for ( j = 0; j < data->regionIdxCount; j++ )
|
|
|
|
{
|
|
|
|
if ( FT_READ_USHORT( data->regionIndices[j] ) )
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
error = FT_Err_Ok;
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
FT_FREE( dataOffsetArray );
|
|
|
|
if ( error )
|
|
|
|
cff_vstore_done( vstore, memory );
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Clear blend stack (after blend values are consumed). */
|
|
|
|
/* */
|
|
|
|
/* TODO: Should do this in cff_run_parse, but subFont */
|
|
|
|
/* ref is not available there. */
|
|
|
|
/* */
|
|
|
|
/* Allocation is not changed when stack is cleared. */
|
|
|
|
FT_LOCAL_DEF( void )
|
|
|
|
cff_blend_clear( CFF_SubFont subFont )
|
|
|
|
{
|
|
|
|
subFont->blend_top = subFont->blend_stack;
|
|
|
|
subFont->blend_used = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Blend numOperands on the stack, */
|
|
|
|
/* store results into the first numBlends values, */
|
|
|
|
/* then pop remaining arguments. */
|
|
|
|
/* */
|
|
|
|
/* This is comparable to `cf2_doBlend' but */
|
|
|
|
/* the cffparse stack is different and can't be written. */
|
|
|
|
/* Blended values are written to a different buffer, */
|
|
|
|
/* using reserved operator 255. */
|
|
|
|
/* */
|
|
|
|
/* Blend calculation is done in 16.16 fixed point. */
|
|
|
|
FT_LOCAL_DEF( FT_Error )
|
|
|
|
cff_blend_doBlend( CFF_SubFont subFont,
|
|
|
|
CFF_Parser parser,
|
|
|
|
FT_UInt numBlends )
|
|
|
|
{
|
|
|
|
FT_UInt delta;
|
|
|
|
FT_UInt base;
|
|
|
|
FT_UInt i, j;
|
|
|
|
FT_UInt size;
|
|
|
|
|
|
|
|
CFF_Blend blend = &subFont->blend;
|
|
|
|
|
|
|
|
FT_Memory memory = subFont->blend.font->memory; /* for FT_REALLOC */
|
|
|
|
FT_Error error = FT_Err_Ok; /* for FT_REALLOC */
|
|
|
|
|
|
|
|
/* compute expected number of operands for this blend */
|
|
|
|
FT_UInt numOperands = (FT_UInt)( numBlends * blend->lenBV );
|
|
|
|
FT_UInt count = (FT_UInt)( parser->top - 1 - parser->stack );
|
|
|
|
|
|
|
|
|
|
|
|
if ( numOperands > count )
|
|
|
|
{
|
|
|
|
FT_TRACE4(( " cff_blend_doBlend: Stack underflow %d args\n", count ));
|
|
|
|
|
|
|
|
error = FT_THROW( Stack_Underflow );
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check whether we have room for `numBlends' values at `blend_top' */
|
|
|
|
size = 5 * numBlends; /* add 5 bytes per entry */
|
|
|
|
if ( subFont->blend_used + size > subFont->blend_alloc )
|
|
|
|
{
|
|
|
|
/* increase or allocate `blend_stack' and reset `blend_top'; */
|
|
|
|
/* prepare to append `numBlends' values to the buffer */
|
|
|
|
if ( FT_REALLOC( subFont->blend_stack,
|
|
|
|
subFont->blend_alloc,
|
|
|
|
subFont->blend_alloc + size ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
subFont->blend_top = subFont->blend_stack + subFont->blend_used;
|
|
|
|
subFont->blend_alloc += size;
|
|
|
|
}
|
|
|
|
subFont->blend_used += size;
|
|
|
|
|
|
|
|
base = count - numOperands; /* index of first blend arg */
|
|
|
|
delta = base + numBlends; /* index of first delta arg */
|
|
|
|
|
|
|
|
for ( i = 0; i < numBlends; i++ )
|
|
|
|
{
|
|
|
|
const FT_Int32* weight = &blend->BV[1];
|
|
|
|
FT_Int32 sum;
|
|
|
|
|
|
|
|
|
|
|
|
/* convert inputs to 16.16 fixed point */
|
|
|
|
sum = cff_parse_num( parser, &parser->stack[i + base] ) << 16;
|
|
|
|
|
|
|
|
for ( j = 1; j < blend->lenBV; j++ )
|
|
|
|
sum += FT_MulFix( *weight++,
|
|
|
|
cff_parse_num( parser,
|
|
|
|
&parser->stack[delta++] ) << 16 );
|
|
|
|
|
|
|
|
/* point parser stack to new value on blend_stack */
|
|
|
|
parser->stack[i + base] = subFont->blend_top;
|
|
|
|
|
|
|
|
/* Push blended result as Type 2 5-byte fixed point number (except */
|
|
|
|
/* that host byte order is used). This will not conflict with */
|
|
|
|
/* actual DICTs because 255 is a reserved opcode in both CFF and */
|
|
|
|
/* CFF2 DICTs. See `cff_parse_num' for decode of this, which rounds */
|
|
|
|
/* to an integer. */
|
|
|
|
*subFont->blend_top++ = 255;
|
2016-12-15 23:10:59 +01:00
|
|
|
*((FT_UInt32*)subFont->blend_top) = (FT_UInt32)sum; /* write 4 bytes */
|
[cff] Implement CFF2 support (2/2).
The font variation code. All parts dependent on the GX code in the
`truetype' module are guarded with TT_CONFIG_OPTION_GX_VAR_SUPPORT.
In other words, you can still compile the `cff' module without
defining TT_CONFIG_OPTION_GX_VAR_SUPPORT (which brings you CFF2
support without font variation).
* src/cff/cf2font.c (cf2_font_setup): Add support for font
variation.
* src/cff/cf2font.h (CF2_Font): Add fields for variation data.
* src/cff/cf2ft.c (cf2_free_instance): Free blend data.
(cf2_getVStore, cf2_getNormalizedVector): New functions.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c: Include `cffload.h'.
(cf2_cmdRESERVED_15, cf2_cmdRESERVED_16): Replace with...
(cf2_cmdVSINDEX, cf2_cmdBLEND): ... this new enum values.
(cf2_doBlend): New function.
(cf2_interpT2CharString): Handle `vsindex' and `blend' opcodes.
* src/cff/cffload.c (FT_fdot14ToFixed): New macro.
(cff_vstore_done, cff_vstore_load): New functions.
(cff_blend_clear, cff_blend_doBlend, cff_blend_build_vector,
cff_blend_check_vector): New functions.
(cff_load_private_dict): Add arguments for blend vector.
Handle blend data.
(cff_subfont_load, cff_subfont_done): Updated.
(cff_font_load): Handle CFF2 variation store data.
(cff_font_done): Updated.
* src/cff/cffload.h: Include `cffparse.h'.
Updated.
* src/cff/cffobjs.c (cff_face_done): Updated.
* src/cff/cffparse.c: Include `cffload.h'.
(cff_parse_num): Handle internal value 255.
(cff_parse_vsindex, cff_parse_blend): New functions.
(CFF_FIELD_BLEND): New macro.
(cff_parser_run): Updated.
* src/cff/cffparse.h (cff_kind_blend): New enum value.
* src/cff/cfftoken.h: Handle `vstore', `vsindex', and `blend'
dictionary values.
* src/cff/cfftypes.h (CFF_VarData, CFF_AxisCoords, CFF_VarRegion,
CFF_VStore, CFF_Blend): New structures.
(CFF_FontRecDict): Add `vstore_offset' field.
(CFF_Private): Add `vsindex' field.
(CFF_SubFont): Add fields for blend data.
(CFF_Font): Add `vstore' field.
* src/truetype/ttgxvar.c (TT_Get_MM_Var): `CFF2' is equal to `gvar',
since glyph variation data is directly embedded.
(TT_Set_MM_Blend): Don't load `gvar' table for CFF2 fonts.
2016-12-15 21:56:44 +01:00
|
|
|
subFont->blend_top += 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* leave only numBlends results on parser stack */
|
|
|
|
parser->top = &parser->stack[base + numBlends];
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Compute a blend vector from variation store index and normalized */
|
|
|
|
/* vector based on pseudo-code in OpenType Font Variations Overview. */
|
|
|
|
/* */
|
|
|
|
/* Note: lenNDV == 0 produces a default blend vector, (1,0,0,...). */
|
|
|
|
FT_LOCAL_DEF( FT_Error )
|
|
|
|
cff_blend_build_vector( CFF_Blend blend,
|
|
|
|
FT_UInt vsindex,
|
|
|
|
FT_UInt lenNDV,
|
|
|
|
FT_Fixed* NDV )
|
|
|
|
{
|
|
|
|
FT_Error error = FT_Err_Ok; /* for FT_REALLOC */
|
|
|
|
FT_Memory memory = blend->font->memory; /* for FT_REALLOC */
|
|
|
|
|
|
|
|
FT_UInt len;
|
|
|
|
CFF_VStore vs;
|
|
|
|
CFF_VarData* varData;
|
|
|
|
FT_UInt master;
|
|
|
|
|
|
|
|
|
|
|
|
FT_ASSERT( lenNDV == 0 || NDV );
|
|
|
|
|
|
|
|
blend->builtBV = FALSE;
|
|
|
|
|
|
|
|
vs = &blend->font->vstore;
|
|
|
|
|
|
|
|
/* VStore and fvar must be consistent */
|
|
|
|
if ( lenNDV != 0 && lenNDV != vs->axisCount )
|
|
|
|
{
|
|
|
|
FT_TRACE4(( " cff_blend_build_vector: Axis count mismatch\n" ));
|
|
|
|
error = FT_THROW( Invalid_File_Format );
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( vsindex >= vs->dataCount )
|
|
|
|
{
|
|
|
|
FT_TRACE4(( " cff_blend_build_vector: vsindex out of range\n" ));
|
|
|
|
error = FT_THROW( Invalid_File_Format );
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* select the item variation data structure */
|
|
|
|
varData = &vs->varData[vsindex];
|
|
|
|
|
|
|
|
/* prepare buffer for the blend vector */
|
|
|
|
len = varData->regionIdxCount + 1; /* add 1 for default component */
|
|
|
|
if ( FT_REALLOC( blend->BV,
|
|
|
|
blend->lenBV * sizeof( *blend->BV ),
|
|
|
|
len * sizeof( *blend->BV ) ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
blend->lenBV = len;
|
|
|
|
|
|
|
|
/* outer loop steps through master designs to be blended */
|
|
|
|
for ( master = 0; master < len; master++ )
|
|
|
|
{
|
|
|
|
FT_UInt j;
|
|
|
|
FT_UInt idx;
|
|
|
|
CFF_VarRegion* varRegion;
|
|
|
|
|
|
|
|
|
|
|
|
/* default factor is always one */
|
|
|
|
if ( master == 0 )
|
|
|
|
{
|
|
|
|
blend->BV[master] = FT_FIXED_ONE;
|
|
|
|
FT_TRACE4(( " build blend vector len %d\n"
|
|
|
|
" [ %f ",
|
|
|
|
len,
|
|
|
|
blend->BV[master] / 65536.0 ));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* VStore array does not include default master, so subtract one */
|
|
|
|
idx = varData->regionIndices[master - 1];
|
|
|
|
varRegion = &vs->varRegionList[idx];
|
|
|
|
|
|
|
|
if ( idx >= vs->regionCount )
|
|
|
|
{
|
|
|
|
FT_TRACE4(( " cff_blend_build_vector:"
|
|
|
|
" region index out of range\n" ));
|
|
|
|
error = FT_THROW( Invalid_File_Format );
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Note: `lenNDV' could be zero. */
|
|
|
|
/* In that case, build default blend vector (1,0,0...). */
|
|
|
|
/* In the normal case, initialize each component to 1 */
|
|
|
|
/* before inner loop. */
|
|
|
|
if ( lenNDV != 0 )
|
|
|
|
blend->BV[master] = FT_FIXED_ONE; /* default */
|
|
|
|
|
|
|
|
/* inner loop steps through axes in this region */
|
|
|
|
for ( j = 0; j < lenNDV; j++ )
|
|
|
|
{
|
|
|
|
CFF_AxisCoords* axis = &varRegion->axisList[j];
|
|
|
|
FT_Fixed axisScalar;
|
|
|
|
|
|
|
|
|
|
|
|
/* compute the scalar contribution of this axis; */
|
|
|
|
/* ignore invalid ranges */
|
|
|
|
if ( axis->startCoord > axis->peakCoord ||
|
|
|
|
axis->peakCoord > axis->endCoord )
|
|
|
|
axisScalar = FT_FIXED_ONE;
|
|
|
|
|
|
|
|
else if ( axis->startCoord < 0 &&
|
|
|
|
axis->endCoord > 0 &&
|
|
|
|
axis->peakCoord != 0 )
|
|
|
|
axisScalar = FT_FIXED_ONE;
|
|
|
|
|
|
|
|
/* peak of 0 means ignore this axis */
|
|
|
|
else if ( axis->peakCoord == 0 )
|
|
|
|
axisScalar = FT_FIXED_ONE;
|
|
|
|
|
|
|
|
/* ignore this region if coords are out of range */
|
|
|
|
else if ( NDV[j] < axis->startCoord ||
|
|
|
|
NDV[j] > axis->endCoord )
|
|
|
|
axisScalar = 0;
|
|
|
|
|
|
|
|
/* calculate a proportional factor */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( NDV[j] == axis->peakCoord )
|
|
|
|
axisScalar = FT_FIXED_ONE;
|
|
|
|
else if ( NDV[j] < axis->peakCoord )
|
|
|
|
axisScalar = FT_DivFix( NDV[j] - axis->startCoord,
|
|
|
|
axis->peakCoord - axis->startCoord );
|
|
|
|
else
|
|
|
|
axisScalar = FT_DivFix( axis->endCoord - NDV[j],
|
|
|
|
axis->endCoord - axis->peakCoord );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* take product of all the axis scalars */
|
|
|
|
blend->BV[master] = FT_MulFix( blend->BV[master], axisScalar );
|
|
|
|
}
|
|
|
|
|
|
|
|
FT_TRACE4(( ", %f ",
|
|
|
|
blend->BV[master] / 65536.0 ));
|
|
|
|
}
|
|
|
|
|
|
|
|
FT_TRACE4(( "]\n" ));
|
|
|
|
|
|
|
|
/* record the parameters used to build the blend vector */
|
|
|
|
blend->lastVsindex = vsindex;
|
|
|
|
|
|
|
|
if ( lenNDV != 0 )
|
|
|
|
{
|
|
|
|
/* user has set a normalized vector */
|
|
|
|
if ( FT_REALLOC( blend->lastNDV,
|
|
|
|
blend->lenNDV * sizeof ( *NDV ),
|
|
|
|
lenNDV * sizeof ( *NDV ) ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
blend->lenNDV = lenNDV;
|
|
|
|
FT_MEM_COPY( blend->lastNDV,
|
|
|
|
NDV,
|
|
|
|
lenNDV * sizeof ( *NDV ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
blend->builtBV = TRUE;
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* `lenNDV' is zero for default vector; */
|
|
|
|
/* return TRUE if blend vector needs to be built. */
|
|
|
|
FT_LOCAL_DEF( FT_Bool )
|
|
|
|
cff_blend_check_vector( CFF_Blend blend,
|
|
|
|
FT_UInt vsindex,
|
|
|
|
FT_UInt lenNDV,
|
|
|
|
FT_Fixed* NDV )
|
|
|
|
{
|
|
|
|
if ( !blend->builtBV ||
|
|
|
|
blend->lastVsindex != vsindex ||
|
|
|
|
blend->lenNDV != lenNDV ||
|
|
|
|
( lenNDV &&
|
|
|
|
memcmp( NDV,
|
|
|
|
blend->lastNDV,
|
|
|
|
lenNDV * sizeof ( *NDV ) ) != 0 ) )
|
|
|
|
{
|
|
|
|
/* need to build blend vector */
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-12-14 19:31:42 +01:00
|
|
|
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
|
|
|
|
|
|
|
|
FT_LOCAL_DEF( FT_Error )
|
2016-12-18 18:12:03 +01:00
|
|
|
cff_get_var_blend( CFF_Face face,
|
|
|
|
FT_UInt *num_coords,
|
|
|
|
FT_Fixed* *coords,
|
|
|
|
FT_MM_Var* *mm_var )
|
2016-12-14 19:31:42 +01:00
|
|
|
{
|
|
|
|
FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
|
|
|
|
|
|
|
|
|
2016-12-18 18:12:03 +01:00
|
|
|
return mm->get_var_blend( FT_FACE( face ), num_coords, coords, mm_var );
|
2016-12-14 19:31:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FT_LOCAL_DEF( void )
|
|
|
|
cff_done_blend( CFF_Face face )
|
|
|
|
{
|
|
|
|
FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
|
|
|
|
|
|
|
|
|
|
|
|
mm->done_blend( FT_FACE( face ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
|
|
|
|
|
|
|
|
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
static void
|
|
|
|
cff_encoding_done( CFF_Encoding encoding )
|
|
|
|
{
|
|
|
|
encoding->format = 0;
|
|
|
|
encoding->offset = 0;
|
|
|
|
encoding->count = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-27 21:46:12 +02:00
|
|
|
static FT_Error
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
cff_encoding_load( CFF_Encoding encoding,
|
2002-03-14 09:57:10 +01:00
|
|
|
CFF_Charset charset,
|
2002-03-30 17:41:09 +01:00
|
|
|
FT_UInt num_glyphs,
|
|
|
|
FT_Stream stream,
|
|
|
|
FT_ULong base_offset,
|
|
|
|
FT_ULong offset )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2013-03-14 11:21:17 +01:00
|
|
|
FT_Error error = FT_Err_Ok;
|
2003-06-02 23:58:05 +02:00
|
|
|
FT_UInt count;
|
|
|
|
FT_UInt j;
|
|
|
|
FT_UShort glyph_sid;
|
|
|
|
FT_UInt glyph_code;
|
2000-12-30 01:37:14 +01:00
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
|
|
|
|
/* Check for charset->sids. If we do not have this, we fail. */
|
2000-12-30 01:37:14 +01:00
|
|
|
if ( !charset->sids )
|
|
|
|
{
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_File_Format );
|
2000-12-30 01:37:14 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
2000-12-08 17:17:16 +01:00
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
/* Zero out the code to gid/sid mappings. */
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
for ( j = 0; j < 256; j++ )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2000-12-30 01:37:14 +01:00
|
|
|
encoding->sids [j] = 0;
|
|
|
|
encoding->codes[j] = 0;
|
|
|
|
}
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2003-06-02 23:58:05 +02:00
|
|
|
/* Note: The encoding table in a CFF font is indexed by glyph index; */
|
|
|
|
/* the first encoded glyph index is 1. Hence, we read the character */
|
2000-12-30 01:37:14 +01:00
|
|
|
/* code (`glyph_code') at index j and make the assignment: */
|
|
|
|
/* */
|
|
|
|
/* encoding->codes[glyph_code] = j + 1 */
|
|
|
|
/* */
|
|
|
|
/* We also make the assignment: */
|
|
|
|
/* */
|
|
|
|
/* encoding->sids[glyph_code] = charset->sids[j + 1] */
|
|
|
|
/* */
|
|
|
|
/* This gives us both a code to GID and a code to SID mapping. */
|
|
|
|
|
|
|
|
if ( offset > 1 )
|
|
|
|
{
|
2000-12-08 03:42:29 +01:00
|
|
|
encoding->offset = base_offset + offset;
|
|
|
|
|
|
|
|
/* we need to parse the table to determine its size */
|
2002-03-20 11:49:31 +01:00
|
|
|
if ( FT_STREAM_SEEK( encoding->offset ) ||
|
2002-03-30 17:41:09 +01:00
|
|
|
FT_READ_BYTE( encoding->format ) ||
|
|
|
|
FT_READ_BYTE( count ) )
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
switch ( encoding->format & 0x7F )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2000-12-08 17:17:16 +01:00
|
|
|
case 0:
|
2000-12-30 01:37:14 +01:00
|
|
|
{
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
FT_Byte* p;
|
2003-01-31 00:24:18 +01:00
|
|
|
|
2003-04-23 08:47:12 +02:00
|
|
|
|
|
|
|
/* By convention, GID 0 is always ".notdef" and is never */
|
|
|
|
/* coded in the font. Hence, the number of codes found */
|
|
|
|
/* in the table is `count+1'. */
|
2002-11-23 17:41:23 +01:00
|
|
|
/* */
|
|
|
|
encoding->count = count + 1;
|
2002-07-26 11:09:10 +02:00
|
|
|
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
if ( FT_FRAME_ENTER( count ) )
|
2000-12-30 01:37:14 +01:00
|
|
|
goto Exit;
|
|
|
|
|
2002-07-26 11:09:10 +02:00
|
|
|
p = (FT_Byte*)stream->cursor;
|
2003-01-31 00:24:18 +01:00
|
|
|
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
for ( j = 1; j <= count; j++ )
|
|
|
|
{
|
|
|
|
glyph_code = *p++;
|
2000-12-30 01:37:14 +01:00
|
|
|
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
/* Make sure j is not too big. */
|
2002-11-23 17:41:23 +01:00
|
|
|
if ( j < num_glyphs )
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
{
|
|
|
|
/* Assign code to GID mapping. */
|
|
|
|
encoding->codes[glyph_code] = (FT_UShort)j;
|
2000-12-30 01:37:14 +01:00
|
|
|
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
/* Assign code to SID mapping. */
|
|
|
|
encoding->sids[glyph_code] = charset->sids[j];
|
|
|
|
}
|
|
|
|
}
|
2003-01-31 00:24:18 +01:00
|
|
|
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
FT_FRAME_EXIT();
|
2000-12-30 01:37:14 +01:00
|
|
|
}
|
2000-12-08 17:17:16 +01:00
|
|
|
break;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
case 1:
|
2000-12-30 01:37:14 +01:00
|
|
|
{
|
2003-06-20 09:50:13 +02:00
|
|
|
FT_UInt nleft;
|
2002-07-26 11:09:10 +02:00
|
|
|
FT_UInt i = 1;
|
|
|
|
FT_UInt k;
|
2000-12-30 01:37:14 +01:00
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
|
2002-11-23 17:41:23 +01:00
|
|
|
encoding->count = 0;
|
|
|
|
|
2000-12-30 01:37:14 +01:00
|
|
|
/* Parse the Format1 ranges. */
|
|
|
|
for ( j = 0; j < count; j++, i += nleft )
|
|
|
|
{
|
2000-12-30 23:14:58 +01:00
|
|
|
/* Read the first glyph code of the range. */
|
* include/freetype/internal/ftstream.h,
src/base/ftstream.c, src/cff/cffload.c, src/pcf/pcfread.c,
src/sfnt/ttcmap.c, src/sfnt/ttcmap0.c, src/sfnt/ttload.c,
src/sfnt/ttpost.c, src/sfnt/ttsbit.c,
src/truetype/ttgload.c, src/truetype/ttpload.c,
src/winfonts/winfnt.c:
changed the definitions of stream macros. Examples:
NEXT_Byte => FT_NEXT_BYTE
NEXT_Short => FT_NEXT_SHORT
NEXT_UShortLE => FT_NEXT_USHORT_LE
READ_Short => FT_READ_SHORT
GET_Long => FT_GET_LONG
etc..
also introduced the FT_PEEK_XXXX functions..
2002-03-22 13:55:23 +01:00
|
|
|
if ( FT_READ_BYTE( glyph_code ) )
|
2000-12-30 01:37:14 +01:00
|
|
|
goto Exit;
|
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
/* Read the number of codes in the range. */
|
* include/freetype/internal/ftstream.h,
src/base/ftstream.c, src/cff/cffload.c, src/pcf/pcfread.c,
src/sfnt/ttcmap.c, src/sfnt/ttcmap0.c, src/sfnt/ttload.c,
src/sfnt/ttpost.c, src/sfnt/ttsbit.c,
src/truetype/ttgload.c, src/truetype/ttpload.c,
src/winfonts/winfnt.c:
changed the definitions of stream macros. Examples:
NEXT_Byte => FT_NEXT_BYTE
NEXT_Short => FT_NEXT_SHORT
NEXT_UShortLE => FT_NEXT_USHORT_LE
READ_Short => FT_READ_SHORT
GET_Long => FT_GET_LONG
etc..
also introduced the FT_PEEK_XXXX functions..
2002-03-22 13:55:23 +01:00
|
|
|
if ( FT_READ_BYTE( nleft ) )
|
2000-12-30 01:37:14 +01:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* Increment nleft, so we read `nleft + 1' codes/sids. */
|
|
|
|
nleft++;
|
2003-01-31 00:24:18 +01:00
|
|
|
|
2002-11-23 17:41:23 +01:00
|
|
|
/* compute max number of character codes */
|
2003-01-31 00:24:18 +01:00
|
|
|
if ( (FT_UInt)nleft > encoding->count )
|
2002-11-23 17:41:23 +01:00
|
|
|
encoding->count = nleft;
|
2003-01-31 00:24:18 +01:00
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
/* Fill in the range of codes/sids. */
|
2000-12-30 01:37:14 +01:00
|
|
|
for ( k = i; k < nleft + i; k++, glyph_code++ )
|
|
|
|
{
|
|
|
|
/* Make sure k is not too big. */
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
if ( k < num_glyphs && glyph_code < 256 )
|
|
|
|
{
|
|
|
|
/* Assign code to GID mapping. */
|
|
|
|
encoding->codes[glyph_code] = (FT_UShort)k;
|
|
|
|
|
|
|
|
/* Assign code to SID mapping. */
|
|
|
|
encoding->sids[glyph_code] = charset->sids[k];
|
|
|
|
}
|
2000-12-30 01:37:14 +01:00
|
|
|
}
|
|
|
|
}
|
2003-01-31 00:24:18 +01:00
|
|
|
|
2003-04-23 08:47:12 +02:00
|
|
|
/* simple check; one never knows what can be found in a font */
|
2002-11-23 17:41:23 +01:00
|
|
|
if ( encoding->count > 256 )
|
|
|
|
encoding->count = 256;
|
2000-12-30 01:37:14 +01:00
|
|
|
}
|
2000-12-08 17:17:16 +01:00
|
|
|
break;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
default:
|
2009-06-26 06:15:41 +02:00
|
|
|
FT_ERROR(( "cff_encoding_load: invalid table format\n" ));
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_File_Format );
|
2000-12-08 17:17:16 +01:00
|
|
|
goto Exit;
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
2000-12-30 01:37:14 +01:00
|
|
|
/* Parse supplemental encodings, if any. */
|
2000-12-08 17:17:16 +01:00
|
|
|
if ( encoding->format & 0x80 )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
FT_UInt gindex;
|
2000-12-30 01:37:14 +01:00
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
/* count supplements */
|
* include/freetype/internal/ftstream.h,
src/base/ftstream.c, src/cff/cffload.c, src/pcf/pcfread.c,
src/sfnt/ttcmap.c, src/sfnt/ttcmap0.c, src/sfnt/ttload.c,
src/sfnt/ttpost.c, src/sfnt/ttsbit.c,
src/truetype/ttgload.c, src/truetype/ttpload.c,
src/winfonts/winfnt.c:
changed the definitions of stream macros. Examples:
NEXT_Byte => FT_NEXT_BYTE
NEXT_Short => FT_NEXT_SHORT
NEXT_UShortLE => FT_NEXT_USHORT_LE
READ_Short => FT_READ_SHORT
GET_Long => FT_GET_LONG
etc..
also introduced the FT_PEEK_XXXX functions..
2002-03-22 13:55:23 +01:00
|
|
|
if ( FT_READ_BYTE( count ) )
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
2000-12-30 01:37:14 +01:00
|
|
|
|
|
|
|
for ( j = 0; j < count; j++ )
|
|
|
|
{
|
2000-12-30 23:14:58 +01:00
|
|
|
/* Read supplemental glyph code. */
|
* include/freetype/internal/ftstream.h,
src/base/ftstream.c, src/cff/cffload.c, src/pcf/pcfread.c,
src/sfnt/ttcmap.c, src/sfnt/ttcmap0.c, src/sfnt/ttload.c,
src/sfnt/ttpost.c, src/sfnt/ttsbit.c,
src/truetype/ttgload.c, src/truetype/ttpload.c,
src/winfonts/winfnt.c:
changed the definitions of stream macros. Examples:
NEXT_Byte => FT_NEXT_BYTE
NEXT_Short => FT_NEXT_SHORT
NEXT_UShortLE => FT_NEXT_USHORT_LE
READ_Short => FT_READ_SHORT
GET_Long => FT_GET_LONG
etc..
also introduced the FT_PEEK_XXXX functions..
2002-03-22 13:55:23 +01:00
|
|
|
if ( FT_READ_BYTE( glyph_code ) )
|
2000-12-30 01:37:14 +01:00
|
|
|
goto Exit;
|
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
/* Read the SID associated with this glyph code. */
|
* include/freetype/internal/ftstream.h,
src/base/ftstream.c, src/cff/cffload.c, src/pcf/pcfread.c,
src/sfnt/ttcmap.c, src/sfnt/ttcmap0.c, src/sfnt/ttload.c,
src/sfnt/ttpost.c, src/sfnt/ttsbit.c,
src/truetype/ttgload.c, src/truetype/ttpload.c,
src/winfonts/winfnt.c:
changed the definitions of stream macros. Examples:
NEXT_Byte => FT_NEXT_BYTE
NEXT_Short => FT_NEXT_SHORT
NEXT_UShortLE => FT_NEXT_USHORT_LE
READ_Short => FT_READ_SHORT
GET_Long => FT_GET_LONG
etc..
also introduced the FT_PEEK_XXXX functions..
2002-03-22 13:55:23 +01:00
|
|
|
if ( FT_READ_USHORT( glyph_sid ) )
|
2000-12-30 01:37:14 +01:00
|
|
|
goto Exit;
|
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
/* Assign code to SID mapping. */
|
2000-12-30 01:37:14 +01:00
|
|
|
encoding->sids[glyph_code] = glyph_sid;
|
|
|
|
|
2003-06-02 23:58:05 +02:00
|
|
|
/* First, look up GID which has been assigned to */
|
|
|
|
/* SID glyph_sid. */
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
for ( gindex = 0; gindex < num_glyphs; gindex++ )
|
2000-12-30 01:37:14 +01:00
|
|
|
{
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
if ( charset->sids[gindex] == glyph_sid )
|
|
|
|
{
|
2003-06-02 23:58:05 +02:00
|
|
|
encoding->codes[glyph_code] = (FT_UShort)gindex;
|
2000-12-30 01:37:14 +01:00
|
|
|
break;
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
}
|
2000-12-30 01:37:14 +01:00
|
|
|
}
|
|
|
|
}
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2000-12-30 01:37:14 +01:00
|
|
|
{
|
2003-06-02 23:58:05 +02:00
|
|
|
/* We take into account the fact a CFF font can use a predefined */
|
|
|
|
/* encoding without containing all of the glyphs encoded by this */
|
|
|
|
/* encoding (see the note at the end of section 12 in the CFF */
|
|
|
|
/* specification). */
|
2000-12-30 01:37:14 +01:00
|
|
|
|
* src/sfnt/ttpost.c (load_post_names, tt_face_free_ps_names,
tt_face_get_ps_name): Replace switch statement with if clauses to
make it more portable.
* src/cff/cffobjs.c (cff_face_init): Ditto.
* include/freetype/ftmodule.h (FT_Module_Class): Use `FT_Long' for
`module_size'.
* include/freetype/ftrender.h (FT_Glyph_Class_): Use `FT_Long' for
`glyph_size'.
* src/base/ftobjs.c (FT_Render_Glyph): Change second parameter to
`FT_Render_Mode'.
(FT_Render_Glyph_Internal): Change third parameter to
`FT_Render_Mode'.
* src/base/ftglyph.c (FT_Glyph_To_Bitmap): Change second parameter
to `FT_Render_Mode'.
* src/raster/ftrend1.c (ft_raster1_render): Change third parameter
to `FT_Render_Mode'.
* src/smooth/ftsmooth.c (ft_smooth_render, ft_smooth_render_lcd,
ft_smooth_render_lcd_v): Ditto.
(ft_smooth_render_generic): Change third and fifth parameter to
`FT_Render_Mode'.
* include/freetype/freetype.h, include/freetype/internal/ftobjs.h,
include/freetype/ftglyph.h: Updated.
* src/cff/cffdrivr.c (Load_Glyph), src/pcf/pcfdriver.c
(PCF_Glyph_Load), src/pfr/pfrobjs.c (pfr_slot_load),
src/winfonts/winfnt.c (FNT_Load_Glyph), src/t42/t42objs.c
(T42_GlyphSlot_Load), src/bdf/bdfdrivr.c (BDF_Glyph_Load): Change
fourth parameter to `FT_Int32'.
* src/pfr/pfrobjs.c (pfr_face_init): Add two missing parameters
and declare them as unused.
* src/cid/cidparse.h (CID_Parser): Use FT_Long for `postscript_len'.
* src/psnames/psnames.h (PS_Unicode_Value_Func): Change return
value to FT_UInt32.
* src/psnames/psmodule.c (ps_unicode_value, ps_build_unicode_table):
Updated accordingly.
* src/cff/cffdrivr.c (Get_Kerning): Use FT_Long for `middle'.
(cff_get_glyph_name): Use cast for result of ft_strlen.
* src/cff/cffparse.c (cff_parse_real): User cast for assigning
`exp'.
* src/cff/cffload.c (cff_index_get_pointers): Use FT_ULong for
some local variables.
(cff_charset_load, cff_encoding_load): Use casts to FT_UInt for some
switch statements.
(cff_font_load): Use cast in call to CFF_Load_FD_Select.
* src/cff/cffobjs.c (cff_size_init): Use more casts.
(cff_face_init): Use FT_Int32 for `flags'.
* src/cff/cffgload.c (cff_operator_seac): Use cast for assigning
`adx' and `ady'.
(cff_decoder_parse_charstrings): Use FT_ULong for third parameter.
Use more casts.
* src/cff/cffcmap.c (cff_cmap_unicode_init): Use cast for `count'.
* src/cid/cidload.c (cid_read_subrs): Use FT_ULong for `len'.
* src/cid/cidgload.c (cid_load_glyph): Add missing cast for
`cid_get_offset'.
* src/psaux/t1decode.c (t1_decoder_parse_charstrings) <18>: Use
cast for `num_points'.
(t1_decoder_init): Use cast for assigning `decoder->num_glyphs'.
* src/base/ftdebug.c (ft_debug_init): Use FT_Int.
* include/freetype/internal/ftdriver.h (FT_Slot_LoadFunc): Use
`FT_Int32' for fourth parameter.
* src/base/ftobjs.c (open_face): Use cast for calling
clazz->init_face.
* src/raster/ftraster.c (Set_High_Precision): Use `1' instead of
`1L'.
(Finalize_Profile_Table, Line_Up, ft_black_init): Use casts.
* src/raster/ftrend1.c (ft_raster1_render): Ditto.
* src/sfnt/sfnt_dir_check: Compare `magic' with unsigned long
constant.
* builds/amiga/include/freetype/config/ftmodule.h: Updated.
2002-09-27 13:09:23 +02:00
|
|
|
switch ( (FT_UInt)offset )
|
2000-12-30 01:37:14 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2000-12-30 23:14:58 +01:00
|
|
|
/* First, copy the code to SID mapping. */
|
2004-01-15 20:07:44 +01:00
|
|
|
FT_ARRAY_COPY( encoding->sids, cff_standard_encoding, 256 );
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
goto Populate;
|
2000-12-30 01:37:14 +01:00
|
|
|
|
|
|
|
case 1:
|
|
|
|
/* First, copy the code to SID mapping. */
|
2004-01-15 20:07:44 +01:00
|
|
|
FT_ARRAY_COPY( encoding->sids, cff_expert_encoding, 256 );
|
2000-12-30 01:37:14 +01:00
|
|
|
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
Populate:
|
2000-12-30 01:37:14 +01:00
|
|
|
/* Construct code to GID mapping from code to SID mapping */
|
|
|
|
/* and charset. */
|
2003-01-31 00:24:18 +01:00
|
|
|
|
2002-11-23 17:41:23 +01:00
|
|
|
encoding->count = 0;
|
|
|
|
|
2006-11-19 10:19:17 +01:00
|
|
|
error = cff_charset_compute_cids( charset, num_glyphs,
|
|
|
|
stream->memory );
|
2006-10-24 07:28:45 +02:00
|
|
|
if ( error )
|
2006-10-23 12:23:17 +02:00
|
|
|
goto Exit;
|
|
|
|
|
2000-12-30 01:37:14 +01:00
|
|
|
for ( j = 0; j < 256; j++ )
|
|
|
|
{
|
2006-10-23 12:23:17 +02:00
|
|
|
FT_UInt sid = encoding->sids[j];
|
|
|
|
FT_UInt gid = 0;
|
|
|
|
|
2006-10-24 07:28:45 +02:00
|
|
|
|
2006-10-23 12:23:17 +02:00
|
|
|
if ( sid )
|
2007-01-05 15:47:08 +01:00
|
|
|
gid = cff_charset_cid_to_gindex( charset, sid );
|
2006-10-23 12:23:17 +02:00
|
|
|
|
|
|
|
if ( gid != 0 )
|
2000-12-30 01:37:14 +01:00
|
|
|
{
|
2006-10-23 12:23:17 +02:00
|
|
|
encoding->codes[j] = (FT_UShort)gid;
|
2010-09-13 07:32:22 +02:00
|
|
|
encoding->count = j + 1;
|
2006-10-23 12:23:17 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
encoding->codes[j] = 0;
|
|
|
|
encoding->sids [j] = 0;
|
2000-12-30 01:37:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2009-06-26 06:15:41 +02:00
|
|
|
FT_ERROR(( "cff_encoding_load: invalid table format\n" ));
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_File_Format );
|
2000-12-30 01:37:14 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
}
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
Exit:
|
2000-12-30 01:37:14 +01:00
|
|
|
|
|
|
|
/* Clean up if there was an error. */
|
2000-12-08 03:42:29 +01:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
[cff] Implement CFF2 support (2/2).
The font variation code. All parts dependent on the GX code in the
`truetype' module are guarded with TT_CONFIG_OPTION_GX_VAR_SUPPORT.
In other words, you can still compile the `cff' module without
defining TT_CONFIG_OPTION_GX_VAR_SUPPORT (which brings you CFF2
support without font variation).
* src/cff/cf2font.c (cf2_font_setup): Add support for font
variation.
* src/cff/cf2font.h (CF2_Font): Add fields for variation data.
* src/cff/cf2ft.c (cf2_free_instance): Free blend data.
(cf2_getVStore, cf2_getNormalizedVector): New functions.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c: Include `cffload.h'.
(cf2_cmdRESERVED_15, cf2_cmdRESERVED_16): Replace with...
(cf2_cmdVSINDEX, cf2_cmdBLEND): ... this new enum values.
(cf2_doBlend): New function.
(cf2_interpT2CharString): Handle `vsindex' and `blend' opcodes.
* src/cff/cffload.c (FT_fdot14ToFixed): New macro.
(cff_vstore_done, cff_vstore_load): New functions.
(cff_blend_clear, cff_blend_doBlend, cff_blend_build_vector,
cff_blend_check_vector): New functions.
(cff_load_private_dict): Add arguments for blend vector.
Handle blend data.
(cff_subfont_load, cff_subfont_done): Updated.
(cff_font_load): Handle CFF2 variation store data.
(cff_font_done): Updated.
* src/cff/cffload.h: Include `cffparse.h'.
Updated.
* src/cff/cffobjs.c (cff_face_done): Updated.
* src/cff/cffparse.c: Include `cffload.h'.
(cff_parse_num): Handle internal value 255.
(cff_parse_vsindex, cff_parse_blend): New functions.
(CFF_FIELD_BLEND): New macro.
(cff_parser_run): Updated.
* src/cff/cffparse.h (cff_kind_blend): New enum value.
* src/cff/cfftoken.h: Handle `vstore', `vsindex', and `blend'
dictionary values.
* src/cff/cfftypes.h (CFF_VarData, CFF_AxisCoords, CFF_VarRegion,
CFF_VStore, CFF_Blend): New structures.
(CFF_FontRecDict): Add `vstore_offset' field.
(CFF_Private): Add `vsindex' field.
(CFF_SubFont): Add fields for blend data.
(CFF_Font): Add `vstore' field.
* src/truetype/ttgxvar.c (TT_Get_MM_Var): `CFF2' is equal to `gvar',
since glyph variation data is directly embedded.
(TT_Set_MM_Blend): Don't load `gvar' table for CFF2 fonts.
2016-12-15 21:56:44 +01:00
|
|
|
/* Parse private dictionary; first call is always from `cff_face_init', */
|
|
|
|
/* so NDV has not been set for CFF2 variation. */
|
|
|
|
/* */
|
|
|
|
/* `cff_slot_load' must call this function each time NDV changes. */
|
2016-12-16 11:15:17 +01:00
|
|
|
FT_LOCAL_DEF( FT_Error )
|
2016-12-15 00:00:45 +01:00
|
|
|
cff_load_private_dict( CFF_Font font,
|
[cff] Implement CFF2 support (2/2).
The font variation code. All parts dependent on the GX code in the
`truetype' module are guarded with TT_CONFIG_OPTION_GX_VAR_SUPPORT.
In other words, you can still compile the `cff' module without
defining TT_CONFIG_OPTION_GX_VAR_SUPPORT (which brings you CFF2
support without font variation).
* src/cff/cf2font.c (cf2_font_setup): Add support for font
variation.
* src/cff/cf2font.h (CF2_Font): Add fields for variation data.
* src/cff/cf2ft.c (cf2_free_instance): Free blend data.
(cf2_getVStore, cf2_getNormalizedVector): New functions.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c: Include `cffload.h'.
(cf2_cmdRESERVED_15, cf2_cmdRESERVED_16): Replace with...
(cf2_cmdVSINDEX, cf2_cmdBLEND): ... this new enum values.
(cf2_doBlend): New function.
(cf2_interpT2CharString): Handle `vsindex' and `blend' opcodes.
* src/cff/cffload.c (FT_fdot14ToFixed): New macro.
(cff_vstore_done, cff_vstore_load): New functions.
(cff_blend_clear, cff_blend_doBlend, cff_blend_build_vector,
cff_blend_check_vector): New functions.
(cff_load_private_dict): Add arguments for blend vector.
Handle blend data.
(cff_subfont_load, cff_subfont_done): Updated.
(cff_font_load): Handle CFF2 variation store data.
(cff_font_done): Updated.
* src/cff/cffload.h: Include `cffparse.h'.
Updated.
* src/cff/cffobjs.c (cff_face_done): Updated.
* src/cff/cffparse.c: Include `cffload.h'.
(cff_parse_num): Handle internal value 255.
(cff_parse_vsindex, cff_parse_blend): New functions.
(CFF_FIELD_BLEND): New macro.
(cff_parser_run): Updated.
* src/cff/cffparse.h (cff_kind_blend): New enum value.
* src/cff/cfftoken.h: Handle `vstore', `vsindex', and `blend'
dictionary values.
* src/cff/cfftypes.h (CFF_VarData, CFF_AxisCoords, CFF_VarRegion,
CFF_VStore, CFF_Blend): New structures.
(CFF_FontRecDict): Add `vstore_offset' field.
(CFF_Private): Add `vsindex' field.
(CFF_SubFont): Add fields for blend data.
(CFF_Font): Add `vstore' field.
* src/truetype/ttgxvar.c (TT_Get_MM_Var): `CFF2' is equal to `gvar',
since glyph variation data is directly embedded.
(TT_Set_MM_Blend): Don't load `gvar' table for CFF2 fonts.
2016-12-15 21:56:44 +01:00
|
|
|
CFF_SubFont subfont,
|
|
|
|
FT_UInt lenNDV,
|
|
|
|
FT_Fixed* NDV )
|
2016-12-15 00:00:45 +01:00
|
|
|
{
|
|
|
|
FT_Error error = FT_Err_Ok;
|
|
|
|
CFF_ParserRec parser;
|
|
|
|
CFF_FontRecDict top = &subfont->font_dict;
|
|
|
|
CFF_Private priv = &subfont->private_dict;
|
|
|
|
FT_Stream stream = font->stream;
|
2016-12-15 11:22:15 +01:00
|
|
|
FT_UInt stackSize;
|
2016-12-15 00:00:45 +01:00
|
|
|
|
|
|
|
|
2016-12-17 07:44:46 +01:00
|
|
|
/* store handle needed to access memory, vstore for blend; */
|
|
|
|
/* we need this for clean-up even if there is no private DICT */
|
[cff] Implement CFF2 support (2/2).
The font variation code. All parts dependent on the GX code in the
`truetype' module are guarded with TT_CONFIG_OPTION_GX_VAR_SUPPORT.
In other words, you can still compile the `cff' module without
defining TT_CONFIG_OPTION_GX_VAR_SUPPORT (which brings you CFF2
support without font variation).
* src/cff/cf2font.c (cf2_font_setup): Add support for font
variation.
* src/cff/cf2font.h (CF2_Font): Add fields for variation data.
* src/cff/cf2ft.c (cf2_free_instance): Free blend data.
(cf2_getVStore, cf2_getNormalizedVector): New functions.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c: Include `cffload.h'.
(cf2_cmdRESERVED_15, cf2_cmdRESERVED_16): Replace with...
(cf2_cmdVSINDEX, cf2_cmdBLEND): ... this new enum values.
(cf2_doBlend): New function.
(cf2_interpT2CharString): Handle `vsindex' and `blend' opcodes.
* src/cff/cffload.c (FT_fdot14ToFixed): New macro.
(cff_vstore_done, cff_vstore_load): New functions.
(cff_blend_clear, cff_blend_doBlend, cff_blend_build_vector,
cff_blend_check_vector): New functions.
(cff_load_private_dict): Add arguments for blend vector.
Handle blend data.
(cff_subfont_load, cff_subfont_done): Updated.
(cff_font_load): Handle CFF2 variation store data.
(cff_font_done): Updated.
* src/cff/cffload.h: Include `cffparse.h'.
Updated.
* src/cff/cffobjs.c (cff_face_done): Updated.
* src/cff/cffparse.c: Include `cffload.h'.
(cff_parse_num): Handle internal value 255.
(cff_parse_vsindex, cff_parse_blend): New functions.
(CFF_FIELD_BLEND): New macro.
(cff_parser_run): Updated.
* src/cff/cffparse.h (cff_kind_blend): New enum value.
* src/cff/cfftoken.h: Handle `vstore', `vsindex', and `blend'
dictionary values.
* src/cff/cfftypes.h (CFF_VarData, CFF_AxisCoords, CFF_VarRegion,
CFF_VStore, CFF_Blend): New structures.
(CFF_FontRecDict): Add `vstore_offset' field.
(CFF_Private): Add `vsindex' field.
(CFF_SubFont): Add fields for blend data.
(CFF_Font): Add `vstore' field.
* src/truetype/ttgxvar.c (TT_Get_MM_Var): `CFF2' is equal to `gvar',
since glyph variation data is directly embedded.
(TT_Set_MM_Blend): Don't load `gvar' table for CFF2 fonts.
2016-12-15 21:56:44 +01:00
|
|
|
subfont->blend.font = font;
|
|
|
|
subfont->blend.usedBV = FALSE; /* clear state */
|
|
|
|
|
2016-12-17 07:44:46 +01:00
|
|
|
if ( !top->private_offset || !top->private_size )
|
|
|
|
goto Exit2; /* no private DICT, do nothing */
|
|
|
|
|
2016-12-15 00:00:45 +01:00
|
|
|
/* set defaults */
|
|
|
|
FT_ZERO( priv );
|
|
|
|
|
|
|
|
priv->blue_shift = 7;
|
|
|
|
priv->blue_fuzz = 1;
|
|
|
|
priv->lenIV = -1;
|
|
|
|
priv->expansion_factor = (FT_Fixed)( 0.06 * 0x10000L );
|
|
|
|
priv->blue_scale = (FT_Fixed)( 0.039625 * 0x10000L * 1000 );
|
|
|
|
|
[cff] Implement CFF2 support (2/2).
The font variation code. All parts dependent on the GX code in the
`truetype' module are guarded with TT_CONFIG_OPTION_GX_VAR_SUPPORT.
In other words, you can still compile the `cff' module without
defining TT_CONFIG_OPTION_GX_VAR_SUPPORT (which brings you CFF2
support without font variation).
* src/cff/cf2font.c (cf2_font_setup): Add support for font
variation.
* src/cff/cf2font.h (CF2_Font): Add fields for variation data.
* src/cff/cf2ft.c (cf2_free_instance): Free blend data.
(cf2_getVStore, cf2_getNormalizedVector): New functions.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c: Include `cffload.h'.
(cf2_cmdRESERVED_15, cf2_cmdRESERVED_16): Replace with...
(cf2_cmdVSINDEX, cf2_cmdBLEND): ... this new enum values.
(cf2_doBlend): New function.
(cf2_interpT2CharString): Handle `vsindex' and `blend' opcodes.
* src/cff/cffload.c (FT_fdot14ToFixed): New macro.
(cff_vstore_done, cff_vstore_load): New functions.
(cff_blend_clear, cff_blend_doBlend, cff_blend_build_vector,
cff_blend_check_vector): New functions.
(cff_load_private_dict): Add arguments for blend vector.
Handle blend data.
(cff_subfont_load, cff_subfont_done): Updated.
(cff_font_load): Handle CFF2 variation store data.
(cff_font_done): Updated.
* src/cff/cffload.h: Include `cffparse.h'.
Updated.
* src/cff/cffobjs.c (cff_face_done): Updated.
* src/cff/cffparse.c: Include `cffload.h'.
(cff_parse_num): Handle internal value 255.
(cff_parse_vsindex, cff_parse_blend): New functions.
(CFF_FIELD_BLEND): New macro.
(cff_parser_run): Updated.
* src/cff/cffparse.h (cff_kind_blend): New enum value.
* src/cff/cfftoken.h: Handle `vstore', `vsindex', and `blend'
dictionary values.
* src/cff/cfftypes.h (CFF_VarData, CFF_AxisCoords, CFF_VarRegion,
CFF_VStore, CFF_Blend): New structures.
(CFF_FontRecDict): Add `vstore_offset' field.
(CFF_Private): Add `vsindex' field.
(CFF_SubFont): Add fields for blend data.
(CFF_Font): Add `vstore' field.
* src/truetype/ttgxvar.c (TT_Get_MM_Var): `CFF2' is equal to `gvar',
since glyph variation data is directly embedded.
(TT_Set_MM_Blend): Don't load `gvar' table for CFF2 fonts.
2016-12-15 21:56:44 +01:00
|
|
|
/* provide inputs for blend calculations */
|
|
|
|
priv->subfont = subfont;
|
|
|
|
subfont->lenNDV = lenNDV;
|
|
|
|
subfont->NDV = NDV;
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
|
|
|
|
stackSize = font->cff2 ? font->top_font.font_dict.maxstack
|
|
|
|
: CFF_MAX_STACK_DEPTH + 1;
|
2016-12-15 11:22:15 +01:00
|
|
|
|
|
|
|
if ( cff_parser_init( &parser,
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
font->cff2 ? CFF2_CODE_PRIVATE : CFF_CODE_PRIVATE,
|
2016-12-15 11:22:15 +01:00
|
|
|
priv,
|
|
|
|
font->library,
|
|
|
|
stackSize,
|
|
|
|
top->num_designs,
|
|
|
|
top->num_axes ) )
|
|
|
|
goto Exit;
|
2016-12-15 00:00:45 +01:00
|
|
|
|
|
|
|
if ( FT_STREAM_SEEK( font->base_offset + top->private_offset ) ||
|
|
|
|
FT_FRAME_ENTER( top->private_size ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
FT_TRACE4(( " private dictionary:\n" ));
|
|
|
|
error = cff_parser_run( &parser,
|
|
|
|
(FT_Byte*)stream->cursor,
|
|
|
|
(FT_Byte*)stream->limit );
|
|
|
|
FT_FRAME_EXIT();
|
|
|
|
|
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* ensure that `num_blue_values' is even */
|
|
|
|
priv->num_blue_values &= ~1;
|
|
|
|
|
|
|
|
Exit:
|
2016-12-15 11:22:15 +01:00
|
|
|
/* clean up */
|
[cff] Implement CFF2 support (2/2).
The font variation code. All parts dependent on the GX code in the
`truetype' module are guarded with TT_CONFIG_OPTION_GX_VAR_SUPPORT.
In other words, you can still compile the `cff' module without
defining TT_CONFIG_OPTION_GX_VAR_SUPPORT (which brings you CFF2
support without font variation).
* src/cff/cf2font.c (cf2_font_setup): Add support for font
variation.
* src/cff/cf2font.h (CF2_Font): Add fields for variation data.
* src/cff/cf2ft.c (cf2_free_instance): Free blend data.
(cf2_getVStore, cf2_getNormalizedVector): New functions.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c: Include `cffload.h'.
(cf2_cmdRESERVED_15, cf2_cmdRESERVED_16): Replace with...
(cf2_cmdVSINDEX, cf2_cmdBLEND): ... this new enum values.
(cf2_doBlend): New function.
(cf2_interpT2CharString): Handle `vsindex' and `blend' opcodes.
* src/cff/cffload.c (FT_fdot14ToFixed): New macro.
(cff_vstore_done, cff_vstore_load): New functions.
(cff_blend_clear, cff_blend_doBlend, cff_blend_build_vector,
cff_blend_check_vector): New functions.
(cff_load_private_dict): Add arguments for blend vector.
Handle blend data.
(cff_subfont_load, cff_subfont_done): Updated.
(cff_font_load): Handle CFF2 variation store data.
(cff_font_done): Updated.
* src/cff/cffload.h: Include `cffparse.h'.
Updated.
* src/cff/cffobjs.c (cff_face_done): Updated.
* src/cff/cffparse.c: Include `cffload.h'.
(cff_parse_num): Handle internal value 255.
(cff_parse_vsindex, cff_parse_blend): New functions.
(CFF_FIELD_BLEND): New macro.
(cff_parser_run): Updated.
* src/cff/cffparse.h (cff_kind_blend): New enum value.
* src/cff/cfftoken.h: Handle `vstore', `vsindex', and `blend'
dictionary values.
* src/cff/cfftypes.h (CFF_VarData, CFF_AxisCoords, CFF_VarRegion,
CFF_VStore, CFF_Blend): New structures.
(CFF_FontRecDict): Add `vstore_offset' field.
(CFF_Private): Add `vsindex' field.
(CFF_SubFont): Add fields for blend data.
(CFF_Font): Add `vstore' field.
* src/truetype/ttgxvar.c (TT_Get_MM_Var): `CFF2' is equal to `gvar',
since glyph variation data is directly embedded.
(TT_Set_MM_Blend): Don't load `gvar' table for CFF2 fonts.
2016-12-15 21:56:44 +01:00
|
|
|
cff_blend_clear( subfont ); /* clear blend stack */
|
2016-12-15 11:22:15 +01:00
|
|
|
cff_parser_done( &parser ); /* free parser stack */
|
|
|
|
|
|
|
|
Exit2:
|
|
|
|
/* no clean up (parser not initialized) */
|
2016-12-15 00:00:45 +01:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
/* There are 3 ways to call this function, distinguished by code. */
|
|
|
|
/* */
|
|
|
|
/* . CFF_CODE_TOPDICT for either a CFF Top DICT or a CFF Font DICT */
|
|
|
|
/* . CFF2_CODE_TOPDICT for CFF2 Top DICT */
|
|
|
|
/* . CFF2_CODE_FONTDICT for CFF2 Font DICT */
|
|
|
|
|
2016-12-15 00:00:45 +01:00
|
|
|
static FT_Error
|
|
|
|
cff_subfont_load( CFF_SubFont subfont,
|
2002-03-30 17:41:09 +01:00
|
|
|
CFF_Index idx,
|
|
|
|
FT_UInt font_index,
|
|
|
|
FT_Stream stream,
|
2009-04-05 16:34:40 +02:00
|
|
|
FT_ULong base_offset,
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
FT_UInt code,
|
2016-12-15 00:00:45 +01:00
|
|
|
CFF_Font font )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2002-03-30 17:41:09 +01:00
|
|
|
FT_Error error;
|
|
|
|
CFF_ParserRec parser;
|
2004-01-24 16:06:57 +01:00
|
|
|
FT_Byte* dict = NULL;
|
2002-03-30 17:41:09 +01:00
|
|
|
FT_ULong dict_len;
|
2016-12-15 00:00:45 +01:00
|
|
|
CFF_FontRecDict top = &subfont->font_dict;
|
|
|
|
CFF_Private priv = &subfont->private_dict;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
FT_Bool cff2 = ( code == CFF2_CODE_TOPDICT ||
|
|
|
|
code == CFF2_CODE_FONTDICT );
|
|
|
|
FT_UInt stackSize = cff2 ? CFF2_DEFAULT_STACK
|
|
|
|
: CFF_MAX_STACK_DEPTH;
|
2016-12-15 11:22:15 +01:00
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
/* Note: We use default stack size for CFF2 Font DICT because */
|
|
|
|
/* Top and Font DICTs are not allowed to have blend operators. */
|
2016-12-15 23:10:59 +01:00
|
|
|
error = cff_parser_init( &parser,
|
|
|
|
code,
|
|
|
|
&subfont->font_dict,
|
|
|
|
font->library,
|
|
|
|
stackSize,
|
|
|
|
0,
|
|
|
|
0 );
|
|
|
|
if ( error )
|
2016-12-15 11:22:15 +01:00
|
|
|
goto Exit;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
/* set defaults */
|
2016-09-28 19:06:21 +02:00
|
|
|
FT_ZERO( top );
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2013-05-04 16:40:12 +02:00
|
|
|
top->underline_position = -( 100L << 16 );
|
Avoid overwriting of numeric font dictionary entries for synthetic
fonts. Additionally, some entries were handled as `integer' instead
of `number'.
* include/freetype/internal/psaux.h (T1_FieldType): Add
T1_FIELD_TYPE_BOOL_P, T1_FIELD_TYPE_INTEGER_P, and
T1_FIELD_TYPE_FIXED_P.
(T1_FIELD_BOOL_P, T1_FIELD_NUM_P, T1_FIELD_FIXED_P): New macros.
* src/psaux/psobjs.c (ps_parser_load_field): Handle new field types.
* include/freetype/internal/cfftypes.h (CFF_FontRecDict),
src/cff/cfftoken.h: Change type of underline_position and
underline_thickness to FT_Fixed.
* src/cff/cffload.c (cff_subfont_load): Fix default values of
underline_position and underline_thickness.
* src/cff/cffobjs.c (cff_face_init): Set underline_position
and underline_thickness in `root'.
* include/freetype/internal/t1types.h (T1_Font): Change point_type
and stroke_width to pointers.
* include/freetype/t1tables.h (PS_FontInfo): Change italic_angle,
is_fixed_pitch, underline_position, and underline_thickness to
pointers.
* src/type1/t1tokens.h: Change italic_angle, is_fixed_pitch,
underline_position, and underline_thickness to pointers. Change
the type of the latter two to `fixed'.
Change type of stroke_width to `fixed' and make it a pointer.
Change paint_type to pointer.
* src/type1/t1objs.c (T1_Face_Done): Updated.
(T1_Face_Init): Updated.
Fix assignment of underline_position and underline_thickness.
* src/cid/cidtoken.h: Change italic_angle, is_fixed_pitch,
underline_position, and underline_thickness to pointers. Change
the type of the latter two to `fixed'.
Change type of stroke_width to `fixed'.
* src/cid/cidobjs.c (cid_face_done): Updated.
(cid_face_init): Updated.
Fix assignment of underline_position and underline_thickness.
* src/type42/t42parse.c: Change italic_angle, is_fixed_pitch,
underline_position, and underline_thickness to pointers. Change the
type of the latter two to `fixed'.
Change type of stroke_width to `fixed' and make it a pointer.
Change paint_type to pointer.
* src/type42/t42objs.c (T42_Face_Init): Updated.
Fix assignment of underline_position and underline_thickness.
(T42_Face_Done): Updated.
* src/base/ftobjs.c (open_face_from_buffer): Fix compiler warning.
* src/pshinter/pshglob.c, src/pshinter/pshglob.h
(psh_globals_set_scale): Make it a local function.
* test/gview.c: Fix remaming ps3->ps typo.
Formatting.
2003-05-30 11:12:50 +02:00
|
|
|
top->underline_thickness = 50L << 16;
|
2000-12-08 03:42:29 +01:00
|
|
|
top->charstring_type = 2;
|
|
|
|
top->font_matrix.xx = 0x10000L;
|
|
|
|
top->font_matrix.yy = 0x10000L;
|
|
|
|
top->cid_count = 8720;
|
|
|
|
|
2003-12-11 18:55:58 +01:00
|
|
|
/* we use the implementation specific SID value 0xFFFF to indicate */
|
|
|
|
/* missing entries */
|
|
|
|
top->version = 0xFFFFU;
|
|
|
|
top->notice = 0xFFFFU;
|
|
|
|
top->copyright = 0xFFFFU;
|
|
|
|
top->full_name = 0xFFFFU;
|
|
|
|
top->family_name = 0xFFFFU;
|
|
|
|
top->weight = 0xFFFFU;
|
|
|
|
top->embedded_postscript = 0xFFFFU;
|
|
|
|
|
|
|
|
top->cid_registry = 0xFFFFU;
|
|
|
|
top->cid_ordering = 0xFFFFU;
|
|
|
|
top->cid_font_name = 0xFFFFU;
|
|
|
|
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
/* set default stack size */
|
|
|
|
top->maxstack = cff2 ? CFF2_DEFAULT_STACK : 48;
|
|
|
|
|
|
|
|
if ( idx->count ) /* count is nonzero for a real index */
|
|
|
|
error = cff_index_access_element( idx, font_index, &dict, &dict_len );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* CFF2 has a fake top dict index; */
|
|
|
|
/* simulate `cff_index_access_element' */
|
|
|
|
|
|
|
|
/* Note: macros implicitly use `stream' and set `error' */
|
|
|
|
if ( FT_STREAM_SEEK( idx->data_offset ) ||
|
|
|
|
FT_FRAME_EXTRACT( idx->data_size, dict ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
dict_len = idx->data_size;
|
|
|
|
}
|
|
|
|
|
2007-12-04 23:05:54 +01:00
|
|
|
if ( !error )
|
[cff] Better tracing of the parsing process.
* src/cff/cffload.c (cff_subfont_load, cff_font_load): Decorate with
FT_TRACE.
* src/cff/cffparse.c (cff_parse_font_matrix, cff_parse_font_bbox,
cff_parse_private_dict, cff_parse_cid_ros): Updated.
(CFF_FIELD_NUM, CFF_FIELD_FIXED, CFF_FIELD_FIXED_1000,
CFF_FIELD_STRING, CFF_FIELD_BOOL, CFF_FIELD_CALLBACK, CFF_FIELD,
CFF_FIELD_DELTA): Add argument for ID.
(cff_parser_run): Decorate with FT_TRACE.
* src/cff/cffparse.h (CFF_Field_Handler) [FT_DEBUG_LEVEL_TRACE]: Add
`id' member.
* src/cff/cfftoken.h: Add IDs to all fields.
2011-08-25 13:41:16 +02:00
|
|
|
{
|
|
|
|
FT_TRACE4(( " top dictionary:\n" ));
|
2007-12-04 23:05:54 +01:00
|
|
|
error = cff_parser_run( &parser, dict, dict + dict_len );
|
[cff] Better tracing of the parsing process.
* src/cff/cffload.c (cff_subfont_load, cff_font_load): Decorate with
FT_TRACE.
* src/cff/cffparse.c (cff_parse_font_matrix, cff_parse_font_bbox,
cff_parse_private_dict, cff_parse_cid_ros): Updated.
(CFF_FIELD_NUM, CFF_FIELD_FIXED, CFF_FIELD_FIXED_1000,
CFF_FIELD_STRING, CFF_FIELD_BOOL, CFF_FIELD_CALLBACK, CFF_FIELD,
CFF_FIELD_DELTA): Add argument for ID.
(cff_parser_run): Decorate with FT_TRACE.
* src/cff/cffparse.h (CFF_Field_Handler) [FT_DEBUG_LEVEL_TRACE]: Add
`id' member.
* src/cff/cfftoken.h: Add IDs to all fields.
2011-08-25 13:41:16 +02:00
|
|
|
}
|
2000-12-08 03:42:29 +01:00
|
|
|
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
/* clean up regardless of error */
|
|
|
|
if ( idx->count )
|
|
|
|
cff_index_forget_element( idx, &dict );
|
|
|
|
else
|
|
|
|
FT_FRAME_RELEASE( dict );
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
2006-10-23 12:23:17 +02:00
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
/* if it is a CID font, we stop there */
|
2003-12-11 18:55:58 +01:00
|
|
|
if ( top->cid_registry != 0xFFFFU )
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
|
|
|
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
/* Parse the private dictionary, if any. */
|
|
|
|
/* */
|
|
|
|
/* CFF2 does not have a private dictionary in the Top DICT */
|
|
|
|
/* but may have one in a Font DICT. We need to parse */
|
|
|
|
/* the latter here in order to load any local subrs. */
|
[cff] Implement CFF2 support (2/2).
The font variation code. All parts dependent on the GX code in the
`truetype' module are guarded with TT_CONFIG_OPTION_GX_VAR_SUPPORT.
In other words, you can still compile the `cff' module without
defining TT_CONFIG_OPTION_GX_VAR_SUPPORT (which brings you CFF2
support without font variation).
* src/cff/cf2font.c (cf2_font_setup): Add support for font
variation.
* src/cff/cf2font.h (CF2_Font): Add fields for variation data.
* src/cff/cf2ft.c (cf2_free_instance): Free blend data.
(cf2_getVStore, cf2_getNormalizedVector): New functions.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c: Include `cffload.h'.
(cf2_cmdRESERVED_15, cf2_cmdRESERVED_16): Replace with...
(cf2_cmdVSINDEX, cf2_cmdBLEND): ... this new enum values.
(cf2_doBlend): New function.
(cf2_interpT2CharString): Handle `vsindex' and `blend' opcodes.
* src/cff/cffload.c (FT_fdot14ToFixed): New macro.
(cff_vstore_done, cff_vstore_load): New functions.
(cff_blend_clear, cff_blend_doBlend, cff_blend_build_vector,
cff_blend_check_vector): New functions.
(cff_load_private_dict): Add arguments for blend vector.
Handle blend data.
(cff_subfont_load, cff_subfont_done): Updated.
(cff_font_load): Handle CFF2 variation store data.
(cff_font_done): Updated.
* src/cff/cffload.h: Include `cffparse.h'.
Updated.
* src/cff/cffobjs.c (cff_face_done): Updated.
* src/cff/cffparse.c: Include `cffload.h'.
(cff_parse_num): Handle internal value 255.
(cff_parse_vsindex, cff_parse_blend): New functions.
(CFF_FIELD_BLEND): New macro.
(cff_parser_run): Updated.
* src/cff/cffparse.h (cff_kind_blend): New enum value.
* src/cff/cfftoken.h: Handle `vstore', `vsindex', and `blend'
dictionary values.
* src/cff/cfftypes.h (CFF_VarData, CFF_AxisCoords, CFF_VarRegion,
CFF_VStore, CFF_Blend): New structures.
(CFF_FontRecDict): Add `vstore_offset' field.
(CFF_Private): Add `vsindex' field.
(CFF_SubFont): Add fields for blend data.
(CFF_Font): Add `vstore' field.
* src/truetype/ttgxvar.c (TT_Get_MM_Var): `CFF2' is equal to `gvar',
since glyph variation data is directly embedded.
(TT_Set_MM_Blend): Don't load `gvar' table for CFF2 fonts.
2016-12-15 21:56:44 +01:00
|
|
|
error = cff_load_private_dict( font, subfont, 0, 0 );
|
2016-12-15 00:00:45 +01:00
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
/* read the local subrs, if any */
|
|
|
|
if ( priv->local_subrs_offset )
|
|
|
|
{
|
2002-03-20 11:49:31 +01:00
|
|
|
if ( FT_STREAM_SEEK( base_offset + top->private_offset +
|
2002-03-30 17:41:09 +01:00
|
|
|
priv->local_subrs_offset ) )
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
|
|
|
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
error = cff_index_init( &subfont->local_subrs_index, stream, 1, cff2 );
|
2000-12-08 03:42:29 +01:00
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
|
2016-12-15 00:00:45 +01:00
|
|
|
error = cff_index_get_pointers( &subfont->local_subrs_index,
|
|
|
|
&subfont->local_subrs, NULL, NULL );
|
2000-12-08 17:17:16 +01:00
|
|
|
if ( error )
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
Exit:
|
2016-12-15 11:22:15 +01:00
|
|
|
cff_parser_done( &parser ); /* free parser stack */
|
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-27 21:46:12 +02:00
|
|
|
static void
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
cff_subfont_done( FT_Memory memory,
|
2002-03-14 09:57:10 +01:00
|
|
|
CFF_SubFont subfont )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
|
|
|
if ( subfont )
|
|
|
|
{
|
2007-01-05 14:14:08 +01:00
|
|
|
cff_index_done( &subfont->local_subrs_index );
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( subfont->local_subrs );
|
[cff] Implement CFF2 support (2/2).
The font variation code. All parts dependent on the GX code in the
`truetype' module are guarded with TT_CONFIG_OPTION_GX_VAR_SUPPORT.
In other words, you can still compile the `cff' module without
defining TT_CONFIG_OPTION_GX_VAR_SUPPORT (which brings you CFF2
support without font variation).
* src/cff/cf2font.c (cf2_font_setup): Add support for font
variation.
* src/cff/cf2font.h (CF2_Font): Add fields for variation data.
* src/cff/cf2ft.c (cf2_free_instance): Free blend data.
(cf2_getVStore, cf2_getNormalizedVector): New functions.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c: Include `cffload.h'.
(cf2_cmdRESERVED_15, cf2_cmdRESERVED_16): Replace with...
(cf2_cmdVSINDEX, cf2_cmdBLEND): ... this new enum values.
(cf2_doBlend): New function.
(cf2_interpT2CharString): Handle `vsindex' and `blend' opcodes.
* src/cff/cffload.c (FT_fdot14ToFixed): New macro.
(cff_vstore_done, cff_vstore_load): New functions.
(cff_blend_clear, cff_blend_doBlend, cff_blend_build_vector,
cff_blend_check_vector): New functions.
(cff_load_private_dict): Add arguments for blend vector.
Handle blend data.
(cff_subfont_load, cff_subfont_done): Updated.
(cff_font_load): Handle CFF2 variation store data.
(cff_font_done): Updated.
* src/cff/cffload.h: Include `cffparse.h'.
Updated.
* src/cff/cffobjs.c (cff_face_done): Updated.
* src/cff/cffparse.c: Include `cffload.h'.
(cff_parse_num): Handle internal value 255.
(cff_parse_vsindex, cff_parse_blend): New functions.
(CFF_FIELD_BLEND): New macro.
(cff_parser_run): Updated.
* src/cff/cffparse.h (cff_kind_blend): New enum value.
* src/cff/cfftoken.h: Handle `vstore', `vsindex', and `blend'
dictionary values.
* src/cff/cfftypes.h (CFF_VarData, CFF_AxisCoords, CFF_VarRegion,
CFF_VStore, CFF_Blend): New structures.
(CFF_FontRecDict): Add `vstore_offset' field.
(CFF_Private): Add `vsindex' field.
(CFF_SubFont): Add fields for blend data.
(CFF_Font): Add `vstore' field.
* src/truetype/ttgxvar.c (TT_Get_MM_Var): `CFF2' is equal to `gvar',
since glyph variation data is directly embedded.
(TT_Set_MM_Blend): Don't load `gvar' table for CFF2 fonts.
2016-12-15 21:56:44 +01:00
|
|
|
|
|
|
|
FT_FREE( subfont->blend.lastNDV );
|
|
|
|
FT_FREE( subfont->blend.BV );
|
|
|
|
FT_FREE( subfont->blend_stack );
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-01 03:26:22 +01:00
|
|
|
FT_LOCAL_DEF( FT_Error )
|
2009-04-05 16:34:40 +02:00
|
|
|
cff_font_load( FT_Library library,
|
|
|
|
FT_Stream stream,
|
2001-06-27 21:46:12 +02:00
|
|
|
FT_Int face_index,
|
2008-07-16 08:13:34 +02:00
|
|
|
CFF_Font font,
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
FT_Bool pure_cff,
|
|
|
|
FT_Bool cff2 )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
|
|
|
static const FT_Frame_Field cff_header_fields[] =
|
|
|
|
{
|
|
|
|
#undef FT_STRUCTURE
|
2002-03-14 09:57:10 +01:00
|
|
|
#define FT_STRUCTURE CFF_FontRec
|
2000-12-08 03:42:29 +01:00
|
|
|
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
FT_FRAME_START( 3 ),
|
2000-12-08 03:42:29 +01:00
|
|
|
FT_FRAME_BYTE( version_major ),
|
|
|
|
FT_FRAME_BYTE( version_minor ),
|
|
|
|
FT_FRAME_BYTE( header_size ),
|
|
|
|
FT_FRAME_END
|
|
|
|
};
|
|
|
|
|
2002-03-30 17:41:09 +01:00
|
|
|
FT_Error error;
|
|
|
|
FT_Memory memory = stream->memory;
|
|
|
|
FT_ULong base_offset;
|
2002-03-14 09:57:10 +01:00
|
|
|
CFF_FontRecDict dict;
|
Improve CFF string (especially glyphname) lookup performance.
We do this by avoiding memory allocation and file I/O. This is
Savannah patch #7104.
* src/cff/cfftypes.h: Include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(CFF_SubFontRec): Remove `num_local_subrs'.
(CFF_FontRec): Add `num_strings', `strings', and `string_pool'
fields.
Remove `string_index' and `num_global_subrs' fields.
Use real types instead of `void' for `pshinter' and `psnames' fields.
* src/cff/cffload.c: Don't include PS cmaps service.
(cff_index_get_pointers): Add `pool' parameter which allows to
insert an extra NUL character for each String INDEX entry.
(cff_index_get_name): Make it a local function.
(cff_index_get_string): New function.
(cff_subfont_load): Updated.
(cff_font_load): Initialize `num_strings', `strings', and
`string_pool' fields in the `CFF_FontRec' structure.
(cff_index_get_sid_string): Use `cff_index_get_string' instead of
`cff_index_get_name'.
(cff_font_done): Updated.
* src/cff/cffload.h: Don't include PS cmaps service.
(cff_index_get_string): Added.
(cff_index_get_sid_string): Updated.
* src/cff/cffobjs.c: Don't include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_size_get_globals_funcs, cff_slot_init): Updated.
(cff_face_init): Follow `cff_index_get_name',
`cff_index_get_string', and `cff_index_get_sid_string' changes.
* src/cff/cffcmap.c (cff_sid_free_glyph_name): Removed.
(cff_sid_to_glyph_name): Use `cff_index_get_cid_string'.
(cff_cmap_unicode_init): Updated.
* src/cff/cffdrivr.c: Don't include PS cmap service.
(cff_get_glyph_name): Avoid unnecessary lookup for POSTSCRIPT_CMAPS
service.
(cff_get_glyph_name, cff_ps_get_font_info, cff_get_ros): Follow API
`cff_index_get_sid_string' change.
(cff_get_name_index): Use `cff_index_get_string' instead of
`cff_index_get_name'.
* src/cff/cffgload.c: Don't include FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_decoder_init, cff_decoder_prepare): Updated.
2010-03-02 13:00:55 +01:00
|
|
|
CFF_IndexRec string_index;
|
2015-02-20 08:35:32 +01:00
|
|
|
FT_UInt subfont_index;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2004-12-28 08:31:35 +01:00
|
|
|
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
FT_ZERO( font );
|
Improve CFF string (especially glyphname) lookup performance.
We do this by avoiding memory allocation and file I/O. This is
Savannah patch #7104.
* src/cff/cfftypes.h: Include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(CFF_SubFontRec): Remove `num_local_subrs'.
(CFF_FontRec): Add `num_strings', `strings', and `string_pool'
fields.
Remove `string_index' and `num_global_subrs' fields.
Use real types instead of `void' for `pshinter' and `psnames' fields.
* src/cff/cffload.c: Don't include PS cmaps service.
(cff_index_get_pointers): Add `pool' parameter which allows to
insert an extra NUL character for each String INDEX entry.
(cff_index_get_name): Make it a local function.
(cff_index_get_string): New function.
(cff_subfont_load): Updated.
(cff_font_load): Initialize `num_strings', `strings', and
`string_pool' fields in the `CFF_FontRec' structure.
(cff_index_get_sid_string): Use `cff_index_get_string' instead of
`cff_index_get_name'.
(cff_font_done): Updated.
* src/cff/cffload.h: Don't include PS cmaps service.
(cff_index_get_string): Added.
(cff_index_get_sid_string): Updated.
* src/cff/cffobjs.c: Don't include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_size_get_globals_funcs, cff_slot_init): Updated.
(cff_face_init): Follow `cff_index_get_name',
`cff_index_get_string', and `cff_index_get_sid_string' changes.
* src/cff/cffcmap.c (cff_sid_free_glyph_name): Removed.
(cff_sid_to_glyph_name): Use `cff_index_get_cid_string'.
(cff_cmap_unicode_init): Updated.
* src/cff/cffdrivr.c: Don't include PS cmap service.
(cff_get_glyph_name): Avoid unnecessary lookup for POSTSCRIPT_CMAPS
service.
(cff_get_glyph_name, cff_ps_get_font_info, cff_get_ros): Follow API
`cff_index_get_sid_string' change.
(cff_get_name_index): Use `cff_index_get_string' instead of
`cff_index_get_name'.
* src/cff/cffgload.c: Don't include FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_decoder_init, cff_decoder_prepare): Updated.
2010-03-02 13:00:55 +01:00
|
|
|
FT_ZERO( &string_index );
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2016-12-15 00:00:45 +01:00
|
|
|
dict = &font->top_font.font_dict;
|
|
|
|
base_offset = FT_STREAM_POS();
|
|
|
|
|
|
|
|
font->library = library;
|
|
|
|
font->stream = stream;
|
|
|
|
font->memory = memory;
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
font->cff2 = cff2;
|
2016-12-15 00:00:45 +01:00
|
|
|
font->base_offset = base_offset;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
/* read CFF font header */
|
2002-03-20 11:49:31 +01:00
|
|
|
if ( FT_STREAM_READ_FIELDS( cff_header_fields, font ) )
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
|
|
|
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
if ( cff2 )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
if ( font->version_major != 2 ||
|
|
|
|
font->header_size < 5 )
|
|
|
|
{
|
|
|
|
FT_TRACE2(( " not a CFF2 font header\n" ));
|
|
|
|
error = FT_THROW( Unknown_File_Format );
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( FT_READ_USHORT( font->top_dict_length ) )
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-12-18 06:42:31 +01:00
|
|
|
FT_Byte absolute_offset;
|
|
|
|
|
|
|
|
|
|
|
|
if ( FT_READ_BYTE( absolute_offset ) )
|
|
|
|
goto Exit;
|
|
|
|
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
if ( font->version_major != 1 ||
|
2016-12-18 06:42:31 +01:00
|
|
|
font->header_size < 4 ||
|
|
|
|
absolute_offset > 4 )
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
{
|
|
|
|
FT_TRACE2(( " not a CFF font header\n" ));
|
|
|
|
error = FT_THROW( Unknown_File_Format );
|
|
|
|
goto Exit;
|
|
|
|
}
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* skip the rest of the header */
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
if ( FT_STREAM_SEEK( base_offset + font->header_size ) )
|
2016-12-18 06:42:31 +01:00
|
|
|
{
|
|
|
|
/* For pure CFFs we have read only four bytes so far. Contrary to */
|
|
|
|
/* other formats like SFNT those bytes doesn't define a signature; */
|
|
|
|
/* it is thus possible that the font isn't a CFF at all. */
|
|
|
|
if ( pure_cff )
|
|
|
|
{
|
|
|
|
FT_TRACE2(( " not a CFF file\n" ));
|
|
|
|
error = FT_THROW( Unknown_File_Format );
|
|
|
|
}
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
2016-12-18 06:42:31 +01:00
|
|
|
}
|
2000-12-08 03:42:29 +01:00
|
|
|
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
if ( cff2 )
|
|
|
|
{
|
|
|
|
/* For CFF2, the top dict data immediately follow the header */
|
|
|
|
/* and the length is stored in the header `offSize' field; */
|
|
|
|
/* there is no index for it. */
|
|
|
|
/* */
|
|
|
|
/* Use the `font_dict_index' to save the current position */
|
|
|
|
/* and length of data, but leave count at zero as an indicator. */
|
|
|
|
FT_ZERO( &font->font_dict_index );
|
|
|
|
|
|
|
|
font->font_dict_index.data_offset = FT_STREAM_POS();
|
|
|
|
font->font_dict_index.data_size = font->top_dict_length;
|
|
|
|
|
|
|
|
/* skip the top dict data for now, we will parse it later */
|
|
|
|
if ( FT_STREAM_SKIP( font->top_dict_length ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* next, read the global subrs index */
|
|
|
|
if ( FT_SET_ERROR( cff_index_init( &font->global_subrs_index,
|
|
|
|
stream, 1, cff2 ) ) )
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* for CFF, read the name, top dict, string and global subrs index */
|
|
|
|
if ( FT_SET_ERROR( cff_index_init( &font->name_index,
|
2016-12-18 06:42:31 +01:00
|
|
|
stream, 0, cff2 ) ) )
|
|
|
|
{
|
|
|
|
if ( pure_cff )
|
|
|
|
{
|
|
|
|
FT_TRACE2(( " not a CFF file\n" ));
|
|
|
|
error = FT_THROW( Unknown_File_Format );
|
|
|
|
}
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( FT_SET_ERROR( cff_index_init( &font->font_dict_index,
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
stream, 0, cff2 ) ) ||
|
|
|
|
FT_SET_ERROR( cff_index_init( &string_index,
|
|
|
|
stream, 1, cff2 ) ) ||
|
|
|
|
FT_SET_ERROR( cff_index_init( &font->global_subrs_index,
|
|
|
|
stream, 1, cff2 ) ) ||
|
|
|
|
FT_SET_ERROR( cff_index_get_pointers( &string_index,
|
|
|
|
&font->strings,
|
|
|
|
&font->string_pool,
|
|
|
|
&font->string_pool_size ) ) )
|
|
|
|
goto Exit;
|
|
|
|
}
|
2000-12-08 03:42:29 +01:00
|
|
|
|
Improve CFF string (especially glyphname) lookup performance.
We do this by avoiding memory allocation and file I/O. This is
Savannah patch #7104.
* src/cff/cfftypes.h: Include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(CFF_SubFontRec): Remove `num_local_subrs'.
(CFF_FontRec): Add `num_strings', `strings', and `string_pool'
fields.
Remove `string_index' and `num_global_subrs' fields.
Use real types instead of `void' for `pshinter' and `psnames' fields.
* src/cff/cffload.c: Don't include PS cmaps service.
(cff_index_get_pointers): Add `pool' parameter which allows to
insert an extra NUL character for each String INDEX entry.
(cff_index_get_name): Make it a local function.
(cff_index_get_string): New function.
(cff_subfont_load): Updated.
(cff_font_load): Initialize `num_strings', `strings', and
`string_pool' fields in the `CFF_FontRec' structure.
(cff_index_get_sid_string): Use `cff_index_get_string' instead of
`cff_index_get_name'.
(cff_font_done): Updated.
* src/cff/cffload.h: Don't include PS cmaps service.
(cff_index_get_string): Added.
(cff_index_get_sid_string): Updated.
* src/cff/cffobjs.c: Don't include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_size_get_globals_funcs, cff_slot_init): Updated.
(cff_face_init): Follow `cff_index_get_name',
`cff_index_get_string', and `cff_index_get_sid_string' changes.
* src/cff/cffcmap.c (cff_sid_free_glyph_name): Removed.
(cff_sid_to_glyph_name): Use `cff_index_get_cid_string'.
(cff_cmap_unicode_init): Updated.
* src/cff/cffdrivr.c: Don't include PS cmap service.
(cff_get_glyph_name): Avoid unnecessary lookup for POSTSCRIPT_CMAPS
service.
(cff_get_glyph_name, cff_ps_get_font_info, cff_get_ros): Follow API
`cff_index_get_sid_string' change.
(cff_get_name_index): Use `cff_index_get_string' instead of
`cff_index_get_name'.
* src/cff/cffgload.c: Don't include FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_decoder_init, cff_decoder_prepare): Updated.
2010-03-02 13:00:55 +01:00
|
|
|
font->num_strings = string_index.count;
|
|
|
|
|
2012-11-13 09:22:11 +01:00
|
|
|
if ( pure_cff )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2012-11-13 09:22:11 +01:00
|
|
|
/* well, we don't really forget the `disabled' fonts... */
|
2015-08-13 15:22:17 +02:00
|
|
|
subfont_index = (FT_UInt)( face_index & 0xFFFF );
|
2012-11-13 09:22:11 +01:00
|
|
|
|
2015-08-13 15:22:17 +02:00
|
|
|
if ( face_index > 0 && subfont_index >= font->name_index.count )
|
2012-11-13 09:22:11 +01:00
|
|
|
{
|
|
|
|
FT_ERROR(( "cff_font_load:"
|
|
|
|
" invalid subfont index for pure CFF font (%d)\n",
|
|
|
|
subfont_index ));
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_Argument );
|
2012-11-13 09:22:11 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
font->num_faces = font->name_index.count;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
subfont_index = 0;
|
|
|
|
|
|
|
|
if ( font->name_index.count > 1 )
|
|
|
|
{
|
|
|
|
FT_ERROR(( "cff_font_load:"
|
|
|
|
" invalid CFF font with multiple subfonts\n"
|
|
|
|
" "
|
|
|
|
" in SFNT wrapper\n" ));
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_File_Format );
|
2012-11-13 09:22:11 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* in case of a font format check, simply exit now */
|
|
|
|
if ( face_index < 0 )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* now, parse the top-level font dictionary */
|
[cff] Better tracing of the parsing process.
* src/cff/cffload.c (cff_subfont_load, cff_font_load): Decorate with
FT_TRACE.
* src/cff/cffparse.c (cff_parse_font_matrix, cff_parse_font_bbox,
cff_parse_private_dict, cff_parse_cid_ros): Updated.
(CFF_FIELD_NUM, CFF_FIELD_FIXED, CFF_FIELD_FIXED_1000,
CFF_FIELD_STRING, CFF_FIELD_BOOL, CFF_FIELD_CALLBACK, CFF_FIELD,
CFF_FIELD_DELTA): Add argument for ID.
(cff_parser_run): Decorate with FT_TRACE.
* src/cff/cffparse.h (CFF_Field_Handler) [FT_DEBUG_LEVEL_TRACE]: Add
`id' member.
* src/cff/cfftoken.h: Add IDs to all fields.
2011-08-25 13:41:16 +02:00
|
|
|
FT_TRACE4(( "parsing top-level\n" ));
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
error = cff_subfont_load( &font->top_font,
|
2000-12-08 03:42:29 +01:00
|
|
|
&font->font_dict_index,
|
2012-11-13 09:22:11 +01:00
|
|
|
subfont_index,
|
2000-12-08 03:42:29 +01:00
|
|
|
stream,
|
2009-04-05 16:34:40 +02:00
|
|
|
base_offset,
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
cff2 ? CFF2_CODE_TOPDICT : CFF_CODE_TOPDICT,
|
2016-12-15 00:00:45 +01:00
|
|
|
font );
|
2000-12-08 03:42:29 +01:00
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
|
2004-01-15 17:12:36 +01:00
|
|
|
if ( FT_STREAM_SEEK( base_offset + dict->charstrings_offset ) )
|
|
|
|
goto Exit;
|
|
|
|
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
error = cff_index_init( &font->charstrings_index, stream, 0, cff2 );
|
2004-01-15 17:12:36 +01:00
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
/* now, check for a CID or CFF2 font */
|
|
|
|
if ( dict->cid_registry != 0xFFFFU ||
|
|
|
|
cff2 )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
* src/base/ftdbgmem.c (ft_mem_table_resize, ft_mem_table_new,
ft_mem_table_set, ft_mem_debug_alloc, ft_mem_debug_free,
ft_mem_debug_realloc, ft_mem_debug_done, FT_Alloc_Debug,
FT_Realloc_Debug, FT_Free_Debug): Fix compiler warnings.
* src/base/ftcalc.c (FT_MulFix): Ditto.
* src/cff/cffdrivr.c (cff_get_name_index): Ditto.
* src/cff/cffobjs.c (CFF_Size_Get_Global_Funcs, CFF_Size_Init,
CFF_GlyphSlot_Init): Ditto.
* src/cid/cidobjs.c (CID_GlyphSlot_Init,
CID_Size_Get_Globals_Funcs): Ditto.
* src/type1/t1objs.c (T1_Size_Get_Globals_Funcs, T1_GlyphSlot_Init):
Ditto.
* src/pshinter/pshmod.c (pshinter_interface): Use `static const'.
* src/winfonts/winfnt.c (FNT_Get_Next_Char): Remove unused
variables.
* include/freetype/internal/psaux.h (T1_Builder_Funcs): Renamed
to...
(T1_Builder_FuncsRec): This.
(T1_Builder_Funcs): New typedef.
(PSAux_Interface): Remove compiler warnings.
* src/psaux/psauxmod.c (t1_builder_funcs), src/psaux/psobjs.h
(t1_builder_funcs): Updated.
* src/pshinter/pshglob.h (PSH_Blue_Align): Replaced with ...
(PSH_BLUE_ALIGN_{NONE,TOP,BOT}): New defines.
(PSH_AlignmentRec): Updated.
* include/freetype/internal/ftstream.h (GET_Char, GET_Byte): Fix
typo.
* include/freetype/internal/ftgloadr.h (FT_SubGlyph): Ditto.
* src/base/ftstream (FT_Get_Char): Rename to...
(FT_Stream_Get_Char): This.
* src/base/ftnames.c (FT_Get_Sfnt_Name): s/index/idx/ -- `index' is
a built-in function in gcc, causing warning messages with gcc 3.0.
* src/autohint/ahglyph.c (ah_outline_load): Ditto.
* src/autohint/ahglobal.c (ah_hinter_compute_blues): Ditto.
* src/cache/ftcmanag.c (ftc_family_table_alloc,
ftc_family_table_free, FTC_Manager_Done, FTC_Manager_Register_Cache):
Ditto.
* src/cff/cffload.c (cff_new_index, cff_done_index,
cff_explicit_index, CFF_Access_Element, CFF_Forget_Element,
CFF_Get_Name, CFF_Get_String, CFF_Load_SubFont, CFF_Load_Font,
CFF_Done_Font): Ditto.
* src/psaux/psobjs.c (PS_Table_Add, PS_Parser_LoadField): Ditto.
* src/psaux/t1decode.c (T1_Decoder_Parse_Charstrings): Ditto.
* src/pshinter/pshrec.c (ps_mask_test_bit, ps_mask_clear_bit,
ps_mask_set_bit, ps_dimension_add_t1stem, ps_hints_t1stem3,
* src/pshinter/pshalgo1.c (psh1_hint_table_record,
psh1_hint_table_record_mask, psh1_hint_table_activate_mask): Ditto.
* src/pshinter/pshalgo2.c (psh2_hint_table_record,
psh2_hint_table_record_mask, psh2_hint_table_activate_mask): Ditto.
* src/sfnt/ttpost.c (Load_Format_20, Load_Format_25,
TT_Get_PS_Name): Ditto.
* src/truetype/ttgload.c (TT_Get_Metrics, Get_HMetrics,
load_truetype_glyph): Ditto.
* src/type1/t1load.c (parse_subrs, T1_Open_Face): Ditto.
* src/type1/t1afm.c (T1_Get_Kerning): Ditto.
* include/freetype/cache/ftcmanag.h (ftc_family_table_free): Ditto.
2002-03-07 22:59:59 +01:00
|
|
|
CFF_IndexRec fd_index;
|
2011-06-14 19:48:33 +02:00
|
|
|
CFF_SubFont sub = NULL;
|
* src/base/ftdbgmem.c (ft_mem_table_resize, ft_mem_table_new,
ft_mem_table_set, ft_mem_debug_alloc, ft_mem_debug_free,
ft_mem_debug_realloc, ft_mem_debug_done, FT_Alloc_Debug,
FT_Realloc_Debug, FT_Free_Debug): Fix compiler warnings.
* src/base/ftcalc.c (FT_MulFix): Ditto.
* src/cff/cffdrivr.c (cff_get_name_index): Ditto.
* src/cff/cffobjs.c (CFF_Size_Get_Global_Funcs, CFF_Size_Init,
CFF_GlyphSlot_Init): Ditto.
* src/cid/cidobjs.c (CID_GlyphSlot_Init,
CID_Size_Get_Globals_Funcs): Ditto.
* src/type1/t1objs.c (T1_Size_Get_Globals_Funcs, T1_GlyphSlot_Init):
Ditto.
* src/pshinter/pshmod.c (pshinter_interface): Use `static const'.
* src/winfonts/winfnt.c (FNT_Get_Next_Char): Remove unused
variables.
* include/freetype/internal/psaux.h (T1_Builder_Funcs): Renamed
to...
(T1_Builder_FuncsRec): This.
(T1_Builder_Funcs): New typedef.
(PSAux_Interface): Remove compiler warnings.
* src/psaux/psauxmod.c (t1_builder_funcs), src/psaux/psobjs.h
(t1_builder_funcs): Updated.
* src/pshinter/pshglob.h (PSH_Blue_Align): Replaced with ...
(PSH_BLUE_ALIGN_{NONE,TOP,BOT}): New defines.
(PSH_AlignmentRec): Updated.
* include/freetype/internal/ftstream.h (GET_Char, GET_Byte): Fix
typo.
* include/freetype/internal/ftgloadr.h (FT_SubGlyph): Ditto.
* src/base/ftstream (FT_Get_Char): Rename to...
(FT_Stream_Get_Char): This.
* src/base/ftnames.c (FT_Get_Sfnt_Name): s/index/idx/ -- `index' is
a built-in function in gcc, causing warning messages with gcc 3.0.
* src/autohint/ahglyph.c (ah_outline_load): Ditto.
* src/autohint/ahglobal.c (ah_hinter_compute_blues): Ditto.
* src/cache/ftcmanag.c (ftc_family_table_alloc,
ftc_family_table_free, FTC_Manager_Done, FTC_Manager_Register_Cache):
Ditto.
* src/cff/cffload.c (cff_new_index, cff_done_index,
cff_explicit_index, CFF_Access_Element, CFF_Forget_Element,
CFF_Get_Name, CFF_Get_String, CFF_Load_SubFont, CFF_Load_Font,
CFF_Done_Font): Ditto.
* src/psaux/psobjs.c (PS_Table_Add, PS_Parser_LoadField): Ditto.
* src/psaux/t1decode.c (T1_Decoder_Parse_Charstrings): Ditto.
* src/pshinter/pshrec.c (ps_mask_test_bit, ps_mask_clear_bit,
ps_mask_set_bit, ps_dimension_add_t1stem, ps_hints_t1stem3,
* src/pshinter/pshalgo1.c (psh1_hint_table_record,
psh1_hint_table_record_mask, psh1_hint_table_activate_mask): Ditto.
* src/pshinter/pshalgo2.c (psh2_hint_table_record,
psh2_hint_table_record_mask, psh2_hint_table_activate_mask): Ditto.
* src/sfnt/ttpost.c (Load_Format_20, Load_Format_25,
TT_Get_PS_Name): Ditto.
* src/truetype/ttgload.c (TT_Get_Metrics, Get_HMetrics,
load_truetype_glyph): Ditto.
* src/type1/t1load.c (parse_subrs, T1_Open_Face): Ditto.
* src/type1/t1afm.c (T1_Get_Kerning): Ditto.
* include/freetype/cache/ftcmanag.h (ftc_family_table_free): Ditto.
2002-03-07 22:59:59 +01:00
|
|
|
FT_UInt idx;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
|
[cff] Implement CFF2 support (2/2).
The font variation code. All parts dependent on the GX code in the
`truetype' module are guarded with TT_CONFIG_OPTION_GX_VAR_SUPPORT.
In other words, you can still compile the `cff' module without
defining TT_CONFIG_OPTION_GX_VAR_SUPPORT (which brings you CFF2
support without font variation).
* src/cff/cf2font.c (cf2_font_setup): Add support for font
variation.
* src/cff/cf2font.h (CF2_Font): Add fields for variation data.
* src/cff/cf2ft.c (cf2_free_instance): Free blend data.
(cf2_getVStore, cf2_getNormalizedVector): New functions.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c: Include `cffload.h'.
(cf2_cmdRESERVED_15, cf2_cmdRESERVED_16): Replace with...
(cf2_cmdVSINDEX, cf2_cmdBLEND): ... this new enum values.
(cf2_doBlend): New function.
(cf2_interpT2CharString): Handle `vsindex' and `blend' opcodes.
* src/cff/cffload.c (FT_fdot14ToFixed): New macro.
(cff_vstore_done, cff_vstore_load): New functions.
(cff_blend_clear, cff_blend_doBlend, cff_blend_build_vector,
cff_blend_check_vector): New functions.
(cff_load_private_dict): Add arguments for blend vector.
Handle blend data.
(cff_subfont_load, cff_subfont_done): Updated.
(cff_font_load): Handle CFF2 variation store data.
(cff_font_done): Updated.
* src/cff/cffload.h: Include `cffparse.h'.
Updated.
* src/cff/cffobjs.c (cff_face_done): Updated.
* src/cff/cffparse.c: Include `cffload.h'.
(cff_parse_num): Handle internal value 255.
(cff_parse_vsindex, cff_parse_blend): New functions.
(CFF_FIELD_BLEND): New macro.
(cff_parser_run): Updated.
* src/cff/cffparse.h (cff_kind_blend): New enum value.
* src/cff/cfftoken.h: Handle `vstore', `vsindex', and `blend'
dictionary values.
* src/cff/cfftypes.h (CFF_VarData, CFF_AxisCoords, CFF_VarRegion,
CFF_VStore, CFF_Blend): New structures.
(CFF_FontRecDict): Add `vstore_offset' field.
(CFF_Private): Add `vsindex' field.
(CFF_SubFont): Add fields for blend data.
(CFF_Font): Add `vstore' field.
* src/truetype/ttgxvar.c (TT_Get_MM_Var): `CFF2' is equal to `gvar',
since glyph variation data is directly embedded.
(TT_Set_MM_Blend): Don't load `gvar' table for CFF2 fonts.
2016-12-15 21:56:44 +01:00
|
|
|
/* for CFF2, read the Variation Store if available; */
|
|
|
|
/* this must follow the Top DICT parse and precede any Private DICT */
|
|
|
|
error = cff_vstore_load( &font->vstore,
|
|
|
|
stream,
|
|
|
|
base_offset,
|
|
|
|
dict->vstore_offset );
|
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
/* this is a CID-keyed font, we must now allocate a table of */
|
|
|
|
/* sub-fonts, then load each of them separately */
|
2002-03-20 11:49:31 +01:00
|
|
|
if ( FT_STREAM_SEEK( base_offset + dict->cid_fd_array_offset ) )
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
|
|
|
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
error = cff_index_init( &fd_index, stream, 0, cff2 );
|
2000-12-08 03:42:29 +01:00
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
/* Font Dicts are not limited to 256 for CFF2. */
|
|
|
|
/* TODO: support this for CFF2 */
|
2000-12-08 03:42:29 +01:00
|
|
|
if ( fd_index.count > CFF_MAX_CID_FONTS )
|
|
|
|
{
|
2009-06-26 06:15:41 +02:00
|
|
|
FT_TRACE0(( "cff_font_load: FD array too large in CID font\n" ));
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Fail_CID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* allocate & read each font dict independently */
|
|
|
|
font->num_subfonts = fd_index.count;
|
2002-03-22 14:52:37 +01:00
|
|
|
if ( FT_NEW_ARRAY( sub, fd_index.count ) )
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Fail_CID;
|
|
|
|
|
2005-12-04 13:48:57 +01:00
|
|
|
/* set up pointer table */
|
* src/base/ftdbgmem.c (ft_mem_table_resize, ft_mem_table_new,
ft_mem_table_set, ft_mem_debug_alloc, ft_mem_debug_free,
ft_mem_debug_realloc, ft_mem_debug_done, FT_Alloc_Debug,
FT_Realloc_Debug, FT_Free_Debug): Fix compiler warnings.
* src/base/ftcalc.c (FT_MulFix): Ditto.
* src/cff/cffdrivr.c (cff_get_name_index): Ditto.
* src/cff/cffobjs.c (CFF_Size_Get_Global_Funcs, CFF_Size_Init,
CFF_GlyphSlot_Init): Ditto.
* src/cid/cidobjs.c (CID_GlyphSlot_Init,
CID_Size_Get_Globals_Funcs): Ditto.
* src/type1/t1objs.c (T1_Size_Get_Globals_Funcs, T1_GlyphSlot_Init):
Ditto.
* src/pshinter/pshmod.c (pshinter_interface): Use `static const'.
* src/winfonts/winfnt.c (FNT_Get_Next_Char): Remove unused
variables.
* include/freetype/internal/psaux.h (T1_Builder_Funcs): Renamed
to...
(T1_Builder_FuncsRec): This.
(T1_Builder_Funcs): New typedef.
(PSAux_Interface): Remove compiler warnings.
* src/psaux/psauxmod.c (t1_builder_funcs), src/psaux/psobjs.h
(t1_builder_funcs): Updated.
* src/pshinter/pshglob.h (PSH_Blue_Align): Replaced with ...
(PSH_BLUE_ALIGN_{NONE,TOP,BOT}): New defines.
(PSH_AlignmentRec): Updated.
* include/freetype/internal/ftstream.h (GET_Char, GET_Byte): Fix
typo.
* include/freetype/internal/ftgloadr.h (FT_SubGlyph): Ditto.
* src/base/ftstream (FT_Get_Char): Rename to...
(FT_Stream_Get_Char): This.
* src/base/ftnames.c (FT_Get_Sfnt_Name): s/index/idx/ -- `index' is
a built-in function in gcc, causing warning messages with gcc 3.0.
* src/autohint/ahglyph.c (ah_outline_load): Ditto.
* src/autohint/ahglobal.c (ah_hinter_compute_blues): Ditto.
* src/cache/ftcmanag.c (ftc_family_table_alloc,
ftc_family_table_free, FTC_Manager_Done, FTC_Manager_Register_Cache):
Ditto.
* src/cff/cffload.c (cff_new_index, cff_done_index,
cff_explicit_index, CFF_Access_Element, CFF_Forget_Element,
CFF_Get_Name, CFF_Get_String, CFF_Load_SubFont, CFF_Load_Font,
CFF_Done_Font): Ditto.
* src/psaux/psobjs.c (PS_Table_Add, PS_Parser_LoadField): Ditto.
* src/psaux/t1decode.c (T1_Decoder_Parse_Charstrings): Ditto.
* src/pshinter/pshrec.c (ps_mask_test_bit, ps_mask_clear_bit,
ps_mask_set_bit, ps_dimension_add_t1stem, ps_hints_t1stem3,
* src/pshinter/pshalgo1.c (psh1_hint_table_record,
psh1_hint_table_record_mask, psh1_hint_table_activate_mask): Ditto.
* src/pshinter/pshalgo2.c (psh2_hint_table_record,
psh2_hint_table_record_mask, psh2_hint_table_activate_mask): Ditto.
* src/sfnt/ttpost.c (Load_Format_20, Load_Format_25,
TT_Get_PS_Name): Ditto.
* src/truetype/ttgload.c (TT_Get_Metrics, Get_HMetrics,
load_truetype_glyph): Ditto.
* src/type1/t1load.c (parse_subrs, T1_Open_Face): Ditto.
* src/type1/t1afm.c (T1_Get_Kerning): Ditto.
* include/freetype/cache/ftcmanag.h (ftc_family_table_free): Ditto.
2002-03-07 22:59:59 +01:00
|
|
|
for ( idx = 0; idx < fd_index.count; idx++ )
|
|
|
|
font->subfonts[idx] = sub + idx;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2005-12-04 13:48:57 +01:00
|
|
|
/* now load each subfont independently */
|
* src/base/ftdbgmem.c (ft_mem_table_resize, ft_mem_table_new,
ft_mem_table_set, ft_mem_debug_alloc, ft_mem_debug_free,
ft_mem_debug_realloc, ft_mem_debug_done, FT_Alloc_Debug,
FT_Realloc_Debug, FT_Free_Debug): Fix compiler warnings.
* src/base/ftcalc.c (FT_MulFix): Ditto.
* src/cff/cffdrivr.c (cff_get_name_index): Ditto.
* src/cff/cffobjs.c (CFF_Size_Get_Global_Funcs, CFF_Size_Init,
CFF_GlyphSlot_Init): Ditto.
* src/cid/cidobjs.c (CID_GlyphSlot_Init,
CID_Size_Get_Globals_Funcs): Ditto.
* src/type1/t1objs.c (T1_Size_Get_Globals_Funcs, T1_GlyphSlot_Init):
Ditto.
* src/pshinter/pshmod.c (pshinter_interface): Use `static const'.
* src/winfonts/winfnt.c (FNT_Get_Next_Char): Remove unused
variables.
* include/freetype/internal/psaux.h (T1_Builder_Funcs): Renamed
to...
(T1_Builder_FuncsRec): This.
(T1_Builder_Funcs): New typedef.
(PSAux_Interface): Remove compiler warnings.
* src/psaux/psauxmod.c (t1_builder_funcs), src/psaux/psobjs.h
(t1_builder_funcs): Updated.
* src/pshinter/pshglob.h (PSH_Blue_Align): Replaced with ...
(PSH_BLUE_ALIGN_{NONE,TOP,BOT}): New defines.
(PSH_AlignmentRec): Updated.
* include/freetype/internal/ftstream.h (GET_Char, GET_Byte): Fix
typo.
* include/freetype/internal/ftgloadr.h (FT_SubGlyph): Ditto.
* src/base/ftstream (FT_Get_Char): Rename to...
(FT_Stream_Get_Char): This.
* src/base/ftnames.c (FT_Get_Sfnt_Name): s/index/idx/ -- `index' is
a built-in function in gcc, causing warning messages with gcc 3.0.
* src/autohint/ahglyph.c (ah_outline_load): Ditto.
* src/autohint/ahglobal.c (ah_hinter_compute_blues): Ditto.
* src/cache/ftcmanag.c (ftc_family_table_alloc,
ftc_family_table_free, FTC_Manager_Done, FTC_Manager_Register_Cache):
Ditto.
* src/cff/cffload.c (cff_new_index, cff_done_index,
cff_explicit_index, CFF_Access_Element, CFF_Forget_Element,
CFF_Get_Name, CFF_Get_String, CFF_Load_SubFont, CFF_Load_Font,
CFF_Done_Font): Ditto.
* src/psaux/psobjs.c (PS_Table_Add, PS_Parser_LoadField): Ditto.
* src/psaux/t1decode.c (T1_Decoder_Parse_Charstrings): Ditto.
* src/pshinter/pshrec.c (ps_mask_test_bit, ps_mask_clear_bit,
ps_mask_set_bit, ps_dimension_add_t1stem, ps_hints_t1stem3,
* src/pshinter/pshalgo1.c (psh1_hint_table_record,
psh1_hint_table_record_mask, psh1_hint_table_activate_mask): Ditto.
* src/pshinter/pshalgo2.c (psh2_hint_table_record,
psh2_hint_table_record_mask, psh2_hint_table_activate_mask): Ditto.
* src/sfnt/ttpost.c (Load_Format_20, Load_Format_25,
TT_Get_PS_Name): Ditto.
* src/truetype/ttgload.c (TT_Get_Metrics, Get_HMetrics,
load_truetype_glyph): Ditto.
* src/type1/t1load.c (parse_subrs, T1_Open_Face): Ditto.
* src/type1/t1afm.c (T1_Get_Kerning): Ditto.
* include/freetype/cache/ftcmanag.h (ftc_family_table_free): Ditto.
2002-03-07 22:59:59 +01:00
|
|
|
for ( idx = 0; idx < fd_index.count; idx++ )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
* src/base/ftdbgmem.c (ft_mem_table_resize, ft_mem_table_new,
ft_mem_table_set, ft_mem_debug_alloc, ft_mem_debug_free,
ft_mem_debug_realloc, ft_mem_debug_done, FT_Alloc_Debug,
FT_Realloc_Debug, FT_Free_Debug): Fix compiler warnings.
* src/base/ftcalc.c (FT_MulFix): Ditto.
* src/cff/cffdrivr.c (cff_get_name_index): Ditto.
* src/cff/cffobjs.c (CFF_Size_Get_Global_Funcs, CFF_Size_Init,
CFF_GlyphSlot_Init): Ditto.
* src/cid/cidobjs.c (CID_GlyphSlot_Init,
CID_Size_Get_Globals_Funcs): Ditto.
* src/type1/t1objs.c (T1_Size_Get_Globals_Funcs, T1_GlyphSlot_Init):
Ditto.
* src/pshinter/pshmod.c (pshinter_interface): Use `static const'.
* src/winfonts/winfnt.c (FNT_Get_Next_Char): Remove unused
variables.
* include/freetype/internal/psaux.h (T1_Builder_Funcs): Renamed
to...
(T1_Builder_FuncsRec): This.
(T1_Builder_Funcs): New typedef.
(PSAux_Interface): Remove compiler warnings.
* src/psaux/psauxmod.c (t1_builder_funcs), src/psaux/psobjs.h
(t1_builder_funcs): Updated.
* src/pshinter/pshglob.h (PSH_Blue_Align): Replaced with ...
(PSH_BLUE_ALIGN_{NONE,TOP,BOT}): New defines.
(PSH_AlignmentRec): Updated.
* include/freetype/internal/ftstream.h (GET_Char, GET_Byte): Fix
typo.
* include/freetype/internal/ftgloadr.h (FT_SubGlyph): Ditto.
* src/base/ftstream (FT_Get_Char): Rename to...
(FT_Stream_Get_Char): This.
* src/base/ftnames.c (FT_Get_Sfnt_Name): s/index/idx/ -- `index' is
a built-in function in gcc, causing warning messages with gcc 3.0.
* src/autohint/ahglyph.c (ah_outline_load): Ditto.
* src/autohint/ahglobal.c (ah_hinter_compute_blues): Ditto.
* src/cache/ftcmanag.c (ftc_family_table_alloc,
ftc_family_table_free, FTC_Manager_Done, FTC_Manager_Register_Cache):
Ditto.
* src/cff/cffload.c (cff_new_index, cff_done_index,
cff_explicit_index, CFF_Access_Element, CFF_Forget_Element,
CFF_Get_Name, CFF_Get_String, CFF_Load_SubFont, CFF_Load_Font,
CFF_Done_Font): Ditto.
* src/psaux/psobjs.c (PS_Table_Add, PS_Parser_LoadField): Ditto.
* src/psaux/t1decode.c (T1_Decoder_Parse_Charstrings): Ditto.
* src/pshinter/pshrec.c (ps_mask_test_bit, ps_mask_clear_bit,
ps_mask_set_bit, ps_dimension_add_t1stem, ps_hints_t1stem3,
* src/pshinter/pshalgo1.c (psh1_hint_table_record,
psh1_hint_table_record_mask, psh1_hint_table_activate_mask): Ditto.
* src/pshinter/pshalgo2.c (psh2_hint_table_record,
psh2_hint_table_record_mask, psh2_hint_table_activate_mask): Ditto.
* src/sfnt/ttpost.c (Load_Format_20, Load_Format_25,
TT_Get_PS_Name): Ditto.
* src/truetype/ttgload.c (TT_Get_Metrics, Get_HMetrics,
load_truetype_glyph): Ditto.
* src/type1/t1load.c (parse_subrs, T1_Open_Face): Ditto.
* src/type1/t1afm.c (T1_Get_Kerning): Ditto.
* include/freetype/cache/ftcmanag.h (ftc_family_table_free): Ditto.
2002-03-07 22:59:59 +01:00
|
|
|
sub = font->subfonts[idx];
|
[cff] Better tracing of the parsing process.
* src/cff/cffload.c (cff_subfont_load, cff_font_load): Decorate with
FT_TRACE.
* src/cff/cffparse.c (cff_parse_font_matrix, cff_parse_font_bbox,
cff_parse_private_dict, cff_parse_cid_ros): Updated.
(CFF_FIELD_NUM, CFF_FIELD_FIXED, CFF_FIELD_FIXED_1000,
CFF_FIELD_STRING, CFF_FIELD_BOOL, CFF_FIELD_CALLBACK, CFF_FIELD,
CFF_FIELD_DELTA): Add argument for ID.
(cff_parser_run): Decorate with FT_TRACE.
* src/cff/cffparse.h (CFF_Field_Handler) [FT_DEBUG_LEVEL_TRACE]: Add
`id' member.
* src/cff/cfftoken.h: Add IDs to all fields.
2011-08-25 13:41:16 +02:00
|
|
|
FT_TRACE4(( "parsing subfont %u\n", idx ));
|
2016-12-15 00:00:45 +01:00
|
|
|
error = cff_subfont_load( sub,
|
|
|
|
&fd_index,
|
|
|
|
idx,
|
|
|
|
stream,
|
|
|
|
base_offset,
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
cff2 ? CFF2_CODE_FONTDICT
|
|
|
|
: CFF_CODE_TOPDICT,
|
2016-12-15 00:00:45 +01:00
|
|
|
font );
|
2000-12-08 03:42:29 +01:00
|
|
|
if ( error )
|
|
|
|
goto Fail_CID;
|
|
|
|
}
|
|
|
|
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
/* now load the FD Select array; */
|
|
|
|
/* CFF2 omits FDSelect if there is only one FD */
|
|
|
|
if ( !cff2 || fd_index.count > 1 )
|
|
|
|
error = CFF_Load_FD_Select( &font->fd_select,
|
|
|
|
font->charstrings_index.count,
|
|
|
|
stream,
|
|
|
|
base_offset + dict->cid_fd_select_offset );
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
Fail_CID:
|
2007-01-05 14:14:08 +01:00
|
|
|
cff_index_done( &fd_index );
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
font->num_subfonts = 0;
|
|
|
|
|
2002-08-23 12:08:38 +02:00
|
|
|
/* read the charstrings index now */
|
|
|
|
if ( dict->charstrings_offset == 0 )
|
2002-08-16 01:07:18 +02:00
|
|
|
{
|
2009-06-26 06:15:41 +02:00
|
|
|
FT_ERROR(( "cff_font_load: no charstrings offset\n" ));
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_File_Format );
|
2002-08-23 12:08:38 +02:00
|
|
|
goto Exit;
|
|
|
|
}
|
2000-12-08 03:42:29 +01:00
|
|
|
|
Improve CFF string (especially glyphname) lookup performance.
We do this by avoiding memory allocation and file I/O. This is
Savannah patch #7104.
* src/cff/cfftypes.h: Include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(CFF_SubFontRec): Remove `num_local_subrs'.
(CFF_FontRec): Add `num_strings', `strings', and `string_pool'
fields.
Remove `string_index' and `num_global_subrs' fields.
Use real types instead of `void' for `pshinter' and `psnames' fields.
* src/cff/cffload.c: Don't include PS cmaps service.
(cff_index_get_pointers): Add `pool' parameter which allows to
insert an extra NUL character for each String INDEX entry.
(cff_index_get_name): Make it a local function.
(cff_index_get_string): New function.
(cff_subfont_load): Updated.
(cff_font_load): Initialize `num_strings', `strings', and
`string_pool' fields in the `CFF_FontRec' structure.
(cff_index_get_sid_string): Use `cff_index_get_string' instead of
`cff_index_get_name'.
(cff_font_done): Updated.
* src/cff/cffload.h: Don't include PS cmaps service.
(cff_index_get_string): Added.
(cff_index_get_sid_string): Updated.
* src/cff/cffobjs.c: Don't include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_size_get_globals_funcs, cff_slot_init): Updated.
(cff_face_init): Follow `cff_index_get_name',
`cff_index_get_string', and `cff_index_get_sid_string' changes.
* src/cff/cffcmap.c (cff_sid_free_glyph_name): Removed.
(cff_sid_to_glyph_name): Use `cff_index_get_cid_string'.
(cff_cmap_unicode_init): Updated.
* src/cff/cffdrivr.c: Don't include PS cmap service.
(cff_get_glyph_name): Avoid unnecessary lookup for POSTSCRIPT_CMAPS
service.
(cff_get_glyph_name, cff_ps_get_font_info, cff_get_ros): Follow API
`cff_index_get_sid_string' change.
(cff_get_name_index): Use `cff_index_get_string' instead of
`cff_index_get_name'.
* src/cff/cffgload.c: Don't include FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_decoder_init, cff_decoder_prepare): Updated.
2010-03-02 13:00:55 +01:00
|
|
|
font->num_glyphs = font->charstrings_index.count;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
error = cff_index_get_pointers( &font->global_subrs_index,
|
2016-02-15 14:28:28 +01:00
|
|
|
&font->global_subrs, NULL, NULL );
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
|
2003-12-11 18:55:58 +01:00
|
|
|
/* read the Charset and Encoding tables if available */
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
if ( !cff2 && font->num_glyphs > 0 )
|
2002-08-15 14:10:48 +02:00
|
|
|
{
|
2008-07-16 08:13:34 +02:00
|
|
|
FT_Bool invert = FT_BOOL( dict->cid_registry != 0xFFFFU && pure_cff );
|
2003-12-18 09:18:37 +01:00
|
|
|
|
|
|
|
|
2002-08-15 14:10:48 +02:00
|
|
|
error = cff_charset_load( &font->charset, font->num_glyphs, stream,
|
2003-12-18 09:18:37 +01:00
|
|
|
base_offset, dict->charset_offset, invert );
|
2002-08-15 14:10:48 +02:00
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
2001-06-28 19:49:10 +02:00
|
|
|
|
2003-12-11 18:55:58 +01:00
|
|
|
/* CID-keyed CFFs don't have an encoding */
|
|
|
|
if ( dict->cid_registry == 0xFFFFU )
|
|
|
|
{
|
|
|
|
error = cff_encoding_load( &font->encoding,
|
|
|
|
&font->charset,
|
|
|
|
font->num_glyphs,
|
|
|
|
stream,
|
|
|
|
base_offset,
|
|
|
|
dict->encoding_offset );
|
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
}
|
2002-08-15 14:10:48 +02:00
|
|
|
}
|
2001-06-28 19:49:10 +02:00
|
|
|
|
2003-12-11 18:55:58 +01:00
|
|
|
/* get the font name (/CIDFontName for CID-keyed fonts, */
|
|
|
|
/* /FontName otherwise) */
|
2012-11-13 09:22:11 +01:00
|
|
|
font->font_name = cff_index_get_name( font, subfont_index );
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
Exit:
|
Improve CFF string (especially glyphname) lookup performance.
We do this by avoiding memory allocation and file I/O. This is
Savannah patch #7104.
* src/cff/cfftypes.h: Include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(CFF_SubFontRec): Remove `num_local_subrs'.
(CFF_FontRec): Add `num_strings', `strings', and `string_pool'
fields.
Remove `string_index' and `num_global_subrs' fields.
Use real types instead of `void' for `pshinter' and `psnames' fields.
* src/cff/cffload.c: Don't include PS cmaps service.
(cff_index_get_pointers): Add `pool' parameter which allows to
insert an extra NUL character for each String INDEX entry.
(cff_index_get_name): Make it a local function.
(cff_index_get_string): New function.
(cff_subfont_load): Updated.
(cff_font_load): Initialize `num_strings', `strings', and
`string_pool' fields in the `CFF_FontRec' structure.
(cff_index_get_sid_string): Use `cff_index_get_string' instead of
`cff_index_get_name'.
(cff_font_done): Updated.
* src/cff/cffload.h: Don't include PS cmaps service.
(cff_index_get_string): Added.
(cff_index_get_sid_string): Updated.
* src/cff/cffobjs.c: Don't include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_size_get_globals_funcs, cff_slot_init): Updated.
(cff_face_init): Follow `cff_index_get_name',
`cff_index_get_string', and `cff_index_get_sid_string' changes.
* src/cff/cffcmap.c (cff_sid_free_glyph_name): Removed.
(cff_sid_to_glyph_name): Use `cff_index_get_cid_string'.
(cff_cmap_unicode_init): Updated.
* src/cff/cffdrivr.c: Don't include PS cmap service.
(cff_get_glyph_name): Avoid unnecessary lookup for POSTSCRIPT_CMAPS
service.
(cff_get_glyph_name, cff_ps_get_font_info, cff_get_ros): Follow API
`cff_index_get_sid_string' change.
(cff_get_name_index): Use `cff_index_get_string' instead of
`cff_index_get_name'.
* src/cff/cffgload.c: Don't include FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_decoder_init, cff_decoder_prepare): Updated.
2010-03-02 13:00:55 +01:00
|
|
|
cff_index_done( &string_index );
|
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-01 03:26:22 +01:00
|
|
|
FT_LOCAL_DEF( void )
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
cff_font_done( CFF_Font font )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
|
|
|
FT_Memory memory = font->memory;
|
* src/base/ftdbgmem.c (ft_mem_table_resize, ft_mem_table_new,
ft_mem_table_set, ft_mem_debug_alloc, ft_mem_debug_free,
ft_mem_debug_realloc, ft_mem_debug_done, FT_Alloc_Debug,
FT_Realloc_Debug, FT_Free_Debug): Fix compiler warnings.
* src/base/ftcalc.c (FT_MulFix): Ditto.
* src/cff/cffdrivr.c (cff_get_name_index): Ditto.
* src/cff/cffobjs.c (CFF_Size_Get_Global_Funcs, CFF_Size_Init,
CFF_GlyphSlot_Init): Ditto.
* src/cid/cidobjs.c (CID_GlyphSlot_Init,
CID_Size_Get_Globals_Funcs): Ditto.
* src/type1/t1objs.c (T1_Size_Get_Globals_Funcs, T1_GlyphSlot_Init):
Ditto.
* src/pshinter/pshmod.c (pshinter_interface): Use `static const'.
* src/winfonts/winfnt.c (FNT_Get_Next_Char): Remove unused
variables.
* include/freetype/internal/psaux.h (T1_Builder_Funcs): Renamed
to...
(T1_Builder_FuncsRec): This.
(T1_Builder_Funcs): New typedef.
(PSAux_Interface): Remove compiler warnings.
* src/psaux/psauxmod.c (t1_builder_funcs), src/psaux/psobjs.h
(t1_builder_funcs): Updated.
* src/pshinter/pshglob.h (PSH_Blue_Align): Replaced with ...
(PSH_BLUE_ALIGN_{NONE,TOP,BOT}): New defines.
(PSH_AlignmentRec): Updated.
* include/freetype/internal/ftstream.h (GET_Char, GET_Byte): Fix
typo.
* include/freetype/internal/ftgloadr.h (FT_SubGlyph): Ditto.
* src/base/ftstream (FT_Get_Char): Rename to...
(FT_Stream_Get_Char): This.
* src/base/ftnames.c (FT_Get_Sfnt_Name): s/index/idx/ -- `index' is
a built-in function in gcc, causing warning messages with gcc 3.0.
* src/autohint/ahglyph.c (ah_outline_load): Ditto.
* src/autohint/ahglobal.c (ah_hinter_compute_blues): Ditto.
* src/cache/ftcmanag.c (ftc_family_table_alloc,
ftc_family_table_free, FTC_Manager_Done, FTC_Manager_Register_Cache):
Ditto.
* src/cff/cffload.c (cff_new_index, cff_done_index,
cff_explicit_index, CFF_Access_Element, CFF_Forget_Element,
CFF_Get_Name, CFF_Get_String, CFF_Load_SubFont, CFF_Load_Font,
CFF_Done_Font): Ditto.
* src/psaux/psobjs.c (PS_Table_Add, PS_Parser_LoadField): Ditto.
* src/psaux/t1decode.c (T1_Decoder_Parse_Charstrings): Ditto.
* src/pshinter/pshrec.c (ps_mask_test_bit, ps_mask_clear_bit,
ps_mask_set_bit, ps_dimension_add_t1stem, ps_hints_t1stem3,
* src/pshinter/pshalgo1.c (psh1_hint_table_record,
psh1_hint_table_record_mask, psh1_hint_table_activate_mask): Ditto.
* src/pshinter/pshalgo2.c (psh2_hint_table_record,
psh2_hint_table_record_mask, psh2_hint_table_activate_mask): Ditto.
* src/sfnt/ttpost.c (Load_Format_20, Load_Format_25,
TT_Get_PS_Name): Ditto.
* src/truetype/ttgload.c (TT_Get_Metrics, Get_HMetrics,
load_truetype_glyph): Ditto.
* src/type1/t1load.c (parse_subrs, T1_Open_Face): Ditto.
* src/type1/t1afm.c (T1_Get_Kerning): Ditto.
* include/freetype/cache/ftcmanag.h (ftc_family_table_free): Ditto.
2002-03-07 22:59:59 +01:00
|
|
|
FT_UInt idx;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
|
2007-01-05 14:14:08 +01:00
|
|
|
cff_index_done( &font->global_subrs_index );
|
|
|
|
cff_index_done( &font->font_dict_index );
|
|
|
|
cff_index_done( &font->name_index );
|
|
|
|
cff_index_done( &font->charstrings_index );
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
/* release font dictionaries, but only if working with */
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
/* a CID keyed CFF font or a CFF2 font */
|
2001-10-21 22:26:59 +02:00
|
|
|
if ( font->num_subfonts > 0 )
|
|
|
|
{
|
* src/base/ftdbgmem.c (ft_mem_table_resize, ft_mem_table_new,
ft_mem_table_set, ft_mem_debug_alloc, ft_mem_debug_free,
ft_mem_debug_realloc, ft_mem_debug_done, FT_Alloc_Debug,
FT_Realloc_Debug, FT_Free_Debug): Fix compiler warnings.
* src/base/ftcalc.c (FT_MulFix): Ditto.
* src/cff/cffdrivr.c (cff_get_name_index): Ditto.
* src/cff/cffobjs.c (CFF_Size_Get_Global_Funcs, CFF_Size_Init,
CFF_GlyphSlot_Init): Ditto.
* src/cid/cidobjs.c (CID_GlyphSlot_Init,
CID_Size_Get_Globals_Funcs): Ditto.
* src/type1/t1objs.c (T1_Size_Get_Globals_Funcs, T1_GlyphSlot_Init):
Ditto.
* src/pshinter/pshmod.c (pshinter_interface): Use `static const'.
* src/winfonts/winfnt.c (FNT_Get_Next_Char): Remove unused
variables.
* include/freetype/internal/psaux.h (T1_Builder_Funcs): Renamed
to...
(T1_Builder_FuncsRec): This.
(T1_Builder_Funcs): New typedef.
(PSAux_Interface): Remove compiler warnings.
* src/psaux/psauxmod.c (t1_builder_funcs), src/psaux/psobjs.h
(t1_builder_funcs): Updated.
* src/pshinter/pshglob.h (PSH_Blue_Align): Replaced with ...
(PSH_BLUE_ALIGN_{NONE,TOP,BOT}): New defines.
(PSH_AlignmentRec): Updated.
* include/freetype/internal/ftstream.h (GET_Char, GET_Byte): Fix
typo.
* include/freetype/internal/ftgloadr.h (FT_SubGlyph): Ditto.
* src/base/ftstream (FT_Get_Char): Rename to...
(FT_Stream_Get_Char): This.
* src/base/ftnames.c (FT_Get_Sfnt_Name): s/index/idx/ -- `index' is
a built-in function in gcc, causing warning messages with gcc 3.0.
* src/autohint/ahglyph.c (ah_outline_load): Ditto.
* src/autohint/ahglobal.c (ah_hinter_compute_blues): Ditto.
* src/cache/ftcmanag.c (ftc_family_table_alloc,
ftc_family_table_free, FTC_Manager_Done, FTC_Manager_Register_Cache):
Ditto.
* src/cff/cffload.c (cff_new_index, cff_done_index,
cff_explicit_index, CFF_Access_Element, CFF_Forget_Element,
CFF_Get_Name, CFF_Get_String, CFF_Load_SubFont, CFF_Load_Font,
CFF_Done_Font): Ditto.
* src/psaux/psobjs.c (PS_Table_Add, PS_Parser_LoadField): Ditto.
* src/psaux/t1decode.c (T1_Decoder_Parse_Charstrings): Ditto.
* src/pshinter/pshrec.c (ps_mask_test_bit, ps_mask_clear_bit,
ps_mask_set_bit, ps_dimension_add_t1stem, ps_hints_t1stem3,
* src/pshinter/pshalgo1.c (psh1_hint_table_record,
psh1_hint_table_record_mask, psh1_hint_table_activate_mask): Ditto.
* src/pshinter/pshalgo2.c (psh2_hint_table_record,
psh2_hint_table_record_mask, psh2_hint_table_activate_mask): Ditto.
* src/sfnt/ttpost.c (Load_Format_20, Load_Format_25,
TT_Get_PS_Name): Ditto.
* src/truetype/ttgload.c (TT_Get_Metrics, Get_HMetrics,
load_truetype_glyph): Ditto.
* src/type1/t1load.c (parse_subrs, T1_Open_Face): Ditto.
* src/type1/t1afm.c (T1_Get_Kerning): Ditto.
* include/freetype/cache/ftcmanag.h (ftc_family_table_free): Ditto.
2002-03-07 22:59:59 +01:00
|
|
|
for ( idx = 0; idx < font->num_subfonts; idx++ )
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
cff_subfont_done( memory, font->subfonts[idx] );
|
2006-05-17 10:54:30 +02:00
|
|
|
|
|
|
|
/* the subfonts array has been allocated as a single block */
|
|
|
|
FT_FREE( font->subfonts[0] );
|
2001-10-21 22:26:59 +02:00
|
|
|
}
|
2001-10-21 18:29:16 +02:00
|
|
|
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
cff_encoding_done( &font->encoding );
|
|
|
|
cff_charset_done( &font->charset, font->stream );
|
[cff] Implement CFF2 support (2/2).
The font variation code. All parts dependent on the GX code in the
`truetype' module are guarded with TT_CONFIG_OPTION_GX_VAR_SUPPORT.
In other words, you can still compile the `cff' module without
defining TT_CONFIG_OPTION_GX_VAR_SUPPORT (which brings you CFF2
support without font variation).
* src/cff/cf2font.c (cf2_font_setup): Add support for font
variation.
* src/cff/cf2font.h (CF2_Font): Add fields for variation data.
* src/cff/cf2ft.c (cf2_free_instance): Free blend data.
(cf2_getVStore, cf2_getNormalizedVector): New functions.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c: Include `cffload.h'.
(cf2_cmdRESERVED_15, cf2_cmdRESERVED_16): Replace with...
(cf2_cmdVSINDEX, cf2_cmdBLEND): ... this new enum values.
(cf2_doBlend): New function.
(cf2_interpT2CharString): Handle `vsindex' and `blend' opcodes.
* src/cff/cffload.c (FT_fdot14ToFixed): New macro.
(cff_vstore_done, cff_vstore_load): New functions.
(cff_blend_clear, cff_blend_doBlend, cff_blend_build_vector,
cff_blend_check_vector): New functions.
(cff_load_private_dict): Add arguments for blend vector.
Handle blend data.
(cff_subfont_load, cff_subfont_done): Updated.
(cff_font_load): Handle CFF2 variation store data.
(cff_font_done): Updated.
* src/cff/cffload.h: Include `cffparse.h'.
Updated.
* src/cff/cffobjs.c (cff_face_done): Updated.
* src/cff/cffparse.c: Include `cffload.h'.
(cff_parse_num): Handle internal value 255.
(cff_parse_vsindex, cff_parse_blend): New functions.
(CFF_FIELD_BLEND): New macro.
(cff_parser_run): Updated.
* src/cff/cffparse.h (cff_kind_blend): New enum value.
* src/cff/cfftoken.h: Handle `vstore', `vsindex', and `blend'
dictionary values.
* src/cff/cfftypes.h (CFF_VarData, CFF_AxisCoords, CFF_VarRegion,
CFF_VStore, CFF_Blend): New structures.
(CFF_FontRecDict): Add `vstore_offset' field.
(CFF_Private): Add `vsindex' field.
(CFF_SubFont): Add fields for blend data.
(CFF_Font): Add `vstore' field.
* src/truetype/ttgxvar.c (TT_Get_MM_Var): `CFF2' is equal to `gvar',
since glyph variation data is directly embedded.
(TT_Set_MM_Blend): Don't load `gvar' table for CFF2 fonts.
2016-12-15 21:56:44 +01:00
|
|
|
cff_vstore_done( &font->vstore, memory );
|
2000-12-08 03:42:29 +01:00
|
|
|
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
cff_subfont_done( memory, &font->top_font );
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
CFF_Done_FD_Select( &font->fd_select, font->stream );
|
|
|
|
|
Improve CFF string (especially glyphname) lookup performance.
We do this by avoiding memory allocation and file I/O. This is
Savannah patch #7104.
* src/cff/cfftypes.h: Include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(CFF_SubFontRec): Remove `num_local_subrs'.
(CFF_FontRec): Add `num_strings', `strings', and `string_pool'
fields.
Remove `string_index' and `num_global_subrs' fields.
Use real types instead of `void' for `pshinter' and `psnames' fields.
* src/cff/cffload.c: Don't include PS cmaps service.
(cff_index_get_pointers): Add `pool' parameter which allows to
insert an extra NUL character for each String INDEX entry.
(cff_index_get_name): Make it a local function.
(cff_index_get_string): New function.
(cff_subfont_load): Updated.
(cff_font_load): Initialize `num_strings', `strings', and
`string_pool' fields in the `CFF_FontRec' structure.
(cff_index_get_sid_string): Use `cff_index_get_string' instead of
`cff_index_get_name'.
(cff_font_done): Updated.
* src/cff/cffload.h: Don't include PS cmaps service.
(cff_index_get_string): Added.
(cff_index_get_sid_string): Updated.
* src/cff/cffobjs.c: Don't include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_size_get_globals_funcs, cff_slot_init): Updated.
(cff_face_init): Follow `cff_index_get_name',
`cff_index_get_string', and `cff_index_get_sid_string' changes.
* src/cff/cffcmap.c (cff_sid_free_glyph_name): Removed.
(cff_sid_to_glyph_name): Use `cff_index_get_cid_string'.
(cff_cmap_unicode_init): Updated.
* src/cff/cffdrivr.c: Don't include PS cmap service.
(cff_get_glyph_name): Avoid unnecessary lookup for POSTSCRIPT_CMAPS
service.
(cff_get_glyph_name, cff_ps_get_font_info, cff_get_ros): Follow API
`cff_index_get_sid_string' change.
(cff_get_name_index): Use `cff_index_get_string' instead of
`cff_index_get_name'.
* src/cff/cffgload.c: Don't include FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_decoder_init, cff_decoder_prepare): Updated.
2010-03-02 13:00:55 +01:00
|
|
|
FT_FREE( font->font_info );
|
2007-07-16 22:46:05 +02:00
|
|
|
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( font->font_name );
|
Improve CFF string (especially glyphname) lookup performance.
We do this by avoiding memory allocation and file I/O. This is
Savannah patch #7104.
* src/cff/cfftypes.h: Include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(CFF_SubFontRec): Remove `num_local_subrs'.
(CFF_FontRec): Add `num_strings', `strings', and `string_pool'
fields.
Remove `string_index' and `num_global_subrs' fields.
Use real types instead of `void' for `pshinter' and `psnames' fields.
* src/cff/cffload.c: Don't include PS cmaps service.
(cff_index_get_pointers): Add `pool' parameter which allows to
insert an extra NUL character for each String INDEX entry.
(cff_index_get_name): Make it a local function.
(cff_index_get_string): New function.
(cff_subfont_load): Updated.
(cff_font_load): Initialize `num_strings', `strings', and
`string_pool' fields in the `CFF_FontRec' structure.
(cff_index_get_sid_string): Use `cff_index_get_string' instead of
`cff_index_get_name'.
(cff_font_done): Updated.
* src/cff/cffload.h: Don't include PS cmaps service.
(cff_index_get_string): Added.
(cff_index_get_sid_string): Updated.
* src/cff/cffobjs.c: Don't include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_size_get_globals_funcs, cff_slot_init): Updated.
(cff_face_init): Follow `cff_index_get_name',
`cff_index_get_string', and `cff_index_get_sid_string' changes.
* src/cff/cffcmap.c (cff_sid_free_glyph_name): Removed.
(cff_sid_to_glyph_name): Use `cff_index_get_cid_string'.
(cff_cmap_unicode_init): Updated.
* src/cff/cffdrivr.c: Don't include PS cmap service.
(cff_get_glyph_name): Avoid unnecessary lookup for POSTSCRIPT_CMAPS
service.
(cff_get_glyph_name, cff_ps_get_font_info, cff_get_ros): Follow API
`cff_index_get_sid_string' change.
(cff_get_name_index): Use `cff_index_get_string' instead of
`cff_index_get_name'.
* src/cff/cffgload.c: Don't include FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_decoder_init, cff_decoder_prepare): Updated.
2010-03-02 13:00:55 +01:00
|
|
|
FT_FREE( font->global_subrs );
|
|
|
|
FT_FREE( font->strings );
|
|
|
|
FT_FREE( font->string_pool );
|
[cff] Add a new Type 2 interpreter and hinter.
This work, written by Dave Arnold <darnold@adobe.com> and fully
integrated into FreeType by me, is a donation by Adobe in
collaboration with Google. It is vastly superior to the old CFF
engine, and it will replace it soon. Right now, it is still off by
default, and you have to explicitly select it using the new
`hinting-engine' property of the cff driver.
For convenience, (most of) the new files are committed separately.
* include/freetype/config/ftheader.h (FT_CFF_DRIVER_H): New macro.
* include/freetype/ftcffdrv.h: New file to access CFF driver
properties.
* include/freetype/fterrdef.h (FT_Err_Glyph_Too_Big): New error
code.
* include/freetype/internal/fttrace.h: Add `cf2blues', `cf2hints',
and `cf2interp'.
* src/cff/cffgload.h (CFF_SubFont): New member `current_subfont'.
* src/cff/cffobjs.h (CFF_DriverRec): New members `hinting_engine'
and `no_stem_darkening'.
* src/cff/cfftypes.h (CFF_FontRec): New member `cf2_instance'.
* src/cff/cff.c: Include new files.
* src/cff/cffdrivr.c (cff_property_set, cff_property_get): Handle
`hinting-engine' and `no-stem-darkening' properties (only the Adobe
engine listens to them).
* src/cff/cffgload.c: Include `cf2ft.h'.
(cff_decoder_prepare): Initialize `current_subfont'.
(cff_build_add_point): Handle Adobe engine which uses 16.16
coordinates.
(cff_slot_load): Handle FT_LOAD_NO_SCALE and FT_LOAD_NO_HINTING
separately.
Choose rendering engine based on `hinting_engine' property.
* src/cff/cffload.c (cff_font_done): Call finalizer of the Adobe
engine.
* src/cff/cffobjs.c: Include FT_CFF_DRIVER_H.
(cff_driver_init): Set default property values.
* src/cff/rules.mk (CFF_DRV_SRC, CFF_DRV_H): Add new files.
* src/cff/cf2*.*: New files, containing the Adobe engine.
2013-04-13 18:53:28 +02:00
|
|
|
|
|
|
|
if ( font->cf2_instance.finalizer )
|
|
|
|
{
|
|
|
|
font->cf2_instance.finalizer( font->cf2_instance.data );
|
|
|
|
FT_FREE( font->cf2_instance.data );
|
|
|
|
}
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* END */
|