- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在尝试使用核心文本在我的 iOS 应用程序中使用自定义 TTF 字体 (scheherazade) 呈现阿拉伯语文本,这在大多数情况下都有效 - 但是 CTFrame 边缘的某些字形被丢弃了。
当我调整框架大小时使丢弃的字形出现在框架内部时,它们正确显示,这让我相信 CTFrameDraw 内部出现问题。下面是我用来呈现阿拉伯文本的代码:
CGContextRef context = UIGraphicsGetCurrentContext();
// Flip the coordinate system
CGContextSetTextMatrix(context, CGAffineTransformIdentity);
CGContextTranslateCTM(context, 0, v.textFrame.size.height);
CGContextScaleCTM(context, 1.0, -1.0);
CGMutablePathRef path = CGPathCreateMutable(); //1
CGPathAddRect(path, NULL, v.textFrame );
CGFloat minLineHeight = 60.0;
CGFloat maxLineHeight = 60.0;
CTTextAlignment paragraphAlignment = kCTRightTextAlignment;
CTLineBreakMode lineBrkMode = kCTLineBreakByWordWrapping;
CTParagraphStyleSetting setting[4] = {
{kCTParagraphStyleSpecifierAlignment, sizeof(CTTextAlignment), ¶graphAlignment},
{kCTParagraphStyleSpecifierMinimumLineHeight, sizeof(CGFloat), &minLineHeight},
{kCTParagraphStyleSpecifierMaximumLineHeight, sizeof(CGFloat), &maxLineHeight},
{kCTParagraphStyleSpecifierLineBreakMode, sizeof(CTLineBreakMode), &lineBrkMode}
};
CTParagraphStyleRef paragraphStyle = CTParagraphStyleCreate(setting, 4);
NSDictionary *attr = [NSDictionary dictionaryWithObjectsAndKeys:
(id)v.arabicFont, (id)kCTFontAttributeName,
paragraphStyle, (id)kCTParagraphStyleAttributeName,
nil];
CFRelease(paragraphStyle);
NSAttributedString* attString = [[[NSAttributedString alloc]
initWithString:v.verseText attributes:attr] autorelease]; //2
CTFramesetterRef framesetter =
CTFramesetterCreateWithAttributedString((CFAttributedStringRef)attString); //3
CTFrameRef frame =
CTFramesetterCreateFrame(framesetter,
CFRangeMake(0, [attString length]), path, NULL);
CTFrameDraw(frame, context); //4
CFRelease(frame); //5
CFRelease(path);
CFRelease(framesetter);
还附上了显示我面临的问题的屏幕截图。任何帮助将非常感激。谢谢。
无效:http://stellarbeacon.com.au/invalid.png有效:http://stellarbeacon.com.au/valid.png
最佳答案
CoreText 中存在一些与确定正确的帧大小相关的错误。其中一些已在 iOS 6 中修复,例如http://www.cocoanetics.com/2012/02/radar-coretext-line-spacing-bug/
如果您的问题仍然存在,那么您应该提交一个包含细节的 Radar。您还应该使用 Apple DTS 打开一个调用,这可能会为您提供解决方法。通常 - 如果您的问题确实是一个错误 - 那么您的 DTS 调用就会被记回。
PS:尝试使用我的 DTCoreText View 显示您的文本,这些 View 进行手动布局和显示,看看问题是否可以在那里重现。如果没有,那么您有解决方法。
关于objective-c - CTFrame 在边缘丢弃字形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13548113/
(>>)的定义功能如下:(>>) :: Monad m => m a -> m b -> m b但我想实现这个功能翻转如下: 我有一个函数tabulate :: Int -> [Int] -> IO
我在新线程中创建一个新的托管对象上下文,并向其中插入一些对象。我可以通过不保存上下文来丢弃(忘记它们)它们吗?我的问题是这样的:我开始一个漫长的过程,在开始时创建一些 NSManagedObjects
关闭。这个问题是opinion-based .它目前不接受答案。 想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题. 3年前关闭。 Improve t
虽然建议打开编译器标志,如 -Wvalue-discard或 -Wunused:implicits通过使用 sbt-tpolecat 显式或隐式地. 有时您需要解决这些问题,但要以一种明确的方式;因为
在 R 中,na.omit()函数可用于丢弃包含 NA 值的 data.frame 中的条目。作为副作用,如果确实丢弃了行,则该函数会向结果添加一个属性 'omit',其中包含被丢弃的 row.nam
使用 geom_blank我想添加一些新的因子水平,但我似乎无法这样做并保留 NA水平 library('ggplot2') pl <- ggplot(data.frame(x = factor(c(
谁能告诉我两者之间是否有什么区别 DROP IF EXISTS [TABLE_NAME] DROP [TABLE_NAME] 我问这个问题是因为我在 MVC Web 应用程序中使用 JDBC 模板。如
例如,我有以下表达式映射: function! DelNthSpace() let col=match(getline('.'), '[[:blank:] ]', col('.'
默认情况下,Chrome 会丢弃后台未使用的选项卡以节省内存。 我想知道是否有一种方法可以让我现在可以在我的网站被 Chrome 丢弃的情况下 - 这样我就可以告诉我的用户,下次他们进入时,如何避免这
我的数据库中有一个元素列表,每个元素都有自己的日期时间字段。我想丢弃比今天更旧的元素,这意味着我只会看到 future 的元素。 这是我当前的代码: def get_dates_approved(re
我为我的 linux 机器编写了一个 C++ 工具,它接收 UDP (OSC) 数据包并立即将它们发回(这是它唯一做的事情)。但似乎有一些丢弃的数据包。当我向我的 linux(从另一台机器)发送 10
在创建 cron 作业时,我总是这样写: 15 0 * * * /somepath/somescript.pl > /dev/null 2>&1 关于末尾“>/dev/null 2>&1”丢弃所有st
我已经四处寻找有关此问题的指示,但找不到任何指示。假设我有一个 Python 列表: list = set([((3, 2), (2, 1)), ((3, 2), (3, 1)
我正在介绍 C,我需要编写一个程序来提示用户输入字符、等号和整数。我需要使用 getchar() 直到 '=' 然后使用 scanf() 获取整数。然后程序应该只输出整数返回给用户。 现在它打印出不必
如何忽略数据框中随机分布在数据框中的空单元格?这是我的例子 ColA ColB ColC ColD ColF ColG ColH A
我无法在网上找到我的问题的单一答案... 我正在为我的投资组合构思一个网站创意,并决定涉足一些 jQuery 让它更令人兴奋。我正确链接了 jQuery 并且工作,但是当我使用 .toggle 方法时
据我了解,在 Linux 中创建虚拟驱动器的过程是这样的 fallocate -l size /path/to/file.img; dd if=/dev/zero of=/path/tofile.im
大多数时候,我都是这样做的。 class a { public: ~ a() { i = 100; // OK delete (int *)j
下面的代码编译。它似乎运行良好。 但是它会导致任何未定义的行为吗? 我想抛弃 *this 的常量。 这是为了允许 const my_iterator 改变它指向的数据。 测试: class A { p
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: Is const_cast safe? 显然我永远不会写这段代码,但它是真实程序中出现的一个非常简单的例子。
我是一名优秀的程序员,十分优秀!