ref: 8ef4183690ab7a8f5fef0eb9ae64b0958aecc6b8
parent: 83efe779e3e3c34af5f3cde93a12b97247f806c6
author: Werner Lemberg <[email protected]>
date: Tue Jun 22 08:28:17 EDT 2004
* 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.
--- 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 <[email protected]>
* docs/CHANGES: Updated.
--- a/docs/CHANGES
+++ b/docs/CHANGES
@@ -9,7 +9,7 @@
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.
@@ -16,6 +16,11 @@
- The TrueType driver with enabled byte code interpreter sometimes
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
--- 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 @@
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. */
--- a/src/bdf/bdfdrivr.c
+++ b/src/bdf/bdfdrivr.c
@@ -109,6 +109,8 @@
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 @@
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 @@
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 @@
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 @@
bdfface->charmap = bdfface->charmaps[0];
}
}
- }
+ }
Exit:
return error;
@@ -636,7 +646,10 @@
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 */
@@ -812,6 +825,7 @@
Fail:
return BDF_Err_Invalid_Argument;
}
+
static FT_Error
bdf_get_charset_id( BDF_Face face,
--- 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
@@ -58,6 +58,8 @@
FT_CharMap charmap_handle;
FT_CharMapRec charmap; /* a single charmap per face */
+
+ FT_UInt default_glyph;
} BDF_FaceRec, *BDF_Face;
--- 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;
}