summaryrefslogtreecommitdiff
path: root/src/gf/gfdrivr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gf/gfdrivr.c')
-rw-r--r--src/gf/gfdrivr.c145
1 files changed, 106 insertions, 39 deletions
diff --git a/src/gf/gfdrivr.c b/src/gf/gfdrivr.c
index 7b0153051..e51f10abc 100644
--- a/src/gf/gfdrivr.c
+++ b/src/gf/gfdrivr.c
@@ -43,9 +43,9 @@
typedef struct GF_CMapRec_
{
- FT_CMapRec cmap;
- FT_UInt32 bc; /* Beginning Character */
- FT_UInt32 ec; /* End Character */
+ FT_CMapRec cmap;
+ FT_ULong num_encodings;
+ GF_Encoding encodings;
} GF_CMapRec, *GF_CMap;
@@ -57,8 +57,8 @@
GF_Face face = (GF_Face)FT_CMAP_FACE( cmap );
FT_UNUSED( init_data );
- cmap->bc = face->gf_glyph->code_min;
- cmap->ec = face->gf_glyph->code_max;
+ cmap->num_encodings = face->gf_glyph->nencodings;
+ cmap->encodings = face->gf_glyph->encodings;
return FT_Err_Ok;
}
@@ -69,54 +69,98 @@
{
GF_CMap cmap = (GF_CMap)gfcmap;
- cmap->bc = 0;
- cmap->ec = -1;
+ cmap->encodings = NULL;
+ cmap->num_encodings = 0;
}
FT_CALLBACK_DEF( FT_UInt )
gf_cmap_char_index( FT_CMap gfcmap,
- FT_UInt32 char_code )
+ FT_UInt32 charcode )
{
- FT_UInt gindex = 0;
- GF_CMap cmap = (GF_CMap)gfcmap;
+ GF_CMap cmap = (GF_CMap)gfcmap;
+ GF_Encoding encodings = cmap->encodings;
+ FT_ULong min, max, mid;
+ FT_UInt result = 0;
- char_code -= cmap->bc;
+ min = 0;
+ max = cmap->num_encodings;
- if ( char_code < cmap->ec - cmap->bc + 1 )
- gindex = (FT_UInt)( char_code );
+ while ( min < max )
+ {
+ FT_ULong code;
+
+
+ mid = ( min + max ) >> 1;
+ code = (FT_ULong)encodings[mid].enc;
+
+ if ( charcode == code )
+ {
+ result = encodings[mid].glyph;
+ break;
+ }
+
+ if ( charcode < code )
+ max = mid;
+ else
+ min = mid + 1;
+ }
- return gindex;
+ return result;
}
FT_CALLBACK_DEF( FT_UInt )
gf_cmap_char_next( FT_CMap gfcmap,
- FT_UInt32 *achar_code )
+ FT_UInt32 *acharcode )
{
- GF_CMap cmap = (GF_CMap)gfcmap;
- FT_UInt gindex = 0;
- FT_UInt32 result = 0;
- FT_UInt32 char_code = *achar_code + 1;
+ GF_CMap cmap = (GF_CMap)gfcmap;
+ GF_Encoding encodings = cmap->encodings;
+ FT_ULong min, max, mid;
+ FT_ULong charcode = *acharcode + 1;
+ FT_UInt result = 0;
- if ( char_code <= cmap->bc )
- {
- result = cmap->bc;
- gindex = 1;
- }
- else
+ min = 0;
+ max = cmap->num_encodings;
+
+ while ( min < max )
{
- char_code -= cmap->bc;
- if ( char_code < cmap->ec - cmap->bc + 1 )
+ FT_ULong code;
+
+
+ mid = ( min + max ) >> 1;
+ code = (FT_ULong)encodings[mid].enc;
+
+ if ( charcode == code )
{
- result = char_code;
- gindex = (FT_UInt)( char_code );
+ result = encodings[mid].glyph + 1;
+ goto Exit;
}
+
+ if ( charcode < code )
+ max = mid;
+ else
+ min = mid + 1;
}
- *achar_code = result;
- return gindex;
+ charcode = 0;
+ if ( min < cmap->num_encodings )
+ {
+ charcode = (FT_ULong)encodings[min].enc;
+ result = encodings[min].glyph ;
+ }
+
+ Exit:
+ if ( charcode > 0xFFFFFFFFUL )
+ {
+ FT_TRACE1(( "gf_cmap_char_next: charcode 0x%x > 32bit API" ));
+ *acharcode = 0;
+ /* XXX: result should be changed to indicate an overflow error */
+ }
+ else
+ *acharcode = (FT_UInt32)charcode;
+ return result;
}
@@ -145,9 +189,10 @@
memory = FT_FACE_MEMORY( face );
- gf_free_font( face );
-
FT_FREE( gfface->available_sizes );
+ FT_FREE( face->gf_glyph->encodings );
+
+ gf_free_font( face );
}
@@ -270,15 +315,37 @@
y_res ); ;
}
+ /* set up charmap */
+ {
+ /* FT_Bool unicode_charmap ; */
+
+ /*
+ * XXX: TO-DO
+ * Currently the unicode_charmap is set to `0'
+ * The functionality of extracting coding scheme
+ * from `xxx' and `yyy' commands will be used to
+ * set the unicode_charmap.
+ */
+ }
+
/* Charmaps */
{
FT_CharMapRec charmap;
+ FT_Bool unicode_charmap = 0;
- /* Unicode Charmap */
- charmap.encoding = FT_ENCODING_UNICODE;
- charmap.platform_id = TT_PLATFORM_MICROSOFT;
- charmap.encoding_id = TT_MS_ID_UNICODE_CS;
charmap.face = FT_FACE( face );
+ charmap.encoding = FT_ENCODING_NONE;
+ /* initial platform/encoding should indicate unset status? */
+ charmap.platform_id = TT_PLATFORM_APPLE_UNICODE;
+ charmap.encoding_id = TT_APPLE_ID_DEFAULT;
+
+ if( unicode_charmap )
+ {
+ /* Unicode Charmap */
+ charmap.encoding = FT_ENCODING_UNICODE;
+ charmap.platform_id = TT_PLATFORM_MICROSOFT;
+ charmap.encoding_id = TT_MS_ID_UNICODE_CS;
+ }
error = FT_CMap_New( &gf_cmap_class, NULL, &charmap, NULL );
@@ -387,7 +454,7 @@
goto Exit;
}
- FT_TRACE1(( "GF_Glyph_Load: glyph index %d\n", glyph_index ));
+ FT_TRACE1(( "GF_Glyph_Load: glyph index %d charcode is %d\n", glyph_index, go->bm_table[glyph_index].code ));
if ( (FT_Int)glyph_index < 0 )
glyph_index = 0;
@@ -563,7 +630,7 @@
}
- FT_CALLBACK_TABLE_DEF
+ FT_CALLBACK_TABLE_DEF
const FT_Driver_ClassRec gf_driver_class =
{
{