[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2] master 3d4ab6b: [pcf] Massive unsigning (part 1).
From: |
Alexei Podtelezhnikov |
Subject: |
[freetype2] master 3d4ab6b: [pcf] Massive unsigning (part 1). |
Date: |
Wed, 8 Aug 2018 00:10:25 -0400 (EDT) |
branch: master
commit 3d4ab6bac14c28dcbce00dd57bb30b0bbc4937db
Author: Alexei Podtelezhnikov <address@hidden>
Commit: Alexei Podtelezhnikov <address@hidden>
[pcf] Massive unsigning (part 1).
Unofficial specifications hesitate to use unsigned 32-bit integers.
Negative values caused a lot of trouble in the past and it is safer
and easier to treat some properties as unsigned.
* src/pcf/pcf.h (PCF_AccelRec): Use unsigned values for `fontAscent',
`fontDescent', and `maxOverlap'.
* src/pcf/pcfread.c (pcf_load_font, pcf_get_accel): Updated.
* src/pcf/pcfdrivr.c (PCF_Glyph_Load, PCF_Size_Select,
PCF_Size_Request): Updated.
---
ChangeLog | 16 +++++++++++++++-
src/pcf/pcf.h | 6 +++---
src/pcf/pcfdrivr.c | 12 ++++++------
src/pcf/pcfread.c | 44 ++++++++++++++++----------------------------
4 files changed, 40 insertions(+), 38 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b9576d8..bbe07ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,18 @@
-2018-08-06 Alexei Podtelezhnikov <address@hidden>
+2018-08-08 Alexei Podtelezhnikov <address@hidden>
+
+ [pcf] Massive unsigning (part 1).
+
+ Unofficial specifications hesitate to use unsigned 32-bit integers.
+ Negative values caused a lot of trouble in the past and it is safer
+ and easier to treat some properties as unsigned.
+
+ * src/pcf/pcf.h (PCF_AccelRec): Use unsigned values for `fontAscent',
+ `fontDescent', and `maxOverlap'.
+ * src/pcf/pcfread.c (pcf_load_font, pcf_get_accel): Updated.
+ * src/pcf/pcfdrivr.c (PCF_Glyph_Load, PCF_Size_Select,
+ PCF_Size_Request): Updated.
+
+2018-08-07 Alexei Podtelezhnikov <address@hidden>
* src/pcf/pcfread.c (pcf_get_bitmaps): Unsign `offsets' and
`bitmapSizes'.
diff --git a/src/pcf/pcf.h b/src/pcf/pcf.h
index 3c4eb6a..a4f6d24 100644
--- a/src/pcf/pcf.h
+++ b/src/pcf/pcf.h
@@ -113,9 +113,9 @@ FT_BEGIN_HEADER
FT_Byte inkInside;
FT_Byte inkMetrics;
FT_Byte drawDirection;
- FT_Long fontAscent;
- FT_Long fontDescent;
- FT_Long maxOverlap;
+ FT_ULong fontAscent;
+ FT_ULong fontDescent;
+ FT_ULong maxOverlap;
PCF_MetricRec minbounds;
PCF_MetricRec maxbounds;
PCF_MetricRec ink_minbounds;
diff --git a/src/pcf/pcfdrivr.c b/src/pcf/pcfdrivr.c
index e2f7e7c..90fb896 100644
--- a/src/pcf/pcfdrivr.c
+++ b/src/pcf/pcfdrivr.c
@@ -441,8 +441,8 @@ THE SOFTWARE.
FT_Select_Metrics( size->face, strike_index );
- size->metrics.ascender = accel->fontAscent * 64;
- size->metrics.descender = -accel->fontDescent * 64;
+ size->metrics.ascender = (FT_Pos)accel->fontAscent * 64;
+ size->metrics.descender = -(FT_Pos)accel->fontDescent * 64;
size->metrics.max_advance = accel->maxbounds.characterWidth * 64;
return FT_Err_Ok;
@@ -470,8 +470,8 @@ THE SOFTWARE.
break;
case FT_SIZE_REQUEST_TYPE_REAL_DIM:
- if ( height == ( face->accel.fontAscent +
- face->accel.fontDescent ) )
+ if ( (FT_ULong)height == ( face->accel.fontAscent +
+ face->accel.fontDescent ) )
error = FT_Err_Ok;
break;
@@ -560,8 +560,8 @@ THE SOFTWARE.
slot->metrics.height = (FT_Pos)( bitmap->rows * 64 );
ft_synthesize_vertical_metrics( &slot->metrics,
- ( face->accel.fontAscent +
- face->accel.fontDescent ) * 64 );
+ (FT_Pos)( face->accel.fontAscent +
+ face->accel.fontDescent ) * 64 );
if ( load_flags & FT_LOAD_BITMAP_METRICS_ONLY )
goto Exit;
diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c
index 14cce67..493c159 100644
--- a/src/pcf/pcfread.c
+++ b/src/pcf/pcfread.c
@@ -1139,9 +1139,9 @@ THE SOFTWARE.
FT_FRAME_BYTE ( inkMetrics ),
FT_FRAME_BYTE ( drawDirection ),
FT_FRAME_SKIP_BYTES( 1 ),
- FT_FRAME_LONG_LE ( fontAscent ),
- FT_FRAME_LONG_LE ( fontDescent ),
- FT_FRAME_LONG_LE ( maxOverlap ),
+ FT_FRAME_ULONG_LE ( fontAscent ),
+ FT_FRAME_ULONG_LE ( fontDescent ),
+ FT_FRAME_ULONG_LE ( maxOverlap ),
FT_FRAME_END
};
@@ -1161,9 +1161,9 @@ THE SOFTWARE.
FT_FRAME_BYTE ( inkMetrics ),
FT_FRAME_BYTE ( drawDirection ),
FT_FRAME_SKIP_BYTES( 1 ),
- FT_FRAME_LONG ( fontAscent ),
- FT_FRAME_LONG ( fontDescent ),
- FT_FRAME_LONG ( maxOverlap ),
+ FT_FRAME_ULONG ( fontAscent ),
+ FT_FRAME_ULONG ( fontDescent ),
+ FT_FRAME_ULONG ( maxOverlap ),
FT_FRAME_END
};
@@ -1217,7 +1217,7 @@ THE SOFTWARE.
FT_TRACE5(( " noOverlap=%s, constantMetrics=%s,"
" terminalFont=%s, constantWidth=%s\n"
" inkInside=%s, inkMetrics=%s, drawDirection=%s\n"
- " fontAscent=%ld, fontDescent=%ld, maxOverlap=%ld\n",
+ " fontAscent=%lu, fontDescent=%lu, maxOverlap=%lu\n",
accel->noOverlap ? "yes" : "no",
accel->constantMetrics ? "yes" : "no",
accel->terminalFont ? "yes" : "no",
@@ -1229,17 +1229,17 @@ THE SOFTWARE.
accel->fontDescent,
accel->maxOverlap ));
- /* sanity checks */
- if ( FT_ABS( accel->fontAscent ) > 0x7FFF )
+ /* sanity checks so that combined height can fit short */
+ if ( accel->fontAscent > 0x3FFFU )
{
- accel->fontAscent = accel->fontAscent < 0 ? -0x7FFF : 0x7FFF;
- FT_TRACE0(( "pfc_get_accel: clamping font ascent to value %d\n",
+ accel->fontAscent = 0x3FFFU;
+ FT_TRACE0(( "pfc_get_accel: clamping font ascent to value %u\n",
accel->fontAscent ));
}
- if ( FT_ABS( accel->fontDescent ) > 0x7FFF )
+ if ( accel->fontDescent > 0x3FFFU )
{
- accel->fontDescent = accel->fontDescent < 0 ? -0x7FFF : 0x7FFF;
- FT_TRACE0(( "pfc_get_accel: clamping font descent to value %d\n",
+ accel->fontDescent = 0x3FFFU;
+ FT_TRACE0(( "pfc_get_accel: clamping font descent to value %u\n",
accel->fontDescent ));
}
@@ -1565,20 +1565,8 @@ THE SOFTWARE.
bsize->height = face->accel.maxbounds.ascent << 6;
#endif
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( face->accel.fontAscent + face->accel.fontDescent < 0 )
- FT_TRACE0(( "pcf_load_font: negative height\n" ));
-#endif
- if ( FT_ABS( face->accel.fontAscent +
- face->accel.fontDescent ) > 0x7FFF )
- {
- bsize->height = 0x7FFF;
- FT_TRACE0(( "pcf_load_font: clamping height to value %d\n",
- bsize->height ));
- }
- else
- bsize->height = FT_ABS( (FT_Short)( face->accel.fontAscent +
- face->accel.fontDescent ) );
+ bsize->height = (FT_Short)( face->accel.fontAscent +
+ face->accel.fontDescent );
prop = pcf_find_property( face, "AVERAGE_WIDTH" );
if ( prop )
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2] master 3d4ab6b: [pcf] Massive unsigning (part 1).,
Alexei Podtelezhnikov <=