@@ -369,6 +369,20 @@ impl FontContext {
369
369
}
370
370
}
371
371
372
+ fn pad_bounding_box ( & self , font : & FontInstance , cbox : & mut FT_BBox ) {
373
+ // Apply extra pixel of padding for subpixel AA, due to the filter.
374
+ if font. render_mode == FontRenderMode :: Subpixel {
375
+ let padding = ( self . lcd_extra_pixels * 64 ) as FT_Pos ;
376
+ if font. flags . contains ( FontInstanceFlags :: LCD_VERTICAL ) {
377
+ cbox. yMin -= padding;
378
+ cbox. yMax += padding;
379
+ } else {
380
+ cbox. xMin -= padding;
381
+ cbox. xMax += padding;
382
+ }
383
+ }
384
+ }
385
+
372
386
// Get the bounding box for a glyph, accounting for sub-pixel positioning.
373
387
fn get_bounding_box (
374
388
& self ,
@@ -389,17 +403,7 @@ impl FontContext {
389
403
}
390
404
}
391
405
392
- // Apply extra pixel of padding for subpixel AA, due to the filter.
393
- if font. render_mode == FontRenderMode :: Subpixel {
394
- let padding = ( self . lcd_extra_pixels * 64 ) as FT_Pos ;
395
- if font. flags . contains ( FontInstanceFlags :: LCD_VERTICAL ) {
396
- cbox. yMin -= padding;
397
- cbox. yMax += padding;
398
- } else {
399
- cbox. xMin -= padding;
400
- cbox. xMax += padding;
401
- }
402
- }
406
+ self . pad_bounding_box ( font, & mut cbox) ;
403
407
404
408
// Offset the bounding box by subpixel positioning.
405
409
// Convert to 26.6 fixed point format for FT.
@@ -572,6 +576,7 @@ impl FontContext {
572
576
let outline = & ( * slot) . outline ;
573
577
let mut cbox: FT_BBox = mem:: uninitialized ( ) ;
574
578
FT_Outline_Get_CBox ( outline, & mut cbox) ;
579
+ self . pad_bounding_box ( font, & mut cbox) ;
575
580
FT_Outline_Translate (
576
581
outline,
577
582
dx - ( ( cbox. xMin + dx) & !63 ) ,
0 commit comments