mirror of
https://github.com/harfbuzz/harfbuzz.git
synced 2025-04-15 01:18:13 +00:00
[coretext-font] Implement get_glyph_extents
This commit is contained in:
parent
8db2997e4e
commit
b5e9f2cb2b
1 changed files with 16 additions and 2 deletions
|
@ -149,8 +149,22 @@ hb_coretext_get_glyph_extents (hb_font_t *font,
|
|||
hb_glyph_extents_t *extents,
|
||||
void *user_data HB_UNUSED)
|
||||
{
|
||||
// TODO
|
||||
return false;
|
||||
CTFontRef ct_font = (CTFontRef) font_data;
|
||||
|
||||
CGFloat ct_font_size = CTFontGetSize (ct_font);
|
||||
CGFloat x_mult = (CGFloat) font->x_scale / ct_font_size;
|
||||
CGFloat y_mult = (CGFloat) font->y_scale / ct_font_size;
|
||||
|
||||
CGGlyph glyphs[1] = { glyph };
|
||||
CGRect bounds = ::CTFontGetBoundingRectsForGlyphs(ct_font,
|
||||
kCTFontDefaultOrientation, glyphs, NULL, 1);
|
||||
|
||||
extents->x_bearing = round (bounds.origin.x * x_mult);
|
||||
extents->y_bearing = round (bounds.origin.y * y_mult);
|
||||
extents->width = round (bounds.size.width * x_mult);
|
||||
extents->height = round (bounds.size.height * y_mult);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static hb_bool_t
|
||||
|
|
Loading…
Add table
Reference in a new issue