From 05bf6877a4b03fa1ea5e2b99f2318104a9de0294 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Thu, 18 Dec 2008 06:32:10 +0000 Subject: [PATCH] * docs/CHANGES: Updated. Provide API for accessing embedding and subsetting restriction information. * include/freetype.h (FT_FSTYPE_INSTALLABLE_EMBEDDING, FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING, FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING, FT_FSTYPE_EDITABLE_EMBEDDING, FT_FSTYPE_NO_SUBSETTING, FT_FSTYPE_BITMAP_EMBEDDING_ONLY): New macros. (FT_Get_FSType_Flags): New function declaration. * src/base/ftobjs.c (FT_Get_FSType_Flags): New function. * src/cid/cidtoken.h, src/type1/t1tokens.h, src/type42/t42parse.c (t42_keywords): Handle `FSType'. * include/freetype/t1tables.h (PS_FontInfoRec): Add `fs_type' field. --- ChangeLog | 23 +++++++++ docs/CHANGES | 4 ++ include/freetype/freetype.h | 93 ++++++++++++++++++++++++++++++++++++- include/freetype/ftimage.h | 25 +++++----- include/freetype/t1tables.h | 4 ++ src/base/ftobjs.c | 23 +++++++++ src/cid/cidtoken.h | 1 + src/type1/t1tokens.h | 3 +- src/type42/t42parse.c | 1 + 9 files changed, 163 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index de61b71a1..b6515b2aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2008-12-18 Werner Lemberg + + * docs/CHANGES: Updated. + +2008-12-18 Bevan, David + + Provide API for accessing embedding and subsetting restriction + information. + + * include/freetype.h (FT_FSTYPE_INSTALLABLE_EMBEDDING, + FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING, + FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING, FT_FSTYPE_EDITABLE_EMBEDDING, + FT_FSTYPE_NO_SUBSETTING, FT_FSTYPE_BITMAP_EMBEDDING_ONLY): New + macros. + (FT_Get_FSType_Flags): New function declaration. + + * src/base/ftobjs.c (FT_Get_FSType_Flags): New function. + + * src/cid/cidtoken.h, src/type1/t1tokens.h, src/type42/t42parse.c + (t42_keywords): Handle `FSType'. + + * include/freetype/t1tables.h (PS_FontInfoRec): Add `fs_type' field. + 2008-12-17 Werner Lemberg * src/base/ftsynth.c (FT_GlyphSlot_Embolden): Don't use internal diff --git a/docs/CHANGES b/docs/CHANGES index 86092eb8d..5ac53f5ec 100644 --- a/docs/CHANGES +++ b/docs/CHANGES @@ -28,6 +28,10 @@ CHANGES BETWEEN 2.3.8 and 2.3.7 `FT_Get_Advance' and `FT_Get_Advances'; they are defined in file `ftadvanc.h' (to be accessed as FT_ADVANCES_H). + - A new function `FT_Get_FSType_Flags' (in FT_FREETYPE_H) has been + contributed by David Bevan to access the embedding and + subsetting restriction information of fonts. + III. MISCELLANEOUS diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h index 5a0a1c4ac..b015a41a2 100644 --- a/include/freetype/freetype.h +++ b/include/freetype/freetype.h @@ -191,6 +191,15 @@ FT_BEGIN_HEADER /* FT_Set_Charmap */ /* FT_Get_Charmap_Index */ /* */ + /* FT_FSTYPE_INSTALLABLE_EMBEDDING */ + /* FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING */ + /* FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING */ + /* FT_FSTYPE_EDITABLE_EMBEDDING */ + /* FT_FSTYPE_NO_SUBSETTING */ + /* FT_FSTYPE_BITMAP_EMBEDDING_ONLY */ + /* */ + /* FT_Get_FSType_Flags */ + /* */ /*************************************************************************/ @@ -2423,7 +2432,7 @@ FT_BEGIN_HEADER * 8~pixels packed into each byte of the bitmap data. * * Note that this has no effect on the hinting algorithm used. You - * should use @FT_LOAD_TARGET_MONO instead so that the + * should rather use @FT_LOAD_TARGET_MONO so that the * monochrome-optimized hinting algorithm is used. * * FT_LOAD_LINEAR_DESIGN :: @@ -3195,6 +3204,88 @@ FT_BEGIN_HEADER FT_Matrix *p_transform ); + /*************************************************************************/ + /* */ + /* */ + /* FT_FSTYPE_XXX */ + /* */ + /* */ + /* A list of bit flags used in the `fsType' field of the OS/2 table */ + /* in a TrueType or OpenType font and the `FSType' entry in a */ + /* PostScript font. These bit flags are returned by */ + /* @FT_Get_FSType_Flags; they inform client applications of embedding */ + /* and subsetting restrictions associated with a font. */ + /* */ + /* See http://www.adobe.com/devnet/acrobat/pdfs/FontPolicies.pdf for */ + /* more details. */ + /* */ + /* */ + /* FT_FSTYPE_INSTALLABLE_EMBEDDING :: */ + /* Fonts with no fsType bit set may be embedded and permanently */ + /* installed on the remote system by an application. */ + /* */ + /* FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING :: */ + /* Fonts that have only this bit set must not be modified, embedded */ + /* or exchanged in any manner without first obtaining permission of */ + /* the font software copyright owner. */ + /* */ + /* FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING :: */ + /* If this bit is set, the font may be embedded and temporarily */ + /* loaded on the remote system. Documents containing Preview & */ + /* Print fonts must be opened `read-only'; no edits can be applied */ + /* to the document. */ + /* */ + /* FT_FSTYPE_EDITABLE_EMBEDDING :: */ + /* If this bit is set, the font may be embedded but must only be */ + /* installed temporarily on other systems. In contrast to Preview */ + /* & Print fonts, documents containing editable fonts may be opened */ + /* for reading, editing is permitted, and changes may be saved. */ + /* */ + /* FT_FSTYPE_NO_SUBSETTING :: */ + /* If this bit is set, the font may not be subsetted prior to */ + /* embedding. */ + /* */ + /* FT_FSTYPE_BITMAP_EMBEDDING_ONLY :: */ + /* If this bit is set, only bitmaps contained in the font may be */ + /* embedded; no outline data may be embedded. If there are no */ + /* bitmaps available in the font, then the font is unembeddable. */ + /* */ + /* */ + /* While the fsType flags can indicate that a font may be embedded, a */ + /* license with the font vendor may be separately required to use the */ + /* font in this way. */ + /* */ +#define FT_FSTYPE_INSTALLABLE_EMBEDDING 0x0000 +#define FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING 0x0002 +#define FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING 0x0004 +#define FT_FSTYPE_EDITABLE_EMBEDDING 0x0008 +#define FT_FSTYPE_NO_SUBSETTING 0x0100 +#define FT_FSTYPE_BITMAP_EMBEDDING_ONLY 0x0200 + + + /*************************************************************************/ + /* */ + /* */ + /* FT_Get_FSType_Flags */ + /* */ + /* */ + /* Return the fsType flags for a font. */ + /* */ + /* */ + /* face :: A handle to the source face object. */ + /* */ + /* */ + /* The fsType flags, @FT_FSTYPE_XXX. */ + /* */ + /* */ + /* Use this function rather than directly reading the `fs_type' field */ + /* in the @PS_FontInfoRec structure which is only guaranteed to */ + /* return the correct results for Type~1 fonts. */ + /* */ + FT_EXPORT( FT_UShort ) + FT_Get_FSType_Flags( FT_Face face ); + + /*************************************************************************/ /* */ /*
*/ diff --git a/include/freetype/ftimage.h b/include/freetype/ftimage.h index 0a1960afc..ccc2f7135 100644 --- a/include/freetype/ftimage.h +++ b/include/freetype/ftimage.h @@ -129,29 +129,30 @@ FT_BEGIN_HEADER /* FT_PIXEL_MODE_GRAY :: */ /* An 8-bit bitmap, generally used to represent anti-aliased glyph */ /* images. Each pixel is stored in one byte. Note that the number */ - /* of value `gray' levels is stored in the `num_grays' field of */ - /* the @FT_Bitmap structure (it generally is 256). */ + /* of `gray' levels is stored in the `num_grays' field of the */ + /* @FT_Bitmap structure (it generally is 256). */ /* */ /* FT_PIXEL_MODE_GRAY2 :: */ - /* A 2-bit/pixel bitmap, used to represent embedded anti-aliased */ - /* bitmaps in font files according to the OpenType specification. */ - /* We haven't found a single font using this format, however. */ + /* A 2-bit per pixel bitmap, used to represent embedded */ + /* anti-aliased bitmaps in font files according to the OpenType */ + /* specification. We haven't found a single font using this */ + /* format, however. */ /* */ /* FT_PIXEL_MODE_GRAY4 :: */ - /* A 4-bit/pixel bitmap, used to represent embedded anti-aliased */ + /* A 4-bit per pixel bitmap, representing embedded anti-aliased */ /* bitmaps in font files according to the OpenType specification. */ /* We haven't found a single font using this format, however. */ /* */ /* FT_PIXEL_MODE_LCD :: */ - /* An 8-bit bitmap, used to represent RGB or BGR decimated glyph */ - /* images used for display on LCD displays; the bitmap is three */ - /* times wider than the original glyph image. See also */ + /* An 8-bit bitmap, representing RGB or BGR decimated glyph images */ + /* used for display on LCD displays; the bitmap is three times */ + /* wider than the original glyph image. See also */ /* @FT_RENDER_MODE_LCD. */ /* */ /* FT_PIXEL_MODE_LCD_V :: */ - /* An 8-bit bitmap, used to represent RGB or BGR decimated glyph */ - /* images used for display on rotated LCD displays; the bitmap */ - /* is three times taller than the original glyph image. See also */ + /* An 8-bit bitmap, representing RGB or BGR decimated glyph images */ + /* used for display on rotated LCD displays; the bitmap is three */ + /* times taller than the original glyph image. See also */ /* @FT_RENDER_MODE_LCD_V. */ /* */ typedef enum FT_Pixel_Mode_ diff --git a/include/freetype/t1tables.h b/include/freetype/t1tables.h index 204d7a71b..e29dd9f54 100644 --- a/include/freetype/t1tables.h +++ b/include/freetype/t1tables.h @@ -78,6 +78,10 @@ FT_BEGIN_HEADER FT_Short underline_position; FT_UShort underline_thickness; + /* since 2.3.8 */ + + FT_UShort fs_type; + } PS_FontInfoRec; diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index fb750fb6c..171a8b49b 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -4374,4 +4374,27 @@ } + /* documentation is in freetype.h */ + + FT_EXPORT_DEF( FT_UShort ) + FT_Get_FSType_Flags( FT_Face face ) + { + PS_FontInfoRec font_info; + TT_OS2* os2; + + + /* look at FSType before fsType for Type42 */ + + if ( !FT_Get_PS_Font_Info( face, &font_info ) && + font_info.fs_type != 0 ) + return font_info.fs_type; + + if ( ( os2 = FT_Get_Sfnt_Table( face, ft_sfnt_os2 ) ) != NULL && + os2->version != 0xFFFFU ) + return os2->fsType; + + return 0; + } + + /* END */ diff --git a/src/cid/cidtoken.h b/src/cid/cidtoken.h index 4d7f1454f..0795f0509 100644 --- a/src/cid/cidtoken.h +++ b/src/cid/cidtoken.h @@ -48,6 +48,7 @@ T1_FIELD_BOOL ( "isFixedPitch", is_fixed_pitch, 0 ) T1_FIELD_NUM ( "UnderlinePosition", underline_position, 0 ) T1_FIELD_NUM ( "UnderlineThickness", underline_thickness, 0 ) + T1_FIELD_NUM ( "FSType", fs_type, 0 ) #undef FT_STRUCTURE diff --git a/src/type1/t1tokens.h b/src/type1/t1tokens.h index 3221ec43d..db08e045c 100644 --- a/src/type1/t1tokens.h +++ b/src/type1/t1tokens.h @@ -41,7 +41,8 @@ T1_FIELD_DICT_FONTDICT ) T1_FIELD_NUM ( "UnderlineThickness", underline_thickness, T1_FIELD_DICT_FONTDICT ) - + T1_FIELD_NUM ( "FSType", fs_type, + T1_FIELD_DICT_FONTDICT ) #undef FT_STRUCTURE #define FT_STRUCTURE PS_PrivateRec diff --git a/src/type42/t42parse.c b/src/type42/t42parse.c index 7d8c267ce..b5e257dbb 100644 --- a/src/type42/t42parse.c +++ b/src/type42/t42parse.c @@ -68,6 +68,7 @@ T1_FIELD_BOOL ( "isFixedPitch", is_fixed_pitch, 0 ) T1_FIELD_NUM ( "UnderlinePosition", underline_position, 0 ) T1_FIELD_NUM ( "UnderlineThickness", underline_thickness, 0 ) + T1_FIELD_NUM ( "FSType", fs_type, 0 ) #undef FT_STRUCTURE #define FT_STRUCTURE T1_FontRec