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 = CFStringCreateWithBytes(kCFAllocatorDefault, (
const UInt8 *)fontname, strlen(fontname), kCFStringEncodingUTF8, FALSE);
41 CFStringRef textref = CFStringCreateWithBytes(kCFAllocatorDefault, (
const UInt8 *)text, strlen(text), kCFStringEncodingUTF8, FALSE);
42 CTLineRef line =
NULL;
44 if (fontnameref && textref) {
46 CTFontRef
font = CTFontCreateWithName(fontnameref, fontsize,
NULL);
47 CFTypeRef attributeNames[] = { kCTFontAttributeName, kCTForegroundColorFromContextAttributeName };
48 CFTypeRef attributeValues[] = {
font, kCFBooleanTrue };
49 CFDictionaryRef attributes = CFDictionaryCreate(
51 (
const void**)attributeNames,
52 (
const void**)attributeValues,
54 &kCFTypeDictionaryKeyCallBacks,
55 &kCFTypeDictionaryValueCallBacks);
56 CFAttributedStringRef attributed = CFAttributedStringCreate(kCFAllocatorDefault, textref, attributes);
57 line = CTLineCreateWithAttributedString(attributed);
59 CFRelease(attributed);
60 CFRelease(attributes);
67 CFRelease(fontnameref);
75 CGFloat descent = 0.0;
76 CGFloat leading = 0.0;
78 *width = CTLineGetTypographicBounds(
layout, &ascent, &descent, &leading);
79 *height = ascent + descent + leading;
80 *yoffset_layout = ascent;
86 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)