20#ifdef __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__
21#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 30200
22#include <CoreText/CoreText.h>
26#if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
27 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050) || \
28 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
29 __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 30200)
31#ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
32#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1060
34extern const CFStringRef kCTForegroundColorFromContextAttributeName;
40 CFStringRef fontnameref = CFStringCreateWithCString(
NULL, fontname, kCFStringEncodingUTF8);
41 CFStringRef textref = CFStringCreateWithCString(
NULL, text, kCFStringEncodingUTF8);
42 CTLineRef line =
NULL;
44 if (fontnameref && textref) {
46 CTFontRef
font = CTFontCreateWithName(fontnameref, fontsize,
NULL);
47 const void *attributeNames[] = {
48 kCTFontAttributeName, kCTForegroundColorFromContextAttributeName};
49 const void *attributeValues[] = {
font, kCFBooleanTrue};
50 CFDictionaryRef attributes = CFDictionaryCreate(
54 sizeof(attributeNames) /
sizeof(attributeNames[0]),
55 &kCFTypeDictionaryKeyCallBacks,
56 &kCFTypeDictionaryValueCallBacks);
57 CFAttributedStringRef attributed = CFAttributedStringCreate(
NULL, textref, attributes);
58 line = CTLineCreateWithAttributedString(attributed);
60 CFRelease(attributed);
61 CFRelease(attributes);
68 CFRelease(fontnameref);
74#pragma GCC diagnostic push
75#pragma GCC diagnostic ignored "-Wcast-qual"
79#pragma GCC diagnostic pop
87 CGFloat descent = 0.0;
88 CGFloat leading = 0.0;
90 *width = CTLineGetTypographicBounds(
layout, &ascent, &descent, &leading);
91 *height = ascent + descent + leading;
92 *yoffset_layout = ascent;
98 CTLineDraw(
layout, context);
void quartz_draw_layout(void *layout, CGContextRef context, CGPoint position)
void * quartz_new_layout(char *fontname, double fontsize, char *text)
void quartz_size_layout(void *layout, double *width, double *height, double *yoffset_layout)
void quartz_free_layout(void *layout)
static gvtextlayout_engine_t quartz_textlayout_engine
gvplugin_installed_t gvtextlayout_quartz_types[]
static bool quartz_textlayout(textspan_t *para, char **fontpath)
static int layout(graph_t *g, layout_info *infop)
double yoffset_centerline
void(* free_layout)(void *layout)