Skip to content
Snippets Groups Projects
Commit 4cc6411f authored by George Nachman's avatar George Nachman
Browse files

Handle failures of CTRunGetGlyphsPtr and CTRunGetPositionsPtr

parent 6724e4df
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -6505,7 +6505,17 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
range.location = 0;
size_t length = CTRunGetGlyphCount(run);
const CGGlyph *buffer = CTRunGetGlyphsPtr(run);
if (!buffer) {
NSMutableData *tempBuffer = [[[NSMutableData alloc] initWithLength:sizeof(CGGlyph) * length] autorelease];
CTRunGetGlyphs(run, CFRangeMake(0, length), (CGGlyph *)tempBuffer.mutableBytes);
buffer = tempBuffer.mutableBytes;
}
const CGPoint *positions = CTRunGetPositionsPtr(run);
if (!positions) {
NSMutableData *tempBuffer = [[[NSMutableData alloc] initWithLength:sizeof(CGPoint) * length] autorelease];
CTRunGetPositions(run, CFRangeMake(0, length), (CGPoint *)tempBuffer.mutableBytes);
positions = tempBuffer.mutableBytes;
}
CTFontRef runFont = CFDictionaryGetValue(CTRunGetAttributes(run), kCTFontAttributeName);
drawGlyphsFunction(runFont, buffer, (NSPoint *)positions, length, cgContext);
if (fakeBold) {
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment