* include/freetype/freetype.h (FT_LOAD_ADVANCE_ONLY): Use value 0x100 instead of 0x10000; the latter value is already occupied by FT_LOAD_TARGET_LIGHT. Bug reported by James Cloos. Handle SFNT with neither outlines nor bitmaps. This fixes Savannah bug #25010. * src/base/ftobjs.c (FT_Load_Glyph): Reject fonts with neither outlines nor bitmaps. * src/sfnt/sfobjs.c (sfnt_load_face): Don't return an error if there is no table with glyphs. * src/sfnt/ttload.c (tt_face_lookup_table): Improve debugging message. Other minor cosmetics.
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
diff --git a/ChangeLog b/ChangeLog
index 43af8bc..2457271 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2008-12-05 Werner Lemberg <wl@nu.org>
+
+ * include/freetype/freetype.h (FT_LOAD_ADVANCE_ONLY): Use value
+ 0x100 instead of 0x10000; the latter value is already occupied by
+ FT_LOAD_TARGET_LIGHT. Bug reported by James Cloos.
+
+
+ Handle SFNT with neither outlines nor bitmaps. This fixes Savannah
+ bug #25010.
+
+ * src/base/ftobjs.c (FT_Load_Glyph): Reject fonts with neither
+ outlines nor bitmaps.
+
+ * src/sfnt/sfobjs.c (sfnt_load_face): Don't return an error if there
+ is no table with glyphs.
+
+
+ * src/sfnt/ttload.c (tt_face_lookup_table): Improve debugging
+ message.
+
2008-12-01 Werner Lemberg <wl@gnu.org>
GDEF tables need `glyph_count' too for validation. Problem reported
diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index 486f29b..f91cc54 100644
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -2429,11 +2429,11 @@ FT_BEGIN_HEADER
#define FT_LOAD_MONOCHROME 0x1000
#define FT_LOAD_LINEAR_DESIGN 0x2000
#define FT_LOAD_NO_AUTOHINT 0x8000U
-#define FT_LOAD_ADVANCE_ONLY 0x10000UL
/* */
/* used internally only by certain font drivers! */
+#define FT_LOAD_ADVANCE_ONLY 0x100
#define FT_LOAD_SBITS_ONLY 0x4000
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 1a344df..e32b934 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -559,6 +559,10 @@
if ( !face || !face->size || !face->glyph )
return FT_Err_Invalid_Face_Handle;
+ /* fonts with neither outlines nor bitmaps can be found in PDFs */
+ if ( !FT_IS_SCALABLE( face ) && !FT_HAS_FIXED_SIZES( face ) )
+ return FT_Err_Invalid_Glyph_Index;
+
/* The validity test for `glyph_index' is performed by the */
/* font drivers. */
@@ -702,7 +706,7 @@
/* compute the linear advance in 16.16 pixels */
if ( ( load_flags & FT_LOAD_LINEAR_DESIGN ) == 0 &&
- ( face->face_flags & FT_FACE_FLAG_SCALABLE ) )
+ ( FT_IS_SCALABLE( face ) ) )
{
FT_Size_Metrics* metrics = &face->size->metrics;
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index c801b4a..b469c15 100644
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -680,19 +680,20 @@
face->os2.version = 0xFFFFU;
}
-
}
/* the optional tables */
- /* embedded bitmap support. */
+ /* embedded bitmap support */
if ( sfnt->load_eblc )
{
LOAD_( eblc );
if ( error )
{
- /* return an error if this font file has no outlines */
- if ( error == SFNT_Err_Table_Missing && has_outline )
+ /* a font which contains neither bitmaps nor outlines is */
+ /* still valid (although rather useless in most cases); */
+ /* however, you can find such stripped fonts in PDFs */
+ if ( error == SFNT_Err_Table_Missing )
error = SFNT_Err_Ok;
else
goto Exit;
diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c
index 5219627..c45a1ed 100644
--- a/src/sfnt/ttload.c
+++ b/src/sfnt/ttload.c
@@ -58,6 +58,9 @@
{
TT_Table entry;
TT_Table limit;
+#ifdef FT_DEBUG_LEVEL_TRACE
+ FT_Bool zero_length = FALSE;
+#endif
FT_TRACE4(( "tt_face_lookup_table: %08p, `%c%c%c%c' -- ",
@@ -72,17 +75,28 @@
for ( ; entry < limit; entry++ )
{
- /* For compatibility with Windows, we consider 0-length */
- /* tables the same as missing tables. */
- if ( entry->Tag == tag && entry->Length != 0 )
- {
- FT_TRACE4(( "found table.\n" ));
- return entry;
+ /* For compatibility with Windows, we consider */
+ /* zero-length tables the same as missing tables. */
+ if ( entry->Tag == tag ) {
+ if ( entry->Length != 0 )
+ {
+ FT_TRACE4(( "found table.\n" ));
+ return entry;
+ }
+#ifdef FT_DEBUG_LEVEL_TRACE
+ zero_length = TRUE;
+#endif
}
}
- FT_TRACE4(( "could not find table!\n" ));
- return 0;
+#ifdef FT_DEBUG_LEVEL_TRACE
+ if ( zero_length )
+ FT_TRACE4(( "ignoring empty table!\n" ));
+ else
+ FT_TRACE4(( "could not find table!\n" ));
+#endif
+
+ return NULL;
}
diff --git a/src/tools/ftrandom/ftrandom.c b/src/tools/ftrandom/ftrandom.c
index fcff27b..4daac0d 100644
--- a/src/tools/ftrandom/ftrandom.c
+++ b/src/tools/ftrandom/ftrandom.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005 by George Williams */
+/* Copyright (C) 2005, 2007, 2008 by George Williams */
/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -151,8 +151,8 @@
int load_flags = FT_LOAD_DEFAULT;
- if ( check_outlines &&
- ( face->face_flags & FT_FACE_FLAG_SCALABLE ) )
+ if ( check_outlines &&
+ FT_IS_SCALABLE( face ) )
load_flags = FT_LOAD_NO_BITMAP;
if ( nohints )
@@ -162,8 +162,8 @@
for ( gid = 0; gid < face->num_glyphs; ++gid )
{
- if ( check_outlines &&
- ( face->face_flags & FT_FACE_FLAG_SCALABLE ) )
+ if ( check_outlines &&
+ FT_IS_SCALABLE( face ) )
{
if ( !FT_Load_Glyph( face, gid, load_flags ) )
FT_Outline_Decompose( &face->glyph->outline, &outlinefuncs, NULL );