* src/base/ftobjs.c (ft_glyphslot_grid_fit_metrics, FT_Load_Glyph): Re-enable glyph metrics grid-fitting. It is now done in the base layer. (FT_Set_Char_Size, FT_Set_Pixel_Sizes): Make sure the width and height are not too small or too large, just like we were doing in 2.1.10. * src/autofit/afloader.c (af_loader_load_g): The vertical metrics are not scaled.
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 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
diff --git a/ChangeLog b/ChangeLog
index 0a77d32..65703f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2006-02-27 Chia-I Wu <b90201047@ntu.edu.tw>
+
+ * src/base/ftobjs.c (ft_glyphslot_grid_fit_metrics, FT_Load_Glyph):
+ Re-enable glyph metrics grid-fitting. It is now done in the base
+ layer.
+ (FT_Set_Char_Size, FT_Set_Pixel_Sizes): Make sure the width and height
+ are not too small or too large, just like we were doing in 2.1.10.
+
+ * src/autofit/afloader.c (af_loader_load_g): The vertical metrics are
+ not scaled.
+
2006-02-26 Werner Lemberg <wl@gnu.org>
* docs/release: Minor additions and clarifications.
diff --git a/src/autofit/afloader.c b/src/autofit/afloader.c
index 821e7e6..3aae43c 100644
--- a/src/autofit/afloader.c
+++ b/src/autofit/afloader.c
@@ -378,12 +378,21 @@
Hint_Metrics:
if ( depth == 0 )
{
- FT_BBox bbox;
+ FT_BBox bbox;
+ FT_Vector vvector;
+ vvector.x = slot->metrics.vertBearingX - slot->metrics.horiBearingX;
+ vvector.y = slot->metrics.vertBearingY - slot->metrics.horiBearingY;
+ vvector.x = FT_MulFix( vvector.x, metrics->scaler.x_scale );
+ vvector.y = FT_MulFix( vvector.y, metrics->scaler.y_scale );
+
/* transform the hinted outline if needed */
if ( loader->transformed )
+ {
FT_Outline_Transform( &gloader->base.outline, &loader->trans_matrix );
+ FT_Vector_Transform( &vvector, &loader->trans_matrix );
+ }
/* we must translate our final outline by -pp1.x and compute */
/* the new metrics */
@@ -402,6 +411,9 @@
slot->metrics.horiBearingX = bbox.xMin;
slot->metrics.horiBearingY = bbox.yMax;
+ slot->metrics.vertBearingX = FT_PIX_FLOOR( bbox.xMin + vvector.x );
+ slot->metrics.vertBearingY = FT_PIX_FLOOR( bbox.yMax + vvector.y );
+
/* for mono-width fonts (like Andale, Courier, etc.) we need */
/* to keep the original rounded advance width */
#if 0
@@ -418,7 +430,11 @@
metrics->scaler.x_scale );
#endif
+ slot->metrics.vertAdvance = FT_MulFix( slot->metrics.vertAdvance,
+ metrics->scaler.y_scale );
+
slot->metrics.horiAdvance = FT_PIX_ROUND( slot->metrics.horiAdvance );
+ slot->metrics.vertAdvance = FT_PIX_ROUND( slot->metrics.vertAdvance );
/* now copy outline into glyph slot */
FT_GlyphLoader_Rewind( internal->loader );
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index c237d65..ddb2157 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -36,6 +36,7 @@
#include FT_SERVICE_KERNING_H
#include FT_SERVICE_TRUETYPE_ENGINE_H
+#define GRID_FIT_METRICS
FT_BASE_DEF( FT_Pointer )
ft_service_list_lookup( FT_ServiceDesc service_descriptors,
@@ -478,6 +479,50 @@
ft_lookup_glyph_renderer( FT_GlyphSlot slot );
+#ifdef GRID_FIT_METRICS
+ static void
+ ft_glyphslot_grid_fit_metrics( FT_GlyphSlot slot,
+ FT_Bool vertical )
+ {
+ FT_Glyph_Metrics* metrics = &slot->metrics;
+ FT_Pos right, bottom;
+
+
+ if ( vertical )
+ {
+ metrics->horiBearingX = FT_PIX_FLOOR( metrics->horiBearingX );
+ metrics->horiBearingY = FT_PIX_CEIL ( metrics->horiBearingY );
+
+ right = FT_PIX_CEIL( metrics->vertBearingX + metrics->width );
+ bottom = FT_PIX_CEIL( metrics->vertBearingY + metrics->height );
+
+ metrics->vertBearingX = FT_PIX_FLOOR( metrics->vertBearingX );
+ metrics->vertBearingY = FT_PIX_FLOOR( metrics->vertBearingY );
+
+ metrics->width = right - metrics->vertBearingX;
+ metrics->height = bottom - metrics->vertBearingY;
+ }
+ else
+ {
+ metrics->vertBearingX = FT_PIX_FLOOR( metrics->vertBearingX );
+ metrics->vertBearingY = FT_PIX_FLOOR( metrics->vertBearingY );
+
+ right = FT_PIX_CEIL ( metrics->horiBearingX + metrics->width );
+ bottom = FT_PIX_FLOOR( metrics->horiBearingY - metrics->height );
+
+ metrics->horiBearingX = FT_PIX_FLOOR( metrics->horiBearingX );
+ metrics->horiBearingY = FT_PIX_CEIL ( metrics->horiBearingY );
+
+ metrics->width = right - metrics->horiBearingX;
+ metrics->height = metrics->horiBearingY - bottom;
+ }
+
+ metrics->horiAdvance = FT_PIX_ROUND( metrics->horiAdvance );
+ metrics->vertAdvance = FT_PIX_ROUND( metrics->vertAdvance );
+ }
+#endif /* GRID_FIT_METRICS */
+
+
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
@@ -575,10 +620,20 @@
if ( error )
goto Exit;
- /* check that the loaded outline is correct */
- error = FT_Outline_Check( &slot->outline );
- if ( error )
- goto Exit;
+ if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
+ {
+ /* check that the loaded outline is correct */
+ error = FT_Outline_Check( &slot->outline );
+ if ( error )
+ goto Exit;
+
+#ifdef GRID_FIT_METRICS
+ if ( !( load_flags & FT_LOAD_NO_HINTING ) )
+ ft_glyphslot_grid_fit_metrics( slot,
+ load_flags
+ & FT_LOAD_VERTICAL_LAYOUT );
+#endif
+ }
}
Load_Ok:
@@ -2063,7 +2118,7 @@
{
/* Compute root ascender, descender, test height, and max_advance */
-#if 1
+#ifdef GRID_FIT_METRICS
metrics->ascender = FT_PIX_CEIL( FT_MulFix( face->ascender,
metrics->y_scale ) );
@@ -2075,7 +2130,7 @@
metrics->max_advance = FT_PIX_ROUND( FT_MulFix( face->max_advance_width,
metrics->x_scale ) );
-#else
+#else /* !GRID_FIT_METRICS */
metrics->ascender = FT_MulFix( face->ascender,
metrics->y_scale );
@@ -2087,7 +2142,7 @@
metrics->max_advance = FT_MulFix( face->max_advance_width,
metrics->x_scale );
-#endif
+#endif /* !GRID_FIT_METRICS */
}
@@ -2327,6 +2382,11 @@
FT_Size_RequestRec req;
+ if ( char_width < 1 * 64 )
+ char_width = 1 * 64;
+ if ( char_height < 1 * 64 )
+ char_height = 1 * 64;
+
req.type = FT_SIZE_REQUEST_TYPE_NOMINAL;
req.width = char_width;
req.height = char_height;
@@ -2347,6 +2407,22 @@
FT_Size_RequestRec req;
+ if ( pixel_width == 0 )
+ pixel_width = pixel_height;
+ else if ( pixel_height == 0 )
+ pixel_height = pixel_width;
+
+ if ( pixel_width < 1 )
+ pixel_width = 1;
+ if ( pixel_height < 1 )
+ pixel_height = 1;
+
+ /* use `>=' to avoid potention compiler warning on 16bit platforms */
+ if ( pixel_width >= 0xFFFFU )
+ pixel_width = 0xFFFFU;
+ if ( pixel_height >= 0xFFFFU )
+ pixel_height = 0xFFFFU;
+
req.type = FT_SIZE_REQUEST_TYPE_NOMINAL;
req.width = pixel_width << 6;
req.height = pixel_height << 6;