]> granicus.if.org Git - graphviz/commitdiff
Quartz: move iOS flip context code
authorGlen Low <glen.low@pixelglow.com>
Thu, 5 Dec 2013 15:12:39 +0000 (23:12 +0800)
committerGlen Low <glen.low@pixelglow.com>
Thu, 5 Dec 2013 16:22:40 +0000 (00:22 +0800)
* 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
plugin/quartz/gvrender_quartz.c

index a67f9ce91c25076f578e56b6ae8403f7e5b00951..a61c59fc7ff2ceba8a4daebda41efd5641514982 100644 (file)
@@ -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
index 2382dd1a70a7e0cb9db57191eeffa9774fde4e3a..8ae44c3a43b507e24355df43bd4e68bf25815e76 100644 (file)
@@ -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);
 }