Update copyright year to 2014 by running admin/update-copyright.
[emacs.git] / src / macfont.h
blob8b451357e42c6e4b81ef97aa036d85be14d8eff2
1 /* Interface definition for Mac OSX Core text font backend.
2 Copyright (C) 2009-2014 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
19 Original author: YAMAMOTO Mitsuharu
22 /* Structure used by Mac `shape' functions for storing layout
23 information for each glyph. */
24 struct mac_glyph_layout
26 /* Range of indices of the characters composed into the group of
27 glyphs that share the cursor position with this glyph. The
28 members `location' and `length' are in UTF-16 indices. */
29 CFRange comp_range;
31 /* UTF-16 index in the source string for the first character
32 associated with this glyph. */
33 CFIndex string_index;
35 /* Horizontal and vertical adjustments of glyph position. The
36 coordinate space is that of Core Text. So, the `baseline_delta'
37 value is negative if the glyph should be placed below the
38 baseline. */
39 CGFloat advance_delta, baseline_delta;
41 /* Typographical width of the glyph. */
42 CGFloat advance;
44 /* Glyph ID of the glyph. */
45 CGGlyph glyph_id;
48 typedef CTFontDescriptorRef FontDescriptorRef;
49 typedef CTFontRef FontRef;
50 typedef CTFontSymbolicTraits FontSymbolicTraits;
51 typedef CTCharacterCollection CharacterCollection;
53 #define MAC_FONT_NAME_ATTRIBUTE kCTFontNameAttribute
54 #define MAC_FONT_FAMILY_NAME_ATTRIBUTE kCTFontFamilyNameAttribute
55 #define MAC_FONT_TRAITS_ATTRIBUTE kCTFontTraitsAttribute
56 #define MAC_FONT_SIZE_ATTRIBUTE kCTFontSizeAttribute
57 #define MAC_FONT_CASCADE_LIST_ATTRIBUTE kCTFontCascadeListAttribute
58 #define MAC_FONT_CHARACTER_SET_ATTRIBUTE kCTFontCharacterSetAttribute
59 #define MAC_FONT_LANGUAGES_ATTRIBUTE kCTFontLanguagesAttribute
60 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
61 #define MAC_FONT_FORMAT_ATTRIBUTE kCTFontFormatAttribute
62 #else
63 #define MAC_FONT_FORMAT_ATTRIBUTE (CFSTR ("NSCTFontFormatAttribute"))
64 #endif
65 #define MAC_FONT_SYMBOLIC_TRAIT kCTFontSymbolicTrait
66 #define MAC_FONT_WEIGHT_TRAIT kCTFontWeightTrait
67 #define MAC_FONT_WIDTH_TRAIT kCTFontWidthTrait
68 #define MAC_FONT_SLANT_TRAIT kCTFontSlantTrait
70 enum {
71 MAC_FONT_TRAIT_ITALIC = kCTFontItalicTrait,
72 MAC_FONT_TRAIT_BOLD = kCTFontBoldTrait,
73 MAC_FONT_TRAIT_MONO_SPACE = kCTFontMonoSpaceTrait,
74 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
75 MAC_FONT_TRAIT_COLOR_GLYPHS = kCTFontColorGlyphsTrait
76 #else
77 MAC_FONT_TRAIT_COLOR_GLYPHS = (1 << 13)
78 #endif
81 enum {
82 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
83 MAC_FONT_FORMAT_BITMAP = kCTFontFormatBitmap
84 #else
85 MAC_FONT_FORMAT_BITMAP = 5
86 #endif
89 enum {
90 MAC_CHARACTER_COLLECTION_IDENTITY_MAPPING = kCTIdentityMappingCharacterCollection,
91 MAC_CHARACTER_COLLECTION_ADOBE_JAPAN1 = kCTAdobeJapan1CharacterCollection
94 #define mac_font_descriptor_create_with_attributes \
95 CTFontDescriptorCreateWithAttributes
96 #define mac_font_descriptor_create_matching_font_descriptors \
97 CTFontDescriptorCreateMatchingFontDescriptors
98 #define mac_font_descriptor_create_matching_font_descriptor \
99 CTFontDescriptorCreateMatchingFontDescriptor
100 #define mac_font_descriptor_copy_attribute CTFontDescriptorCopyAttribute
101 #define mac_font_descriptor_supports_languages \
102 mac_ctfont_descriptor_supports_languages
103 #define mac_font_create_with_name(name, size) \
104 CTFontCreateWithName (name, size, NULL)
105 #define mac_font_get_size CTFontGetSize
106 #define mac_font_copy_family_name CTFontCopyFamilyName
107 #define mac_font_copy_character_set CTFontCopyCharacterSet
108 #define mac_font_get_glyphs_for_characters CTFontGetGlyphsForCharacters
109 #define mac_font_get_ascent CTFontGetAscent
110 #define mac_font_get_descent CTFontGetDescent
111 #define mac_font_get_leading CTFontGetLeading
112 #define mac_font_get_underline_position CTFontGetUnderlinePosition
113 #define mac_font_get_underline_thickness CTFontGetUnderlineThickness
114 #define mac_font_copy_graphics_font(font) CTFontCopyGraphicsFont (font, NULL)
115 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
116 #define mac_font_copy_non_synthetic_table(font, table) \
117 CTFontCopyTable (font, table, kCTFontTableOptionNoOptions)
118 #else
119 #define mac_font_copy_non_synthetic_table(font, table) \
120 CTFontCopyTable (font, table, kCTFontTableOptionExcludeSynthetic)
121 #endif
123 #define mac_font_create_preferred_family_for_attributes \
124 mac_ctfont_create_preferred_family_for_attributes
125 #define mac_font_get_advance_width_for_glyph \
126 mac_ctfont_get_advance_width_for_glyph
127 #define mac_font_get_bounding_rect_for_glyph \
128 mac_ctfont_get_bounding_rect_for_glyph
129 #define mac_font_create_available_families mac_ctfont_create_available_families
130 #define mac_font_shape mac_ctfont_shape
131 #if USE_CT_GLYPH_INFO
132 #define mac_font_get_glyph_for_cid mac_ctfont_get_glyph_for_cid
133 #endif
135 #define mac_nsctfont_copy_font_descriptor CTFontCopyFontDescriptor
137 #ifndef kCTVersionNumber10_9
138 #define kCTVersionNumber10_9 0x00060000
139 #endif
140 #define MAC_FONT_CHARACTER_SET_STRING_ATTRIBUTE \
141 (CFSTR ("MAC_FONT_CHARACTER_SET_STRING_ATTRIBUTE"))
143 typedef const struct _EmacsScreenFont *ScreenFontRef; /* opaque */
145 extern void mac_register_font_driver (struct frame *f);
146 extern void *macfont_get_nsctfont (struct font *font);