From a2b9c42cbd41d722aa4b37a728fd97bd394f1068 Mon Sep 17 00:00:00 2001 From: Glen Low Date: Thu, 5 Dec 2013 23:12:39 +0800 Subject: [PATCH] Quartz: move iOS flip context code * Move iOS flip context code from quartzgen_textpara to -[GVTextLayout drawInContext:], since this is specific to GVTextLayout and not iOS rendering. This will eventually allow iOS and Mac OS X to share the same CoreText-based rendering. --- plugin/quartz/GVTextLayout.m | 14 +++++--------- plugin/quartz/gvrender_quartz.c | 9 --------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/plugin/quartz/GVTextLayout.m b/plugin/quartz/GVTextLayout.m index a67f9ce91..a61c59fc7 100644 --- a/plugin/quartz/GVTextLayout.m +++ b/plugin/quartz/GVTextLayout.m @@ -76,18 +76,14 @@ static NSString* _defaultFontName = @"TimesNewRomanPSMT"; *yoffset = ascender; } -- (void)drawAtPoint:(CGPoint)point inContext:(CGContextRef)context -{ - UIGraphicsPushContext(context); - [_text drawAtPoint:point withFont:_font]; - UIGraphicsPopContext(); -} - - (void)drawInContext:(CGContextRef)context atPosition:(CGPoint)position { UIGraphicsPushContext(context); - [_text drawAtPoint:position withFont:_font]; - UIGraphicsPopContext(); + CGContextSaveGState(context); + CGContextScaleCTM(context, 1.0, -1.0); + [_text drawAtPoint:CGPointMake(position.x, -position.y - _font.ascender) withFont:_font]; + CGContextRestoreGState(context); + UIGraphicsPopContext(); } - (void)dealloc diff --git a/plugin/quartz/gvrender_quartz.c b/plugin/quartz/gvrender_quartz.c index 2382dd1a7..8ae44c3a4 100644 --- a/plugin/quartz/gvrender_quartz.c +++ b/plugin/quartz/gvrender_quartz.c @@ -349,21 +349,12 @@ void quartzgen_textspan(GVJ_t * job, pointf p, textspan_t * span) layout = quartz_new_layout(span->font->name, span->font->size, span->str); -#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 20000 - CGContextSaveGState(context); - CGContextScaleCTM(context, 1.0, -1.0); - p.y = -p.y - span->yoffset_layout; -#endif CGContextSetRGBFillColor(context, job->obj->pencolor.u.RGBA[0], job->obj->pencolor.u.RGBA[1], job->obj->pencolor.u.RGBA[2], job->obj->pencolor.u.RGBA[3]); quartz_draw_layout(layout, context, CGPointMake(p.x, p.y)); -#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 20000 - CGContextRestoreGState(context); -#endif - if (span->free_layout != &quartz_free_layout) quartz_free_layout(layout); } -- 2.40.0