CGContextShowText正在渲染颠倒的文本(镜像) [英] CGContextShowText is rendering upside down text (mirror image)

查看:66
本文介绍了CGContextShowText正在渲染颠倒的文本(镜像)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

没有做任何事情来请求上下颠倒的文本,CGContextShowText就以这种方式绘制文本。

Without my doing anything to request upside down text, CGContextShowText is drawing it in that fashion. It is a mirror image vertically of what it should be.

float font_size = 19.;
CGContextSelectFont (context, "Helvetica", font_size, kCGEncodingMacRoman);
CGContextSetTextDrawingMode (context, kCGTextFill); 
CGContextSetRGBStrokeColor (context, 255, 0, 0, 0); 
CGContextSetRGBFillColor (context, 255, 0, 0, 0); 
CGContextSetTextPosition (context, x, y);
CGContextShowText (context, cstring, strlen(cstring));

我该如何解决?还有为什么这是默认的绘制模式?

How can I fix this? Also why is this the default drawing mode?

谢谢。

推荐答案

当API从顶部到底部渲染到您的cgContext时,这种颠倒性通常会起作用,但是以某种方式从底部到顶部进行绘制。无论如何,我使用的2行解决方案是:

This "upsidedownness" commonly comes into play when the API renders to your cgContext from top to bottom, but somehow you're drawing from bottom to top. Anyway, the 2 line solution I use is:

CGAffineTransform trans = CGAffineTransformMakeScale(1, -1);
CGContextSetTextMatrix(tex->cgContext, trans);

这篇关于CGContextShowText正在渲染颠倒的文本(镜像)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆