[bdf] Fix size and resolution handling. * src/bdf/bdfdrivr.c (BDF_Face_Init): Use `SIZE' values if `POINT_SIZE', `RESOLUTION_X', or `RESOLUTION_Y' properties are missing. * docs/CHANGES: Document it.
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
diff --git a/ChangeLog b/ChangeLog
index 8d67fcb..6ae91dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2017-09-05 Werner Lemberg <wl@gnu.org>
+
+ [bdf] Fix size and resolution handling.
+
+ * src/bdf/bdfdrivr.c (BDF_Face_Init): Use `SIZE' values if
+ `POINT_SIZE', `RESOLUTION_X', or `RESOLUTION_Y' properties are
+ missing.
+
+ * docs/CHANGES: Document it.
+
2017-08-25 Alexei Podtelezhnikov <apodtele@gmail.com>
Swap `ALLOC_MULT' arguments (#51833).
diff --git a/docs/CHANGES b/docs/CHANGES
index f3e4b06..7bb5fce 100644
--- a/docs/CHANGES
+++ b/docs/CHANGES
@@ -48,6 +48,12 @@ CHANGES BETWEEN 2.8 and 2.8.1
- FreeType now synthesizes a missing Unicode cmap for (older)
TrueType fonts also if glyph names are available.
+ - FreeType has improved handling of BDF fonts without the
+ `POINT_SIZE', `RESOLUTION_X', or `RESOLUTION_Y' properties; the
+ library now uses the values of the `SIZE' keyword if they are
+ missing. Previously, `SIZE' was completely ignored, and
+ FreeType used heuristic values instead.
+
======================================================================
diff --git a/src/bdf/bdfdrivr.c b/src/bdf/bdfdrivr.c
index 37e6eea..fb77810 100644
--- a/src/bdf/bdfdrivr.c
+++ b/src/bdf/bdfdrivr.c
@@ -437,6 +437,7 @@ THE SOFTWARE.
{
FT_Bitmap_Size* bsize = bdfface->available_sizes;
FT_Short resolution_x = 0, resolution_y = 0;
+ long value;
FT_ZERO( bsize );
@@ -500,6 +501,17 @@ THE SOFTWARE.
64 * 7200,
72270L );
}
+ else if ( font->point_size )
+ {
+ if ( font->point_size > 0x7FFF )
+ {
+ bsize->size = 0x7FFF;
+ FT_TRACE0(( "BDF_Face_Init: clamping point size to value %d\n",
+ bsize->size ));
+ }
+ else
+ bsize->size = (FT_Pos)font->point_size << 6;
+ }
else
{
/* this is a heuristical value */
@@ -525,36 +537,44 @@ THE SOFTWARE.
prop = bdf_get_font_property( font, "RESOLUTION_X" );
if ( prop )
+ value = prop->value.l;
+ else
+ value = (long)font->resolution_x;
+ if ( value )
{
#ifdef FT_DEBUG_LEVEL_TRACE
- if ( prop->value.l < 0 )
+ if ( value < 0 )
FT_TRACE0(( "BDF_Face_Init: negative X resolution\n" ));
#endif
- if ( prop->value.l > 0x7FFF || prop->value.l < -0x7FFF )
+ if ( value > 0x7FFF || value < -0x7FFF )
{
resolution_x = 0x7FFF;
FT_TRACE0(( "BDF_Face_Init: clamping X resolution to value %d\n",
resolution_x ));
}
else
- resolution_x = FT_ABS( (FT_Short)prop->value.l );
+ resolution_x = FT_ABS( (FT_Short)value );
}
prop = bdf_get_font_property( font, "RESOLUTION_Y" );
if ( prop )
+ value = prop->value.l;
+ else
+ value = (long)font->resolution_y;
+ if ( value )
{
#ifdef FT_DEBUG_LEVEL_TRACE
- if ( prop->value.l < 0 )
+ if ( value < 0 )
FT_TRACE0(( "BDF_Face_Init: negative Y resolution\n" ));
#endif
- if ( prop->value.l > 0x7FFF || prop->value.l < -0x7FFF )
+ if ( value > 0x7FFF || value < -0x7FFF )
{
resolution_y = 0x7FFF;
FT_TRACE0(( "BDF_Face_Init: clamping Y resolution to value %d\n",
resolution_y ));
}
else
- resolution_y = FT_ABS( (FT_Short)prop->value.l );
+ resolution_y = FT_ABS( (FT_Short)value );
}
if ( bsize->y_ppem == 0 )