if (fontnameref && textref) {
/* set up the Core Text line */
CTFontRef font = CTFontCreateWithName(fontnameref, fontsize, NULL);
-
+ CFTypeRef attributeNames[] = { kCTFontAttributeName, kCTForegroundColorFromContextAttributeName };
+ CFTypeRef attributeValues[] = { font, kCFBooleanTrue };
CFDictionaryRef attributes = CFDictionaryCreate(
kCFAllocatorDefault,
- (const void**)&kCTFontAttributeName,
- (const void**)&font,
- 1,
+ (const void**)attributeNames,
+ (const void**)attributeValues,
+ 2,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
CFAttributedStringRef attributed = CFAttributedStringCreate(kCFAllocatorDefault, textref, attributes);
void quartz_draw_layout(void *layout, CGContextRef context, CGPoint position)
{
CGContextSetTextPosition(context, position.x, position.y);
-
- CFArrayRef runs = CTLineGetGlyphRuns((CTLineRef)layout);
- CFIndex run_count = CFArrayGetCount(runs);
- CFIndex run_index;
- for (run_index = 0; run_index < run_count; ++run_index)
- {
- CTRunRef run = (CTRunRef)CFArrayGetValueAtIndex(runs, run_index);
- CTFontRef run_font = CFDictionaryGetValue(CTRunGetAttributes(run), kCTFontAttributeName);
- CGFontRef glyph_font = CTFontCopyGraphicsFont(run_font, NULL);
- CFIndex glyph_count = CTRunGetGlyphCount(run);
- CGGlyph glyphs[glyph_count];
- CGPoint positions[glyph_count];
- CFRange everything = CFRangeMake(0, 0);
- CTRunGetGlyphs(run, everything, glyphs);
- CTRunGetPositions(run, everything, positions);
-
- CGContextSetFont(context, glyph_font);
- CGContextSetFontSize(context, CTFontGetSize(run_font));
- CGContextShowGlyphsAtPositions(context, glyphs, positions, glyph_count);
-
- CGFontRelease(glyph_font);
- }
+ CTLineDraw((CTLineRef)layout, context);
}
void quartz_free_layout(void *layout)