Formatting, improving documentation.

This commit is contained in:
Werner Lemberg 2007-10-20 16:15:07 +00:00
parent cf432dbf22
commit 7f2425fb4f
7 changed files with 292 additions and 204 deletions

View File

@ -1,15 +1,33 @@
2007-10-18 David Turner <david@freetype.org>
* 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 <gww@silcom.com>
Add support for cmap type 14.

View File

@ -2992,168 +2992,6 @@ FT_BEGIN_HEADER
FT_UInt *agindex );
/*************************************************************************/
/* */
/* <Function> */
/* FT_Face_GetCharVariantIndex */
/* */
/* <Description> */
/* Return the glyph index of a given character code as modified by */
/* the variation selector. */
/* */
/* <Input> */
/* face :: */
/* A handle to the source face object. */
/* */
/* charcode :: */
/* The character code point in Unicode. */
/* */
/* variantSelector :: */
/* The Unicode code point of the variation selector. */
/* */
/* <Return> */
/* The glyph index. 0 means either `undefined character code', or */
/* `undefined selector code', or `no variation selector cmap */
/* subtable', or `current CharMap is not Unicode'. */
/* */
/* <Note> */
/* If you use FreeType to manipulate the contents of font files */
/* directly, be aware that the glyph index returned by this function */
/* doesn't always correspond to the internal indices used within */
/* 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 */
/* */
FT_EXPORT( FT_UInt )
FT_Face_GetCharVariantIndex( FT_Face face,
FT_ULong charcode,
FT_ULong variantSelector );
/*************************************************************************/
/* */
/* <Function> */
/* FT_Face_GetCharVariantIsDefault */
/* */
/* <Description> */
/* Check whether this variant of this Unicode character is the one to */
/* be found in the `cmap'. */
/* */
/* <Input> */
/* face :: */
/* A handle to the source face object. */
/* */
/* charcode :: */
/* The character codepoint in Unicode. */
/* */
/* variantSelector :: */
/* The Unicode codepoint of the variation selector. */
/* */
/* <Return> */
/* 1 if found in the standard (Unicode) cmap, 0 if found in the */
/* variation selector cmap, or -1 if it is not a variant. */
/* */
/* <Note> */
/* This function is only meaningful if the font has a variation */
/* selector cmap subtable. */
/* */
FT_EXPORT( FT_Int )
FT_Face_GetCharVariantIsDefault( FT_Face face,
FT_ULong charcode,
FT_ULong variantSelector );
/*************************************************************************/
/* */
/* <Function> */
/* FT_Face_GetVariantSelectors */
/* */
/* <Description> */
/* Return a zero-terminated list of Unicode variant selectors found */
/* in the font. */
/* */
/* <Input> */
/* face :: A handle to the source face object. */
/* */
/* <Return> */
/* A pointer to an array of selector code points, or NULL if there is */
/* 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. */
/* */
FT_EXPORT( FT_UInt32* )
FT_Face_GetVariantSelectors( FT_Face face );
/*************************************************************************/
/* */
/* <Function> */
/* FT_Face_GetVariantsOfChar */
/* */
/* <Description> */
/* Return a zero-terminated list of Unicode variant selectors found */
/* for the specified character code. */
/* */
/* <Input> */
/* face :: */
/* A handle to the source face object. */
/* */
/* charcode :: */
/* The character codepoint in Unicode. */
/* */
/* <Return> */
/* A pointer to an array of variant selector code points which are */
/* active for the given character, or NULL if the corresponding list */
/* 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. */
/* */
FT_EXPORT( FT_UInt32* )
FT_Face_GetVariantsOfChar( FT_Face face,
FT_ULong charcode );
/*************************************************************************/
/* */
/* <Function> */
/* FT_Face_GetCharsOfVariant */
/* */
/* <Description> */
/* Return a zero-terminated list of Unicode character codes found for */
/* the specified variant selector. */
/* */
/* <Input> */
/* face :: */
/* A handle to the source face object. */
/* */
/* variantSelector :: */
/* The variant selector code point in Unicode. */
/* */
/* <Return> */
/* A list of all the code points which are specified by this selector */
/* (both default and non-default codes are returned) or NULL if there */
/* 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. */
/* */
FT_EXPORT( FT_UInt32* )
FT_Face_GetCharsOfVariant( FT_Face face,
FT_ULong variantSelector );
/*************************************************************************/
/* */
/* <Function> */
@ -3256,6 +3094,223 @@ FT_BEGIN_HEADER
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> */
/* Return the glyph index of a given character code as modified by */
/* the variation selector. */
/* */
/* <Input> */
/* face :: */
/* A handle to the source face object. */
/* */
/* charcode :: */
/* The character code point in Unicode. */
/* */
/* variantSelector :: */
/* The Unicode code point of the variation selector. */
/* */
/* <Return> */
/* The glyph index. 0 means either `undefined character code', or */
/* `undefined selector code', or `no variation selector cmap */
/* subtable', or `current CharMap is not Unicode'. */
/* */
/* <Note> */
/* If you use FreeType to manipulate the contents of font files */
/* directly, be aware that the glyph index returned by this function */
/* doesn't always correspond to the internal indices used within */
/* the file. This is done to ensure that value 0 always corresponds */
/* to the `missing glyph'. */
/* */
/* 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,
FT_ULong variantSelector );
/*************************************************************************/
/* */
/* <Function> */
/* FT_Face_GetCharVariantIsDefault */
/* */
/* <Description> */
/* Check whether this variant of this Unicode character is the one to */
/* be found in the `cmap'. */
/* */
/* <Input> */
/* face :: */
/* A handle to the source face object. */
/* */
/* charcode :: */
/* The character codepoint in Unicode. */
/* */
/* variantSelector :: */
/* The Unicode codepoint of the variation selector. */
/* */
/* <Return> */
/* 1 if found in the standard (Unicode) cmap, 0 if found in the */
/* variation selector cmap, or -1 if it is not a variant. */
/* */
/* <Note> */
/* 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,
FT_ULong variantSelector );
/*************************************************************************/
/* */
/* <Function> */
/* FT_Face_GetVariantSelectors */
/* */
/* <Description> */
/* Return a zero-terminated list of Unicode variant selectors found */
/* in the font. */
/* */
/* <Input> */
/* face :: */
/* A handle to the source face object. */
/* */
/* <Return> */
/* A pointer to an array of selector code points, or NULL if there is */
/* no valid variant selector cmap subtable. */
/* */
/* <Note> */
/* 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 );
/*************************************************************************/
/* */
/* <Function> */
/* FT_Face_GetVariantsOfChar */
/* */
/* <Description> */
/* Return a zero-terminated list of Unicode variant selectors found */
/* for the specified character code. */
/* */
/* <Input> */
/* face :: */
/* A handle to the source face object. */
/* */
/* charcode :: */
/* The character codepoint in Unicode. */
/* */
/* <Return> */
/* A pointer to an array of variant selector code points which are */
/* active for the given character, or NULL if the corresponding list */
/* is empty. */
/* */
/* <Note> */
/* 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 );
/*************************************************************************/
/* */
/* <Function> */
/* FT_Face_GetCharsOfVariant */
/* */
/* <Description> */
/* Return a zero-terminated list of Unicode character codes found for */
/* the specified variant selector. */
/* */
/* <Input> */
/* face :: */
/* A handle to the source face object. */
/* */
/* variantSelector :: */
/* The variant selector code point in Unicode. */
/* */
/* <Return> */
/* A list of all the code points which are specified by this selector */
/* (both default and non-default codes are returned) or NULL if there */
/* 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 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 );
/*************************************************************************/
/* */
/* <Section> */

View File

@ -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 @@ FT_BEGIN_HEADER
/* 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> */

View File

@ -32,6 +32,7 @@
/* version */
/* basic_types */
/* base_interface */
/* glyph_variants */
/* glyph_management */
/* mac_specific */
/* sizes_management */

View File

@ -73,10 +73,14 @@ FT_BEGIN_HEADER
* 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,

View File

@ -56,7 +56,7 @@ FT_BEGIN_HEADER
/* */
/* <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). */
/* */
/*************************************************************************/

View File

@ -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,