Use CTFont::draw_glyphs to rasterize glyphs

This API supports rendering emojis in addition to normal glyphs.
This commit is contained in:
Antonio Scandurra 2022-04-12 19:37:26 +02:00
parent 00fb5755a3
commit 6b629dfa5c

View File

@ -198,14 +198,17 @@ impl FontSystemState {
ty: -transform.vector.y() as CGFloat, ty: -transform.vector.y() as CGFloat,
}); });
cx.set_font(&font.native_font().copy_to_CGFont()); cx.set_should_subpixel_position_fonts(true);
cx.set_font_size(font_size as CGFloat); cx.set_should_subpixel_quantize_fonts(false);
cx.show_glyphs_at_positions( font.native_font()
.clone_with_font_size(font_size as CGFloat)
.draw_glyphs(
&[glyph_id as CGGlyph], &[glyph_id as CGGlyph],
&[CGPoint::new( &[CGPoint::new(
(subpixel_shift.x() / scale_factor) as CGFloat, (subpixel_shift.x() / scale_factor) as CGFloat,
(subpixel_shift.y() / scale_factor) as CGFloat, (subpixel_shift.y() / scale_factor) as CGFloat,
)], )],
cx,
); );
Some((bounds, pixels)) Some((bounds, pixels))