the font driver now supports CEF fonts and needs a few more work to fully support pure CFF fonts.. yet another patch inspired by Tom !! Aaaaa :-)
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
diff --git a/src/cff/t2driver.c b/src/cff/t2driver.c
index eea6699..e600f68 100644
--- a/src/cff/t2driver.c
+++ b/src/cff/t2driver.c
@@ -241,8 +241,8 @@
/* Glyph index. 0 means `undefined character code'. */
/* */
static
- FT_UInt Get_Char_Index( TT_CharMap charmap,
- FT_Long charcode )
+ FT_UInt t2_get_char_index( TT_CharMap charmap,
+ FT_Long charcode )
{
FT_Error error;
T2_Face face;
@@ -331,7 +331,7 @@
(FTDriver_setPixelSizes)0,
(FTDriver_loadGlyph) Load_Glyph,
- (FTDriver_getCharIndex) Get_Char_Index,
+ (FTDriver_getCharIndex) t2_get_char_index,
(FTDriver_getKerning) Get_Kerning,
(FTDriver_attachFile) 0,
diff --git a/src/cff/t2objs.c b/src/cff/t2objs.c
index ecce927..6f4f1c2 100644
--- a/src/cff/t2objs.c
+++ b/src/cff/t2objs.c
@@ -69,6 +69,7 @@
}
+#if 0
/* this function is used to build a Unicode charmap from the glyph names */
/* in a file.. */
static
@@ -94,6 +95,9 @@
goto Exit;
}
+ /* allocate the charmap */
+ if ( ALLOC( face->charmap,
+
/* seek to charset table and allocate glyph names table */
if ( FILE_Seek( base_offset + charset_offset ) ||
ALLOC_ARRAY( glyph_names, num_glyphs, const char* ) )
@@ -177,6 +181,58 @@
Exit:
return error;
}
+#endif
+
+
+
+ static
+ FT_Encoding find_encoding( int platform_id,
+ int encoding_id )
+ {
+ typedef struct TEncoding
+ {
+ int platform_id;
+ int encoding_id;
+ FT_Encoding encoding;
+
+ } TEncoding;
+
+ static
+ const TEncoding tt_encodings[] =
+ {
+ { TT_PLATFORM_ISO, -1, ft_encoding_unicode },
+
+ { TT_PLATFORM_APPLE_UNICODE, -1, ft_encoding_unicode },
+
+ { TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, ft_encoding_apple_roman },
+
+ { TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, ft_encoding_unicode },
+ { TT_PLATFORM_MICROSOFT, TT_MS_ID_SJIS, ft_encoding_sjis },
+ { TT_PLATFORM_MICROSOFT, TT_MS_ID_GB2312, ft_encoding_gb2312 },
+ { TT_PLATFORM_MICROSOFT, TT_MS_ID_BIG_5, ft_encoding_big5 },
+ { TT_PLATFORM_MICROSOFT, TT_MS_ID_WANSUNG, ft_encoding_wansung },
+ { TT_PLATFORM_MICROSOFT, TT_MS_ID_JOHAB, ft_encoding_johab }
+ };
+
+ const TEncoding *cur, *limit;
+
+
+ cur = tt_encodings;
+ limit = cur + sizeof ( tt_encodings ) / sizeof ( tt_encodings[0] );
+
+ for ( ; cur < limit; cur++ )
+ {
+ if ( cur->platform_id == platform_id )
+ {
+ if ( cur->encoding_id == encoding_id ||
+ cur->encoding_id == -1 )
+ return cur->encoding;
+ }
+ }
+
+ return ft_encoding_none;
+ }
+
/*************************************************************************/
/* */
@@ -284,11 +340,14 @@
FT_Memory memory = face->root.memory;
FT_Face root;
FT_UInt flags;
+ FT_ULong base_offset;
if ( ALLOC( cff, sizeof ( *cff ) ) )
goto Exit;
+ base_offset = FILE_Pos();
+
face->extra.data = cff;
error = T2_Load_CFF_Font( stream, face_index, cff );
if ( error )
@@ -371,6 +430,47 @@
flags |= FT_STYLE_FLAG_BOLD;
root->style_flags = flags;
+
+ /* set the charmaps if any */
+ if (sfnt_format)
+ {
+ /*********************************************************************/
+ /* */
+ /* Polish the charmaps. */
+ /* */
+ /* Try to set the charmap encoding according to the platform & */
+ /* encoding ID of each charmap. */
+ /* */
+ TT_CharMap charmap;
+ FT_Int n;
+
+ charmap = face->charmaps;
+ root->num_charmaps = face->num_charmaps;
+
+ /* allocate table of pointers */
+ if ( ALLOC_ARRAY( root->charmaps, root->num_charmaps, FT_CharMap ) )
+ goto Exit;
+
+ for ( n = 0; n < root->num_charmaps; n++, charmap++ )
+ {
+ FT_Int platform = charmap->cmap.platformID;
+ FT_Int encoding = charmap->cmap.platformEncodingID;
+
+
+ charmap->root.face = (FT_Face)face;
+ charmap->root.platform_id = platform;
+ charmap->root.encoding_id = encoding;
+ charmap->root.encoding = find_encoding( platform, encoding );
+
+ /* now, set root->charmap with a unicode charmap */
+ /* wherever available */
+ if ( !root->charmap &&
+ charmap->root.encoding == ft_encoding_unicode )
+ root->charmap = (FT_CharMap)charmap;
+
+ root->charmaps[n] = (FT_CharMap)charmap;
+ }
+ }
}
}
diff --git a/src/cff/t2objs.h b/src/cff/t2objs.h
index cc37d23..bdb4aba 100644
--- a/src/cff/t2objs.h
+++ b/src/cff/t2objs.h
@@ -23,7 +23,7 @@
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/t2types.h>
#include <freetype/internal/t2errors.h>
-
+#include <freetype/internal/psnames.h>
#ifdef __cplusplus
extern "C" {
@@ -89,6 +89,15 @@
} T2_Transform;
+ /* this is only used in the case of a pure CFF font with no charmap */
+ typedef struct T2_CharMapRec_
+ {
+ TT_CharMapRec root;
+ PS_Unicodes unicodes;
+
+ } T2_CharMapRec, *T2_CharMap;
+
+
/***********************************************************************/
/* */
/* TrueType driver class. */