John Tracid
John Tracid

Reputation: 4046

Custom font produce crash

We created custom font for our application with custom Emoji symbols. Sometimes app crashes with following stacktrace (always the same):

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

I don't know is it possible to get help for such situation, but maybe someone from Apple could give advice what is wrong with font. I could provide font if needed.

Upvotes: 1

Views: 756

Answers (1)

djangodude
djangodude

Reputation: 5690

Unfortunately this is not a conclusive answer, but it's too long for a comment so I guess feel free to downvote, those who do that sort of thing. But I hope you won't, because I think this could be useful information.

I took a pretty deep look into this font, which uses the newly-defined 'sbix' table, just as Apple's Color Emoji font does, to store color images (PNGs in this case) for icons. I went through the data table and dumped out each of the icons to PNG files and everything appeared to be okay (what it means is: the 'sbix' table itself seems to follow the specification, and the resulting PNG images do not appear to be corrupted and are in fact rather amusing!).

However: there are some characteristics of this font compared to the Apple Color Emoji font that I find a bit odd. Apple's font has 7 "strikes" (sizes): 20, 32, 40, 48, 64, 96, 160, whereas yours has only one: 285. My understanding is that the system is supposed to up/down-scale when asked for a font size that doesn't exist in the font (e.g. you call for 50, it scales 285 down to 50), but given that Apple's maximum strike size is 160 it makes me wonder whether there is some unspecified upper size limit for fonts. Another thing I noticed is that the PNG data is 256 pixels wide and I'm not sure how that's supposed to relate to the 285 size (maybe padding?).

Looking at the stack trace, it looks like it's getting the image data out of the font, but failing somewhere during the actual rendering of the image.

I'm not sure what you used to create this font, but something you might try if you can is to scale the images such that your strike size is 160, matching Apple's maximum, and see what happens there. Sorry I could not be of more help, but I hope this at least gives you something to investigate further.

Upvotes: 3

Related Questions