* src/bdf/bdfdrivr.h (BDF_FaceRec): New element `default_glyph'. * src/bdf/bdflib.c (_bdf_add_property, _bdf_parse_start), src/bdf/bdf.h (bdf_font_t): s/default_glyph/default_char/. * src/bdf/bdfdrivr.c (BDF_Face_Init): Fix number of glyphs. Set `default_glyph'. (BDF_Glyph_Load): Use `default_glyph' for undefined glyph. * docs/CHANGES: Updated.
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
diff --git a/ChangeLog b/ChangeLog
index 459df6f..65891bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,17 @@
* src/pcf/pcfdrivr.c (FT_COMPOMENT): Move up.
(PCF_Face_Init): Simplify code.
+ * src/bdf/bdfdrivr.h (BDF_FaceRec): New element `default_glyph'.
+
+ * src/bdf/bdflib.c (_bdf_add_property, _bdf_parse_start),
+ src/bdf/bdf.h (bdf_font_t): s/default_glyph/default_char/.
+
+ * src/bdf/bdfdrivr.c (BDF_Face_Init): Fix number of glyphs.
+ Set `default_glyph'.
+ (BDF_Glyph_Load): Use `default_glyph' for undefined glyph.
+
+ * docs/CHANGES: Updated.
+
2004-06-21 Werner Lemberg <wl@gnu.org>
* docs/CHANGES: Updated.
diff --git a/docs/CHANGES b/docs/CHANGES
index 62b56cc..fdb9ce3 100644
--- a/docs/CHANGES
+++ b/docs/CHANGES
@@ -9,7 +9,7 @@ LATEST CHANGES BETWEEN 2.1.9 and 2.1.8
cmap caches.)
- `FT_Outline_Get_BBox' sometimes returned incorrect values for
- conic outlines (e.g. for TrueType fonts).
+ conic outlines (e.g., for TrueType fonts).
- Handling of `bhed' table has been fixed.
@@ -17,6 +17,11 @@ LATEST CHANGES BETWEEN 2.1.9 and 2.1.8
returned artifacts due to incorrect rounding. This bug has been
introduced after version 2.1.4.
+ - The BDF driver dropped the last glyph in the font.
+
+ - The BDF driver now uses the DEFAULT_CHAR property (if available)
+ to select a glyph shape for the undefined glyph.
+
II. IMPORTANT CHANGES
diff --git a/src/bdf/bdf.h b/src/bdf/bdf.h
index 4dab5ae..b42baa6 100644
--- a/src/bdf/bdf.h
+++ b/src/bdf/bdf.h
@@ -1,6 +1,6 @@
/*
* Copyright 2000 Computing Research Labs, New Mexico State University
- * Copyright 2001, 2002, 2003 Francesco Zappa Nardelli
+ * Copyright 2001, 2002, 2003, 2004 Francesco Zappa Nardelli
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -202,7 +202,7 @@ FT_BEGIN_HEADER
unsigned short monowidth; /* Logical width for monowidth font. */
- long default_glyph; /* Encoding of the default glyph. */
+ long default_char; /* Encoding of the default glyph. */
long font_ascent; /* Font ascent. */
long font_descent; /* Font descent. */
diff --git a/src/bdf/bdfdrivr.c b/src/bdf/bdfdrivr.c
index a7c3eaf..8f33d53 100644
--- a/src/bdf/bdfdrivr.c
+++ b/src/bdf/bdfdrivr.c
@@ -109,6 +109,8 @@ THE SOFTWARE.
if ( charcode == code )
{
+ /* increase glyph index by 1 -- */
+ /* we reserve slot 0 for the undefined glyph */
result = encodings[mid].glyph + 1;
break;
}
@@ -147,6 +149,8 @@ THE SOFTWARE.
if ( charcode == code )
{
+ /* increase glyph index by 1 -- */
+ /* we reserve slot 0 for the undefined glyph */
result = encodings[mid].glyph + 1;
goto Exit;
}
@@ -397,7 +401,9 @@ THE SOFTWARE.
if ( ( error = bdf_interpret_style( face ) ) != 0 )
goto Exit;
- bdfface->num_glyphs = font->glyphs_size; /* unencoded included */
+ /* the number of glyphs (with one slot for the undefined glyph */
+ /* at position 0 and all unencoded glyphs) */
+ bdfface->num_glyphs = font->glyphs_size + 1;
bdfface->num_fixed_sizes = 1;
if ( FT_NEW_ARRAY( bdfface->available_sizes, 1 ) )
@@ -457,11 +463,15 @@ THE SOFTWARE.
if ( FT_NEW_ARRAY( face->en_table, font->glyphs_size ) )
goto Exit;
+ face->default_glyph = 0;
for ( n = 0; n < font->glyphs_size; n++ )
{
(face->en_table[n]).enc = cur[n].encoding;
FT_TRACE4(( "idx %d, val 0x%lX\n", n, cur[n].encoding ));
(face->en_table[n]).glyph = (FT_Short)n;
+
+ if ( cur[n].encoding == font->default_char )
+ face->default_glyph = n;
}
}
@@ -556,7 +566,7 @@ THE SOFTWARE.
bdfface->charmap = bdfface->charmaps[0];
}
}
- }
+ }
Exit:
return error;
@@ -636,7 +646,10 @@ THE SOFTWARE.
goto Exit;
}
- if ( glyph_index > 0 )
+ /* index 0 is the undefined glyph */
+ if ( glyph_index == 0 )
+ glyph_index = face->default_glyph;
+ else
glyph_index--;
/* slot, bitmap => freetype, glyph => bdflib */
@@ -813,6 +826,7 @@ THE SOFTWARE.
return BDF_Err_Invalid_Argument;
}
+
static FT_Error
bdf_get_charset_id( BDF_Face face,
const char* *acharset_encoding,
diff --git a/src/bdf/bdfdrivr.h b/src/bdf/bdfdrivr.h
index 148041f..86f40ee 100644
--- a/src/bdf/bdfdrivr.h
+++ b/src/bdf/bdfdrivr.h
@@ -2,7 +2,7 @@
FreeType font driver for bdf fonts
- Copyright (C) 2001, 2002, 2003 by
+ Copyright (C) 2001, 2002, 2003, 2004 by
Francesco Zappa Nardelli
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -59,6 +59,8 @@ FT_BEGIN_HEADER
FT_CharMap charmap_handle;
FT_CharMapRec charmap; /* a single charmap per face */
+ FT_UInt default_glyph;
+
} BDF_FaceRec, *BDF_Face;
diff --git a/src/bdf/bdflib.c b/src/bdf/bdflib.c
index be0e398..825385e 100644
--- a/src/bdf/bdflib.c
+++ b/src/bdf/bdflib.c
@@ -1404,7 +1404,7 @@
/* present, and the SPACING property should override the default */
/* spacing. */
if ( ft_memcmp( name, "DEFAULT_CHAR", 12 ) == 0 )
- font->default_glyph = fp->value.int32;
+ font->default_char = fp->value.int32;
else if ( ft_memcmp( name, "FONT_ASCENT", 11 ) == 0 )
font->font_ascent = fp->value.int32;
else if ( ft_memcmp( name, "FONT_DESCENT", 12 ) == 0 )
@@ -2048,8 +2048,8 @@
error = hash_init( (hashtable *)p->font->internal,memory );
if ( error )
goto Exit;
- p->font->spacing = p->opts->font_spacing;
- p->font->default_glyph = -1;
+ p->font->spacing = p->opts->font_spacing;
+ p->font->default_char = -1;
goto Exit;
}