ios - 自定义字体产生崩溃

标签 ios fonts

我们使用自定义表情符号为应用程序创建了自定义字体。有时,应用程序会因以下堆栈跟踪而崩溃(总是一样):

0   libsystem_platform.dylib            0x38b8d486 _platform_memmove$VARIANT$Swift + 102
1   CoreFoundation                      0x2d8f7575 CFDataGetBytes + 237
2   ImageIO                             0x2e6e1e8f CGImageReadGetBytesAtOffset + 299
3   ImageIO                             0x2e6e1d59 CGImageReadSessionGetBytes + 29
4   ImageIO                             0x2e825973 read_fn + 23
5   ImageIO                             0x2e6e1cb1 png_read_sig + 45
6   ImageIO                             0x2e6e1935 _cg_png_read_info + 33
7   ImageIO                             0x2e6ea15b copyImageBlockSetPNG + 1123
8   ImageIO                             0x2e6e9779 ImageProviderCopyImageBlockSetCallback + 529
9   CoreGraphics                        0x2da2647d CGImageProviderCopyImageBlockSetWithOptions + 137
10  CoreGraphics                        0x2da492f7 CGImageProviderCopyImageBlockSet + 39
11  CoreGraphics                        0x2da2614f img_blocks_create + 411
12  CoreGraphics                        0x2da492bb img_blocks_extent + 63
13  CoreGraphics                        0x2da49271 img_interpolate_extent + 109
14  CoreGraphics                        0x2da1a12d img_data_lock + 4421
15  CoreGraphics                        0x2da187e9 CGSImageDataLock + 89
16  libRIP.A.dylib                      0x2dd65da7 ripc_AcquireImage + 99
17  libRIP.A.dylib                      0x2dd65131 ripc_DrawImage + 601
18  CoreGraphics                        0x2da186fb CGContextDelegateDrawImage + 51
19  CoreGraphics                        0x2da18581 CGContextDrawImage + 285
20  CoreText                            0x2e0a43db TCGImageData::DrawInRect(CGRect) const + 311
21  CoreText                            0x2e062299 CTFontDrawGlyphsWithAdvances + 705
22  CoreText                            0x2e070d55 TRun::DrawGlyphs(CGContext*, CFRange) const + 241
23  CoreText                            0x2e070c25 TLine::DrawGlyphs(CGContext*) const + 157
24  UIFoundation                        0x358860df __NSStringDrawingEngine + 10151
25  UIFoundation                        0x35883863 -[NSString(NSExtendedStringDrawing) drawWithRect:options:attributes:context:] + 151
26  UIKit                               0x301e72c9 -[UILabel _drawTextInRect:baselineCalculationOnly:] + 4225
27  UIKit                               0x3024d709 -[UILabel drawTextInRect:] + 501
28  UIKit                               0x3024d50b -[UILabel drawRect:] + 79
29  UIKit                               0x3024d4a9 -[UIView(CALayerDelegate) drawLayer:inContext:] + 373
30  QuartzCore                          0x2fe79189 -[CALayer drawInContext:] + 101

我不知道是否可以针对这种情况寻求帮助,但是也许苹果公司的某人可以提供建议以解决字体问题。如果需要,我可以提供字体。

最佳答案

不幸的是,这不是一个决定性的答案,但是评论太久了,所以我想随随便便投票赞成那些人。但是我希望您不会,因为我认为这可能是有用的信息。

我对该字体进行了深入的研究,该字体使用了新定义的'sbix' table(与Apple的Color Emoji字体一样)来存储图标的彩色图像(在这种情况下为PNG)。我浏览了数据表,然后将每个图标转储到PNG文件中,一切似乎都正常(这意味着:“sbix”表本身似乎符合规范,并且生成的PNG图像似乎不符合要求)损坏,实际上相当可笑!)。

但是:与我发现的Apple Color Emoji字体相比,该字体有一些特征。 Apple的字体有7种“字体”(大小):20、32、40、48、64、96、160,而您的字体只有一种:285。我的理解是,当系统要求时,系统应该按比例放大/缩小字体中不存在的字体大小(例如,您要求50,它将285缩小为50),但是考虑到Apple的最大字体大小为160,这使我想知道字体是否存在一些未指定的大小上限。我注意到的另一件事是PNG数据的宽度为256像素,我不确定这与285尺寸有什么关系(也许是填充?)。

查看堆栈跟踪,看起来好像是从字体中获取了图像数据,但是在实际渲染图像时出现了故障。

我不确定您用来创建此字体的方式,但是如果可以的话,您可以尝试缩放图像,使执行大小为160,与Apple的最大值匹配,然后查看发生了什么。抱歉,我无法提供更多帮助,但是我希望这至少能给您一些进一步调查的信息。

关于ios - 自定义字体产生崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25872007/

相关文章:

delphi - fmx delphi berlin 如何更改 Tgrid 行中的字体颜色

css - 在我的 css 中应用 light open sans 字体的问题

android - 如何打开默认文件管理器

ios - 能够在导航堆栈上推送无限 View Controller 的设计是否可以接受?

ios - 作为开发者,如何为 IOS 应用程序的订单退款?

javascript - Epiphany GNOME Web 浏览器 2.28.0 在呈现日语日期时挂起

linux - PDFBox 错误无法加载字体文件

HTML 和 CSS 自定义字体未出现在我的页面上

ios - 构建 iOS8 扩展目标时出现重复符号

ios - 如何更新静态库架构以支持 arm64 Build?