From 0c80d34dee1d81737b61e3915ac205369f344bf3 Mon Sep 17 00:00:00 2001 From: Glen Low Date: Thu, 5 Dec 2013 23:59:57 +0800 Subject: [PATCH] Quartz: rework text layout * quartz_size_layout now respects font leading, even if it is zero * quartz_textlayout now correctly sets yoffset_centerline, consistent with pango layout --- plugin/quartz/gvtextlayout_quartz.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/plugin/quartz/gvtextlayout_quartz.c b/plugin/quartz/gvtextlayout_quartz.c index d6a82e4d0..0c8ddf4a0 100644 --- a/plugin/quartz/gvtextlayout_quartz.c +++ b/plugin/quartz/gvtextlayout_quartz.c @@ -62,11 +62,9 @@ void quartz_size_layout(void *layout, double* width, double* height, double* yof CGFloat ascent = 0.0; CGFloat descent = 0.0; CGFloat leading = 0.0; - double typowidth = CTLineGetTypographicBounds((CTLineRef)layout, &ascent, &descent, &leading); - CGFloat typoheight = ascent + descent; - *width = typowidth; - *height = leading == 0.0 ? typoheight * 1.2 : typoheight + leading; /* if no leading, use 20% of height */ + *width = CTLineGetTypographicBounds((CTLineRef)layout, &ascent, &descent, &leading); + *height = ascent + descent + leading; *yoffset_layout = ascent; } @@ -92,8 +90,8 @@ boolean quartz_textlayout(textspan_t *para, char **fontpath) /* report the layout */ para->layout = (void*)line; para->free_layout = &quartz_free_layout; - para->yoffset_centerline = 0; quartz_size_layout((void*)line, ¶->size.x, ¶->size.y, ¶->yoffset_layout); + para->yoffset_centerline = 0.2 * para->font->size; return TRUE; } else -- 2.40.0