summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Lemberg <wl@gnu.org>2017-09-05 15:28:21 +0200
committerWerner Lemberg <wl@gnu.org>2017-09-05 15:28:21 +0200
commit7d017ba810d0b29a941f83188ac39cf3c8d52a48 (patch)
tree7deb63d9e847624f9c2133945c8efe0c3b983fa3
parentf0898b9259d4b3b99a1e720924683730dd36d3db (diff)
downloadfreetype2-7d017ba810d0b29a941f83188ac39cf3c8d52a48.tar.gz
[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.
-rw-r--r--ChangeLog10
-rw-r--r--docs/CHANGES6
-rw-r--r--src/bdf/bdfdrivr.c32
3 files changed, 42 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 8d67fcb5a..6ae91dd6f 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 f3e4b062b..7bb5fceb5 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 37e6eea1c..fb7781000 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 )