1 --- freetype-2.1.2/src/base/ftobjs.c.slighthint Sat Jun 15 21:14:16 2002
2 +++ freetype-2.1.2/src/base/ftobjs.c Wed Jul 3 16:40:03 2002
7 + /* documentation is in freetype.h */
9 + FT_EXPORT_DEF( void )
10 + FT_Set_Hint_Flags( FT_Face face,
13 + FT_Face_Internal internal;
18 + internal = face->internal;
20 + internal->hint_flags = (FT_UInt)flags;
24 ft_lookup_glyph_renderer( FT_GlyphSlot slot );
26 --- freetype-2.1.2/src/psaux/t1decode.c.slighthint Wed May 22 00:53:25 2002
27 +++ freetype-2.1.2/src/psaux/t1decode.c Wed Jul 3 17:35:04 2002
29 /* apply hints to the loaded glyph outline now */
30 hinter->apply( hinter->hints,
32 - (PSH_Globals)builder->hints_globals );
33 + (PSH_Globals)builder->hints_globals,
34 + decoder->hint_flags );
37 /* add current outline to the glyph slot */
38 @@ -1147,10 +1148,13 @@
39 decoder->num_glyphs = face->num_glyphs;
40 decoder->glyph_names = glyph_names;
41 decoder->blend = blend;
42 + decoder->hint_flags = face->internal->hint_flags;
43 decoder->parse_callback = parse_callback;
45 decoder->funcs = t1_decoder_funcs;
52 --- freetype-2.1.2/src/pshinter/pshalgo1.c.slighthint Fri Apr 12 05:31:46 2002
53 +++ freetype-2.1.2/src/pshinter/pshalgo1.c Wed Jul 3 16:40:03 2002
56 ps1_hints_apply( PS_Hints ps_hints,
58 - PSH_Globals globals )
59 + PSH_Globals globals,
60 + FT_ULong hint_flags )
62 PSH1_Hint_TableRec hints;
64 --- freetype-2.1.2/src/pshinter/pshalgo1.h.slighthint Tue Dec 4 20:22:05 2001
65 +++ freetype-2.1.2/src/pshinter/pshalgo1.h Wed Jul 3 16:40:03 2002
68 ps1_hints_apply( PS_Hints ps_hints,
70 - PSH_Globals globals );
71 + PSH_Globals globals,
72 + FT_ULong hint_flags );
76 --- freetype-2.1.2/src/pshinter/pshalgo2.c.slighthint Wed Jul 3 16:40:03 2002
77 +++ freetype-2.1.2/src/pshinter/pshalgo2.c Wed Jul 3 18:08:53 2002
83 + psh2_hint_snap_stem_side_delta ( FT_Fixed pos,
86 + FT_Fixed delta1 = ( ( pos + 32 ) & -64 ) - pos;
87 + FT_Fixed delta2 = ( ( pos + len + 32 ) & -64 ) - pos - len;
89 + if ( ABS( delta1 ) <= ABS( delta2 ) )
101 psh2_hint_align( PSH2_Hint hint,
105 + FT_ULong hint_flags )
107 PSH_Dimension dim = &globals->dimension[dimension];
108 FT_Fixed scale = dim->scale_mult;
109 @@ -372,16 +391,33 @@
111 PSH_AlignmentRec align;
113 + if ( ( dimension == 0 && ( hint_flags & FT_HINT_NO_VSTEM_ALIGN ) != 0 ) ||
114 + ( dimension == 1 && ( hint_flags & FT_HINT_NO_HSTEM_ALIGN ) != 0 ) )
116 + hint->cur_pos = pos;
117 + hint->cur_len = len;
119 + psh2_hint_set_fitted( hint );
121 - /* compute fitted width/height */
123 - if ( hint->org_len )
125 - fit_len = psh_dimension_snap_width( dim, hint->org_len );
126 - if ( fit_len < 64 )
129 - fit_len = ( fit_len + 32 ) & -64;
133 + if ( ( hint_flags & FT_HINT_NO_INTEGER_STEM ) == 0 )
135 + /* compute fitted width/height */
137 + if ( hint->org_len )
139 + fit_len = psh_dimension_snap_width( dim, hint->org_len );
140 + if ( fit_len < 64 )
143 + fit_len = ( fit_len + 32 ) & -64;
151 hint->cur_len = fit_len;
154 /* ensure that parent is already fitted */
155 if ( !psh2_hint_is_fitted( parent ) )
156 - psh2_hint_align( parent, globals, dimension );
157 + psh2_hint_align( parent, globals, dimension, hint_flags );
159 par_org_center = parent->org_pos + ( parent->org_len / 2);
160 par_cur_center = parent->cur_pos + ( parent->cur_len / 2);
161 @@ -443,22 +479,105 @@
162 pos = par_cur_center + cur_delta - ( len >> 1 );
165 - /* normal processing */
166 - if ( ( fit_len / 64 ) & 1 )
168 - /* odd number of pixels */
169 - fit_center = ( ( pos + ( len >> 1 ) ) & -64 ) + 32;
173 - /* even number of pixels */
174 - fit_center = ( pos + ( len >> 1 ) + 32 ) & -64;
177 - hint->cur_pos = fit_center - ( fit_len >> 1 );
179 + if ( ( hint_flags & FT_HINT_NO_INTEGER_STEM ) == 0 )
181 + /* normal processing */
182 + if ( ( fit_len / 64 ) & 1 )
184 + /* odd number of pixels */
185 + fit_center = ( ( pos + ( len >> 1 ) ) & -64 ) + 32;
189 + /* even number of pixels */
190 + fit_center = ( pos + ( len >> 1 ) + 32 ) & -64;
193 + hint->cur_pos = fit_center - ( fit_len >> 1 );
197 + /* Stems less than one pixel wide are easy - we want to
198 + * make them as dark as possible, so they must fall within
199 + * one pixel. If the stem is split between two pixels
200 + * then snap the edge that is nearer to the pixel boundary
201 + * to the pixel boundary
205 + if ( ( pos + len + 63 ) / 64 != pos / 64 + 1 )
206 + pos += psh2_hint_snap_stem_side_delta ( pos, len );
208 + /* Position stems other to minimize the amount of mid-grays.
209 + * There are, in general, two positions that do this,
210 + * illustrated as A) and B) below.
214 + * A) |--------------------------------|
215 + * B) |--------------------------------|
216 + * C) |--------------------------------|
218 + * Position A) (split the excess stem equally) should be better
219 + * for stems of width N + f where f < 0.5
221 + * Position B) (split the deficiency equally) should be better
222 + * for stems of width N + f where f > 0.5
224 + * It turns out though that minimizing the total number of lit
225 + * pixels is also important, so position C), with one edge
226 + * aligned with a pixel boundary is actually preferable
227 + * to A). There are also more possibile positions for C) than
228 + * for A) or B), so it involves less distortion of the overall
233 + FT_Fixed frac_len = len & 63;
234 + FT_Fixed center = pos + ( len >> 1 );
236 + FT_Fixed delta_a, delta_b;
238 + if ( ( len / 64 ) & 1 )
240 + delta_a = ( center & -64 ) + 32 - center;
241 + delta_b = ( ( center + 32 ) & - 64 ) - center;
245 + delta_a = ( ( center + 32 ) & - 64 ) - center;
246 + delta_b = ( center & -64 ) + 32 - center;
249 + /* We choose between B) and C) above based on the amount
250 + * of fractinal stem width; for small amounts, choose
251 + * C) always, for large amounts, B) always, and inbetween,
252 + * pick whichever one involves less stem movement.
256 + pos += psh2_hint_snap_stem_side_delta ( pos, len );
258 + else if (frac_len < 48)
260 + FT_Fixed side_delta = psh2_hint_snap_stem_side_delta ( pos, len );
262 + if ( ABS( side_delta ) < ABS( delta_b ) )
273 + hint->cur_pos = pos;
279 psh2_hint_set_fitted( hint );
284 psh2_hint_table_align_hints( PSH2_Hint_Table table,
288 + FT_ULong hint_flags )
293 count = table->max_hints;
295 for ( ; count > 0; count--, hint++ )
296 - psh2_hint_align( hint, globals, dimension );
297 + psh2_hint_align( hint, globals, dimension, hint_flags );
301 @@ -1494,7 +1614,8 @@
303 ps2_hints_apply( PS_Hints ps_hints,
305 - PSH_Globals globals )
306 + PSH_Globals globals,
307 + FT_ULong hint_flags )
309 PSH2_GlyphRec glyphrec;
310 PSH2_Glyph glyph = &glyphrec;
311 @@ -1532,7 +1653,8 @@
312 /* compute aligned stem/hints positions */
313 psh2_hint_table_align_hints( &glyph->hint_tables[dimension],
319 /* find strong points, align them, then interpolate others */
320 psh2_glyph_find_strong_points( glyph, dimension );
321 --- freetype-2.1.2/src/pshinter/pshalgo2.h.slighthint Tue Dec 4 20:22:05 2001
322 +++ freetype-2.1.2/src/pshinter/pshalgo2.h Wed Jul 3 16:40:03 2002
325 ps2_hints_apply( PS_Hints ps_hints,
327 - PSH_Globals globals );
328 + PSH_Globals globals,
329 + FT_ULong hint_flags );
333 --- freetype-2.1.2/include/freetype/internal/ftobjs.h.slighthint Mon Jun 10 19:03:35 2002
334 +++ freetype-2.1.2/include/freetype/internal/ftobjs.h Wed Jul 3 16:40:03 2002
336 FT_Vector transform_delta;
337 FT_Int transform_flags;
339 + FT_UInt hint_flags;
341 const char* postscript_name;
343 } FT_Face_InternalRec;
344 --- freetype-2.1.2/include/freetype/internal/pshints.h.slighthint Sat Mar 30 08:16:33 2002
345 +++ freetype-2.1.2/include/freetype/internal/pshints.h Wed Jul 3 16:40:03 2002
348 (*T1_Hints_ApplyFunc)( T1_Hints hints,
350 - PSH_Globals globals );
351 + PSH_Globals globals,
352 + FT_ULong hint_flags );
355 /*************************************************************************/
356 --- freetype-2.1.2/include/freetype/internal/psaux.h.slighthint Fri Mar 29 18:23:28 2002
357 +++ freetype-2.1.2/include/freetype/internal/psaux.h Wed Jul 3 16:40:03 2002
359 FT_Vector flex_vectors[7];
361 PS_Blend blend; /* for multiple master support */
362 + FT_ULong hint_flags;
364 T1_Decoder_Callback parse_callback;
365 T1_Decoder_FuncsRec funcs;
366 --- freetype-2.1.2/include/freetype/freetype.h.slighthint Sun Jun 23 06:57:31 2002
367 +++ freetype-2.1.2/include/freetype/freetype.h Wed Jul 3 16:40:03 2002
369 /* FT_Set_Char_Size */
370 /* FT_Set_Pixel_Sizes */
371 /* FT_Set_Transform */
372 + /* FT_Set_Hint_Flags */
374 + /* FT_HINT_NO_INTEGER_STEM */
375 + /* FT_HINT_NO_HSTEM_ALIGN */
376 + /* FT_HINT_NO_VSTEM_ALIGN */
379 /* FT_Get_Char_Index */
380 /* FT_Get_Name_Index */
381 @@ -2181,9 +2187,67 @@
386 + /*************************************************************************/
389 + /* FT_Set_Hint_Flags */
391 + /* <Description> */
392 + /* A function used to set a number of flags that are used to control */
393 + /* the hinting process when glyphs are loaded. */
396 + /* face :: A handle to the source face object. */
399 + /* flags :: A set of bit flags that control the hinting process */
400 + /* see the FT_HINT_XXX constants for details. */
403 + /* The interpretation of the flags depends on the hinter module in */
404 + /* use. Not all modules will support all flags */
407 + FT_Set_Hint_Flags( FT_Face face,
408 + FT_ULong hint_flags );
411 + /*************************************************************************/
414 + /* FT_HINT_NO_INTEGER_STEM */
416 + /* <Description> */
417 + /* A bit-field constant, used with FT_Set_Hint_Flags() to to suppress */
418 + /* snapping of stem widths to integer values */
420 +#define FT_HINT_NO_INTEGER_STEM 1
422 + /*************************************************************************/
425 + /* FT_HINT_NO_HSTEM_ALIGN */
427 + /* <Description> */
428 + /* A bit-field constant, used with FT_Set_Hint_Flags() to to suppress */
429 + /* alignment of horizontal stems with the pixel grid. */
431 +#define FT_HINT_NO_HSTEM_ALIGN 2
433 /*************************************************************************/
436 + /* FT_HINT_NO_VSTEM_ALIGN */
438 + /* <Description> */
439 + /* A bit-field constant, used with FT_Set_Hint_Flags() to to suppress */
440 + /* alignment of vertical stems with the pixel grid */
442 +#define FT_HINT_NO_VSTEM_ALIGN 4
444 + /*************************************************************************/