/* Font driver on Mac OSX Core text.
- Copyright (C) 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2009-2015 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#include "macfont.h"
#include "macuvs.h"
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
-
#include <libkern/OSByteOrder.h>
static struct font_driver macfont_driver;
-/* Core Text, for Mac OS X 10.5 and later. */
-static Lisp_Object Qmac_ct;
-
static double mac_ctfont_get_advance_width_for_glyph (CTFontRef, CGGlyph);
static CGRect mac_ctfont_get_bounding_rect_for_glyph (CTFontRef, CGGlyph);
static CFArrayRef mac_ctfont_create_available_families (void);
CGFontIndex);
#endif
-/* The font property key specifying the font design destination. The
- value is an unsigned integer code: 0 for WYSIWYG, and 1 for Video
- text. (See the documentation of X Logical Font Description
- Conventions.) In the Mac font driver, 1 means the screen font is
- used for calculating some glyph metrics. You can see the
- difference with Monaco 8pt or 9pt, for example. */
-static Lisp_Object QCdestination;
-
-/* The boolean-valued font property key specifying the use of
- leading. */
-static Lisp_Object QCminspace;
-
struct macfont_metrics;
/* The actual structure for Mac font that can be cast to struct font. */
if (family_name == NULL)
return NULL;
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
- if (CTFontManagerCompareFontFamilyNames != NULL)
-#endif
{
family_name_comparator = CTFontManagerCompareFontFamilyNames;
}
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
- else /* CTFontManagerCompareFontFamilyNames == NULL */
-#endif
-#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 */
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
- {
- family_name_comparator = mac_font_family_compare;
- }
-#endif
if ((*family_name_comparator) (family_name, CFSTR ("LastResort"), NULL)
== kCFCompareEqualTo)
bounds.size =
CGSizeApplyAffineTransform (bounds.size, synthetic_italic_atfm);
}
- if (macfont_info->synthetic_bold_p)
+ if (macfont_info->synthetic_bold_p && ! force_integral_p)
{
CGFloat d =
- synthetic_bold_factor * mac_font_get_size (macfont) / 2;
CGGlyph *glyphs;
int i, len;
int nrows;
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
dispatch_queue_t queue;
dispatch_group_t group = NULL;
-#else
- int nkeys;
-#endif
if (row != 0)
{
return glyph;
}
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
queue =
dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
group = dispatch_group_create ();
dispatch_group_async (group, queue, ^{
int nkeys;
uintptr_t key;
-#endif
nkeys = nkeys_or_perm;
for (key = row * (256 / NGLYPHS_IN_VALUE); ; key++)
if (CFDictionaryContainsKey (dictionary,
if (--nkeys == 0)
break;
}
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
});
-#endif
}
len = 0;
cache->glyph.matrix[nrows - 1] = glyphs;
cache->glyph.nrows = nrows;
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
if (group)
{
dispatch_group_wait (group, DISPATCH_TIME_FOREVER);
dispatch_release (group);
}
-#endif
}
return cache->glyph.matrix[nkeys_or_perm - ROW_PERM_OFFSET][c % 256];
CGPoint *positions;
CGFloat font_size = mac_font_get_size (macfont_info->macfont);
bool no_antialias_p =
- (macfont_info->antialias == MACFONT_ANTIALIAS_OFF
+ (NILP (ns_antialias_text)
+ || macfont_info->antialias == MACFONT_ANTIALIAS_OFF
|| (macfont_info->antialias == MACFONT_ANTIALIAS_DEFAULT
&& font_size <= macfont_antialias_threshold));
int len = to - from;
s->width, FONT_HEIGHT (s->font));
else
background_rect = CGRectNull;
-
+
text_position = CGPointMake (x, -y);
glyphs = xmalloc (sizeof (CGGlyph) * len);
{
if (!CGRectIsNull (background_rect))
{
- if (s->hl == DRAW_MOUSE_FACE)
+ if (s->hl == DRAW_MOUSE_FACE)
{
face = FACE_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id);
if (!face)
CG_SET_FILL_COLOR_WITH_FACE_BACKGROUND (context, face, f);
CGContextFillRects (context, &background_rect, 1);
}
-
+
if (macfont_info->cgfont)
{
CGAffineTransform atfm;
atfm = synthetic_italic_atfm;
else
atfm = CGAffineTransformIdentity;
- if (macfont_info->synthetic_bold_p)
+ if (macfont_info->synthetic_bold_p && ! no_antialias_p)
{
CGContextSetTextDrawingMode (context, kCGTextFillStroke);
CGContextSetLineWidth (context, synthetic_bold_factor * font_size);
struct variation_selector_record *records = uvs->variation_selector_records;
CFIndex i;
UInt32 ir, nrecords;
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
dispatch_queue_t queue =
dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_group_t group = dispatch_group_create ();
-#endif
nrecords = BUINT32_VALUE (uvs->num_var_selector_records);
i = 0;
default_uvs_offset = BUINT32_VALUE (records[ir].default_uvs_offset);
non_default_uvs_offset =
BUINT32_VALUE (records[ir].non_default_uvs_offset);
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
dispatch_group_async (group, queue, ^{
-#endif
glyphs[i] = kCGFontIndexInvalid;
if (default_uvs_offset)
BUINT24_VALUE (mappings[hi - 1].unicode_value) == c)
glyphs[i] = BUINT16_VALUE (mappings[hi - 1].glyph_id);
}
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
});
-#endif
i++;
ir++;
}
while (i < count)
glyphs[i++] = kCGFontIndexInvalid;
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
dispatch_group_wait (group, DISPATCH_TIME_FOREVER);
dispatch_release (group);
-#endif
}
static int
{
CFMutableArrayRef families = NULL;
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
- if (CTFontManagerCopyAvailableFontFamilyNames != NULL)
-#endif
{
CFArrayRef orig_families = CTFontManagerCopyAvailableFontFamilyNames ();
CFRelease (orig_families);
}
}
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
- else /* CTFontManagerCopyAvailableFontFamilyNames == NULL */
-#endif
-#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 */
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
- {
- CTFontCollectionRef collection;
- CFArrayRef descs = NULL;
-
- collection = CTFontCollectionCreateFromAvailableFonts (NULL);
- if (collection)
- {
- descs = CTFontCollectionCreateMatchingFontDescriptors (collection);
- CFRelease (collection);
- }
- if (descs)
- {
- CFIndex i, count = CFArrayGetCount (descs);
- families = CFArrayCreateMutable (NULL, count, &kCFTypeArrayCallBacks);
- if (families)
- for (i = 0; i < count; i++)
- {
- FontDescriptorRef desc = CFArrayGetValueAtIndex (descs, i);
- CFStringRef name =
- mac_font_descriptor_copy_attribute (desc,
- MAC_FONT_FAMILY_NAME_ATTRIBUTE);
-
- if (name)
- {
- CFIndex p, limit = CFArrayGetCount (families);
-
- p = CFArrayBSearchValues (families, CFRangeMake (0, limit),
- (const void *) name,
- mac_font_family_compare, NULL);
- if (p >= limit)
- CFArrayAppendValue (families, name);
- else if (mac_font_family_compare
- (CFArrayGetValueAtIndex (families, p),
- name, NULL) != kCFCompareEqualTo)
- CFArrayInsertValueAtIndex (families, p, name);
- CFRelease (name);
- }
- }
- CFRelease (descs);
- }
- }
-#endif
-
- return families;
+ return families;
}
static Boolean
}
#endif
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
-static inline int
-mac_font_family_group (CFStringRef family)
-{
- if (CFStringHasPrefix (family, CFSTR ("#")))
- return 2;
- else
- {
- CFRange range;
-
- range = CFStringFind (family, CFSTR ("Apple"),
- kCFCompareCaseInsensitive | kCFCompareAnchored);
- if (range.location != kCFNotFound)
- return 1;
-
- return 0;
- }
-}
-
-static CFComparisonResult
-mac_font_family_compare (const void *val1, const void *val2, void *context)
-{
- CFStringRef family1 = (CFStringRef) val1, family2 = (CFStringRef) val2;
- int group1, group2;
-
- group1 = mac_font_family_group (family1);
- group2 = mac_font_family_group (family2);
- if (group1 < group2)
- return kCFCompareLessThan;
- if (group1 > group2)
- return kCFCompareGreaterThan;
- return CFStringCompare (family1, family2, kCFCompareCaseInsensitive);
-}
-#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1060 */
-
static CFArrayRef
mac_font_copy_default_descriptors_for_language (CFStringRef language)
{
register_font_driver (&macfont_driver, f);
}
-#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
-
\f
void
syms_of_macfont (void)
{
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
static struct font_driver mac_font_driver;
+ /* Core Text, for Mac OS X. */
DEFSYM (Qmac_ct, "mac-ct");
macfont_driver.type = Qmac_ct;
register_font_driver (&macfont_driver, NULL);
+ /* The font property key specifying the font design destination. The
+ value is an unsigned integer code: 0 for WYSIWYG, and 1 for Video
+ text. (See the documentation of X Logical Font Description
+ Conventions.) In the Mac font driver, 1 means the screen font is
+ used for calculating some glyph metrics. You can see the
+ difference with Monaco 8pt or 9pt, for example. */
DEFSYM (QCdestination, ":destination");
+
+ /* The boolean-valued font property key specifying the use of leading. */
DEFSYM (QCminspace, ":minspace");
-#endif
}