27 CFStringRef fontnameref = CFStringCreateWithBytes(kCFAllocatorDefault, (
const UInt8 *)fontname, strlen(fontname), kCFStringEncodingUTF8, FALSE);
28 CFStringRef textref = CFStringCreateWithBytes(kCFAllocatorDefault, (
const UInt8 *)text, strlen(text), kCFStringEncodingUTF8, FALSE);
29 CTLineRef line =
NULL;
31 if (fontnameref && textref) {
33 CTFontRef
font = CTFontCreateWithName(fontnameref, fontsize,
NULL);
34 CFTypeRef attributeNames[] = { kCTFontAttributeName, kCTForegroundColorFromContextAttributeName };
35 CFTypeRef attributeValues[] = {
font, kCFBooleanTrue };
36 CFDictionaryRef attributes = CFDictionaryCreate(
38 (
const void**)attributeNames,
39 (
const void**)attributeValues,
41 &kCFTypeDictionaryKeyCallBacks,
42 &kCFTypeDictionaryValueCallBacks);
43 CFAttributedStringRef attributed = CFAttributedStringCreate(kCFAllocatorDefault, textref, attributes);
44 line = CTLineCreateWithAttributedString(attributed);
46 CFRelease(attributed);
47 CFRelease(attributes);
54 CFRelease(fontnameref);
62 CGFloat descent = 0.0;
63 CGFloat leading = 0.0;
65 *width = CTLineGetTypographicBounds(
layout, &ascent, &descent, &leading);
66 *height = ascent + descent + leading;
67 *yoffset_layout = ascent;
void quartz_draw_layout(void *layout, CGContextRef context, CGPoint position)
void * quartz_new_layout(char *fontname, double fontsize, char *text)
static gvtextlayout_engine_t quartz_textlayout_engine
void quartz_size_layout(void *layout, double *width, double *height, double *yoffset_layout)
gvplugin_installed_t gvtextlayout_quartz_types[]
void quartz_free_layout(void *layout)
static bool quartz_textlayout(textspan_t *para, char **fontpath)
double yoffset_centerline
void(* free_layout)(void *layout)