ref: fd97d137e0eb0992ca8145edf21d852548573f92
parent: d2e3d4ff8cb6e53d36129b277dc168a142e84c70
author: Werner Lemberg <[email protected]>
date: Sat Jun 15 21:14:16 EDT 2002
Fix glyph indices to make index zero always the undefined glyph. * src/bdf/bdfdrivr.c (bdf_cmap_init): Don't decrease cmap->num_encodings. (bdf_cmap_char_index, bdf_cmap_char_next, BDF_Get_Char_Index): Increase result by 1 for normal cases. (BDF_Glyph_Load): Decrease index by 1. * src/pcf/pcfdriver.c (pcf_cmap_char_index, pcf_cmap_char_next, PCF_Char_Get_Index): Increase result by 1 for normal cases. (PCF_Glyph_Load): Decrease index by 1. * src/pcf/pcfread.c (pcf_get_encodings): Don't decrease j for allocating `encoding'. * src/base/ftobjs.c (FT_Load_Glyph, FT_Get_Glyph_Name): Fix bounding tests.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,24 @@
2002-06-14 Detlef W�rkner <[email protected]>
+ Fix glyph indices to make index zero always the undefined glyph.
+
+ * src/bdf/bdfdrivr.c (bdf_cmap_init): Don't decrease
+ cmap->num_encodings.
+ (bdf_cmap_char_index, bdf_cmap_char_next, BDF_Get_Char_Index):
+ Increase result by 1 for normal cases.
+ (BDF_Glyph_Load): Decrease index by 1.
+
+ * src/pcf/pcfdriver.c (pcf_cmap_char_index, pcf_cmap_char_next,
+ PCF_Char_Get_Index): Increase result by 1 for normal cases.
+ (PCF_Glyph_Load): Decrease index by 1.
+ * src/pcf/pcfread.c (pcf_get_encodings): Don't decrease j for
+ allocating `encoding'.
+
+ * src/base/ftobjs.c (FT_Load_Glyph, FT_Get_Glyph_Name): Fix
+ bounding tests.
+
+2002-06-14 Detlef W�rkner <[email protected]>
+
Add new cmap support to BDF driver
* src/bdf/bdfdrivr.c (BDF_CMapRec) [FT_CONFIG_OPTION_USE_CMAPS]:
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -2424,6 +2424,12 @@
/* <Return> */
/* The glyph index. 0 means `undefined character code'. */
/* */
+ /* <Note> */
+ /* FreeType computes its own glyph indices which are not necessarily */
+ /* the same as used in the font in case the font is based on glyph */
+ /* indices. Reason for this behaviour is to assure that index 0 is */
+ /* never used, representing the missing glyph. */
+ /* */
FT_EXPORT( FT_UInt )
FT_Get_Char_Index( FT_Face face,
FT_ULong charcode );
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -402,7 +402,7 @@
if ( !face || !face->size || !face->glyph )
return FT_Err_Invalid_Face_Handle;
- if ( glyph_index >= (FT_UInt)face->num_glyphs )
+ if ( glyph_index > (FT_UInt)face->num_glyphs )
return FT_Err_Invalid_Argument;
slot = face->glyph;
@@ -1676,9 +1676,9 @@
if ( buffer && buffer_max > 0 )
((FT_Byte*)buffer)[0] = 0;
- if ( face &&
- glyph_index < (FT_UInt)face->num_glyphs &&
- FT_HAS_GLYPH_NAMES( face ) )
+ if ( face &&
+ glyph_index <= (FT_UInt)face->num_glyphs &&
+ FT_HAS_GLYPH_NAMES( face ) )
{
/* now, lookup for glyph name */
FT_Driver driver = face->driver;
--- a/src/bdf/bdfdrivr.c
+++ b/src/bdf/bdfdrivr.c
@@ -64,7 +64,7 @@
BDF_Face face = (BDF_Face)FT_CMAP_FACE( cmap );
- cmap->num_encodings = face->bdffont->glyphs_used - 1;
+ cmap->num_encodings = face->bdffont->glyphs_used;
cmap->encodings = face->en_table;
return FT_Err_Ok;
@@ -101,7 +101,7 @@
if ( charcode == code )
{
- result = encodings[mid].glyph;
+ result = encodings[mid].glyph + 1;
break;
}
@@ -138,7 +138,7 @@
if ( charcode == code )
{
- result = encodings[mid].glyph;
+ result = encodings[mid].glyph + 1;
goto Exit;
}
@@ -152,7 +152,7 @@
if ( min < cmap->num_encodings )
{
charcode = encodings[min].enc;
- result = encodings[min].glyph;
+ result = encodings[min].glyph + 1;
}
Exit:
@@ -196,10 +196,10 @@
else if ( char_code > en_table[mid].enc )
low = mid + 1;
else
- return en_table[mid].glyph;
+ return en_table[mid].glyph + 1;
}
- return face->bdffont->default_glyph;
+ return face->bdffont->default_glyph + 1;
}
@@ -559,6 +559,9 @@
error = BDF_Err_Invalid_Argument;
goto Exit;
}
+
+ if ( glyph_index > 0 )
+ glyph_index--;
/* slot, bitmap => freetype, glyph => bdflib */
glyph = face->bdffont->glyphs[glyph_index];
--- a/src/pcf/pcfdriver.c
+++ b/src/pcf/pcfdriver.c
@@ -95,7 +95,7 @@
if ( charcode == code )
{
- result = encodings[mid].glyph;
+ result = encodings[mid].glyph + 1;
break;
}
@@ -132,7 +132,7 @@
if ( charcode == code )
{
- result = encodings[mid].glyph;
+ result = encodings[mid].glyph + 1;
goto Exit;
}
@@ -146,7 +146,7 @@
if ( min < cmap->num_encodings )
{
charcode = encodings[min].enc;
- result = encodings[min].glyph;
+ result = encodings[min].glyph + 1;
}
Exit:
@@ -187,7 +187,7 @@
else if ( char_code > en_table[mid].enc )
low = mid + 1;
else
- return en_table[mid].glyph;
+ return en_table[mid].glyph + 1;
}
return 0;
@@ -432,6 +432,9 @@
error = PCF_Err_Invalid_Argument;
goto Exit;
}
+
+ if ( glyph_index > 0 )
+ glyph_index--;
metric = face->metrics + glyph_index;
--- a/src/pcf/pcfread.c
+++ b/src/pcf/pcfread.c
@@ -716,7 +716,6 @@
}
FT_Stream_ExitFrame( stream );
- j--;
if ( FT_NEW_ARRAY( encoding, j ) )
goto Bail;