36 #include FT_FREETYPE_H
37 #include FT_INTERNAL_DEBUG_H
38 #include FT_INTERNAL_STREAM_H
39 #include FT_INTERNAL_OBJECTS_H
52 #define FT_COMPONENT trace_bdflib
82 { (
char *)
"ADD_STYLE_NAME",
BDF_ATOM, 1, { 0 } },
84 { (
char *)
"AVG_CAPITAL_WIDTH",
BDF_INTEGER, 1, { 0 } },
85 { (
char *)
"AVG_LOWERCASE_WIDTH",
BDF_INTEGER, 1, { 0 } },
87 { (
char *)
"CHARSET_COLLECTIONS",
BDF_ATOM, 1, { 0 } },
88 { (
char *)
"CHARSET_ENCODING",
BDF_ATOM, 1, { 0 } },
89 { (
char *)
"CHARSET_REGISTRY",
BDF_ATOM, 1, { 0 } },
90 { (
char *)
"COMMENT",
BDF_ATOM, 1, { 0 } },
91 { (
char *)
"COPYRIGHT",
BDF_ATOM, 1, { 0 } },
94 { (
char *)
"DEVICE_FONT_NAME",
BDF_ATOM, 1, { 0 } },
96 { (
char *)
"FACE_NAME",
BDF_ATOM, 1, { 0 } },
97 { (
char *)
"FAMILY_NAME",
BDF_ATOM, 1, { 0 } },
99 { (
char *)
"FONT",
BDF_ATOM, 1, { 0 } },
100 { (
char *)
"FONTNAME_REGISTRY",
BDF_ATOM, 1, { 0 } },
103 { (
char *)
"FOUNDRY",
BDF_ATOM, 1, { 0 } },
104 { (
char *)
"FULL_NAME",
BDF_ATOM, 1, { 0 } },
109 { (
char *)
"NOTICE",
BDF_ATOM, 1, { 0 } },
114 { (
char *)
"RAW_AVERAGE_WIDTH",
BDF_INTEGER, 1, { 0 } },
115 { (
char *)
"RAW_AVG_CAPITAL_WIDTH",
BDF_INTEGER, 1, { 0 } },
116 { (
char *)
"RAW_AVG_LOWERCASE_WIDTH",
BDF_INTEGER, 1, { 0 } },
117 { (
char *)
"RAW_CAP_HEIGHT",
BDF_INTEGER, 1, { 0 } },
119 { (
char *)
"RAW_END_SPACE",
BDF_INTEGER, 1, { 0 } },
120 { (
char *)
"RAW_FIGURE_WIDTH",
BDF_INTEGER, 1, { 0 } },
121 { (
char *)
"RAW_MAX_SPACE",
BDF_INTEGER, 1, { 0 } },
122 { (
char *)
"RAW_MIN_SPACE",
BDF_INTEGER, 1, { 0 } },
123 { (
char *)
"RAW_NORM_SPACE",
BDF_INTEGER, 1, { 0 } },
124 { (
char *)
"RAW_PIXEL_SIZE",
BDF_INTEGER, 1, { 0 } },
125 { (
char *)
"RAW_POINT_SIZE",
BDF_INTEGER, 1, { 0 } },
126 { (
char *)
"RAW_PIXELSIZE",
BDF_INTEGER, 1, { 0 } },
127 { (
char *)
"RAW_POINTSIZE",
BDF_INTEGER, 1, { 0 } },
128 { (
char *)
"RAW_QUAD_WIDTH",
BDF_INTEGER, 1, { 0 } },
129 { (
char *)
"RAW_SMALL_CAP_SIZE",
BDF_INTEGER, 1, { 0 } },
130 { (
char *)
"RAW_STRIKEOUT_ASCENT",
BDF_INTEGER, 1, { 0 } },
131 { (
char *)
"RAW_STRIKEOUT_DESCENT",
BDF_INTEGER, 1, { 0 } },
132 { (
char *)
"RAW_SUBSCRIPT_SIZE",
BDF_INTEGER, 1, { 0 } },
133 { (
char *)
"RAW_SUBSCRIPT_X",
BDF_INTEGER, 1, { 0 } },
134 { (
char *)
"RAW_SUBSCRIPT_Y",
BDF_INTEGER, 1, { 0 } },
135 { (
char *)
"RAW_SUPERSCRIPT_SIZE",
BDF_INTEGER, 1, { 0 } },
136 { (
char *)
"RAW_SUPERSCRIPT_X",
BDF_INTEGER, 1, { 0 } },
137 { (
char *)
"RAW_SUPERSCRIPT_Y",
BDF_INTEGER, 1, { 0 } },
138 { (
char *)
"RAW_UNDERLINE_POSITION",
BDF_INTEGER, 1, { 0 } },
139 { (
char *)
"RAW_UNDERLINE_THICKNESS",
BDF_INTEGER, 1, { 0 } },
141 { (
char *)
"RELATIVE_SETWIDTH",
BDF_CARDINAL, 1, { 0 } },
146 { (
char *)
"SETWIDTH_NAME",
BDF_ATOM, 1, { 0 } },
147 { (
char *)
"SLANT",
BDF_ATOM, 1, { 0 } },
148 { (
char *)
"SMALL_CAP_SIZE",
BDF_INTEGER, 1, { 0 } },
149 { (
char *)
"SPACING",
BDF_ATOM, 1, { 0 } },
150 { (
char *)
"STRIKEOUT_ASCENT",
BDF_INTEGER, 1, { 0 } },
151 { (
char *)
"STRIKEOUT_DESCENT",
BDF_INTEGER, 1, { 0 } },
152 { (
char *)
"SUBSCRIPT_SIZE",
BDF_INTEGER, 1, { 0 } },
155 { (
char *)
"SUPERSCRIPT_SIZE",
BDF_INTEGER, 1, { 0 } },
156 { (
char *)
"SUPERSCRIPT_X",
BDF_INTEGER, 1, { 0 } },
157 { (
char *)
"SUPERSCRIPT_Y",
BDF_INTEGER, 1, { 0 } },
158 { (
char *)
"UNDERLINE_POSITION",
BDF_INTEGER, 1, { 0 } },
159 { (
char *)
"UNDERLINE_THICKNESS",
BDF_INTEGER, 1, { 0 } },
161 { (
char *)
"WEIGHT_NAME",
BDF_ATOM, 1, { 0 } },
163 { (
char *)
"_MULE_BASELINE_OFFSET",
BDF_INTEGER, 1, { 0 } },
164 { (
char *)
"_MULE_RELATIVE_COMPOSE",
BDF_INTEGER, 1, { 0 } },
167 static const unsigned long
169 sizeof ( _bdf_properties[0] );
173 #define ACMSG1 "FONT_ASCENT property missing. " \
174 "Added `FONT_ASCENT %hd'.\n"
175 #define ACMSG2 "FONT_DESCENT property missing. " \
176 "Added `FONT_DESCENT %hd'.\n"
177 #define ACMSG3 "Font width != actual width. Old: %hd New: %hd.\n"
178 #define ACMSG4 "Font left bearing != actual left bearing. " \
179 "Old: %hd New: %hd.\n"
180 #define ACMSG5 "Font ascent != actual ascent. Old: %hd New: %hd.\n"
181 #define ACMSG6 "Font descent != actual descent. Old: %hd New: %hd.\n"
182 #define ACMSG7 "Font height != actual height. Old: %hd New: %hd.\n"
183 #define ACMSG8 "Glyph scalable width (SWIDTH) adjustments made.\n"
184 #define ACMSG9 "SWIDTH field missing at line %ld. Set automatically.\n"
185 #define ACMSG10 "DWIDTH field missing at line %ld. Set to glyph width.\n"
186 #define ACMSG11 "SIZE bits per pixel field adjusted to %hd.\n"
187 #define ACMSG12 "Duplicate encoding %ld (%s) changed to unencoded.\n"
188 #define ACMSG13 "Glyph %ld extra rows removed.\n"
189 #define ACMSG14 "Glyph %ld extra columns removed.\n"
190 #define ACMSG15 "Incorrect glyph count: %ld indicated but %ld found.\n"
191 #define ACMSG16 "Glyph %ld missing columns padded with zero bits.\n"
194 #define ERRMSG1 "[line %ld] Missing `%s' line.\n"
195 #define ERRMSG2 "[line %ld] Font header corrupted or missing fields.\n"
196 #define ERRMSG3 "[line %ld] Font glyphs corrupted or missing fields.\n"
197 #define ERRMSG4 "[line %ld] BBX too big.\n"
198 #define ERRMSG5 "[line %ld] `%s' value too big.\n"
199 #define ERRMSG6 "[line %ld] Input line too long.\n"
200 #define ERRMSG7 "[line %ld] Font name too long.\n"
201 #define ERRMSG8 "[line %ld] Invalid `%s' value.\n"
202 #define ERRMSG9 "[line %ld] Invalid keyword.\n"
205 #define DBGMSG1 " [%6ld] %s"
206 #define DBGMSG2 " (0x%lX)\n"
218 #define INITIAL_HT_SIZE 241
227 const char* kp = key;
228 unsigned long res = 0;
234 res = ( res << 5 ) - res + *kp++;
236 ndp = bp + ( res % ht->
size );
240 if ( kp[0] == key[0] &&
ft_strcmp( kp, key ) == 0 )
244 ndp = bp + ( ht->
size - 1 );
256 int i, sz = ht->
size;
266 for ( i = 0,
bp = obp; i < sz; i++,
bp++ )
307 int i, sz = ht->
size;
311 for ( i = 0; i < sz; i++, bp++ )
377 unsigned long linelen,
378 unsigned long lineno,
385 typedef struct _bdf_list_t_
397 typedef struct _bdf_parse_t_
417 unsigned long have[34816];
426 #define setsbit( m, cc ) \
427 ( m[(FT_Byte)(cc) >> 3] |= (FT_Byte)( 1 << ( (cc) & 7 ) ) )
428 #define sbitset( m, cc ) \
429 ( m[(FT_Byte)(cc) >> 3] & ( 1 << ( (cc) & 7 ) ) )
437 list->memory = memory;
457 unsigned long num_items )
462 if ( num_items > list->size )
464 unsigned long oldsize = list->size;
465 unsigned long newsize = oldsize + ( oldsize >> 1 ) + 5;
466 unsigned long bigsize = (
unsigned long)(
FT_INT_MAX /
sizeof (
char* ) );
470 if ( oldsize == bigsize )
472 error = BDF_Err_Out_Of_Memory;
475 else if ( newsize < oldsize || newsize > bigsize )
481 list->size = newsize;
496 if ( list == 0 || list->used == 0 || n == 0 )
499 if ( n >= list->used )
505 for ( u = n, i = 0; u < list->used; i++, u++ )
506 list->field[i] = list->field[u];
519 unsigned long *alen )
527 if ( list == 0 || list->used == 0 )
531 for ( i = j = 0; i < list->used; i++ )
537 if ( i + 1 < list->used )
556 unsigned long linelen )
558 int mult, final_empty;
568 list->field[0] = (
char*)empty;
569 list->field[1] = (
char*)empty;
570 list->field[2] = (
char*)empty;
571 list->field[3] = (
char*)empty;
575 if ( linelen == 0 || line[0] == 0 )
581 if ( separators == 0 || *separators == 0 )
583 error = BDF_Err_Invalid_Argument;
593 for ( mult = 0, sp = separators; sp && *sp; sp++ )
595 if ( *sp ==
'+' && *( sp + 1 ) == 0 )
602 for ( final_empty = 0, sp = ep = line, end = sp + linelen;
606 for ( ; *ep && !
sbitset( seps, *ep ); ep++ )
610 if ( list->used == list->size )
618 list->field[list->used++] = ( ep > sp ) ? sp : (
char*)
empty;
626 for ( ; *ep &&
sbitset( seps, *ep ); ep++ )
634 final_empty = ( ep > sp && *ep == 0 );
639 if ( list->used + final_empty >= list->size )
647 list->field[list->used++] = (
char*)empty;
649 list->field[list->used] = 0;
666 unsigned long lineno, buf_size;
667 int refill, hold, to_skip;
668 ptrdiff_t bytes,
start,
end, cursor, avail;
676 error = BDF_Err_Invalid_Argument;
702 stream, (
FT_Byte*)buf + cursor,
704 avail = cursor + bytes;
712 if ( start < avail && buf[start] == to_skip )
720 while ( end < avail && buf[end] !=
'\n' && buf[end] !=
'\r' )
737 if ( buf_size >= 65536UL )
740 error = BDF_Err_Invalid_Argument;
744 new_size = buf_size * 2;
753 bytes = avail -
start;
770 if ( buf[start] !=
'#' && buf[start] != 0x1a && end > start )
772 error = (*cb)( buf +
start, end -
start, lineno,
773 (
void*)&cb, client_data );
776 error = (*cb)( buf +
start, end -
start, lineno,
777 (
void*)&cb, client_data );
783 buf[
end] = (char)hold;
788 else if ( hold ==
'\r' )
804 static const unsigned char a2i[128] =
806 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
807 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
808 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
809 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
810 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x00, 0x00,
811 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00,
812 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
813 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
814 0x00, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
815 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
816 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
821 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
822 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
823 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
824 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
829 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x03,
830 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
831 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
832 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
837 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x03,
838 0x7e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00,
839 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
840 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
844 #define isdigok( m, d ) (m[(d) >> 3] & ( 1 << ( (d) & 7 ) ) )
854 const unsigned char* dmap;
857 if ( s == 0 || *s == 0 )
877 ( *( s + 1 ) ==
'x' || *( s + 1 ) ==
'X' ) )
884 for ( v = 0;
isdigok( dmap, *s ); s++ )
885 v = v * base + a2i[(
int)*
s];
901 const unsigned char* dmap;
904 if ( s == 0 || *s == 0 )
932 ( *( s + 1 ) ==
'x' || *( s + 1 ) ==
'X' ) )
939 for ( v = 0;
isdigok( dmap, *s ); s++ )
940 v = v * base + a2i[(
int)*
s];
945 return ( !neg ) ? v : -
v;
956 const unsigned char* dmap;
959 if ( s == 0 || *s == 0 )
987 ( *( s + 1 ) ==
'x' || *( s + 1 ) ==
'X' ) )
994 for ( v = 0;
isdigok( dmap, *s ); s++ )
995 v = (
short)( v * base + a2i[(
int)*s] );
1000 return (
short)( ( !neg ) ? v : -v );
1052 return BDF_Err_Invalid_Argument;
1083 if ( name == 0 || *name == 0 )
1086 if ( ( hn =
hash_lookup( name, &(font->proptbl) ) ) == 0 )
1106 #define _BDF_START 0x0001
1107 #define _BDF_FONT_NAME 0x0002
1108 #define _BDF_SIZE 0x0004
1109 #define _BDF_FONT_BBX 0x0008
1110 #define _BDF_PROPS 0x0010
1111 #define _BDF_GLYPHS 0x0020
1112 #define _BDF_GLYPH 0x0040
1113 #define _BDF_ENCODING 0x0080
1114 #define _BDF_SWIDTH 0x0100
1115 #define _BDF_DWIDTH 0x0200
1116 #define _BDF_BBX 0x0400
1117 #define _BDF_BITMAP 0x0800
1119 #define _BDF_SWIDTH_ADJ 0x1000
1121 #define _BDF_GLYPH_BITS ( _BDF_GLYPH | \
1128 #define _BDF_GLYPH_WIDTH_CHECK 0x40000000UL
1129 #define _BDF_GLYPH_HEIGHT_CHECK 0x80000000UL
1164 unsigned long lineno )
1173 if ( font == 0 || font->
name == 0 || font->
name[0] == 0 )
1175 error = BDF_Err_Invalid_Argument;
1190 error = BDF_Err_Invalid_Argument;
1200 if ( list.used == 15 )
1202 switch ( list.field[11][0] )
1231 unsigned long linelen,
1241 *name = sp = ep = line;
1243 while ( *ep && *ep !=
' ' && *ep !=
'\t' )
1266 ep = line + linelen;
1272 ( *sp ==
' ' || *sp ==
'\t' ) )
1282 ( *( ep - 1 ) ==
' ' || *( ep - 1 ) ==
'\t' ) )
1286 if ( ep > sp && *( ep - 1 ) ==
'"' )
1297 unsigned long lineno )
1319 if ( value && value[0] != 0 )
1389 if ( value != 0 && value[0] )
1407 if (
ft_memcmp( name,
"COMMENT", 7 ) != 0 )
1425 if (
ft_memcmp( name,
"DEFAULT_CHAR", 12 ) == 0 )
1427 else if (
ft_memcmp( name,
"FONT_ASCENT", 11 ) == 0 )
1429 else if (
ft_memcmp( name,
"FONT_DESCENT", 12 ) == 0 )
1431 else if (
ft_memcmp( name,
"SPACING", 7 ) == 0 )
1436 error = BDF_Err_Invalid_File_Format;
1455 0xFF, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE
1462 unsigned long linelen,
1463 unsigned long lineno,
1470 unsigned long i, slen, nibbles;
1489 if (
ft_memcmp( line,
"COMMENT", 7 ) == 0 )
1506 if (
ft_memcmp( line,
"CHARS", 5 ) != 0 )
1509 error = BDF_Err_Missing_Chars_Field;
1524 if ( p->cnt >= 0x110000UL )
1527 error = BDF_Err_Invalid_Argument;
1540 if (
ft_memcmp( line,
"ENDFONT", 7 ) == 0 )
1554 if (
ft_memcmp( line,
"ENDCHAR", 7 ) == 0 )
1565 p->glyph_enc == -1 &&
1566 p->opts->keep_unencoded == 0 )
1570 if (
ft_memcmp( line,
"STARTCHAR", 9 ) == 0 )
1587 error = BDF_Err_Invalid_File_Format;
1604 if (
ft_memcmp( line,
"ENCODING", 8 ) == 0 )
1610 error = BDF_Err_Missing_Startchar_Field;
1618 p->glyph_enc =
_bdf_atol( p->list.field[1], 0, 10 );
1622 if ( p->glyph_enc < -1 )
1626 if ( p->glyph_enc == -1 && p->list.used > 2 )
1627 p->glyph_enc =
_bdf_atol( p->list.field[2], 0, 10 );
1633 if ( p->glyph_enc > 0 &&
1634 (
size_t)p->glyph_enc >=
sizeof ( p->have ) * 8 )
1637 error = BDF_Err_Invalid_File_Format;
1644 if ( p->glyph_enc >= 0 )
1651 p->glyph_enc, p->glyph_name ));
1659 if ( p->glyph_enc >= 0 )
1674 glyph->
name = p->glyph_name;
1684 if ( p->opts->keep_unencoded != 0 )
1698 glyph->
name = p->glyph_name;
1719 if ( p->glyph_enc == -1 )
1729 if ( p->row >= (
unsigned long)glyph->
bbx.
height )
1743 nibbles = glyph->
bpr << 1;
1744 bp = glyph->
bitmap + p->row * glyph->
bpr;
1746 for ( i = 0; i < nibbles; i++ )
1751 *bp = (
FT_Byte)( ( *bp << 4 ) + a2i[
c] );
1752 if ( i + 1 < nibbles && ( i & 1 ) )
1767 mask_index = ( glyph->
bbx.
width * p->font->bpp ) & 7;
1769 *bp &= nibble_mask[mask_index];
1772 if ( i == nibbles &&
1773 isdigok( hdigits, line[nibbles] ) &&
1786 if (
ft_memcmp( line,
"SWIDTH", 6 ) == 0 )
1789 goto Missing_Encoding;
1802 if (
ft_memcmp( line,
"DWIDTH", 6 ) == 0 )
1805 goto Missing_Encoding;
1833 goto Missing_Encoding;
1855 p->maxrb = (short)
FT_MAX( p->rbearing, p->maxrb );
1869 if ( p->opts->correct_metrics != 0 )
1872 unsigned short sw = (
unsigned short)
FT_MulDiv(
1878 if ( sw != glyph->
swidth )
1882 if ( p->glyph_enc == -1 )
1898 if (
ft_memcmp( line,
"BITMAP", 6 ) == 0 )
1900 unsigned long bitmap_size;
1907 error = BDF_Err_Missing_Bbx_Field;
1912 glyph->
bpr = ( glyph->
bbx.
width * p->font->bpp + 7 ) >> 3;
1915 if ( glyph->
bpr > 0xFFFFU || bitmap_size > 0xFFFFU )
1918 error = BDF_Err_Bbx_Too_Big;
1922 glyph->
bytes = (
unsigned short)bitmap_size;
1934 error = BDF_Err_Invalid_File_Format;
1940 error = BDF_Err_Missing_Encoding_Field;
1953 unsigned long linelen,
1954 unsigned long lineno,
1973 if (
ft_memcmp( line,
"ENDPROPERTIES", 13 ) == 0 )
1983 p->font->font_ascent = p->font->bbx.ascent;
1984 ft_sprintf( nbuf,
"%hd", p->font->bbx.ascent );
1991 p->font->modified = 1;
1996 p->font->font_descent = p->font->bbx.descent;
1997 ft_sprintf( nbuf,
"%hd", p->font->bbx.descent );
2003 FT_TRACE2((
"_bdf_parse_properties: " ACMSG2, p->font->bbx.descent ));
2004 p->font->modified = 1;
2014 if (
ft_memcmp( line,
"_XFREE86_GLYPH_RANGES", 21 ) == 0 )
2019 if (
ft_memcmp( line,
"COMMENT", 7 ) == 0 )
2021 name = value = line;
2029 else if (
_bdf_is_atom( line, linelen, &name, &value, p->font ) )
2040 name = p->list.field[0];
2058 unsigned long linelen,
2059 unsigned long lineno,
2079 memory = p->font->memory;
2083 if (
ft_memcmp( line,
"COMMENT", 7 ) == 0 )
2085 if ( p->opts->keep_comments != 0 && p->font != 0 )
2109 if (
ft_memcmp( line,
"STARTFONT", 9 ) != 0 )
2113 error = BDF_Err_Missing_Startfont_Field;
2124 font->
memory = p->memory;
2150 p->font->spacing = p->opts->font_spacing;
2151 p->font->default_char = -1;
2157 if (
ft_memcmp( line,
"STARTPROPERTIES", 15 ) == 0 )
2162 FT_ERROR((
"_bdf_parse_start: " ERRMSG1, lineno,
"FONTBOUNDINGBOX" ));
2163 error = BDF_Err_Missing_Fontboundingbox_Field;
2171 p->cnt = p->font->props_size =
_bdf_atoul( p->list.field[1], 0, 10 );
2183 if (
ft_memcmp( line,
"FONTBOUNDINGBOX", 15 ) == 0 )
2189 error = BDF_Err_Missing_Size_Field;
2197 p->font->bbx.width =
_bdf_atos( p->list.field[1], 0, 10 );
2198 p->font->bbx.height =
_bdf_atos( p->list.field[2], 0, 10 );
2200 p->font->bbx.x_offset =
_bdf_atos( p->list.field[3], 0, 10 );
2201 p->font->bbx.y_offset =
_bdf_atos( p->list.field[4], 0, 10 );
2203 p->font->bbx.ascent = (short)( p->font->bbx.height +
2204 p->font->bbx.y_offset );
2206 p->font->bbx.descent = (short)( -p->font->bbx.y_offset );
2214 if (
ft_memcmp( line,
"FONT", 4 ) == 0 )
2226 error = BDF_Err_Invalid_File_Format;
2249 if (
ft_memcmp( line,
"SIZE", 4 ) == 0 )
2255 error = BDF_Err_Missing_Font_Field;
2263 p->font->point_size =
_bdf_atoul( p->list.field[1], 0, 10 );
2264 p->font->resolution_x =
_bdf_atoul( p->list.field[2], 0, 10 );
2265 p->font->resolution_y =
_bdf_atoul( p->list.field[3], 0, 10 );
2268 if ( p->list.used == 5 )
2270 unsigned short bitcount,
i, shift;
2273 p->font->bpp = (
unsigned short)
_bdf_atos( p->list.field[4], 0, 10 );
2276 shift = p->font->bpp;
2278 for ( i = 0; shift > 0; i++ )
2285 shift = (short)( ( bitcount > 3 ) ? 8 : ( 1 << bitcount ) );
2287 if ( p->font->bpp > shift || p->font->bpp != shift )
2290 p->font->bpp = (
unsigned short)( shift << 1 );
2303 if (
ft_memcmp( line,
"CHARS", 5 ) == 0 )
2311 FT_ERROR((
"_bdf_parse_start: " ERRMSG1, lineno,
"FONTBOUNDINGBOX" ));
2312 error = BDF_Err_Missing_Fontboundingbox_Field;
2318 p->font->font_ascent = p->font->bbx.ascent;
2319 ft_sprintf( nbuf,
"%hd", p->font->bbx.ascent );
2326 p->font->font_descent = p->font->bbx.descent;
2327 ft_sprintf( nbuf,
"%hd", p->font->bbx.descent );
2332 FT_TRACE2((
"_bdf_parse_properties: " ACMSG2, p->font->bbx.descent ));
2334 p->font->modified = 1;
2344 error = BDF_Err_Invalid_File_Format;
2364 unsigned long lineno = 0;
2377 p->memory = extmemory;
2382 (
void *)p, &lineno );
2390 memory = p->font->memory;
2393 p->font->monowidth = p->font->bbx.width;
2397 if ( p->cnt != p->font->glyphs_used + p->font->unencoded_used )
2400 p->font->glyphs_used + p->font->unencoded_used ));
2401 p->font->modified = 1;
2406 if ( p->opts->correct_metrics != 0 &&
2407 ( p->font->glyphs_used > 0 || p->font->unencoded_used > 0 ) )
2409 if ( p->maxrb - p->minlb != p->font->bbx.width )
2412 p->font->bbx.width, p->maxrb - p->minlb ));
2413 p->font->bbx.width = (
unsigned short)( p->maxrb - p->minlb );
2414 p->font->modified = 1;
2417 if ( p->font->bbx.x_offset != p->minlb )
2420 p->font->bbx.x_offset, p->minlb ));
2421 p->font->bbx.x_offset = p->minlb;
2422 p->font->modified = 1;
2425 if ( p->font->bbx.ascent != p->maxas )
2428 p->font->bbx.ascent, p->maxas ));
2429 p->font->bbx.ascent = p->maxas;
2430 p->font->modified = 1;
2433 if ( p->font->bbx.descent != p->maxds )
2436 p->font->bbx.descent, p->maxds ));
2437 p->font->bbx.descent = p->maxds;
2438 p->font->bbx.y_offset = (short)( -p->maxds );
2439 p->font->modified = 1;
2442 if ( p->maxas + p->maxds != p->font->bbx.height )
2445 p->font->bbx.height, p->maxas + p->maxds ));
2446 p->font->bbx.height = (
unsigned short)( p->maxas + p->maxds );
2461 error = BDF_Err_Corrupted_Font_Header;
2468 error = BDF_Err_Corrupted_Font_Glyphs;
2476 memory = p->font->memory;
2478 if ( p->font->comments_len > 0 )
2481 p->font->comments_len,
2482 p->font->comments_len + 1 ) )
2485 p->font->comments[p->font->comments_len] = 0;
2488 else if ( error == BDF_Err_Ok )
2489 error = BDF_Err_Invalid_File_Format;
2528 memory = font->memory;
2533 if ( font->internal )
2543 for ( i = 0; i < font->props_size; i++ )
2545 if ( font->props[i].format ==
BDF_ATOM )
2546 FT_FREE( font->props[i].value.atom );
2552 for ( i = 0, glyphs = font->glyphs;
2553 i < font->glyphs_used; i++, glyphs++ )
2559 for ( i = 0, glyphs = font->unencoded; i < font->unencoded_used;
2570 for ( i = 0, glyphs = font->overflow.glyphs;
2571 i < font->overflow.glyphs_used; i++, glyphs++ )
2577 FT_FREE( font->overflow.glyphs );
2583 for ( prop = font->user_props, i = 0;
2584 i < font->nuser_props; i++, prop++ )
2604 if ( font == 0 || font->props_size == 0 || name == 0 || *name == 0 )
2609 return hn ? ( font->props + hn->
data ) : 0;
static const unsigned char odigits[32]
#define FT_ALLOC(ptr, size)
static FT_Error _bdf_readstream(FT_Stream stream, _bdf_line_func_t callback, void *client_data, unsigned long *lno)
#define _BDF_GLYPH_WIDTH_CHECK
unsigned long unencoded_size
static unsigned long _bdf_atoul(char *s, char **end, int base)
bdf_property_t * user_props
union bdf_property_t_::@25 value
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
#define _bdf_set_glyph_modified(map, e)
#define _bdf_glyph_modified(map, e)
static int by_encoding(const void *a, const void *b)
#define FT_MEM_ZERO(dest, count)
FT_Stream_TryRead(FT_Stream stream, FT_Byte *buffer, FT_ULong count)
void(* hash_free_func)(hashnode node)
static const unsigned char ddigits[32]
static long _bdf_atol(char *s, char **end, int base)
static FT_Error hash_init(hashtable *ht, FT_Memory memory)
static FT_Error hash_rehash(hashtable *ht, FT_Memory memory)
static FT_Error bdf_create_property(char *name, int format, bdf_font_t *font)
bdf_free_font(bdf_font_t *font)
GLboolean GLboolean GLboolean GLboolean a
static FT_Error _bdf_add_comment(bdf_font_t *font, char *comment, unsigned long len)
EGLImageKHR EGLint * name
static FT_Error _bdf_parse_properties(char *line, unsigned long linelen, unsigned long lineno, void *call_data, void *client_data)
static const bdf_options_t _bdf_opts
bdf_get_font_property(bdf_font_t *font, const char *name)
unsigned long resolution_x
#define FT_ERROR(varformat)
#define FT_TRACE4(varformat)
static void _bdf_list_done(_bdf_list_t *list)
GLenum GLenum GLvoid * row
static void hash_free(hashtable *ht, FT_Memory memory)
struct _bdf_list_t_ _bdf_list_t
unsigned long glyphs_size
FT_MulDiv(FT_Long a, FT_Long b, FT_Long c)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
static FT_Error _bdf_list_ensure(_bdf_list_t *list, unsigned long num_items)
static const char empty[1]
static FT_Error _bdf_add_property(bdf_font_t *font, char *name, char *value, unsigned long lineno)
static char * _bdf_list_join(_bdf_list_t *list, int c, unsigned long *alen)
#define FT_TRACE2(varformat)
unsigned long nuser_props
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum format
#define FT_RENEW_ARRAY(ptr, curcnt, newcnt)
static FT_Error _bdf_list_split(_bdf_list_t *list, char *separators, char *line, unsigned long linelen)
unsigned long unencoded_used
static const unsigned char hdigits[32]
unsigned long comments_len
static const unsigned long _num_bdf_properties
static FT_Error _bdf_parse_start(char *line, unsigned long linelen, unsigned long lineno, void *call_data, void *client_data)
static void _bdf_list_shift(_bdf_list_t *list, unsigned long n)
static void _bdf_list_init(_bdf_list_t *list, FT_Memory memory)
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
#define FT_NEW_ARRAY(ptr, count)
static const unsigned char nibble_mask[8]
static int _bdf_is_atom(char *line, unsigned long linelen, char **name, char **value, bdf_font_t *font)
EGLSurface EGLint void ** value
bdf_load_font(FT_Stream stream, FT_Memory memory, bdf_options_t *opts, bdf_font_t **font)
unsigned long nmod[34816]
GLenum GLuint GLsizei const GLchar * buf
GLenum GLsizei GLsizei GLsizei GLsizei GLbitfield flags
static short _bdf_atos(char *s, char **end, int base)
GLdouble GLdouble GLdouble b
static FT_Error hash_insert(char *key, size_t data, hashtable *ht, FT_Memory memory)
static hashnode * hash_bucket(const char *key, hashtable *ht)
#define FT_STRDUP(dst, str)
static hashnode hash_lookup(const char *key, hashtable *ht)
unsigned long glyphs_used
bdf_get_property(char *name, bdf_font_t *font)
#define FT_MEM_COPY(dest, source, count)
static const unsigned char a2i[128]
static const bdf_property_t _bdf_properties[]
static FT_Error _bdf_set_default_spacing(bdf_font_t *font, bdf_options_t *opts, unsigned long lineno)
static FT_Error _bdf_parse_glyphs(char *line, unsigned long linelen, unsigned long lineno, void *call_data, void *client_data)
unsigned long umod[34816]
#define _BDF_GLYPH_HEIGHT_CHECK
FT_Error(* _bdf_line_func_t)(char *line, unsigned long linelen, unsigned long lineno, void *call_data, void *client_data)
struct _bdf_parse_t_ _bdf_parse_t