Commit 5aa6716a5eb8409f606886b5d4e63476d85a3519

Werner Lemberg 2017-04-22T13:27:21

Add new `slight' auto-hinting mode. This mode uses fractional advance widths and doesn't scale glyphs horizontally, only applying vertical scaling and hinting. At the same time, the behaviour of the `light' auto-hinter gets restored for backwards compatibility: Both vertical and horizontal scaling is again based on rounded metrics values (this was changed in a commit from 2017-03-30 as a side effect). To be more precise, the behaviour is restored for TrueType fonts only; for other font formats like Type 1, this is a new feature of the `light' hinting mode. * include/freetype/freetype.h (FT_LOAD_TARGET_SLIGHT): New macro. (FT_RENDER_MODE_SLIGHT): New render mode. * include/freetype/internal/ftobjs.h (FT_Size_InternalRec): Add `autohint_mode' and `autohint_metrics' fields. * src/autofit/afcjk.c (af_cjk_hints_init), src/autofit/aflatin.c (af_latin_hints_init), src/autofit/aflatin2 (af_latin2_hints_init): Updated. * src/autofit/afloader.c (af_loader_embolden_glyph_in_slot): Use `autohint_metrics'. (af_loader_load_glyph): s/internal/slot_internal/. Initialize `autohint_metrics' and `autohint_mode' depending on current auto-hint mode. Use `autohint_metrics'. Updated. * src/base/ftadvanc.c (LOAD_ADVANCE_FAST_CHECK): Updated. * src/base/ftobjs.c (FT_Load_Glyph): Updated. (FT_New_Size): Allocate `internal' object. * src/pshinter/pshalgo.c (ps_hints_apply): Updated. * src/smooth/ftsmooth.c (ft_smooth_render): Updated.

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
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
diff --git a/ChangeLog b/ChangeLog
index 00ba418..05db1d1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,47 @@
 2017-04-22  Werner Lemberg  <wl@gnu.org>
 
+	Add new `slight' auto-hinting mode.
+
+	This mode uses fractional advance widths and doesn't scale glyphs
+	horizontally, only applying vertical scaling and hinting.
+
+	At the same time, the behaviour of the `light' auto-hinter gets
+	restored for backwards compatibility: Both vertical and horizontal
+	scaling is again based on rounded metrics values (this was changed
+	in a commit from 2017-03-30 as a side effect).  To be more precise,
+	the behaviour is restored for TrueType fonts only; for other font
+	formats like Type 1, this is a new feature of the `light' hinting
+	mode.
+
+	* include/freetype/freetype.h (FT_LOAD_TARGET_SLIGHT): New macro.
+	(FT_RENDER_MODE_SLIGHT): New render mode.
+
+	* include/freetype/internal/ftobjs.h (FT_Size_InternalRec): Add
+	`autohint_mode' and `autohint_metrics' fields.
+
+	* src/autofit/afcjk.c (af_cjk_hints_init), src/autofit/aflatin.c
+	(af_latin_hints_init), src/autofit/aflatin2 (af_latin2_hints_init):
+	Updated.
+
+	* src/autofit/afloader.c (af_loader_embolden_glyph_in_slot): Use
+	`autohint_metrics'.
+	(af_loader_load_glyph): s/internal/slot_internal/.
+	Initialize `autohint_metrics' and `autohint_mode' depending on
+	current auto-hint mode.
+	Use `autohint_metrics'.
+	Updated.
+
+	* src/base/ftadvanc.c (LOAD_ADVANCE_FAST_CHECK): Updated.
+
+	* src/base/ftobjs.c (FT_Load_Glyph): Updated.
+	(FT_New_Size): Allocate `internal' object.
+
+	* src/pshinter/pshalgo.c (ps_hints_apply): Updated.
+
+	* src/smooth/ftsmooth.c (ft_smooth_render): Updated.
+
+2017-04-22  Werner Lemberg  <wl@gnu.org>
+
 	Introduce `FT_Size_InternalRec' structure.
 
 	We are going to extend this later on.
diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index 4ed86b9..e579056 100644
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -221,6 +221,7 @@ FT_BEGIN_HEADER
   /*                                                                       */
   /*    FT_LOAD_TARGET_NORMAL                                              */
   /*    FT_LOAD_TARGET_LIGHT                                               */
+  /*    FT_LOAD_TARGET_SLIGHT                                              */
   /*    FT_LOAD_TARGET_MONO                                                */
   /*    FT_LOAD_TARGET_LCD                                                 */
   /*    FT_LOAD_TARGET_LCD_V                                               */
@@ -1755,7 +1756,8 @@ FT_BEGIN_HEADER
   /*    `slot->format' is also changed to @FT_GLYPH_FORMAT_BITMAP.         */
   /*                                                                       */
   /*    Here is a small pseudo code fragment that shows how to use         */
-  /*    `lsb_delta' and `rsb_delta':                                       */
+  /*    `lsb_delta' and `rsb_delta' to improve (integer) positioning of    */
+  /*    glyphs:                                                            */
   /*                                                                       */
   /*    {                                                                  */
   /*      FT_Pos  origin_x       = 0;                                      */
@@ -2941,6 +2943,18 @@ FT_BEGIN_HEADER
    *     driver, if the driver itself and the font support it, or by the
    *     auto-hinter.
    *
+   *     Use this hinting mode if you mainly need integer advance widths
+   *     and want to avoid sub-pixel rendering.
+   *
+   *   FT_LOAD_TARGET_SLIGHT ::
+   *     This is similar to @FT_LOAD_TARGET_LIGHT with a main difference:
+   *     Advance widths are not rounded to integer values; instead, the
+   *     linearly scaled values are used.  In particular this implies that
+   *     you have to apply sub-pixel rendering.
+   *
+   *     In general, this mode yields better results than
+   *     @FT_LOAD_TARGET_LIGHT.
+   *
    *   FT_LOAD_TARGET_MONO ::
    *     Strong hinting algorithm that should only be used for monochrome
    *     output.  The result is probably unpleasant if the glyph is rendered
@@ -2975,11 +2989,19 @@ FT_BEGIN_HEADER
    *       FT_Render_Glyph( face->glyph, FT_RENDER_MODE_LCD );
    *     }
    *
+   *   In general, you should stick with one rendering mode.  For example,
+   *   switching between @FT_LOAD_TARGET_LIGHT and @FT_LOAD_TARGET_SLIGHT
+   *   enforces a lot of recomputation, which is slow.  Another reason is
+   *   caching: Selecting a different mode usually causes changes in both
+   *   the outlines and the rasterized bitmaps; it is thus necessary to
+   *   empty the cache after a mode switch to avoid false hits.
+   *
    */
 #define FT_LOAD_TARGET_( x )   ( (FT_Int32)( (x) & 15 ) << 16 )
 
 #define FT_LOAD_TARGET_NORMAL  FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL )
 #define FT_LOAD_TARGET_LIGHT   FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT  )
+#define FT_LOAD_TARGET_SLIGHT  FT_LOAD_TARGET_( FT_RENDER_MODE_SLIGHT )
 #define FT_LOAD_TARGET_MONO    FT_LOAD_TARGET_( FT_RENDER_MODE_MONO   )
 #define FT_LOAD_TARGET_LCD     FT_LOAD_TARGET_( FT_RENDER_MODE_LCD    )
 #define FT_LOAD_TARGET_LCD_V   FT_LOAD_TARGET_( FT_RENDER_MODE_LCD_V  )
@@ -3060,6 +3082,12 @@ FT_BEGIN_HEADER
   /*      indirectly to define hinting algorithm selectors.  See           */
   /*      @FT_LOAD_TARGET_XXX for details.                                 */
   /*                                                                       */
+  /*    FT_RENDER_MODE_SLIGHT ::                                           */
+  /*      This is equivalent to @FT_RENDER_MODE_NORMAL.  It is only        */
+  /*      defined as a separate value because render modes are also used   */
+  /*      indirectly to define hinting algorithm selectors.  See           */
+  /*      @FT_LOAD_TARGET_XXX for details.                                 */
+  /*                                                                       */
   /*    FT_RENDER_MODE_MONO ::                                             */
   /*      This mode corresponds to 1-bit bitmaps (with 2~levels of         */
   /*      opacity).                                                        */
@@ -3092,6 +3120,7 @@ FT_BEGIN_HEADER
   {
     FT_RENDER_MODE_NORMAL = 0,
     FT_RENDER_MODE_LIGHT,
+    FT_RENDER_MODE_SLIGHT,
     FT_RENDER_MODE_MONO,
     FT_RENDER_MODE_LCD,
     FT_RENDER_MODE_LCD_V,
diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h
index c8526e6..5584091 100644
--- a/include/freetype/internal/ftobjs.h
+++ b/include/freetype/internal/ftobjs.h
@@ -443,7 +443,11 @@ FT_BEGIN_HEADER
   /*    object.                                                            */
   /*                                                                       */
   /* <Fields>                                                              */
-  /*    module_data :: Data specific to a driver module.                   */
+  /*    module_data      :: Data specific to a driver module.              */
+  /*                                                                       */
+  /*    autohint_mode    :: The used auto-hinting mode.                    */
+  /*                                                                       */
+  /*    autohint_metrics :: Metrics used by the auto-hinter.               */
   /*                                                                       */
   /*************************************************************************/
 
@@ -451,6 +455,9 @@ FT_BEGIN_HEADER
   {
     void*  module_data;
 
+    FT_Render_Mode   autohint_mode;
+    FT_Size_Metrics  autohint_metrics;
+
   } FT_Size_InternalRec;
 
 
diff --git a/src/autofit/afcjk.c b/src/autofit/afcjk.c
index 61e29cd..86b8b40 100644
--- a/src/autofit/afcjk.c
+++ b/src/autofit/afcjk.c
@@ -1398,9 +1398,12 @@
       other_flags |= AF_LATIN_HINTS_VERT_SNAP;
 
     /*
-     *  We adjust stems to full pixels unless in `light' or `lcd' mode.
+     *  We adjust stems to full pixels unless in `light', `slight',
+     *  or `lcd' mode.
      */
-    if ( mode != FT_RENDER_MODE_LIGHT && mode != FT_RENDER_MODE_LCD )
+    if ( mode != FT_RENDER_MODE_LIGHT  &&
+         mode != FT_RENDER_MODE_SLIGHT &&
+         mode != FT_RENDER_MODE_LCD    )
       other_flags |= AF_LATIN_HINTS_STEM_ADJUST;
 
     if ( mode == FT_RENDER_MODE_MONO )
diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c
index 11fa523..e03fdf0 100644
--- a/src/autofit/aflatin.c
+++ b/src/autofit/aflatin.c
@@ -2577,7 +2577,9 @@
     /*
      *  We adjust stems to full pixels unless in `light' or `lcd' mode.
      */
-    if ( mode != FT_RENDER_MODE_LIGHT && mode != FT_RENDER_MODE_LCD )
+    if ( mode != FT_RENDER_MODE_LIGHT  &&
+         mode != FT_RENDER_MODE_SLIGHT &&
+         mode != FT_RENDER_MODE_LCD    )
       other_flags |= AF_LATIN_HINTS_STEM_ADJUST;
 
     if ( mode == FT_RENDER_MODE_MONO )
@@ -2590,8 +2592,10 @@
      *  However, if warping is enabled (which only works in `light' hinting
      *  mode), advance widths get adjusted, too.
      */
-    if ( mode == FT_RENDER_MODE_LIGHT || mode == FT_RENDER_MODE_LCD ||
-         ( face->style_flags & FT_STYLE_FLAG_ITALIC ) != 0          )
+    if ( mode == FT_RENDER_MODE_LIGHT                      ||
+         mode == FT_RENDER_MODE_SLIGHT                     ||
+         mode == FT_RENDER_MODE_LCD                        ||
+         ( face->style_flags & FT_STYLE_FLAG_ITALIC ) != 0 )
       scaler_flags |= AF_SCALER_FLAG_NO_HORIZONTAL;
 
 #ifdef AF_CONFIG_OPTION_USE_WARPER
diff --git a/src/autofit/aflatin2.c b/src/autofit/aflatin2.c
index 0607278..87ab91d 100644
--- a/src/autofit/aflatin2.c
+++ b/src/autofit/aflatin2.c
@@ -1560,7 +1560,9 @@
     /*
      *  We adjust stems to full pixels unless in `light' or `lcd' mode.
      */
-    if ( mode != FT_RENDER_MODE_LIGHT && mode != FT_RENDER_MODE_LCD )
+    if ( mode != FT_RENDER_MODE_LIGHT  &&
+         mode != FT_RENDER_MODE_SLIGHT &&
+         mode != FT_RENDER_MODE_LCD    )
       other_flags |= AF_LATIN_HINTS_STEM_ADJUST;
 
     if ( mode == FT_RENDER_MODE_MONO )
@@ -1570,8 +1572,10 @@
      *  In `light' or `lcd' mode we disable horizontal hinting completely.
      *  We also do it if the face is italic.
      */
-    if ( mode == FT_RENDER_MODE_LIGHT || mode == FT_RENDER_MODE_LCD ||
-         ( face->style_flags & FT_STYLE_FLAG_ITALIC ) != 0          )
+    if ( mode == FT_RENDER_MODE_LIGHT                      ||
+         mode == FT_RENDER_MODE_SLIGHT                     ||
+         mode == FT_RENDER_MODE_LCD                        ||
+         ( face->style_flags & FT_STYLE_FLAG_ITALIC ) != 0 )
       scaler_flags |= AF_SCALER_FLAG_NO_HORIZONTAL;
 
 #ifdef AF_CONFIG_OPTION_USE_WARPER
diff --git a/src/autofit/afloader.c b/src/autofit/afloader.c
index fb8ea3c..d90c217 100644
--- a/src/autofit/afloader.c
+++ b/src/autofit/afloader.c
@@ -97,11 +97,13 @@
     AF_FaceGlobals         globals = loader->globals;
     AF_WritingSystemClass  writing_system_class;
 
+    FT_Size_Metrics*  size_metrics = &face->size->internal->autohint_metrics;
+
     FT_Pos  stdVW = 0;
     FT_Pos  stdHW = 0;
 
-    FT_Bool  size_changed = face->size->metrics.x_ppem
-                              != globals->stem_darkening_for_ppem;
+    FT_Bool  size_changed = size_metrics->x_ppem !=
+                              globals->stem_darkening_for_ppem;
 
     FT_Fixed  em_size  = af_intToFixed( face->units_per_EM );
     FT_Fixed  em_ratio = FT_DivFix( af_intToFixed( 1000 ), em_size );
@@ -145,11 +147,11 @@
                                                     face,
                                                     stdVW ) );
       darken_x = FT_DivFix( FT_MulFix( darken_by_font_units_x,
-                                       face->size->metrics.x_scale ),
+                                       size_metrics->x_scale ),
                             em_ratio );
 
       globals->standard_vertical_width = stdVW;
-      globals->stem_darkening_for_ppem = face->size->metrics.x_ppem;
+      globals->stem_darkening_for_ppem = size_metrics->x_ppem;
       globals->darken_x                = af_fixedToInt( darken_x );
     }
 
@@ -164,11 +166,11 @@
                                                     face,
                                                     stdHW ) );
       darken_y = FT_DivFix( FT_MulFix( darken_by_font_units_y,
-                                       face->size->metrics.y_scale ),
+                                       size_metrics->y_scale ),
                             em_ratio );
 
       globals->standard_horizontal_width = stdHW;
-      globals->stem_darkening_for_ppem   = face->size->metrics.x_ppem;
+      globals->stem_darkening_for_ppem   = size_metrics->x_ppem;
       globals->darken_y                  = af_fixedToInt( darken_y );
 
       /*
@@ -217,10 +219,11 @@
   {
     FT_Error  error;
 
-    FT_Size           size     = face->size;
-    FT_GlyphSlot      slot     = face->glyph;
-    FT_Slot_Internal  internal = slot->internal;
-    FT_GlyphLoader    gloader  = internal->loader;
+    FT_Size           size          = face->size;
+    FT_Size_Internal  size_internal = size->internal;
+    FT_GlyphSlot      slot          = face->glyph;
+    FT_Slot_Internal  slot_internal = slot->internal;
+    FT_GlyphLoader    gloader       = slot_internal->loader;
 
     AF_GlyphHints          hints         = loader->hints;
     AF_ScalerRec           scaler;
@@ -239,6 +242,44 @@
 
     FT_ZERO( &scaler );
 
+    if ( !size_internal->autohint_metrics.x_scale                          ||
+         size_internal->autohint_mode != FT_LOAD_TARGET_MODE( load_flags ) )
+    {
+      /* switching between LIGHT and SLIGHT (and vice versa) usually means */
+      /* different scaling values; this later on enforces recomputation of */
+      /* everything related to the current size                            */
+
+      size_internal->autohint_mode    = FT_LOAD_TARGET_MODE( load_flags );
+      size_internal->autohint_metrics = size->metrics;
+
+      if ( size_internal->autohint_mode != FT_RENDER_MODE_SLIGHT )
+      {
+        FT_Size_Metrics*  size_metrics = &size_internal->autohint_metrics;
+
+
+        /* set metrics to integer values and adjust scaling accordingly; */
+        /* this is the same setup as with TrueType fonts, cf. function   */
+        /* `tt_size_reset' in file `ttobjs.c'                            */
+        size_metrics->ascender  = FT_PIX_ROUND(
+                                    FT_MulFix( face->ascender,
+                                               size_metrics->y_scale ) );
+        size_metrics->descender = FT_PIX_ROUND(
+                                    FT_MulFix( face->descender,
+                                               size_metrics->y_scale ) );
+        size_metrics->height    = FT_PIX_ROUND(
+                                    FT_MulFix( face->height,
+                                               size_metrics->y_scale ) );
+
+        size_metrics->x_scale     = FT_DivFix( size_metrics->x_ppem << 6,
+                                               face->units_per_EM );
+        size_metrics->y_scale     = FT_DivFix( size_metrics->y_ppem << 6,
+                                               face->units_per_EM );
+        size_metrics->max_advance = FT_PIX_ROUND(
+                                      FT_MulFix( face->max_advance_width,
+                                                 size_metrics->x_scale ) );
+      }
+    }
+
     /*
      *  TODO: This code currently doesn't support fractional advance widths,
      *  i.e., placing hinted glyphs at anything other than integer
@@ -249,9 +290,9 @@
      *  values of the scaler would need to be adjusted.
      */
     scaler.face    = face;
-    scaler.x_scale = size->metrics.x_scale;
+    scaler.x_scale = size_internal->autohint_metrics.x_scale;
     scaler.x_delta = 0;
-    scaler.y_scale = size->metrics.y_scale;
+    scaler.y_scale = size_internal->autohint_metrics.y_scale;
     scaler.y_delta = 0;
 
     scaler.render_mode = FT_LOAD_TARGET_MODE( load_flags );
@@ -339,21 +380,22 @@
      *
      */
 
-    /* stem darkening only works well in `light' mode */
-    if ( scaler.render_mode == FT_RENDER_MODE_LIGHT    &&
+    /* stem darkening only works well in `light' and `slight' modes */
+    if ( ( scaler.render_mode == FT_RENDER_MODE_LIGHT  ||
+           scaler.render_mode == FT_RENDER_MODE_SLIGHT ) &&
          ( !face->internal->no_stem_darkening        ||
            ( face->internal->no_stem_darkening < 0 &&
-             !module->no_stem_darkening            ) ) )
+             !module->no_stem_darkening            ) )   )
       af_loader_embolden_glyph_in_slot( loader, face, style_metrics );
 
-    loader->transformed = internal->glyph_transformed;
+    loader->transformed = slot_internal->glyph_transformed;
     if ( loader->transformed )
     {
       FT_Matrix  inverse;
 
 
-      loader->trans_matrix = internal->glyph_matrix;
-      loader->trans_delta  = internal->glyph_delta;
+      loader->trans_matrix = slot_internal->glyph_matrix;
+      loader->trans_delta  = slot_internal->glyph_delta;
 
       inverse = loader->trans_matrix;
       if ( !FT_Matrix_Invert( &inverse ) )
@@ -391,7 +433,8 @@
 
       /* we now need to adjust the metrics according to the change in */
       /* width/positioning that occurred during the hinting process   */
-      if ( scaler.render_mode != FT_RENDER_MODE_LIGHT )
+      if ( scaler.render_mode != FT_RENDER_MODE_LIGHT  &&
+           scaler.render_mode != FT_RENDER_MODE_SLIGHT )
       {
         FT_Pos  old_rsb, old_lsb, new_lsb;
         FT_Pos  pp1x_uh, pp2x_uh;
@@ -448,7 +491,10 @@
           slot->rsb_delta = loader->pp2.x - pp2x;
         }
       }
-      else
+      /* `light' mode uses integer advance widths */
+      /* (but sets `lsb_delta' and `rsb_delta'),  */
+      /* `slight' mode uses fractional values     */
+      else if ( scaler.render_mode == FT_RENDER_MODE_LIGHT )
       {
         FT_Pos  pp1x = loader->pp1.x;
         FT_Pos  pp2x = loader->pp2.x;
@@ -460,6 +506,11 @@
         slot->lsb_delta = loader->pp1.x - pp1x;
         slot->rsb_delta = loader->pp2.x - pp2x;
       }
+      else
+      {
+        slot->lsb_delta = 0;
+        slot->rsb_delta = 0;
+      }
 
       break;
 
@@ -510,6 +561,7 @@
       /* to keep the original rounded advance width; ditto for     */
       /* digits if all have the same advance width                 */
       if ( scaler.render_mode != FT_RENDER_MODE_LIGHT                       &&
+           scaler.render_mode != FT_RENDER_MODE_SLIGHT                      &&
            ( FT_IS_FIXED_WIDTH( slot->face )                              ||
              ( af_face_globals_is_digit( loader->globals, glyph_index ) &&
                style_metrics->digits_have_same_width                    ) ) )
@@ -533,7 +585,8 @@
       slot->metrics.vertAdvance = FT_MulFix( slot->metrics.vertAdvance,
                                              style_metrics->scaler.y_scale );
 
-      slot->metrics.horiAdvance = FT_PIX_ROUND( slot->metrics.horiAdvance );
+      if ( scaler.render_mode != FT_RENDER_MODE_SLIGHT )
+        slot->metrics.horiAdvance = FT_PIX_ROUND( slot->metrics.horiAdvance );
       slot->metrics.vertAdvance = FT_PIX_ROUND( slot->metrics.vertAdvance );
 
       slot->format  = FT_GLYPH_FORMAT_OUTLINE;
diff --git a/src/base/ftadvanc.c b/src/base/ftadvanc.c
index 1557607..5f2e0b1 100644
--- a/src/base/ftadvanc.c
+++ b/src/base/ftadvanc.c
@@ -59,14 +59,15 @@
    /*                                                              */
    /*  - unscaled load                                             */
    /*  - unhinted load                                             */
-   /*  - light-hinted load                                         */
+   /*  - light-hinted and slight-hinted load                       */
    /*  - if a variations font, it must have an `HVAR' or `VVAR'    */
    /*    table (thus the old MM or GX fonts don't qualify; this    */
    /*    gets checked by the driver-specific functions)            */
 
-#define LOAD_ADVANCE_FAST_CHECK( face, flags )                      \
-          ( flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING )    || \
-            FT_LOAD_TARGET_MODE( flags ) == FT_RENDER_MODE_LIGHT )
+#define LOAD_ADVANCE_FAST_CHECK( face, flags )                           \
+          ( flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING )         || \
+            ( FT_LOAD_TARGET_MODE( flags ) == FT_RENDER_MODE_LIGHT  ||   \
+              FT_LOAD_TARGET_MODE( flags ) == FT_RENDER_MODE_SLIGHT ) )
 
 
   /* documentation is in ftadvanc.h */
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 83d51c0..7a9169b 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -668,8 +668,8 @@
      * - Then, auto-hint if FT_LOAD_FORCE_AUTOHINT is set or if we don't
      *   have a native font hinter.
      *
-     * - Otherwise, auto-hint for LIGHT hinting mode or if there isn't
-     *   any hinting bytecode in the TrueType/OpenType font.
+     * - Otherwise, auto-hint for LIGHT or SLIGHT hinting mode or if there
+     *   isn't any hinting bytecode in the TrueType/OpenType font.
      *
      * - Exception: The font is `tricky' and requires the native hinter to
      *   load properly.
@@ -702,8 +702,9 @@
         /* check the size of the `fpgm' and `prep' tables, too --    */
         /* the assumption is that there don't exist real TTFs where  */
         /* both `fpgm' and `prep' tables are missing                 */
-        if ( ( mode == FT_RENDER_MODE_LIGHT                   &&
-               !FT_DRIVER_HINTS_LIGHTLY( driver ) )             ||
+        if ( ( ( mode == FT_RENDER_MODE_LIGHT  ||
+                 mode == FT_RENDER_MODE_SLIGHT )              &&
+               !FT_DRIVER_HINTS_LIGHTLY( driver )             ) ||
              ( FT_IS_SFNT( face )                             &&
                ttface->num_locations                          &&
                ttface->max_profile.maxSizeOfInstructions == 0 &&
diff --git a/src/pshinter/pshalgo.c b/src/pshinter/pshalgo.c
index 9ad1a3a..27cb229 100644
--- a/src/pshinter/pshalgo.c
+++ b/src/pshinter/pshalgo.c
@@ -2149,7 +2149,8 @@
       glyph->do_vert_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_MONO  ||
                                          hint_mode == FT_RENDER_MODE_LCD_V );
 
-      glyph->do_stem_adjust   = FT_BOOL( hint_mode != FT_RENDER_MODE_LIGHT );
+      glyph->do_stem_adjust = FT_BOOL( hint_mode != FT_RENDER_MODE_LIGHT  &&
+                                       hint_mode != FT_RENDER_MODE_SLIGHT );
 
       for ( dimension = 0; dimension < 2; dimension++ )
       {
diff --git a/src/smooth/ftsmooth.c b/src/smooth/ftsmooth.c
index 435854e..52e61e5 100644
--- a/src/smooth/ftsmooth.c
+++ b/src/smooth/ftsmooth.c
@@ -433,7 +433,8 @@
                     FT_Render_Mode    mode,
                     const FT_Vector*  origin )
   {
-    if ( mode == FT_RENDER_MODE_LIGHT )
+    if ( mode == FT_RENDER_MODE_LIGHT  ||
+         mode == FT_RENDER_MODE_SLIGHT )
       mode = FT_RENDER_MODE_NORMAL;
 
     return ft_smooth_render_generic( render, slot, mode, origin,