ref: 7f2425fb4f7d77d8e43907451d26b466b1c4d349
parent: cf432dbf2273c084b011162ea6b8350a33dfd3da
author: Werner Lemberg <[email protected]>
date: Sat Oct 20 12:15:07 EDT 2007
Formatting, improving documentation.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,14 +1,32 @@
2007-10-18 David Turner <[email protected]>
- * include/freetype/freetype.h, src/base/ftobjs.c: renamed
- cmap14-related new APIs to the FT_Object_ActionName scheme.
- update the documentation for these APIs
+ * include/freetype/freetype.h, src/base/ftobjs.c: Rename API
+ functions related to cmap type 14 support to the
+ `FT_Object_ActionName' scheme:
- * src/sfnt/ttcmap.c: stronger cmap 14 validation, make the
- code a little more consistent with FreeType coding conventions
- and modify the cmap14 functions that returned a newly allocated
- array to use a persistent vector from the TT_CMap14 object
+ FT_Get_Char_Variant_index -> FT_Face_GetCharVariantIndex
+ FT_Get_Char_Variant_IsDefault -> FT_Face_GetCharVariantIsDefault
+ FT_Get_Variant_Selectors -> FT_Face_GetVariantSelectors
+ FT_Get_Variants_Of_Char -> FT_Face_GetVariantsOfChar
+ FT_Get_Chars_Of_Variant -> FT_Face_GetCharsOfVariant
+
+ Update documentation accordingly.
+
+ * src/sfnt/ttcmap.c: Stronger cmap 14 validation.
+ Make the code a little more consistent with FreeType coding
+ conventions and modify the cmap14 functions that returned a newly
+ allocated array to use a persistent vector from the TT_CMap14 object
instead.
+
+ (TT_CMap14Rec): Provide array and auxiliary data for result.
+ (tt_cmap14_done, tt_cmap14_ensure): New functions.
+
+ (tt_cmap14_init, tt_cmap14_validate, tt_cmap14_char_map_def_binary,
+ tt_cmap14_char_map_nondef_binary, tt_cmap14_find_variant,
+ tt_cmap14_char_var_index, tt_cmap14_variants,
+ tt_cmap14_char_variants, tt_cmap14_def_char_count,
+ tt_cmap14_get_def_chars, tt_cmap14_get_nondef_chars,
+ tt_cmap14_variant_chars, tt_cmap14_class_rec): Updated and improved.
2007-10-15 George Williams <[email protected]>
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -2995,6 +2995,147 @@
/*************************************************************************/
/* */
/* <Function> */
+ /* FT_Get_Name_Index */
+ /* */
+ /* <Description> */
+ /* Return the glyph index of a given glyph name. This function uses */
+ /* driver specific objects to do the translation. */
+ /* */
+ /* <Input> */
+ /* face :: A handle to the source face object. */
+ /* */
+ /* glyph_name :: The glyph name. */
+ /* */
+ /* <Return> */
+ /* The glyph index. 0 means `undefined character code'. */
+ /* */
+ FT_EXPORT( FT_UInt )
+ FT_Get_Name_Index( FT_Face face,
+ FT_String* glyph_name );
+
+
+ /*************************************************************************
+ *
+ * @macro:
+ * FT_SUBGLYPH_FLAG_XXX
+ *
+ * @description:
+ * A list of constants used to describe subglyphs. Please refer to the
+ * TrueType specification for the meaning of the various flags.
+ *
+ * @values:
+ * FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS ::
+ * FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES ::
+ * FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID ::
+ * FT_SUBGLYPH_FLAG_SCALE ::
+ * FT_SUBGLYPH_FLAG_XY_SCALE ::
+ * FT_SUBGLYPH_FLAG_2X2 ::
+ * FT_SUBGLYPH_FLAG_USE_MY_METRICS ::
+ *
+ */
+#define FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS 1
+#define FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES 2
+#define FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID 4
+#define FT_SUBGLYPH_FLAG_SCALE 8
+#define FT_SUBGLYPH_FLAG_XY_SCALE 0x40
+#define FT_SUBGLYPH_FLAG_2X2 0x80
+#define FT_SUBGLYPH_FLAG_USE_MY_METRICS 0x200
+
+
+ /*************************************************************************
+ *
+ * @func:
+ * FT_Get_SubGlyph_Info
+ *
+ * @description:
+ * Retrieve a description of a given subglyph. Only use it if
+ * `glyph->format' is @FT_GLYPH_FORMAT_COMPOSITE, or an error is
+ * returned.
+ *
+ * @input:
+ * glyph ::
+ * The source glyph slot.
+ *
+ * sub_index ::
+ * The index of subglyph. Must be less than `glyph->num_subglyphs'.
+ *
+ * @output:
+ * p_index ::
+ * The glyph index of the subglyph.
+ *
+ * p_flags ::
+ * The subglyph flags, see @FT_SUBGLYPH_FLAG_XXX.
+ *
+ * p_arg1 ::
+ * The subglyph's first argument (if any).
+ *
+ * p_arg2 ::
+ * The subglyph's second argument (if any).
+ *
+ * p_transform ::
+ * The subglyph transformation (if any).
+ *
+ * @return:
+ * FreeType error code. 0 means success.
+ *
+ * @note:
+ * The values of `*p_arg1', `*p_arg2', and `*p_transform' must be
+ * interpreted depending on the flags returned in `*p_flags'. See the
+ * TrueType specification for details.
+ *
+ */
+ FT_EXPORT( FT_Error )
+ FT_Get_SubGlyph_Info( FT_GlyphSlot glyph,
+ FT_UInt sub_index,
+ FT_Int *p_index,
+ FT_UInt *p_flags,
+ FT_Int *p_arg1,
+ FT_Int *p_arg2,
+ FT_Matrix *p_transform );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Section> */
+ /* glyph_variants */
+ /* */
+ /* <Title> */
+ /* Glyph Variants */
+ /* */
+ /* <Abstract> */
+ /* The FreeType 2 interface to Unicode Ideographic Variation */
+ /* Sequences (IVS), using the SFNT cmap format 14. */
+ /* */
+ /* <Description> */
+ /* Many CJK characters have variant forms. They are a sort of grey */
+ /* area somewhere between being totally irrelevant and semantically */
+ /* distinct; for this reason, the Unicode consortium decided to */
+ /* introduce Ideographic Variation Sequences (IVS), consisting of a */
+ /* Unicode base character and one of 240 variant selectors */
+ /* (U+E0100-U+E01EF), instead of further extending the already huge */
+ /* code range for CJK characters. */
+ /* */
+ /* An IVS is registered and unique; for further details please refer */
+ /* to Unicode Technical Report #37, the Ideographic Variation */
+ /* Database. To date (October 2007), the character with the most */
+ /* variants is U+908A, having 8 such IVS. */
+ /* */
+ /* Adobe and MS decided to support IVS with a new cmap subtable */
+ /* (format 14). It is an odd subtable because it is not a mapping of */
+ /* input code points to glyphs, but contains lists of all variants */
+ /* supported by the font. */
+ /* */
+ /* A variant may be either `default' or `non-default'. A default */
+ /* variant is the one you will get for that code point if you look it */
+ /* up in the standard Unicode cmap. A non-default variant is a */
+ /* different glyph. */
+ /* */
+ /*************************************************************************/
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
/* FT_Face_GetCharVariantIndex */
/* */
/* <Description> */
@@ -3023,11 +3164,14 @@
/* the file. This is done to ensure that value 0 always corresponds */
/* to the `missing glyph'. */
/* */
- /* <Note> */
- /* This function is only meaningful if: */
- /* a) the font has a variation selector cmap sub table */
- /* b) the current charmap has a Unicode encoding */
+ /* This function is only meaningful if */
+ /* a) the font has a variation selector cmap sub table, */
+ /* and */
+ /* b) the current charmap has a Unicode encoding. */
/* */
+ /* <Since> */
+ /* 2.3.6 */
+ /* */
FT_EXPORT( FT_UInt )
FT_Face_GetCharVariantIndex( FT_Face face,
FT_ULong charcode,
@@ -3061,6 +3205,9 @@
/* This function is only meaningful if the font has a variation */
/* selector cmap subtable. */
/* */
+ /* <Since> */
+ /* 2.3.6 */
+ /* */
FT_EXPORT( FT_Int )
FT_Face_GetCharVariantIsDefault( FT_Face face,
FT_ULong charcode,
@@ -3077,7 +3224,8 @@
/* in the font. */
/* */
/* <Input> */
- /* face :: A handle to the source face object. */
+ /* face :: */
+ /* A handle to the source face object. */
/* */
/* <Return> */
/* A pointer to an array of selector code points, or NULL if there is */
@@ -3084,10 +3232,13 @@
/* no valid variant selector cmap subtable. */
/* */
/* <Note> */
- /* the last item in the array is 0. the array is owned by the FT_Face */
- /* but can be overwritten or released on the next call to a FreeType */
- /* function. */
+ /* The last item in the array is 0; the array is owned by the */
+ /* @FT_Face object but can be overwritten or released on the next */
+ /* call to a FreeType function. */
/* */
+ /* <Since> */
+ /* 2.3.6 */
+ /* */
FT_EXPORT( FT_UInt32* )
FT_Face_GetVariantSelectors( FT_Face face );
@@ -3114,10 +3265,13 @@
/* is empty. */
/* */
/* <Note> */
- /* the last item in the array is 0. the array is owned by the FT_Face */
- /* but can be overwritten or released on the next call to a FreeType */
- /* function. */
+ /* The last item in the array is 0; the array is owned by the */
+ /* @FT_Face object but can be overwritten or released on the next */
+ /* call to a FreeType function. */
/* */
+ /* <Since> */
+ /* 2.3.6 */
+ /* */
FT_EXPORT( FT_UInt32* )
FT_Face_GetVariantsOfChar( FT_Face face,
FT_ULong charcode );
@@ -3145,115 +3299,16 @@
/* is no valid cmap or the variant selector is invalid. */
/* */
/* <Note> */
- /* the last item in the array is 0. the array is owned by the FT_Face */
- /* but can be overwritten or released on the next call to a FreeType */
- /* function. */
+ /* The last item in the array is 0; the array is owned by the */
+ /* @FT_Face object but can be overwritten or released on the next */
+ /* call to a FreeType function. */
/* */
+ /* <Since> */
+ /* 2.3.6 */
+ /* */
FT_EXPORT( FT_UInt32* )
FT_Face_GetCharsOfVariant( FT_Face face,
FT_ULong variantSelector );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Get_Name_Index */
- /* */
- /* <Description> */
- /* Return the glyph index of a given glyph name. This function uses */
- /* driver specific objects to do the translation. */
- /* */
- /* <Input> */
- /* face :: A handle to the source face object. */
- /* */
- /* glyph_name :: The glyph name. */
- /* */
- /* <Return> */
- /* The glyph index. 0 means `undefined character code'. */
- /* */
- FT_EXPORT( FT_UInt )
- FT_Get_Name_Index( FT_Face face,
- FT_String* glyph_name );
-
-
- /*************************************************************************
- *
- * @macro:
- * FT_SUBGLYPH_FLAG_XXX
- *
- * @description:
- * A list of constants used to describe subglyphs. Please refer to the
- * TrueType specification for the meaning of the various flags.
- *
- * @values:
- * FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS ::
- * FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES ::
- * FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID ::
- * FT_SUBGLYPH_FLAG_SCALE ::
- * FT_SUBGLYPH_FLAG_XY_SCALE ::
- * FT_SUBGLYPH_FLAG_2X2 ::
- * FT_SUBGLYPH_FLAG_USE_MY_METRICS ::
- *
- */
-#define FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS 1
-#define FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES 2
-#define FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID 4
-#define FT_SUBGLYPH_FLAG_SCALE 8
-#define FT_SUBGLYPH_FLAG_XY_SCALE 0x40
-#define FT_SUBGLYPH_FLAG_2X2 0x80
-#define FT_SUBGLYPH_FLAG_USE_MY_METRICS 0x200
-
-
- /*************************************************************************
- *
- * @func:
- * FT_Get_SubGlyph_Info
- *
- * @description:
- * Retrieve a description of a given subglyph. Only use it if
- * `glyph->format' is @FT_GLYPH_FORMAT_COMPOSITE, or an error is
- * returned.
- *
- * @input:
- * glyph ::
- * The source glyph slot.
- *
- * sub_index ::
- * The index of subglyph. Must be less than `glyph->num_subglyphs'.
- *
- * @output:
- * p_index ::
- * The glyph index of the subglyph.
- *
- * p_flags ::
- * The subglyph flags, see @FT_SUBGLYPH_FLAG_XXX.
- *
- * p_arg1 ::
- * The subglyph's first argument (if any).
- *
- * p_arg2 ::
- * The subglyph's second argument (if any).
- *
- * p_transform ::
- * The subglyph transformation (if any).
- *
- * @return:
- * FreeType error code. 0 means success.
- *
- * @note:
- * The values of `*p_arg1', `*p_arg2', and `*p_transform' must be
- * interpreted depending on the flags returned in `*p_flags'. See the
- * TrueType specification for details.
- *
- */
- FT_EXPORT( FT_Error )
- FT_Get_SubGlyph_Info( FT_GlyphSlot glyph,
- FT_UInt sub_index,
- FT_Int *p_index,
- FT_UInt *p_flags,
- FT_Int *p_arg1,
- FT_Int *p_arg2,
- FT_Matrix *p_transform );
/*************************************************************************/
--- a/include/freetype/ftbbox.h
+++ b/include/freetype/ftbbox.h
@@ -4,7 +4,7 @@
/* */
/* FreeType exact bbox computation (specification). */
/* */
-/* Copyright 1996-2001, 2003 by */
+/* Copyright 1996-2001, 2003, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -61,7 +61,7 @@
/* Computes the exact bounding box of an outline. This is slower */
/* than computing the control box. However, it uses an advanced */
/* algorithm which returns _very_ quickly when the two boxes */
- /* coincide. Otherwise, the outline Bézier arcs are walked over to */
+ /* coincide. Otherwise, the outline Bézier arcs are traversed to */
/* extract their extrema. */
/* */
/* <Input> */
--- a/include/freetype/ftchapters.h
+++ b/include/freetype/ftchapters.h
@@ -32,6 +32,7 @@
/* version */
/* basic_types */
/* base_interface */
+/* glyph_variants */
/* glyph_management */
/* mac_specific */
/* sizes_management */
--- a/include/freetype/ftcid.h
+++ b/include/freetype/ftcid.h
@@ -73,10 +73,14 @@
* The supplement.
*
* @return:
- * FreeType error code. 0 means success.
+ * FreeType error code. 0 means success.
*
* @note:
- * This function only works with CID faces, returning an error otherwise.
+ * This function only works with CID faces, returning an error
+ * otherwise.
+ *
+ * @since:
+ * 2.3.6
*/
FT_EXPORT( FT_Error )
FT_Get_CID_Registry_Ordering_Supplement( FT_Face face,
--- a/include/freetype/ftotval.h
+++ b/include/freetype/ftotval.h
@@ -56,7 +56,7 @@
/* */
/* <Description> */
/* This section contains the declaration of functions to validate */
- /* some OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF). */
+ /* some OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH). */
/* */
/*************************************************************************/
--- a/src/sfnt/ttcmap.c
+++ b/src/sfnt/ttcmap.c
@@ -2295,10 +2295,10 @@
TT_CMapRec cmap;
FT_ULong num_selectors;
- /* this array is used to store the results of various
- * cmap 14 query functions. its content is overwritten
- * on each call to these functions
- */
+ /* This array is used to store the results of various
+ * cmap 14 query functions. The data is overwritten
+ * on each call to these functions.
+ */
FT_UInt max_results;
FT_UInt32* results;
FT_Memory memory;
@@ -2311,8 +2311,9 @@
{
FT_Memory memory = cmap->memory;
+
cmap->max_results = 0;
- if (memory != NULL && cmap->results != NULL)
+ if ( memory != NULL && cmap->results != NULL )
FT_FREE( cmap->results );
}
@@ -2326,7 +2327,7 @@
FT_Error error = 0;
- if (num_results > cmap->max_results)
+ if ( num_results > cmap->max_results )
{
cmap->memory = memory;
@@ -2335,6 +2336,7 @@
cmap->max_results = num_results;
}
+
return error;
}
@@ -2368,9 +2370,9 @@
/* check selectors, they must be in increasing order */
{
- /* we start lastVarSel at 1 because a variant selector value of 0
- * isn't legal.
- */
+ /* we start lastVarSel at 1 because a variant selector value of 0
+ * isn't valid.
+ */
FT_ULong n, lastVarSel = 1;
@@ -2398,7 +2400,8 @@
FT_ULong i;
FT_ULong lastBase = 0;
- if ( defp + numRanges*4 > valid->limit )
+
+ if ( defp + numRanges * 4 > valid->limit )
FT_INVALID_TOO_SHORT;
for ( i = 0; i < numRanges; ++i )
@@ -2424,7 +2427,7 @@
FT_ULong i, lastUni = 0;
- if ( ndp + numMappings*4 > valid->limit )
+ if ( ndp + numMappings * 4 > valid->limit )
FT_INVALID_TOO_SHORT;
for ( i = 0; i < numMappings; ++i )
@@ -2553,6 +2556,7 @@
else
return TT_PEEK_USHORT( p );
}
+
return 0;
}
@@ -2596,9 +2600,9 @@
FT_ULong charcode,
FT_ULong variantSelector)
{
- FT_Byte* p = tt_cmap14_find_variant( cmap->data + 6, variantSelector );
- FT_ULong defOff;
- FT_ULong nondefOff;
+ FT_Byte* p = tt_cmap14_find_variant( cmap->data + 6, variantSelector );
+ FT_ULong defOff;
+ FT_ULong nondefOff;
if ( !p )
@@ -2628,9 +2632,9 @@
FT_ULong charcode,
FT_ULong variantSelector )
{
- FT_Byte* p = tt_cmap14_find_variant( cmap->data + 6, variantSelector );
- FT_ULong defOff;
- FT_ULong nondefOff;
+ FT_Byte* p = tt_cmap14_find_variant( cmap->data + 6, variantSelector );
+ FT_ULong defOff;
+ FT_ULong nondefOff;
if ( !p )
@@ -2652,7 +2656,7 @@
}
- FT_CALLBACK_DEF( FT_UInt32 * )
+ FT_CALLBACK_DEF( FT_UInt32* )
tt_cmap14_variants( TT_CMap cmap,
FT_Memory memory )
{
@@ -2662,7 +2666,8 @@
FT_UInt32* result;
FT_UInt i;
- if ( tt_cmap14_ensure( cmap14, (count + 1), memory ) )
+
+ if ( tt_cmap14_ensure( cmap14, ( count + 1 ), memory ) )
return NULL;
result = cmap14->results;
@@ -2688,7 +2693,7 @@
FT_UInt32* q;
- if ( tt_cmap14_ensure( cmap14, (count + 1), memory ) )
+ if ( tt_cmap14_ensure( cmap14, ( count + 1 ), memory ) )
return NULL;
for ( q = cmap14->results; count > 0; --count )
@@ -2747,21 +2752,21 @@
cnt = tt_cmap14_def_char_count( p );
numRanges = TT_NEXT_ULONG( p );
- if ( tt_cmap14_ensure( cmap14, (cnt + 1), memory ) )
+ if ( tt_cmap14_ensure( cmap14, ( cnt + 1 ), memory ) )
return NULL;
for ( q = cmap14->results; numRanges > 0; --numRanges )
{
FT_UInt uni = TT_NEXT_UINT24( p );
- FT_UInt cnt = FT_NEXT_BYTE( p ) + 1;
+
+ cnt = FT_NEXT_BYTE( p ) + 1;
do
{
q[0] = uni;
uni += 1;
q += 1;
- }
- while ( --cnt != 0 );
+ } while ( --cnt != 0 );
}
q[0] = 0;
@@ -2782,7 +2787,7 @@
numMappings = TT_NEXT_ULONG( p );
- if ( tt_cmap14_ensure( cmap14, (numMappings + 1), memory ) )
+ if ( tt_cmap14_ensure( cmap14, ( numMappings + 1 ), memory ) )
return NULL;
ret = cmap14->results;
@@ -2820,9 +2825,11 @@
return NULL;
if ( defOff == 0 )
- return tt_cmap14_get_nondef_chars( cmap, cmap->data + nondefOff, memory );
+ return tt_cmap14_get_nondef_chars( cmap, cmap->data + nondefOff,
+ memory );
else if ( nondefOff == 0 )
- return tt_cmap14_get_def_chars( cmap, cmap->data + defOff, memory );
+ return tt_cmap14_get_def_chars( cmap, cmap->data + defOff,
+ memory );
else
{
/* Both a default and a non-default glyph set? That's probably not */
@@ -2845,11 +2852,13 @@
numRanges = TT_NEXT_ULONG( dp );
if ( numMappings == 0 )
- return tt_cmap14_get_def_chars( cmap, cmap->data + defOff, memory );
+ return tt_cmap14_get_def_chars( cmap, cmap->data + defOff,
+ memory );
if ( dcnt == 0 )
- return tt_cmap14_get_nondef_chars( cmap, cmap->data + nondefOff, memory );
+ return tt_cmap14_get_nondef_chars( cmap, cmap->data + nondefOff,
+ memory );
- if ( tt_cmap14_ensure( cmap14, (dcnt + numMappings + 1), memory ) )
+ if ( tt_cmap14_ensure( cmap14, ( dcnt + numMappings + 1 ), memory ) )
return NULL;
ret = cmap14->results;
@@ -2940,6 +2949,7 @@
(FT_CMap_DoneFunc) tt_cmap14_done,
(FT_CMap_CharIndexFunc)tt_cmap14_char_index,
(FT_CMap_CharNextFunc) tt_cmap14_char_next,
+
/* Format 14 extension functions */
(FT_CMap_CharVarIndexFunc) tt_cmap14_char_var_index,
(FT_CMap_CharVarIsDefaultFunc)tt_cmap14_char_var_isdefault,