changed the structure of FT_Outline in order to pack all outline flags in a single integer.. Changed the rest of the library and demo programs accordingly..
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 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369
diff --git a/demos/src/fttimer.c b/demos/src/fttimer.c
index 0d69c6a..8aaf6bd 100644
--- a/demos/src/fttimer.c
+++ b/demos/src/fttimer.c
@@ -151,11 +151,11 @@
if ( error )
return error;
- glyph->outline.second_pass = 0;
- glyph->outline.dropout_mode = 0;
+ glyph->outline.outline_flags |= ft_outline_single_pass |
+ ft_outline_ignore_dropouts;
if (force_low)
- glyph->outline.high_precision = 0;
+ glyph->outline.outline_flags &= ~ft_outline_high_precision;
/* debugging */
#if 0
@@ -176,9 +176,9 @@
&outlines[cur_glyph] );
/* copy the glyph outline into it */
- glyph->outline.second_pass = 0;
+ glyph->outline.outline_flags |= ft_outline_single_pass;
if (force_low)
- glyph->outline.high_precision = 0;
+ glyph->outline.outline_flags &= ~ft_outline_high_precision;
FT_Copy_Outline( &glyph->outline, &outlines[cur_glyph] );
@@ -211,7 +211,7 @@
FT_Error ConvertRaster( int index )
{
- outlines[index].second_pass = 0;
+ outlines[index].outline_flags |= ~ft_outline_single_pass;
return FT_Get_Outline_Bitmap( library, &outlines[index], &Bit );
}
diff --git a/demos/src/ftview.c b/demos/src/ftview.c
index 49f5521..1390b7f 100644
--- a/demos/src/ftview.c
+++ b/demos/src/ftview.c
@@ -181,7 +181,7 @@
memset( bit_buffer, 0, size );
if (low_prec)
- glyph->outline.high_precision = 0;
+ glyph->outline.outline_flags &= ~ft_outline_high_precision;
FT_Get_Outline_Bitmap( library, &glyph->outline, &bit2 );
}
diff --git a/include/ftimage.h b/include/ftimage.h
index 565109c..1d51215 100644
--- a/include/ftimage.h
+++ b/include/ftimage.h
@@ -250,34 +250,10 @@
/* defined by the points `contours[0]+1' to */
/* `contours[1]', etc. */
/* */
- /* owner :: This flag is a boolean which is set whenever the */
- /* outline structure/object owns the arrays it */
- /* refers to in the fields `points', `flags', and */
- /* `contours'. */
- /* */
- /* high_precision :: This flag is set automatically by the FreeType */
- /* library. It indicates that the scan-line */
- /* converter should use a higher precision when */
- /* rendering the outline. This is useful at small */
- /* pixel sizes to get adequate results, though at */
- /* the price of slower rendering. Don't try to */
- /* render large outlines with this flag set. Note */
- /* that it may be ignored in later implementations. */
- /* */
- /* second_pass :: A boolean which is set when the scan-line */
- /* converter should perform a second pass to */
- /* eliminate vertical drop-outs (only vertical */
- /* drop-outs are checked on the first pass). This */
- /* field may be ignored by later implementations. */
- /* */
- /* dropout_mode :: Specifies the drop-out control mode to use while */
- /* rendering an outline. Valid values are 0 (no */
- /* drop out check), 1, 2, 4, and 5. See the */
- /* TrueType specification for more details. A */
- /* value of 2 is usually an excellent generic */
- /* choice. This field may be ignored by some */
- /* raster implementations. */
- /* */
+ /* outline_flags :: a set of bit flags used to characterize the */
+ /* outline and give hints to the scan-converter */
+ /* and hinter on how to convert/grid-fit it.. */
+ /* see FT_Outline_Flags.. */
/* */
typedef struct FT_Outline_
{
@@ -288,14 +264,70 @@
char* flags; /* the points flags */
short* contours; /* the contour end points */
- char owner; /* the outline owns the coordinates, */
- /* flags, and contours array it uses */
+ int outline_flags; /* outline masks */
+
+ } FT_Outline;
- char high_precision; /* high precision rendering */
- char second_pass; /* two sweeps rendering */
- char dropout_mode; /* dropout mode */
+ /*************************************************************************/
+ /* */
+ /* <Enum> */
+ /* FT_Outline_Flags */
+ /* */
+ /* <Description> */
+ /* A simple type used to enumerates the flags in an outline's */
+ /* "outline_flags" field. */
+ /* */
+ /* <Fields> */
+ /* ft_outline_owner :: */
+ /* when set, this flag indicates that the outline's field arrays */
+ /* (i.e. "points", "flags" & "contours") are "owned" by the */
+ /* outline object, and should thus be freed when it is destroyed. */
+ /* */
+ /* ft_outline_even_odd_fill :: */
+ /* by default, outlines are filled using the non-zero winding */
+ /* rule. When set to 1, the outline will be filled using the */
+ /* even-odd fill rule.. (XXX: unimplemented) */
+ /* */
+ /* ft_outline_reverse_fill :: */
+ /* By default, outside contours of an outline are oriented in */
+ /* clock-wise direction, as defined in the TrueType specification. */
+ /* This flag is set when the outline uses the opposite direction, */
+ /* (typically for Type 1 fonts). This flag is ignored by the */
+ /* scan-converter. However, it is very important for the */
+ /* auto-hinter.. */
+ /* */
+ /* ft_outline_ignore_dropouts :: */
+ /* By default, the scan converter will try to detect drop-outs */
+ /* in an outline and correct the glyph bitmap to ensure consistent */
+ /* shape continuity. When set, this flag hints the scan-line */
+ /* converter to ignore such cases. */
+ /* */
+ /* ft_outline_high_precision :: */
+ /* this flag indicates that the scan-line converter should try */
+ /* to convert this outline to bitmaps with the highest possible */
+ /* quality. It is typically set for small character sizes. Note */
+ /* that this is only a hint, that might be completely ignored */
+ /* by a given scan-converter. */
+ /* */
+ /* ft_outline_single_pass :: */
+ /* this flag is set to force a given scan-converter to only */
+ /* use a single pass over the outline to render a bitmap glyph */
+ /* image. Normally, it is set for very large character sizes. */
+ /* It is only a hint, that might be completely ignored by a */
+ /* given scan-converter. */
+ /* */
+ typedef enum FT_Outline_Flags_
+ {
+ ft_outline_none = 0,
+ ft_outline_owner = 1,
+ ft_outline_even_odd_fill = 2,
+ ft_outline_reverse_fill = 4,
+ ft_outline_ignore_dropouts = 8,
+ ft_outline_high_precision = 256,
+ ft_outline_single_pass = 512
+
+ } FT_Outline_Flags;
- } FT_Outline;
#define FT_CURVE_TAG( flag ) (flag & 3)
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 9e7f0b6..9b06afc 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -2256,7 +2256,7 @@
static
- const FT_Outline null_outline = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ const FT_Outline null_outline = { 0, 0, 0, 0, 0, 0 };
/*************************************************************************/
@@ -2314,14 +2314,14 @@
ALLOC_ARRAY( outline->contours, numContours, FT_UShort ) )
goto Fail;
- outline->n_points = (FT_UShort)numPoints;
- outline->n_contours = (FT_Short)numContours;
- outline->owner = TRUE;
+ outline->n_points = (FT_UShort)numPoints;
+ outline->n_contours = (FT_Short)numContours;
+ outline->outline_flags |= ft_outline_owner;
return FT_Err_Ok;
Fail:
- outline->owner = TRUE;
+ outline->outline_flags |= ft_outline_owner;
FT_Done_Outline( library, outline );
return error;
@@ -2366,7 +2366,7 @@
if ( outline )
{
- if ( outline->owner )
+ if ( outline->outline_flags & ft_outline_owner )
{
FREE( outline->points );
FREE( outline->flags );
diff --git a/src/base/ftoutln.c b/src/base/ftoutln.c
index 20be50c..222cf7b 100644
--- a/src/base/ftoutln.c
+++ b/src/base/ftoutln.c
@@ -50,6 +50,8 @@
FT_Error FT_Copy_Outline( FT_Outline* source,
FT_Outline* target )
{
+ FT_Int is_owner;
+
if ( !source || !target ||
source->n_points != target->n_points ||
source->n_contours != target->n_contours )
@@ -64,10 +66,12 @@
MEM_Copy( target->contours, source->contours,
source->n_contours * sizeof ( FT_Short ) );
- target->high_precision = source->high_precision;
- target->second_pass = target->second_pass;
- target->dropout_mode = source->dropout_mode;
-
+ /* copy all flags, except the "ft_outline_owner" one */
+ is_owner = target->outline_flags & ft_outline_owner;
+ target->outline_flags = source->outline_flags;
+
+ target->outline_flags &= ~ft_outline_owner;
+ target->outline_flags |= is_owner;
return FT_Err_Ok;
}
diff --git a/src/base/ftraster.c b/src/base/ftraster.c
index 99dcf35..2a9c36c 100644
--- a/src/base/ftraster.c
+++ b/src/base/ftraster.c
@@ -4121,10 +4121,17 @@ Scan_DropOuts :
ras.outline = outline;
ras.target = *target_map;
-
+
+ /* Note that we always use drop-out mode 2, because it seems that */
+ /* it's the only way to do to get results consistent with Windows */
+ /* rendering.. */
+#if 0
ras.dropout_mode = outline->dropout_mode;
- ras.second_pass = outline->second_pass;
- SET_High_Precision( outline->high_precision );
+#else
+ ras.dropout_mode = 2;
+#endif
+ ras.second_pass = (outline->outline_flags & ft_outline_single_pass) == 0;
+ SET_High_Precision( outline->outline_flags & ft_outline_high_precision );
switch ( target_map->pixel_mode )
{
diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c
index cd96d33..816dfe7 100644
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -550,8 +550,8 @@
/* now load the glyph outline if necessary */
error = TT_Load_Glyph( size, slot, glyph_index, load_flags );
- /* force drop-out mode to 2 */
- slot->outline.dropout_mode = 2;
+ /* force drop-out mode to 2 - irrelevant now */
+ /* slot->outline.dropout_mode = 2; */
return error;
}
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index 5e66247..34888b4 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -968,7 +968,9 @@
glyph->outline.n_points = num_points;
glyph->outline.n_contours = num_contours;
- glyph->outline.second_pass = TRUE;
+
+ /* glyph->outline.second_pass = TRUE; */
+ glyph->outline.outline_flags &= ~ft_outline_single_pass;
/* translate array so that (0,0) is the glyph's origin */
translate_array( (TT_UShort)(num_points + 2),
@@ -1125,12 +1127,15 @@
glyph->metrics.horiAdvance = widths[glyph_index] << 6;
}
+/* drop-out mode is irrelevant, we always use mode 2 */
+#if 0
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
if (loader->exec)
glyph->outline.dropout_mode = (TT_Char)loader->exec->GS.scan_type;
#else
glyph->outline.dropout_mode = 2;
#endif
+#endif
/* set glyph dimensions */
glyph->metrics.width = bbox.xMax - bbox.xMin;
@@ -1257,8 +1262,11 @@
}
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
- if (size)
- glyph->outline.high_precision = ( size->root.metrics.y_ppem < 24 );
+ /* clear all outline flags, except the "owner" one */
+ glyph->outline.outline_flags &= ft_outline_owner;
+
+ if (size && size->root.metrics.y_ppem < 24 )
+ glyph->outline.outline_flags |= ft_outline_high_precision;
/************************************************************************/
/* let's initialise the rest of our loader now */
diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c
index a24cfb9..a125563 100644
--- a/src/type1/t1gload.c
+++ b/src/type1/t1gload.c
@@ -1537,9 +1537,16 @@
glyph->root.format = ft_glyph_format_outline;
+ glyph->root.outline.outline_flags &= ft_outline_owner;
+
+ if ( size->root.metrics.y_ppem < 24 )
+ glyph->root.outline.outline_flags |= ft_outline_high_precision;
+
+ /*
glyph->root.outline.second_pass = TRUE;
glyph->root.outline.high_precision = ( size->root.metrics.y_ppem < 24 );
glyph->root.outline.dropout_mode = 2;
+ */
if ( hinting )
{
diff --git a/src/type1z/t1gload.c b/src/type1z/t1gload.c
index 54abf7d..ea94980 100644
--- a/src/type1z/t1gload.c
+++ b/src/type1z/t1gload.c
@@ -1275,9 +1275,14 @@
glyph->root.format = ft_glyph_format_outline;
+ glyph->root.outline.outline_flags &= ft_outline_owner;
+ if ( size->root.metrics.y_ppem < 24 )
+ glyph->root.outline.outline_flags |= ft_outline_high_precision;
+ /*
glyph->root.outline.second_pass = TRUE;
glyph->root.outline.high_precision = ( size->root.metrics.y_ppem < 24 );
glyph->root.outline.dropout_mode = 2;
+ */
if ( (load_flags & FT_LOAD_NO_SCALE) == 0 )
{