26 CFStringRef fontnameref = CFStringCreateWithCString(
NULL, fontname, kCFStringEncodingUTF8);
27 CFStringRef textref = CFStringCreateWithCString(
NULL, text, kCFStringEncodingUTF8);
28 CTLineRef line =
NULL;
30 if (fontnameref && textref) {
32 CTFontRef
font = CTFontCreateWithName(fontnameref, fontsize,
NULL);
33 const void *attributeNames[] = {
34 kCTFontAttributeName, kCTForegroundColorFromContextAttributeName};
35 const void *attributeValues[] = {
font, kCFBooleanTrue};
36 CFDictionaryRef attributes = CFDictionaryCreate(
40 sizeof(attributeNames) /
sizeof(attributeNames[0]),
41 &kCFTypeDictionaryKeyCallBacks,
42 &kCFTypeDictionaryValueCallBacks);
43 CFAttributedStringRef attributed = CFAttributedStringCreate(
NULL, textref, attributes);
44 line = CTLineCreateWithAttributedString(attributed);
46 CFRelease(attributed);
47 CFRelease(attributes);
54 CFRelease(fontnameref);
60#pragma GCC diagnostic push
61#pragma GCC diagnostic ignored "-Wcast-qual"
65#pragma GCC diagnostic pop
73 CGFloat descent = 0.0;
74 CGFloat leading = 0.0;
76 *width = CTLineGetTypographicBounds(
layout, &ascent, &descent, &leading);
77 *height = ascent + descent + leading;
78 *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)