]> git.pld-linux.org Git - packages/freetype.git/blob - freetype2-slighthint.patch
- fixes
[packages/freetype.git] / freetype2-slighthint.patch
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
3 @@ -380,6 +380,22 @@
4    }
5  
6  
7 +  /* documentation is in freetype.h */
8 +
9 +  FT_EXPORT_DEF( void )
10 +  FT_Set_Hint_Flags( FT_Face     face,
11 +                     FT_ULong    flags )
12 +  {
13 +    FT_Face_Internal  internal;
14 +
15 +    if ( !face )
16 +      return;
17 +
18 +    internal = face->internal;
19 +
20 +    internal->hint_flags = (FT_UInt)flags;
21 +  }
22 +
23    static FT_Renderer
24    ft_lookup_glyph_renderer( FT_GlyphSlot  slot );
25  
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
28 @@ -752,7 +752,8 @@
29              /* apply hints to the loaded glyph outline now */
30              hinter->apply( hinter->hints,
31                             builder->current,
32 -                           (PSH_Globals)builder->hints_globals );
33 +                           (PSH_Globals)builder->hints_globals,
34 +                          decoder->hint_flags );
35            }
36  
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;
44  
45      decoder->funcs          = t1_decoder_funcs;
46  
47 +    
48 +
49      return 0;
50    }
51  
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
54 @@ -744,7 +744,8 @@
55    FT_Error
56    ps1_hints_apply( PS_Hints     ps_hints,
57                     FT_Outline*  outline,
58 -                   PSH_Globals  globals )
59 +                   PSH_Globals  globals,
60 +                  FT_ULong     hint_flags )
61    {
62      PSH1_Hint_TableRec  hints;
63      FT_Error            error = 0;
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
66 @@ -88,7 +88,8 @@
67    extern FT_Error
68    ps1_hints_apply( PS_Hints     ps_hints,
69                     FT_Outline*  outline,
70 -                   PSH_Globals  globals );
71 +                   PSH_Globals  globals,
72 +                  FT_ULong     hint_flags );
73  
74  
75  #ifdef DEBUG_HINTER
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
78 @@ -352,10 +352,29 @@
79  #endif
80  
81  
82 +static FT_Fixed
83 +  psh2_hint_snap_stem_side_delta ( FT_Fixed pos,
84 +                                  FT_Fixed len )
85 +  {
86 +    FT_Fixed delta1 = ( ( pos + 32 ) & -64 ) - pos;
87 +    FT_Fixed delta2 = ( ( pos + len + 32 ) & -64  ) - pos - len;
88 +             
89 +    if ( ABS( delta1 ) <= ABS( delta2 ) )
90 +    {
91 +      return delta1;
92 +    }
93 +    else
94 +    {
95 +      return delta2;
96 +    }
97 +  }
98 +
99 +
100    static void
101    psh2_hint_align( PSH2_Hint    hint,
102                     PSH_Globals  globals,
103 -                   FT_Int       dimension )
104 +                   FT_Int       dimension,
105 +                  FT_ULong     hint_flags )
106    {
107      PSH_Dimension  dim   = &globals->dimension[dimension];
108      FT_Fixed       scale = dim->scale_mult;
109 @@ -372,16 +391,33 @@
110  
111        PSH_AlignmentRec  align;
112  
113 +      if ( ( dimension == 0 && ( hint_flags & FT_HINT_NO_VSTEM_ALIGN ) != 0 ) ||
114 +          ( dimension == 1 && ( hint_flags & FT_HINT_NO_HSTEM_ALIGN ) != 0 ) )
115 +      {
116 +       hint->cur_pos = pos;
117 +       hint->cur_len = len;
118 +
119 +       psh2_hint_set_fitted( hint );
120  
121 -      /* compute fitted width/height */
122 -      fit_len = 0;
123 -      if ( hint->org_len )
124 -      {
125 -        fit_len = psh_dimension_snap_width( dim, hint->org_len );
126 -        if ( fit_len < 64 )
127 -          fit_len = 64;
128 -        else
129 -          fit_len = ( fit_len + 32 ) & -64;
130 +       return;
131 +      }
132 +    
133 +      if ( ( hint_flags & FT_HINT_NO_INTEGER_STEM ) == 0 )
134 +      {
135 +       /* compute fitted width/height */
136 +       fit_len = 0;
137 +       if ( hint->org_len )
138 +       {
139 +         fit_len = psh_dimension_snap_width( dim, hint->org_len );
140 +         if ( fit_len < 64 )
141 +           fit_len = 64;
142 +         else
143 +            fit_len = ( fit_len + 32 ) & -64;
144 +       }
145 +      }
146 +      else
147 +      {
148 +       fit_len = len;
149        }
150  
151        hint->cur_len = fit_len;
152 @@ -427,7 +463,7 @@
153  
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 );
158  
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 );
163            }
164  
165 -          /* normal processing */
166 -          if ( ( fit_len / 64 ) & 1 )
167 -          {
168 -            /* odd number of pixels */
169 -            fit_center = ( ( pos + ( len >> 1 ) ) & -64 ) + 32;
170 -          }
171 -          else
172 -          {
173 -            /* even number of pixels */
174 -            fit_center = ( pos + ( len >> 1 ) + 32 ) & -64;
175 -          }
176 -
177 -          hint->cur_pos = fit_center - ( fit_len >> 1 );
178 -        }
179 +         if ( ( hint_flags & FT_HINT_NO_INTEGER_STEM ) == 0 )
180 +         {
181 +           /* normal processing */
182 +           if ( ( fit_len / 64 ) & 1 )
183 +            {
184 +             /* odd number of pixels */
185 +             fit_center = ( ( pos + ( len >> 1 ) ) & -64 ) + 32;
186 +            }
187 +           else
188 +           {
189 +             /* even number of pixels */
190 +              fit_center = ( pos + ( len >> 1 ) + 32 ) & -64;
191 +           }
192 +
193 +           hint->cur_pos = fit_center - ( fit_len >> 1 );
194 +         }
195 +         else
196 +         {
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
202 +            */
203 +           if (len <= 64)
204 +           {
205 +             if ( ( pos + len + 63 ) / 64  != pos / 64 + 1 )
206 +               pos += psh2_hint_snap_stem_side_delta ( pos, len );
207 +           }
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.
211 +            *
212 +            *   +                   +                   +                   +
213 +            *
214 +            * A)             |--------------------------------|
215 +            * B)   |--------------------------------|
216 +            * C)       |--------------------------------|
217 +            *
218 +            * Position A) (split the excess stem equally) should be better
219 +            * for stems of width N + f where f < 0.5
220 +            *
221 +            * Position B) (split the deficiency equally) should be better
222 +            * for stems of width N + f where f > 0.5
223 +            *
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
229 +            * character shape.
230 +            */
231 +           else
232 +           {
233 +             FT_Fixed frac_len = len & 63;
234 +             FT_Fixed center = pos + ( len >> 1 );
235 +
236 +             FT_Fixed delta_a, delta_b;
237 +
238 +             if ( ( len / 64 ) & 1 )
239 +             {
240 +               delta_a = ( center & -64 ) + 32 - center;
241 +               delta_b = ( ( center + 32 ) & - 64 ) - center;
242 +             }
243 +             else
244 +             {
245 +               delta_a = ( ( center + 32 ) & - 64 ) - center;
246 +               delta_b = ( center & -64 ) + 32 - center;
247 +             }
248 +
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.
253 +              */
254 +             if (frac_len < 32)
255 +             {
256 +               pos += psh2_hint_snap_stem_side_delta ( pos, len );
257 +             }
258 +             else if (frac_len < 48)
259 +             {
260 +               FT_Fixed side_delta = psh2_hint_snap_stem_side_delta ( pos, len );
261 +                 
262 +               if ( ABS( side_delta ) < ABS( delta_b ) )
263 +                 pos += side_delta;
264 +               else
265 +                 pos += delta_b;
266 +             }
267 +             else
268 +             {
269 +               pos += delta_b;
270 +             }
271 +           }
272 +
273 +           hint->cur_pos = pos;
274 +         }
275 +       }
276        }
277 -
278 +      
279        psh2_hint_set_fitted( hint );
280  
281  #ifdef DEBUG_HINTER
282 @@ -472,7 +591,8 @@
283    static void
284    psh2_hint_table_align_hints( PSH2_Hint_Table  table,
285                                 PSH_Globals      globals,
286 -                               FT_Int           dimension )
287 +                               FT_Int           dimension,
288 +                              FT_ULong         hint_flags )
289    {
290      PSH2_Hint      hint;
291      FT_UInt        count;
292 @@ -500,7 +620,7 @@
293      count = table->max_hints;
294  
295      for ( ; count > 0; count--, hint++ )
296 -      psh2_hint_align( hint, globals, dimension );
297 +      psh2_hint_align( hint, globals, dimension, hint_flags );
298    }
299  
300  
301 @@ -1494,7 +1614,8 @@
302    FT_Error
303    ps2_hints_apply( PS_Hints     ps_hints,
304                     FT_Outline*  outline,
305 -                   PSH_Globals  globals )
306 +                   PSH_Globals  globals,
307 +                  FT_ULong     hint_flags )
308    {
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],
314                                     glyph->globals,
315 -                                   dimension );
316 +                                   dimension,
317 +                                  hint_flags );
318  
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
323 @@ -190,7 +190,8 @@
324    extern FT_Error
325    ps2_hints_apply( PS_Hints     ps_hints,
326                     FT_Outline*  outline,
327 -                   PSH_Globals  globals );
328 +                   PSH_Globals  globals,
329 +                  FT_ULong     hint_flags );
330  
331  
332  FT_END_HEADER
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
335 @@ -302,6 +302,8 @@
336      FT_Vector    transform_delta;
337      FT_Int       transform_flags;
338  
339 +    FT_UInt      hint_flags;
340 +
341      const char*  postscript_name;
342  
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
346 @@ -280,7 +280,8 @@
347    typedef FT_Error
348    (*T1_Hints_ApplyFunc)( T1_Hints     hints,
349                           FT_Outline*  outline,
350 -                         PSH_Globals  globals );
351 +                         PSH_Globals  globals,
352 +                        FT_ULong     hint_flags );
353  
354  
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
358 @@ -644,6 +644,7 @@
359      FT_Vector            flex_vectors[7];
360  
361      PS_Blend             blend;       /* for multiple master support */
362 +    FT_ULong             hint_flags;
363  
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
368 @@ -121,6 +121,12 @@
369    /*    FT_Set_Char_Size                                                   */
370    /*    FT_Set_Pixel_Sizes                                                 */
371    /*    FT_Set_Transform                                                   */
372 +  /*    FT_Set_Hint_Flags                                                  */
373 +  /*                                                                       */
374 +  /*    FT_HINT_NO_INTEGER_STEM                                            */
375 +  /*    FT_HINT_NO_HSTEM_ALIGN                                             */
376 +  /*    FT_HINT_NO_VSTEM_ALIGN                                             */
377 +  /*                                                                       */
378    /*    FT_Load_Glyph                                                      */
379    /*    FT_Get_Char_Index                                                  */
380    /*    FT_Get_Name_Index                                                  */
381 @@ -2181,9 +2187,67 @@
382                      FT_Matrix*  matrix,
383                      FT_Vector*  delta );
384  
385 +  
386 +  /*************************************************************************/
387 +  /*                                                                       */
388 +  /* <Function>                                                            */
389 +  /*    FT_Set_Hint_Flags                                                  */
390 +  /*                                                                       */
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.                        */
394 +  /*                                                                       */
395 +  /* <InOut>                                                               */
396 +  /*    face   :: A handle to the source face object.                      */
397 +  /*                                                                       */
398 +  /* <Input>                                                               */
399 +  /*    flags  :: A set of bit flags that control the hinting process      */
400 +  /*              see the FT_HINT_XXX constants for details.               */
401 +  /*                                                                       */
402 +  /* <Note>                                                                */
403 +  /*    The interpretation of the flags depends on the hinter module in    */
404 +  /*    use. Not all modules will support all flags                        */
405 +  /*                                                                       */
406 +  FT_EXPORT( void )
407 +  FT_Set_Hint_Flags( FT_Face     face,
408 +                     FT_ULong    hint_flags );
409 +  
410 +
411 +  /*************************************************************************/
412 +  /*                                                                       */
413 +  /* <Constant>                                                            */
414 +  /*    FT_HINT_NO_INTEGER_STEM                                            */
415 +  /*                                                                       */
416 +  /* <Description>                                                         */
417 +  /*    A bit-field constant, used with FT_Set_Hint_Flags() to to suppress */
418 +  /*    snapping of stem widths to integer values                          */
419 +  /*                                                                       */
420 +#define FT_HINT_NO_INTEGER_STEM 1
421 +
422 +  /*************************************************************************/
423 +  /*                                                                       */
424 +  /* <Constant>                                                            */
425 +  /*    FT_HINT_NO_HSTEM_ALIGN                                             */
426 +  /*                                                                       */
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.                 */
430 +  /*                                                                       */
431 +#define FT_HINT_NO_HSTEM_ALIGN 2
432  
433    /*************************************************************************/
434    /*                                                                       */
435 +  /* <Constant>                                                            */
436 +  /*    FT_HINT_NO_VSTEM_ALIGN                                             */
437 +  /*                                                                       */
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                    */
441 +  /*                                                                       */
442 +#define FT_HINT_NO_VSTEM_ALIGN 4
443 +  
444 +  /*************************************************************************/
445 +  /*                                                                       */
446    /* <Enum>                                                                */
447    /*    FT_Render_Mode                                                     */
448    /*                                                                       */
This page took 0.265342 seconds and 4 git commands to generate.