aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorK. Handa2015-09-01 20:46:15 +0900
committerK. Handa2015-09-01 20:46:15 +0900
commit3e0e2339cd379eeba8d9bc758f2e8e574144e252 (patch)
tree9d119efed6e52e5c24dbd84836148157271799a8 /src
parent524eeb2e5e158d98ea52fe5ebe4768c4433ba8b2 (diff)
parentff0a92f6461941902eb9e974bdd2ff9adacb7bc4 (diff)
downloademacs-3e0e2339cd379eeba8d9bc758f2e8e574144e252.tar.gz
emacs-3e0e2339cd379eeba8d9bc758f2e8e574144e252.zip
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog.137
-rw-r--r--src/fileio.c22
-rw-r--r--src/gtkutil.c2
-rw-r--r--src/macfont.h70
-rw-r--r--src/macfont.m451
-rw-r--r--src/syntax.c2
-rw-r--r--src/w32.c95
-rw-r--r--src/w32.h1
-rw-r--r--src/w32term.c2
-rw-r--r--src/xterm.c2
10 files changed, 325 insertions, 329 deletions
diff --git a/src/ChangeLog.13 b/src/ChangeLog.13
index 196bd8e0d6d..ac2162830c4 100644
--- a/src/ChangeLog.13
+++ b/src/ChangeLog.13
@@ -5245,8 +5245,7 @@
5245 (xg_set_toolkit_horizontal_scroll_bar_thumb) 5245 (xg_set_toolkit_horizontal_scroll_bar_thumb)
5246 (xg_get_default_scrollbar_height) 5246 (xg_get_default_scrollbar_height)
5247 (xg_clear_under_internal_border): Extern. 5247 (xg_clear_under_internal_border): Extern.
5248 * gtkutil.c (xg_frame_resized): Don't call 5248 * gtkutil.c (xg_frame_resized): Call do_pending_window_change.
5249 do_pending_window_change.
5250 (xg_frame_set_char_size): Use adjust_frame_size. 5249 (xg_frame_set_char_size): Use adjust_frame_size.
5251 (style_changed_cb): Call update_theme_scrollbar_height and 5250 (style_changed_cb): Call update_theme_scrollbar_height and
5252 x_set_scroll_bar_default_height. 5251 x_set_scroll_bar_default_height.
@@ -5367,7 +5366,7 @@
5367 build without toolkit. Always clear under internal border. 5366 build without toolkit. Always clear under internal border.
5368 (x_set_window_size): Don't check frame size or recompute 5367 (x_set_window_size): Don't check frame size or recompute
5369 fringes. Reset fullscreen status before applying sizes. 5368 fringes. Reset fullscreen status before applying sizes.
5370 Always resize as requested by pixelwise argument. Don't call 5369 Always resize as requested by pixelwise argument. Call
5371 do_pending_window_change. 5370 do_pending_window_change.
5372 (x_wm_set_size_hint): Add call for FRAME_SCROLL_BAR_AREA_HEIGHT. 5371 (x_wm_set_size_hint): Add call for FRAME_SCROLL_BAR_AREA_HEIGHT.
5373 (w32_initialize_display_info): Initialize dpyinfo's 5372 (w32_initialize_display_info): Initialize dpyinfo's
@@ -5519,7 +5518,7 @@
5519 Call x_net_wm_state. 5518 Call x_net_wm_state.
5520 (x_set_window_size_1, x_wm_set_size_hint): Don't call 5519 (x_set_window_size_1, x_wm_set_size_hint): Don't call
5521 check_frame_size. 5520 check_frame_size.
5522 (x_set_window_size): Don't call check_frame_size and 5521 (x_set_window_size): Don't call check_frame_size. Call
5523 do_pending_window_change. 5522 do_pending_window_change.
5524 (x_term_init): Init horizontal_scroll_bar_cursor display info. 5523 (x_term_init): Init horizontal_scroll_bar_cursor display info.
5525 (x_create_terminal): Add set_horizontal_scroll_bar_hook. 5524 (x_create_terminal): Add set_horizontal_scroll_bar_hook.
diff --git a/src/fileio.c b/src/fileio.c
index debd1f30a4f..a36dfbcfa36 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2655,11 +2655,7 @@ and the directory must allow you to open files in it. In order to use a
2655directory as a buffer's current directory, this predicate must return true. 2655directory as a buffer's current directory, this predicate must return true.
2656A directory name spec may be given instead; then the value is t 2656A directory name spec may be given instead; then the value is t
2657if the directory so specified exists and really is a readable and 2657if the directory so specified exists and really is a readable and
2658searchable directory. 2658searchable directory. */)
2659
2660The result might be a false positive on MS-Windows in some rare cases,
2661i.e., this function could return t for a directory that is not
2662accessible by the current user. */)
2663 (Lisp_Object filename) 2659 (Lisp_Object filename)
2664{ 2660{
2665 Lisp_Object absname; 2661 Lisp_Object absname;
@@ -2689,10 +2685,18 @@ bool
2689file_accessible_directory_p (Lisp_Object file) 2685file_accessible_directory_p (Lisp_Object file)
2690{ 2686{
2691#ifdef DOS_NT 2687#ifdef DOS_NT
2692 /* There's no need to test whether FILE is searchable, as the 2688# ifdef WINDOWSNT
2693 searchable/executable bit is invented on DOS_NT platforms. */ 2689 /* We need a special-purpose test because (a) NTFS security data is
2690 not reflected in Posix-style mode bits, and (b) the trick with
2691 accessing "DIR/.", used below on Posix hosts, doesn't work on
2692 Windows, because "DIR/." is normalized to just "DIR" before
2693 hitting the disk. */
2694 return (SBYTES (file) == 0
2695 || w32_accessible_directory_p (SSDATA (file), SBYTES (file)));
2696# else /* MSDOS */
2694 return file_directory_p (SSDATA (file)); 2697 return file_directory_p (SSDATA (file));
2695#else 2698# endif /* MSDOS */
2699#else /* !DOS_NT */
2696 /* On POSIXish platforms, use just one system call; this avoids a 2700 /* On POSIXish platforms, use just one system call; this avoids a
2697 race and is typically faster. */ 2701 race and is typically faster. */
2698 const char *data = SSDATA (file); 2702 const char *data = SSDATA (file);
@@ -2725,7 +2729,7 @@ file_accessible_directory_p (Lisp_Object file)
2725 SAFE_FREE (); 2729 SAFE_FREE ();
2726 errno = saved_errno; 2730 errno = saved_errno;
2727 return ok; 2731 return ok;
2728#endif 2732#endif /* !DOS_NT */
2729} 2733}
2730 2734
2731DEFUN ("file-regular-p", Ffile_regular_p, Sfile_regular_p, 1, 1, 0, 2735DEFUN ("file-regular-p", Ffile_regular_p, Sfile_regular_p, 1, 1, 0,
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 89647ee8d97..725e3306c82 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -920,8 +920,6 @@ xg_frame_resized (struct frame *f, int pixelwidth, int pixelheight)
920 change_frame_size (f, width, height, 0, 1, 0, 1); 920 change_frame_size (f, width, height, 0, 1, 0, 1);
921 SET_FRAME_GARBAGED (f); 921 SET_FRAME_GARBAGED (f);
922 cancel_mouse_face (f); 922 cancel_mouse_face (f);
923
924 do_pending_window_change (0);
925 } 923 }
926} 924}
927 925
diff --git a/src/macfont.h b/src/macfont.h
index 403be94e332..cab57372abb 100644
--- a/src/macfont.h
+++ b/src/macfont.h
@@ -45,82 +45,32 @@ struct mac_glyph_layout
45 CGGlyph glyph_id; 45 CGGlyph glyph_id;
46}; 46};
47 47
48typedef CTFontDescriptorRef FontDescriptorRef; 48#if MAC_OS_X_VERSION_MAX_ALLOWED < 1080
49typedef CTFontRef FontRef;
50typedef CTFontSymbolicTraits FontSymbolicTraits;
51typedef NSCharacterCollection CharacterCollection;
52
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#define MAC_FONT_FORMAT_ATTRIBUTE kCTFontFormatAttribute
61#define MAC_FONT_SYMBOLIC_TRAIT kCTFontSymbolicTrait
62#define MAC_FONT_WEIGHT_TRAIT kCTFontWeightTrait
63#define MAC_FONT_WIDTH_TRAIT kCTFontWidthTrait
64#define MAC_FONT_SLANT_TRAIT kCTFontSlantTrait
65
66enum { 49enum {
67 MAC_FONT_TRAIT_ITALIC = kCTFontItalicTrait, 50 kCTFontTraitItalic = kCTFontItalicTrait,
68 MAC_FONT_TRAIT_BOLD = kCTFontBoldTrait, 51 kCTFontTraitBold = kCTFontBoldTrait,
69 MAC_FONT_TRAIT_MONO_SPACE = kCTFontMonoSpaceTrait, 52 kCTFontTraitMonoSpace = kCTFontMonoSpaceTrait,
70#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 53#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
71 MAC_FONT_TRAIT_COLOR_GLYPHS = kCTFontColorGlyphsTrait 54 kCTFontTraitColorGlyphs = kCTFontColorGlyphsTrait
72#else 55#else
73 MAC_FONT_TRAIT_COLOR_GLYPHS = (1 << 13) 56 kCTFontTraitColorGlyphs = (1 << 13)
74#endif 57#endif
75}; 58};
76 59
77enum { 60enum {
78 MAC_FONT_FORMAT_BITMAP = kCTFontFormatBitmap 61 kCTCharacterCollectionIdentityMapping = kCTIdentityMappingCharacterCollection,
62 kCTCharacterCollectionAdobeJapan1 = kCTAdobeJapan1CharacterCollection
79}; 63};
80 64
81enum { 65enum {
82 MAC_CHARACTER_COLLECTION_IDENTITY_MAPPING = NSIdentityMappingCharacterCollection, 66 kCTFontOrientationDefault = kCTFontDefaultOrientation
83 MAC_CHARACTER_COLLECTION_ADOBE_JAPAN1 = NSAdobeJapan1CharacterCollection
84}; 67};
68#endif
85 69
86#define mac_font_descriptor_create_with_attributes \
87 CTFontDescriptorCreateWithAttributes
88#define mac_font_descriptor_create_matching_font_descriptors \
89 CTFontDescriptorCreateMatchingFontDescriptors
90#define mac_font_descriptor_create_matching_font_descriptor \
91 CTFontDescriptorCreateMatchingFontDescriptor
92#define mac_font_descriptor_copy_attribute CTFontDescriptorCopyAttribute
93#define mac_font_descriptor_supports_languages \
94 mac_ctfont_descriptor_supports_languages
95#define mac_font_create_with_name(name, size) \
96 CTFontCreateWithName (name, size, NULL)
97#define mac_font_get_size CTFontGetSize
98#define mac_font_copy_family_name CTFontCopyFamilyName
99#define mac_font_copy_character_set CTFontCopyCharacterSet
100#define mac_font_get_glyphs_for_characters CTFontGetGlyphsForCharacters
101#define mac_font_get_ascent CTFontGetAscent
102#define mac_font_get_descent CTFontGetDescent
103#define mac_font_get_leading CTFontGetLeading
104#define mac_font_get_underline_position CTFontGetUnderlinePosition
105#define mac_font_get_underline_thickness CTFontGetUnderlineThickness
106#define mac_font_copy_graphics_font(font) CTFontCopyGraphicsFont (font, NULL)
107#define mac_font_copy_non_synthetic_table(font, table) \
108 CTFontCopyTable (font, table, kCTFontTableOptionNoOptions)
109
110#define mac_font_create_preferred_family_for_attributes \
111 mac_ctfont_create_preferred_family_for_attributes
112#define mac_font_get_advance_width_for_glyph \
113 mac_ctfont_get_advance_width_for_glyph
114#define mac_font_get_bounding_rect_for_glyph \
115 mac_ctfont_get_bounding_rect_for_glyph
116#define mac_font_create_available_families mac_ctfont_create_available_families
117#define mac_font_shape mac_ctfont_shape
118#if USE_CT_GLYPH_INFO 70#if USE_CT_GLYPH_INFO
119#define mac_font_get_glyph_for_cid mac_ctfont_get_glyph_for_cid 71#define mac_font_get_glyph_for_cid mac_ctfont_get_glyph_for_cid
120#endif 72#endif
121 73
122#define mac_nsctfont_copy_font_descriptor CTFontCopyFontDescriptor
123
124#ifndef kCTVersionNumber10_9 74#ifndef kCTVersionNumber10_9
125#define kCTVersionNumber10_9 0x00060000 75#define kCTVersionNumber10_9 0x00060000
126#endif 76#endif
diff --git a/src/macfont.m b/src/macfont.m
index d0d7252f350..23d272c9129 100644
--- a/src/macfont.m
+++ b/src/macfont.m
@@ -40,29 +40,21 @@ Original author: YAMAMOTO Mitsuharu
40 40
41static struct font_driver macfont_driver; 41static struct font_driver macfont_driver;
42 42
43static double mac_ctfont_get_advance_width_for_glyph (CTFontRef, CGGlyph); 43static double mac_font_get_advance_width_for_glyph (CTFontRef, CGGlyph);
44static CGRect mac_ctfont_get_bounding_rect_for_glyph (CTFontRef, CGGlyph); 44static CGRect mac_font_get_bounding_rect_for_glyph (CTFontRef, CGGlyph);
45static CFArrayRef mac_ctfont_create_available_families (void); 45static CFArrayRef mac_font_create_available_families (void);
46static Boolean mac_ctfont_equal_in_postscript_name (CTFontRef, CTFontRef); 46static Boolean mac_font_equal_in_postscript_name (CTFontRef, CTFontRef);
47static CTLineRef mac_ctfont_create_line_with_string_and_font (CFStringRef, 47static CTLineRef mac_font_create_line_with_string_and_font (CFStringRef,
48 CTFontRef); 48 CTFontRef);
49static CFComparisonResult mac_font_family_compare (const void *, 49static Boolean mac_font_descriptor_supports_languages (CTFontDescriptorRef,
50 const void *, void *); 50 CFArrayRef);
51static Boolean mac_ctfont_descriptor_supports_languages (CTFontDescriptorRef, 51static CFStringRef mac_font_create_preferred_family_for_attributes (CFDictionaryRef);
52 CFArrayRef); 52static CFIndex mac_font_shape (CTFontRef, CFStringRef,
53static CFStringRef mac_ctfont_create_preferred_family_for_attributes (CFDictionaryRef); 53 struct mac_glyph_layout *, CFIndex);
54static CFIndex mac_ctfont_shape (CTFontRef, CFStringRef, 54static CFArrayRef mac_font_copy_default_descriptors_for_language (CFStringRef);
55 struct mac_glyph_layout *, CFIndex); 55static CFStringRef mac_font_copy_default_name_for_charset_and_languages (CFCharacterSetRef, CFArrayRef);
56static CFArrayRef
57mac_font_copy_default_descriptors_for_language (CFStringRef language);
58
59static CFStringRef
60mac_font_copy_default_name_for_charset_and_languages (CFCharacterSetRef charset,
61 CFArrayRef languages);
62
63#if USE_CT_GLYPH_INFO 56#if USE_CT_GLYPH_INFO
64static CGGlyph mac_ctfont_get_glyph_for_cid (CTFontRef, 57static CGGlyph mac_ctfont_get_glyph_for_cid (CTFontRef, CTCharacterCollection,
65 CTCharacterCollection,
66 CGFontIndex); 58 CGFontIndex);
67#endif 59#endif
68 60
@@ -73,7 +65,7 @@ struct macfont_metrics;
73struct macfont_info 65struct macfont_info
74{ 66{
75 struct font font; 67 struct font font;
76 FontRef macfont; 68 CTFontRef macfont;
77 CGFontRef cgfont; 69 CGFontRef cgfont;
78 ScreenFontRef screen_font; 70 ScreenFontRef screen_font;
79 struct macfont_cache *cache; 71 struct macfont_cache *cache;
@@ -112,23 +104,22 @@ static const CGAffineTransform synthetic_italic_atfm = {1, 0, 0.25, 1, 0, 0};
112static const CGFloat synthetic_bold_factor = 0.024; 104static const CGFloat synthetic_bold_factor = 0.024;
113 105
114static Boolean cfnumber_get_font_symbolic_traits_value (CFNumberRef, 106static Boolean cfnumber_get_font_symbolic_traits_value (CFNumberRef,
115 FontSymbolicTraits *); 107 CTFontSymbolicTraits *);
116static void macfont_store_descriptor_attributes (FontDescriptorRef, 108static void macfont_store_descriptor_attributes (CTFontDescriptorRef,
117 Lisp_Object); 109 Lisp_Object);
118static Lisp_Object macfont_descriptor_entity (FontDescriptorRef, 110static Lisp_Object macfont_descriptor_entity (CTFontDescriptorRef, Lisp_Object,
119 Lisp_Object, 111 CTFontSymbolicTraits);
120 FontSymbolicTraits);
121static CFStringRef macfont_create_family_with_symbol (Lisp_Object); 112static CFStringRef macfont_create_family_with_symbol (Lisp_Object);
122static int macfont_glyph_extents (struct font *, CGGlyph, 113static int macfont_glyph_extents (struct font *, CGGlyph,
123 struct font_metrics *, CGFloat *, int); 114 struct font_metrics *, CGFloat *, int);
124static CFMutableDictionaryRef macfont_create_attributes_with_spec (Lisp_Object); 115static CFMutableDictionaryRef macfont_create_attributes_with_spec (Lisp_Object);
125static Boolean macfont_supports_charset_and_languages_p (FontDescriptorRef, 116static Boolean macfont_supports_charset_and_languages_p (CTFontDescriptorRef,
126 CFCharacterSetRef, 117 CFCharacterSetRef,
127 Lisp_Object, 118 Lisp_Object,
128 CFArrayRef); 119 CFArrayRef);
129static Boolean macfont_closest_traits_index_p (CFArrayRef, FontSymbolicTraits, 120static Boolean macfont_closest_traits_index_p (CFArrayRef, CTFontSymbolicTraits,
130 CFIndex); 121 CFIndex);
131static CFDataRef mac_font_copy_uvs_table (FontRef); 122static CFDataRef mac_font_copy_uvs_table (CTFontRef);
132static void mac_font_get_glyphs_for_variants (CFDataRef, UTF32Char, 123static void mac_font_get_glyphs_for_variants (CFDataRef, UTF32Char,
133 const UTF32Char [], 124 const UTF32Char [],
134 CGGlyph [], CFIndex); 125 CGGlyph [], CFIndex);
@@ -208,7 +199,7 @@ mac_screen_font_get_advance_width_for_glyph (ScreenFontRef font, CGGlyph glyph)
208} 199}
209 200
210static CGGlyph 201static CGGlyph
211mac_font_get_glyph_for_cid (FontRef font, CharacterCollection collection, 202mac_font_get_glyph_for_cid (CTFontRef font, CTCharacterCollection collection,
212 CGFontIndex cid) 203 CGFontIndex cid)
213{ 204{
214#if USE_CT_GLYPH_INFO 205#if USE_CT_GLYPH_INFO
@@ -755,7 +746,7 @@ macfont_store_utf32char_to_unichars (UTF32Char c, UniChar *unichars)
755 746
756static Boolean 747static Boolean
757cfnumber_get_font_symbolic_traits_value (CFNumberRef number, 748cfnumber_get_font_symbolic_traits_value (CFNumberRef number,
758 FontSymbolicTraits *sym_traits) 749 CTFontSymbolicTraits *sym_traits)
759{ 750{
760 SInt64 sint64_value; 751 SInt64 sint64_value;
761 752
@@ -763,7 +754,7 @@ cfnumber_get_font_symbolic_traits_value (CFNumberRef number,
763 OS X 10.6 when the value is greater than or equal to 1 << 31. */ 754 OS X 10.6 when the value is greater than or equal to 1 << 31. */
764 if (CFNumberGetValue (number, kCFNumberSInt64Type, &sint64_value)) 755 if (CFNumberGetValue (number, kCFNumberSInt64Type, &sint64_value))
765 { 756 {
766 *sym_traits = (FontSymbolicTraits) sint64_value; 757 *sym_traits = (CTFontSymbolicTraits) sint64_value;
767 758
768 return true; 759 return true;
769 } 760 }
@@ -772,7 +763,7 @@ cfnumber_get_font_symbolic_traits_value (CFNumberRef number,
772} 763}
773 764
774static void 765static void
775macfont_store_descriptor_attributes (FontDescriptorRef desc, 766macfont_store_descriptor_attributes (CTFontDescriptorRef desc,
776 Lisp_Object spec_or_entity) 767 Lisp_Object spec_or_entity)
777{ 768{
778 CFStringRef str; 769 CFStringRef str;
@@ -780,15 +771,14 @@ macfont_store_descriptor_attributes (FontDescriptorRef desc,
780 CFNumberRef num; 771 CFNumberRef num;
781 CGFloat floatval; 772 CGFloat floatval;
782 773
783 str = mac_font_descriptor_copy_attribute (desc, 774 str = CTFontDescriptorCopyAttribute (desc, kCTFontFamilyNameAttribute);
784 MAC_FONT_FAMILY_NAME_ATTRIBUTE);
785 if (str) 775 if (str)
786 { 776 {
787 ASET (spec_or_entity, FONT_FAMILY_INDEX, 777 ASET (spec_or_entity, FONT_FAMILY_INDEX,
788 macfont_intern_prop_cfstring (str)); 778 macfont_intern_prop_cfstring (str));
789 CFRelease (str); 779 CFRelease (str);
790 } 780 }
791 dict = mac_font_descriptor_copy_attribute (desc, MAC_FONT_TRAITS_ATTRIBUTE); 781 dict = CTFontDescriptorCopyAttribute (desc, kCTFontTraitsAttribute);
792 if (dict) 782 if (dict)
793 { 783 {
794 struct { 784 struct {
@@ -796,16 +786,16 @@ macfont_store_descriptor_attributes (FontDescriptorRef desc,
796 CFStringRef trait; 786 CFStringRef trait;
797 CGPoint points[6]; 787 CGPoint points[6];
798 } numeric_traits[] = 788 } numeric_traits[] =
799 {{FONT_WEIGHT_INDEX, MAC_FONT_WEIGHT_TRAIT, 789 {{FONT_WEIGHT_INDEX, kCTFontWeightTrait,
800 {{-0.4, 50}, /* light */ 790 {{-0.4, 50}, /* light */
801 {-0.24, 87.5}, /* (semi-light + normal) / 2 */ 791 {-0.24, 87.5}, /* (semi-light + normal) / 2 */
802 {0, 100}, /* normal */ 792 {0, 100}, /* normal */
803 {0.24, 140}, /* (semi-bold + normal) / 2 */ 793 {0.24, 140}, /* (semi-bold + normal) / 2 */
804 {0.4, 200}, /* bold */ 794 {0.4, 200}, /* bold */
805 {CGFLOAT_MAX, CGFLOAT_MAX}}}, 795 {CGFLOAT_MAX, CGFLOAT_MAX}}},
806 {FONT_SLANT_INDEX, MAC_FONT_SLANT_TRAIT, 796 {FONT_SLANT_INDEX, kCTFontSlantTrait,
807 {{0, 100}, {0.1, 200}, {CGFLOAT_MAX, CGFLOAT_MAX}}}, 797 {{0, 100}, {0.1, 200}, {CGFLOAT_MAX, CGFLOAT_MAX}}},
808 {FONT_WIDTH_INDEX, MAC_FONT_WIDTH_TRAIT, 798 {FONT_WIDTH_INDEX, kCTFontWidthTrait,
809 {{0, 100}, {1, 200}, {CGFLOAT_MAX, CGFLOAT_MAX}}}}; 799 {{0, 100}, {1, 200}, {CGFLOAT_MAX, CGFLOAT_MAX}}}};
810 int i; 800 int i;
811 801
@@ -830,21 +820,21 @@ macfont_store_descriptor_attributes (FontDescriptorRef desc,
830 } 820 }
831 } 821 }
832 822
833 num = CFDictionaryGetValue (dict, MAC_FONT_SYMBOLIC_TRAIT); 823 num = CFDictionaryGetValue (dict, kCTFontSymbolicTrait);
834 if (num) 824 if (num)
835 { 825 {
836 FontSymbolicTraits sym_traits; 826 CTFontSymbolicTraits sym_traits;
837 int spacing; 827 int spacing;
838 828
839 cfnumber_get_font_symbolic_traits_value (num, &sym_traits); 829 cfnumber_get_font_symbolic_traits_value (num, &sym_traits);
840 spacing = (sym_traits & MAC_FONT_TRAIT_MONO_SPACE 830 spacing = (sym_traits & kCTFontTraitMonoSpace
841 ? FONT_SPACING_MONO : FONT_SPACING_PROPORTIONAL); 831 ? FONT_SPACING_MONO : FONT_SPACING_PROPORTIONAL);
842 ASET (spec_or_entity, FONT_SPACING_INDEX, make_number (spacing)); 832 ASET (spec_or_entity, FONT_SPACING_INDEX, make_number (spacing));
843 } 833 }
844 834
845 CFRelease (dict); 835 CFRelease (dict);
846 } 836 }
847 num = mac_font_descriptor_copy_attribute (desc, MAC_FONT_SIZE_ATTRIBUTE); 837 num = CTFontDescriptorCopyAttribute (desc, kCTFontSizeAttribute);
848 if (num && CFNumberGetValue (num, kCFNumberCGFloatType, &floatval)) 838 if (num && CFNumberGetValue (num, kCFNumberCGFloatType, &floatval))
849 ASET (spec_or_entity, FONT_SIZE_INDEX, make_number (floatval)); 839 ASET (spec_or_entity, FONT_SIZE_INDEX, make_number (floatval));
850 else 840 else
@@ -854,12 +844,12 @@ macfont_store_descriptor_attributes (FontDescriptorRef desc,
854} 844}
855 845
856static Lisp_Object 846static Lisp_Object
857macfont_descriptor_entity (FontDescriptorRef desc, Lisp_Object extra, 847macfont_descriptor_entity (CTFontDescriptorRef desc, Lisp_Object extra,
858 FontSymbolicTraits synth_sym_traits) 848 CTFontSymbolicTraits synth_sym_traits)
859{ 849{
860 Lisp_Object entity; 850 Lisp_Object entity;
861 CFDictionaryRef dict; 851 CFDictionaryRef dict;
862 FontSymbolicTraits sym_traits = 0; 852 CTFontSymbolicTraits sym_traits = 0;
863 CFStringRef name; 853 CFStringRef name;
864 854
865 entity = font_make_entity (); 855 entity = font_make_entity ();
@@ -869,10 +859,10 @@ macfont_descriptor_entity (FontDescriptorRef desc, Lisp_Object extra,
869 859
870 macfont_store_descriptor_attributes (desc, entity); 860 macfont_store_descriptor_attributes (desc, entity);
871 861
872 dict = mac_font_descriptor_copy_attribute (desc, MAC_FONT_TRAITS_ATTRIBUTE); 862 dict = CTFontDescriptorCopyAttribute (desc, kCTFontTraitsAttribute);
873 if (dict) 863 if (dict)
874 { 864 {
875 CFNumberRef num = CFDictionaryGetValue (dict, MAC_FONT_SYMBOLIC_TRAIT); 865 CFNumberRef num = CFDictionaryGetValue (dict, kCTFontSymbolicTrait);
876 866
877 if (num) 867 if (num)
878 cfnumber_get_font_symbolic_traits_value (num, &sym_traits); 868 cfnumber_get_font_symbolic_traits_value (num, &sym_traits);
@@ -881,16 +871,16 @@ macfont_descriptor_entity (FontDescriptorRef desc, Lisp_Object extra,
881 if (EQ (AREF (entity, FONT_SIZE_INDEX), make_number (0))) 871 if (EQ (AREF (entity, FONT_SIZE_INDEX), make_number (0)))
882 ASET (entity, FONT_AVGWIDTH_INDEX, make_number (0)); 872 ASET (entity, FONT_AVGWIDTH_INDEX, make_number (0));
883 ASET (entity, FONT_EXTRA_INDEX, Fcopy_sequence (extra)); 873 ASET (entity, FONT_EXTRA_INDEX, Fcopy_sequence (extra));
884 name = mac_font_descriptor_copy_attribute (desc, MAC_FONT_NAME_ATTRIBUTE); 874 name = CTFontDescriptorCopyAttribute (desc, kCTFontNameAttribute);
885 font_put_extra (entity, QCfont_entity, 875 font_put_extra (entity, QCfont_entity,
886 make_save_ptr_int ((void *) name, sym_traits)); 876 make_save_ptr_int ((void *) name, sym_traits));
887 if (synth_sym_traits & MAC_FONT_TRAIT_ITALIC) 877 if (synth_sym_traits & kCTFontTraitItalic)
888 FONT_SET_STYLE (entity, FONT_SLANT_INDEX, 878 FONT_SET_STYLE (entity, FONT_SLANT_INDEX,
889 make_number (FONT_SLANT_SYNTHETIC_ITALIC)); 879 make_number (FONT_SLANT_SYNTHETIC_ITALIC));
890 if (synth_sym_traits & MAC_FONT_TRAIT_BOLD) 880 if (synth_sym_traits & kCTFontTraitBold)
891 FONT_SET_STYLE (entity, FONT_WEIGHT_INDEX, 881 FONT_SET_STYLE (entity, FONT_WEIGHT_INDEX,
892 make_number (FONT_WEIGHT_SYNTHETIC_BOLD)); 882 make_number (FONT_WEIGHT_SYNTHETIC_BOLD));
893 if (synth_sym_traits & MAC_FONT_TRAIT_MONO_SPACE) 883 if (synth_sym_traits & kCTFontTraitMonoSpace)
894 ASET (entity, FONT_SPACING_INDEX, 884 ASET (entity, FONT_SPACING_INDEX,
895 make_number (FONT_SPACING_SYNTHETIC_MONO)); 885 make_number (FONT_SPACING_SYNTHETIC_MONO));
896 886
@@ -1039,7 +1029,7 @@ macfont_create_family_with_symbol (Lisp_Object symbol)
1039{ 1029{
1040 CFStringRef result = NULL, family_name; 1030 CFStringRef result = NULL, family_name;
1041 CFDictionaryRef attributes = NULL; 1031 CFDictionaryRef attributes = NULL;
1042 FontDescriptorRef pat_desc = NULL; 1032 CTFontDescriptorRef pat_desc = NULL;
1043 1033
1044 if (macfont_get_family_cache_if_present (symbol, &result)) 1034 if (macfont_get_family_cache_if_present (symbol, &result))
1045 return result ? CFRetain (result) : NULL; 1035 return result ? CFRetain (result) : NULL;
@@ -1049,7 +1039,7 @@ macfont_create_family_with_symbol (Lisp_Object symbol)
1049 { 1039 {
1050 attributes = 1040 attributes =
1051 CFDictionaryCreate (NULL, 1041 CFDictionaryCreate (NULL,
1052 (const void **) &MAC_FONT_FAMILY_NAME_ATTRIBUTE, 1042 (const void **) &kCTFontFamilyNameAttribute,
1053 (const void **) &family_name, 1, 1043 (const void **) &family_name, 1,
1054 &kCFTypeDictionaryKeyCallBacks, 1044 &kCFTypeDictionaryKeyCallBacks,
1055 &kCFTypeDictionaryValueCallBacks); 1045 &kCFTypeDictionaryValueCallBacks);
@@ -1057,19 +1047,18 @@ macfont_create_family_with_symbol (Lisp_Object symbol)
1057 } 1047 }
1058 if (attributes) 1048 if (attributes)
1059 { 1049 {
1060 pat_desc = mac_font_descriptor_create_with_attributes (attributes); 1050 pat_desc = CTFontDescriptorCreateWithAttributes (attributes);
1061 CFRelease (attributes); 1051 CFRelease (attributes);
1062 } 1052 }
1063 if (pat_desc) 1053 if (pat_desc)
1064 { 1054 {
1065 FontDescriptorRef desc = 1055 CTFontDescriptorRef desc =
1066 mac_font_descriptor_create_matching_font_descriptor (pat_desc, NULL); 1056 CTFontDescriptorCreateMatchingFontDescriptor (pat_desc, NULL);
1067 1057
1068 if (desc) 1058 if (desc)
1069 { 1059 {
1070 result = 1060 result =
1071 mac_font_descriptor_copy_attribute (desc, 1061 CTFontDescriptorCopyAttribute (desc, kCTFontFamilyNameAttribute);
1072 MAC_FONT_FAMILY_NAME_ATTRIBUTE);
1073 CFRelease (desc); 1062 CFRelease (desc);
1074 } 1063 }
1075 macfont_set_family_cache (symbol, result); 1064 macfont_set_family_cache (symbol, result);
@@ -1126,7 +1115,7 @@ macfont_glyph_extents (struct font *font, CGGlyph glyph,
1126 int force_integral_p) 1115 int force_integral_p)
1127{ 1116{
1128 struct macfont_info *macfont_info = (struct macfont_info *) font; 1117 struct macfont_info *macfont_info = (struct macfont_info *) font;
1129 FontRef macfont = macfont_info->macfont; 1118 CTFontRef macfont = macfont_info->macfont;
1130 int row, col; 1119 int row, col;
1131 struct macfont_metrics *cache; 1120 struct macfont_metrics *cache;
1132 int width; 1121 int width;
@@ -1196,10 +1185,9 @@ macfont_glyph_extents (struct font *font, CGGlyph glyph,
1196 } 1185 }
1197 if (macfont_info->synthetic_bold_p && ! force_integral_p) 1186 if (macfont_info->synthetic_bold_p && ! force_integral_p)
1198 { 1187 {
1199 CGFloat d = 1188 CGFloat d = - synthetic_bold_factor * CTFontGetSize (macfont) / 2;
1200 - synthetic_bold_factor * mac_font_get_size (macfont) / 2;
1201 1189
1202 bounds = CGRectInset (bounds, d, d); 1190 bounds = CGRectInset (bounds, d, d);
1203 } 1191 }
1204 switch (macfont_info->spacing) 1192 switch (macfont_info->spacing)
1205 { 1193 {
@@ -1302,8 +1290,8 @@ struct macfont_cache
1302 /* Character collection specifying the destination of the mapping 1290 /* Character collection specifying the destination of the mapping
1303 provided by `table' above. If `table' is obtained from the UVS 1291 provided by `table' above. If `table' is obtained from the UVS
1304 subtable in the font cmap table, then the value of this member 1292 subtable in the font cmap table, then the value of this member
1305 should be MAC_CHARACTER_COLLECTION_IDENTITY_MAPPING. */ 1293 should be kCTCharacterCollectionIdentityMapping. */
1306 CharacterCollection collection; 1294 CTCharacterCollection collection;
1307 } uvs; 1295 } uvs;
1308}; 1296};
1309 1297
@@ -1314,8 +1302,8 @@ static CFCharacterSetRef macfont_get_cf_charset (struct font *);
1314static CFCharacterSetRef macfont_get_cf_charset_for_name (CFStringRef); 1302static CFCharacterSetRef macfont_get_cf_charset_for_name (CFStringRef);
1315static CGGlyph macfont_get_glyph_for_character (struct font *, UTF32Char); 1303static CGGlyph macfont_get_glyph_for_character (struct font *, UTF32Char);
1316static CGGlyph macfont_get_glyph_for_cid (struct font *font, 1304static CGGlyph macfont_get_glyph_for_cid (struct font *font,
1317 CharacterCollection, CGFontIndex); 1305 CTCharacterCollection, CGFontIndex);
1318static CFDataRef macfont_get_uvs_table (struct font *, CharacterCollection *); 1306static CFDataRef macfont_get_uvs_table (struct font *, CTCharacterCollection *);
1319 1307
1320static struct macfont_cache * 1308static struct macfont_cache *
1321macfont_lookup_cache (CFStringRef key) 1309macfont_lookup_cache (CFStringRef key)
@@ -1335,7 +1323,7 @@ macfont_lookup_cache (CFStringRef key)
1335 1323
1336 if (cache == NULL) 1324 if (cache == NULL)
1337 { 1325 {
1338 FontRef macfont = mac_font_create_with_name (key, 0); 1326 CTFontRef macfont = CTFontCreateWithName (key, 0, NULL);
1339 1327
1340 if (macfont) 1328 if (macfont)
1341 { 1329 {
@@ -1353,7 +1341,7 @@ macfont_lookup_cache (CFStringRef key)
1353 CFCharacterSetCreateWithCharactersInRange (NULL, range); 1341 CFCharacterSetCreateWithCharactersInRange (NULL, range);
1354 } 1342 }
1355 if (cache->cf_charset == NULL) 1343 if (cache->cf_charset == NULL)
1356 cache->cf_charset = mac_font_copy_character_set (macfont); 1344 cache->cf_charset = CTFontCopyCharacterSet (macfont);
1357 CFDictionaryAddValue (macfont_cache_dictionary, key, 1345 CFDictionaryAddValue (macfont_cache_dictionary, key,
1358 (const void *) cache); 1346 (const void *) cache);
1359 CFRelease (macfont); 1347 CFRelease (macfont);
@@ -1410,7 +1398,7 @@ static CGGlyph
1410macfont_get_glyph_for_character (struct font *font, UTF32Char c) 1398macfont_get_glyph_for_character (struct font *font, UTF32Char c)
1411{ 1399{
1412 struct macfont_info *macfont_info = (struct macfont_info *) font; 1400 struct macfont_info *macfont_info = (struct macfont_info *) font;
1413 FontRef macfont = macfont_info->macfont; 1401 CTFontRef macfont = macfont_info->macfont;
1414 struct macfont_cache *cache = macfont_info->cache; 1402 struct macfont_cache *cache = macfont_info->cache;
1415 1403
1416 if (c < 0xD800 || (c > 0xDFFF && c < 0x10000)) 1404 if (c < 0xD800 || (c > 0xDFFF && c < 0x10000))
@@ -1449,8 +1437,7 @@ macfont_get_glyph_for_character (struct font *font, UTF32Char c)
1449 if (nkeys_or_perm + 1 != ROW_PERM_OFFSET) 1437 if (nkeys_or_perm + 1 != ROW_PERM_OFFSET)
1450 { 1438 {
1451 ch = c; 1439 ch = c;
1452 if (!mac_font_get_glyphs_for_characters (macfont, &ch, 1440 if (!CTFontGetGlyphsForCharacters (macfont, &ch, &glyph, 1)
1453 &glyph, 1)
1454 || glyph == 0) 1441 || glyph == 0)
1455 glyph = kCGFontIndexInvalid; 1442 glyph = kCGFontIndexInvalid;
1456 1443
@@ -1493,8 +1480,7 @@ macfont_get_glyph_for_character (struct font *font, UTF32Char c)
1493 glyphs = xmalloc (sizeof (CGGlyph) * 256); 1480 glyphs = xmalloc (sizeof (CGGlyph) * 256);
1494 if (len > 0) 1481 if (len > 0)
1495 { 1482 {
1496 mac_font_get_glyphs_for_characters (macfont, unichars, 1483 CTFontGetGlyphsForCharacters (macfont, unichars, glyphs, len);
1497 glyphs, len);
1498 while (i > len) 1484 while (i > len)
1499 { 1485 {
1500 int next = unichars[len - 1] % 256; 1486 int next = unichars[len - 1] % 256;
@@ -1550,8 +1536,7 @@ macfont_get_glyph_for_character (struct font *font, UTF32Char c)
1550 CGGlyph glyphs[2]; 1536 CGGlyph glyphs[2];
1551 CFIndex count = macfont_store_utf32char_to_unichars (c, unichars); 1537 CFIndex count = macfont_store_utf32char_to_unichars (c, unichars);
1552 1538
1553 if (mac_font_get_glyphs_for_characters (macfont, unichars, glyphs, 1539 if (CTFontGetGlyphsForCharacters (macfont, unichars, glyphs, count))
1554 count))
1555 glyph = glyphs[0]; 1540 glyph = glyphs[0];
1556 if (glyph == 0) 1541 if (glyph == 0)
1557 glyph = kCGFontIndexInvalid; 1542 glyph = kCGFontIndexInvalid;
@@ -1566,33 +1551,33 @@ macfont_get_glyph_for_character (struct font *font, UTF32Char c)
1566} 1551}
1567 1552
1568static CGGlyph 1553static CGGlyph
1569macfont_get_glyph_for_cid (struct font *font, CharacterCollection collection, 1554macfont_get_glyph_for_cid (struct font *font, CTCharacterCollection collection,
1570 CGFontIndex cid) 1555 CGFontIndex cid)
1571{ 1556{
1572 struct macfont_info *macfont_info = (struct macfont_info *) font; 1557 struct macfont_info *macfont_info = (struct macfont_info *) font;
1573 FontRef macfont = macfont_info->macfont; 1558 CTFontRef macfont = macfont_info->macfont;
1574 1559
1575 /* Cache it? */ 1560 /* Cache it? */
1576 return mac_font_get_glyph_for_cid (macfont, collection, cid); 1561 return mac_font_get_glyph_for_cid (macfont, collection, cid);
1577} 1562}
1578 1563
1579static CFDataRef 1564static CFDataRef
1580macfont_get_uvs_table (struct font *font, CharacterCollection *collection) 1565macfont_get_uvs_table (struct font *font, CTCharacterCollection *collection)
1581{ 1566{
1582 struct macfont_info *macfont_info = (struct macfont_info *) font; 1567 struct macfont_info *macfont_info = (struct macfont_info *) font;
1583 FontRef macfont = macfont_info->macfont; 1568 CTFontRef macfont = macfont_info->macfont;
1584 struct macfont_cache *cache = macfont_info->cache; 1569 struct macfont_cache *cache = macfont_info->cache;
1585 CFDataRef result = NULL; 1570 CFDataRef result = NULL;
1586 1571
1587 if (cache->uvs.table == NULL) 1572 if (cache->uvs.table == NULL)
1588 { 1573 {
1589 CFDataRef uvs_table = mac_font_copy_uvs_table (macfont); 1574 CFDataRef uvs_table = mac_font_copy_uvs_table (macfont);
1590 CharacterCollection uvs_collection = 1575 CTCharacterCollection uvs_collection =
1591 MAC_CHARACTER_COLLECTION_IDENTITY_MAPPING; 1576 kCTCharacterCollectionIdentityMapping;
1592 1577
1593 if (uvs_table == NULL 1578 if (uvs_table == NULL
1594 && mac_font_get_glyph_for_cid (macfont, 1579 && mac_font_get_glyph_for_cid (macfont,
1595 MAC_CHARACTER_COLLECTION_ADOBE_JAPAN1, 1580 kCTCharacterCollectionAdobeJapan1,
1596 6480) != kCGFontIndexInvalid) 1581 6480) != kCGFontIndexInvalid)
1597 { 1582 {
1598 /* If the glyph for U+4E55 is accessible via its CID 6480, 1583 /* If the glyph for U+4E55 is accessible via its CID 6480,
@@ -1609,7 +1594,7 @@ macfont_get_uvs_table (struct font *font, CharacterCollection *collection)
1609 if (mac_uvs_table_adobe_japan1) 1594 if (mac_uvs_table_adobe_japan1)
1610 { 1595 {
1611 uvs_table = CFRetain (mac_uvs_table_adobe_japan1); 1596 uvs_table = CFRetain (mac_uvs_table_adobe_japan1);
1612 uvs_collection = MAC_CHARACTER_COLLECTION_ADOBE_JAPAN1; 1597 uvs_collection = kCTCharacterCollectionAdobeJapan1;
1613 } 1598 }
1614 } 1599 }
1615 if (uvs_table == NULL) 1600 if (uvs_table == NULL)
@@ -1852,16 +1837,16 @@ macfont_create_attributes_with_spec (Lisp_Object spec)
1852 CFStringRef trait; 1837 CFStringRef trait;
1853 CGPoint points[6]; 1838 CGPoint points[6];
1854 } numeric_traits[] = 1839 } numeric_traits[] =
1855 {{FONT_WEIGHT_INDEX, MAC_FONT_WEIGHT_TRAIT, 1840 {{FONT_WEIGHT_INDEX, kCTFontWeightTrait,
1856 {{-0.4, 50}, /* light */ 1841 {{-0.4, 50}, /* light */
1857 {-0.24, 87.5}, /* (semi-light + normal) / 2 */ 1842 {-0.24, 87.5}, /* (semi-light + normal) / 2 */
1858 {0, 100}, /* normal */ 1843 {0, 100}, /* normal */
1859 {0.24, 140}, /* (semi-bold + normal) / 2 */ 1844 {0.24, 140}, /* (semi-bold + normal) / 2 */
1860 {0.4, 200}, /* bold */ 1845 {0.4, 200}, /* bold */
1861 {CGFLOAT_MAX, CGFLOAT_MAX}}}, 1846 {CGFLOAT_MAX, CGFLOAT_MAX}}},
1862 {FONT_SLANT_INDEX, MAC_FONT_SLANT_TRAIT, 1847 {FONT_SLANT_INDEX, kCTFontSlantTrait,
1863 {{0, 100}, {0.1, 200}, {CGFLOAT_MAX, CGFLOAT_MAX}}}, 1848 {{0, 100}, {0.1, 200}, {CGFLOAT_MAX, CGFLOAT_MAX}}},
1864 {FONT_WIDTH_INDEX, MAC_FONT_WIDTH_TRAIT, 1849 {FONT_WIDTH_INDEX, kCTFontWidthTrait,
1865 {{0, 100}, {1, 200}, {CGFLOAT_MAX, CGFLOAT_MAX}}}}; 1850 {{0, 100}, {1, 200}, {CGFLOAT_MAX, CGFLOAT_MAX}}}};
1866 1851
1867 registry = AREF (spec, FONT_REGISTRY_INDEX); 1852 registry = AREF (spec, FONT_REGISTRY_INDEX);
@@ -1977,7 +1962,7 @@ macfont_create_attributes_with_spec (Lisp_Object spec)
1977 1962
1978 if (! family) 1963 if (! family)
1979 goto err; 1964 goto err;
1980 CFDictionaryAddValue (attributes, MAC_FONT_FAMILY_NAME_ATTRIBUTE, 1965 CFDictionaryAddValue (attributes, kCTFontFamilyNameAttribute,
1981 family); 1966 family);
1982 CFRelease (family); 1967 CFRelease (family);
1983 } 1968 }
@@ -2018,16 +2003,16 @@ macfont_create_attributes_with_spec (Lisp_Object spec)
2018 } 2003 }
2019 } 2004 }
2020 if (CFDictionaryGetCount (traits)) 2005 if (CFDictionaryGetCount (traits))
2021 CFDictionaryAddValue (attributes, MAC_FONT_TRAITS_ATTRIBUTE, traits); 2006 CFDictionaryAddValue (attributes, kCTFontTraitsAttribute, traits);
2022 2007
2023 if (charset) 2008 if (charset)
2024 CFDictionaryAddValue (attributes, MAC_FONT_CHARACTER_SET_ATTRIBUTE, 2009 CFDictionaryAddValue (attributes, kCTFontCharacterSetAttribute,
2025 charset); 2010 charset);
2026 if (charset_string) 2011 if (charset_string)
2027 CFDictionaryAddValue (attributes, MAC_FONT_CHARACTER_SET_STRING_ATTRIBUTE, 2012 CFDictionaryAddValue (attributes, MAC_FONT_CHARACTER_SET_STRING_ATTRIBUTE,
2028 charset_string); 2013 charset_string);
2029 if (langarray) 2014 if (langarray)
2030 CFDictionaryAddValue (attributes, MAC_FONT_LANGUAGES_ATTRIBUTE, langarray); 2015 CFDictionaryAddValue (attributes, kCTFontLanguagesAttribute, langarray);
2031 2016
2032 goto finish; 2017 goto finish;
2033 2018
@@ -2056,7 +2041,7 @@ macfont_create_attributes_with_spec (Lisp_Object spec)
2056} 2041}
2057 2042
2058static Boolean 2043static Boolean
2059macfont_supports_charset_and_languages_p (FontDescriptorRef desc, 2044macfont_supports_charset_and_languages_p (CTFontDescriptorRef desc,
2060 CFCharacterSetRef charset, 2045 CFCharacterSetRef charset,
2061 Lisp_Object chars, 2046 Lisp_Object chars,
2062 CFArrayRef languages) 2047 CFArrayRef languages)
@@ -2066,8 +2051,7 @@ macfont_supports_charset_and_languages_p (FontDescriptorRef desc,
2066 if (charset || VECTORP (chars)) 2051 if (charset || VECTORP (chars))
2067 { 2052 {
2068 CFCharacterSetRef desc_charset = 2053 CFCharacterSetRef desc_charset =
2069 mac_font_descriptor_copy_attribute (desc, 2054 CTFontDescriptorCopyAttribute (desc, kCTFontCharacterSetAttribute);
2070 MAC_FONT_CHARACTER_SET_ATTRIBUTE);
2071 2055
2072 if (desc_charset == NULL) 2056 if (desc_charset == NULL)
2073 result = false; 2057 result = false;
@@ -2097,20 +2081,20 @@ macfont_supports_charset_and_languages_p (FontDescriptorRef desc,
2097} 2081}
2098 2082
2099static int 2083static int
2100macfont_traits_distance (FontSymbolicTraits sym_traits1, 2084macfont_traits_distance (CTFontSymbolicTraits sym_traits1,
2101 FontSymbolicTraits sym_traits2) 2085 CTFontSymbolicTraits sym_traits2)
2102{ 2086{
2103 FontSymbolicTraits diff = (sym_traits1 ^ sym_traits2); 2087 CTFontSymbolicTraits diff = (sym_traits1 ^ sym_traits2);
2104 int distance = 0; 2088 int distance = 0;
2105 2089
2106 /* We prefer synthetic bold of italic to synthetic italic of bold 2090 /* We prefer synthetic bold of italic to synthetic italic of bold
2107 when both bold and italic are available but bold-italic is not 2091 when both bold and italic are available but bold-italic is not
2108 available. */ 2092 available. */
2109 if (diff & MAC_FONT_TRAIT_BOLD) 2093 if (diff & kCTFontTraitBold)
2110 distance |= (1 << 0); 2094 distance |= (1 << 0);
2111 if (diff & MAC_FONT_TRAIT_ITALIC) 2095 if (diff & kCTFontTraitItalic)
2112 distance |= (1 << 1); 2096 distance |= (1 << 1);
2113 if (diff & MAC_FONT_TRAIT_MONO_SPACE) 2097 if (diff & kCTFontTraitMonoSpace)
2114 distance |= (1 << 2); 2098 distance |= (1 << 2);
2115 2099
2116 return distance; 2100 return distance;
@@ -2118,21 +2102,21 @@ macfont_traits_distance (FontSymbolicTraits sym_traits1,
2118 2102
2119static Boolean 2103static Boolean
2120macfont_closest_traits_index_p (CFArrayRef traits_array, 2104macfont_closest_traits_index_p (CFArrayRef traits_array,
2121 FontSymbolicTraits target, 2105 CTFontSymbolicTraits target,
2122 CFIndex index) 2106 CFIndex index)
2123{ 2107{
2124 CFIndex i, count = CFArrayGetCount (traits_array); 2108 CFIndex i, count = CFArrayGetCount (traits_array);
2125 FontSymbolicTraits traits; 2109 CTFontSymbolicTraits traits;
2126 int my_distance; 2110 int my_distance;
2127 2111
2128 traits = ((FontSymbolicTraits) (uintptr_t) 2112 traits = ((CTFontSymbolicTraits) (uintptr_t)
2129 CFArrayGetValueAtIndex (traits_array, index)); 2113 CFArrayGetValueAtIndex (traits_array, index));
2130 my_distance = macfont_traits_distance (target, traits); 2114 my_distance = macfont_traits_distance (target, traits);
2131 2115
2132 for (i = 0; i < count; i++) 2116 for (i = 0; i < count; i++)
2133 if (i != index) 2117 if (i != index)
2134 { 2118 {
2135 traits = ((FontSymbolicTraits) (uintptr_t) 2119 traits = ((CTFontSymbolicTraits) (uintptr_t)
2136 CFArrayGetValueAtIndex (traits_array, i)); 2120 CFArrayGetValueAtIndex (traits_array, i));
2137 if (macfont_traits_distance (target, traits) < my_distance) 2121 if (macfont_traits_distance (target, traits) < my_distance)
2138 return false; 2122 return false;
@@ -2150,7 +2134,7 @@ macfont_list (struct frame *f, Lisp_Object spec)
2150 CFMutableDictionaryRef attributes = NULL, traits; 2134 CFMutableDictionaryRef attributes = NULL, traits;
2151 Lisp_Object chars = Qnil; 2135 Lisp_Object chars = Qnil;
2152 int spacing = -1; 2136 int spacing = -1;
2153 FontSymbolicTraits synth_sym_traits = 0; 2137 CTFontSymbolicTraits synth_sym_traits = 0;
2154 CFArrayRef families; 2138 CFArrayRef families;
2155 CFIndex families_count; 2139 CFIndex families_count;
2156 CFCharacterSetRef charset = NULL; 2140 CFCharacterSetRef charset = NULL;
@@ -2170,28 +2154,28 @@ macfont_list (struct frame *f, Lisp_Object spec)
2170 if (! attributes) 2154 if (! attributes)
2171 goto finish; 2155 goto finish;
2172 2156
2173 languages = CFDictionaryGetValue (attributes, MAC_FONT_LANGUAGES_ATTRIBUTE); 2157 languages = CFDictionaryGetValue (attributes, kCTFontLanguagesAttribute);
2174 2158
2175 if (INTEGERP (AREF (spec, FONT_SPACING_INDEX))) 2159 if (INTEGERP (AREF (spec, FONT_SPACING_INDEX)))
2176 spacing = XINT (AREF (spec, FONT_SPACING_INDEX)); 2160 spacing = XINT (AREF (spec, FONT_SPACING_INDEX));
2177 2161
2178 traits = ((CFMutableDictionaryRef) 2162 traits = ((CFMutableDictionaryRef)
2179 CFDictionaryGetValue (attributes, MAC_FONT_TRAITS_ATTRIBUTE)); 2163 CFDictionaryGetValue (attributes, kCTFontTraitsAttribute));
2180 2164
2181 n = FONT_SLANT_NUMERIC (spec); 2165 n = FONT_SLANT_NUMERIC (spec);
2182 if (n < 0 || n == FONT_SLANT_SYNTHETIC_ITALIC) 2166 if (n < 0 || n == FONT_SLANT_SYNTHETIC_ITALIC)
2183 { 2167 {
2184 synth_sym_traits |= MAC_FONT_TRAIT_ITALIC; 2168 synth_sym_traits |= kCTFontTraitItalic;
2185 if (traits) 2169 if (traits)
2186 CFDictionaryRemoveValue (traits, MAC_FONT_SLANT_TRAIT); 2170 CFDictionaryRemoveValue (traits, kCTFontSlantTrait);
2187 } 2171 }
2188 2172
2189 n = FONT_WEIGHT_NUMERIC (spec); 2173 n = FONT_WEIGHT_NUMERIC (spec);
2190 if (n < 0 || n == FONT_WEIGHT_SYNTHETIC_BOLD) 2174 if (n < 0 || n == FONT_WEIGHT_SYNTHETIC_BOLD)
2191 { 2175 {
2192 synth_sym_traits |= MAC_FONT_TRAIT_BOLD; 2176 synth_sym_traits |= kCTFontTraitBold;
2193 if (traits) 2177 if (traits)
2194 CFDictionaryRemoveValue (traits, MAC_FONT_WEIGHT_TRAIT); 2178 CFDictionaryRemoveValue (traits, kCTFontWeightTrait);
2195 } 2179 }
2196 2180
2197 if (languages 2181 if (languages
@@ -2202,7 +2186,7 @@ macfont_list (struct frame *f, Lisp_Object spec)
2202 if (CFStringHasPrefix (language, CFSTR ("ja")) 2186 if (CFStringHasPrefix (language, CFSTR ("ja"))
2203 || CFStringHasPrefix (language, CFSTR ("ko")) 2187 || CFStringHasPrefix (language, CFSTR ("ko"))
2204 || CFStringHasPrefix (language, CFSTR ("zh"))) 2188 || CFStringHasPrefix (language, CFSTR ("zh")))
2205 synth_sym_traits |= MAC_FONT_TRAIT_MONO_SPACE; 2189 synth_sym_traits |= kCTFontTraitMonoSpace;
2206 } 2190 }
2207 2191
2208 /* Create array of families. */ 2192 /* Create array of families. */
@@ -2254,12 +2238,11 @@ macfont_list (struct frame *f, Lisp_Object spec)
2254 } 2238 }
2255 } 2239 }
2256 2240
2257 charset = CFDictionaryGetValue (attributes, 2241 charset = CFDictionaryGetValue (attributes, kCTFontCharacterSetAttribute);
2258 MAC_FONT_CHARACTER_SET_ATTRIBUTE);
2259 if (charset) 2242 if (charset)
2260 { 2243 {
2261 CFRetain (charset); 2244 CFRetain (charset);
2262 CFDictionaryRemoveValue (attributes, MAC_FONT_CHARACTER_SET_ATTRIBUTE); 2245 CFDictionaryRemoveValue (attributes, kCTFontCharacterSetAttribute);
2263 } 2246 }
2264 else 2247 else
2265 { 2248 {
@@ -2276,7 +2259,7 @@ macfont_list (struct frame *f, Lisp_Object spec)
2276 if (languages) 2259 if (languages)
2277 { 2260 {
2278 CFRetain (languages); 2261 CFRetain (languages);
2279 CFDictionaryRemoveValue (attributes, MAC_FONT_LANGUAGES_ATTRIBUTE); 2262 CFDictionaryRemoveValue (attributes, kCTFontLanguagesAttribute);
2280 } 2263 }
2281 2264
2282 val = Qnil; 2265 val = Qnil;
@@ -2285,16 +2268,16 @@ macfont_list (struct frame *f, Lisp_Object spec)
2285 for (i = 0; i < families_count; i++) 2268 for (i = 0; i < families_count; i++)
2286 { 2269 {
2287 CFStringRef family_name = CFArrayGetValueAtIndex (families, i); 2270 CFStringRef family_name = CFArrayGetValueAtIndex (families, i);
2288 FontDescriptorRef pat_desc; 2271 CTFontDescriptorRef pat_desc;
2289 CFArrayRef descs; 2272 CFArrayRef descs;
2290 CFIndex descs_count; 2273 CFIndex descs_count;
2291 CFMutableArrayRef filtered_descs, traits_array; 2274 CFMutableArrayRef filtered_descs, traits_array;
2292 Lisp_Object entity; 2275 Lisp_Object entity;
2293 int j; 2276 int j;
2294 2277
2295 CFDictionarySetValue (attributes, MAC_FONT_FAMILY_NAME_ATTRIBUTE, 2278 CFDictionarySetValue (attributes, kCTFontFamilyNameAttribute,
2296 family_name); 2279 family_name);
2297 pat_desc = mac_font_descriptor_create_with_attributes (attributes); 2280 pat_desc = CTFontDescriptorCreateWithAttributes (attributes);
2298 if (! pat_desc) 2281 if (! pat_desc)
2299 goto err; 2282 goto err;
2300 2283
@@ -2303,13 +2286,11 @@ macfont_list (struct frame *f, Lisp_Object spec)
2303 So we use CTFontDescriptorCreateMatchingFontDescriptor (no 2286 So we use CTFontDescriptorCreateMatchingFontDescriptor (no
2304 trailing "s") for such a font. */ 2287 trailing "s") for such a font. */
2305 if (!CFEqual (family_name, CFSTR ("LastResort"))) 2288 if (!CFEqual (family_name, CFSTR ("LastResort")))
2306 descs = mac_font_descriptor_create_matching_font_descriptors (pat_desc, 2289 descs = CTFontDescriptorCreateMatchingFontDescriptors (pat_desc, NULL);
2307 NULL);
2308 else 2290 else
2309 { 2291 {
2310 FontDescriptorRef lr_desc = 2292 CTFontDescriptorRef lr_desc =
2311 mac_font_descriptor_create_matching_font_descriptor (pat_desc, 2293 CTFontDescriptorCreateMatchingFontDescriptor (pat_desc, NULL);
2312 NULL);
2313 if (lr_desc) 2294 if (lr_desc)
2314 { 2295 {
2315 descs = CFArrayCreate (NULL, (const void **) &lr_desc, 1, 2296 descs = CFArrayCreate (NULL, (const void **) &lr_desc, 1,
@@ -2338,31 +2319,30 @@ macfont_list (struct frame *f, Lisp_Object spec)
2338 traits_array = CFArrayCreateMutable (NULL, descs_count, NULL); 2319 traits_array = CFArrayCreateMutable (NULL, descs_count, NULL);
2339 for (j = 0; j < descs_count; j++) 2320 for (j = 0; j < descs_count; j++)
2340 { 2321 {
2341 FontDescriptorRef desc = CFArrayGetValueAtIndex (descs, j); 2322 CTFontDescriptorRef desc = CFArrayGetValueAtIndex (descs, j);
2342 CFDictionaryRef dict; 2323 CFDictionaryRef dict;
2343 CFNumberRef num; 2324 CFNumberRef num;
2344 FontSymbolicTraits sym_traits; 2325 CTFontSymbolicTraits sym_traits;
2345 2326
2346 dict = mac_font_descriptor_copy_attribute (desc, 2327 dict = CTFontDescriptorCopyAttribute (desc, kCTFontTraitsAttribute);
2347 MAC_FONT_TRAITS_ATTRIBUTE);
2348 if (dict == NULL) 2328 if (dict == NULL)
2349 continue; 2329 continue;
2350 2330
2351 num = CFDictionaryGetValue (dict, MAC_FONT_SYMBOLIC_TRAIT); 2331 num = CFDictionaryGetValue (dict, kCTFontSymbolicTrait);
2352 CFRelease (dict); 2332 CFRelease (dict);
2353 if (num == NULL 2333 if (num == NULL
2354 || !cfnumber_get_font_symbolic_traits_value (num, &sym_traits)) 2334 || !cfnumber_get_font_symbolic_traits_value (num, &sym_traits))
2355 continue; 2335 continue;
2356 2336
2357 if (spacing >= 0 2337 if (spacing >= 0
2358 && !(synth_sym_traits & MAC_FONT_TRAIT_MONO_SPACE) 2338 && !(synth_sym_traits & kCTFontTraitMonoSpace)
2359 && (((sym_traits & MAC_FONT_TRAIT_MONO_SPACE) != 0) 2339 && (((sym_traits & kCTFontTraitMonoSpace) != 0)
2360 != (spacing >= FONT_SPACING_MONO))) 2340 != (spacing >= FONT_SPACING_MONO)))
2361 continue; 2341 continue;
2362 2342
2363 /* Don't use a color bitmap font unless its family is 2343 /* Don't use a color bitmap font unless its family is
2364 explicitly specified. */ 2344 explicitly specified. */
2365 if ((sym_traits & MAC_FONT_TRAIT_COLOR_GLYPHS) && NILP (family)) 2345 if ((sym_traits & kCTFontTraitColorGlyphs) && NILP (family))
2366 continue; 2346 continue;
2367 2347
2368 if (j > 0 2348 if (j > 0
@@ -2381,27 +2361,26 @@ macfont_list (struct frame *f, Lisp_Object spec)
2381 2361
2382 for (j = 0; j < descs_count; j++) 2362 for (j = 0; j < descs_count; j++)
2383 { 2363 {
2384 FontDescriptorRef desc = CFArrayGetValueAtIndex (descs, j); 2364 CTFontDescriptorRef desc = CFArrayGetValueAtIndex (descs, j);
2385 FontSymbolicTraits sym_traits = 2365 CTFontSymbolicTraits sym_traits =
2386 ((FontSymbolicTraits) (uintptr_t) 2366 ((CTFontSymbolicTraits) (uintptr_t)
2387 CFArrayGetValueAtIndex (traits_array, j)); 2367 CFArrayGetValueAtIndex (traits_array, j));
2388 FontSymbolicTraits mask_min, mask_max, imask, bmask, mmask; 2368 CTFontSymbolicTraits mask_min, mask_max, imask, bmask, mmask;
2389 2369
2390 mask_min = ((synth_sym_traits ^ sym_traits) 2370 mask_min = ((synth_sym_traits ^ sym_traits)
2391 & (MAC_FONT_TRAIT_ITALIC | MAC_FONT_TRAIT_BOLD)); 2371 & (kCTFontTraitItalic | kCTFontTraitBold));
2392 if (FONT_SLANT_NUMERIC (spec) < 0) 2372 if (FONT_SLANT_NUMERIC (spec) < 0)
2393 mask_min &= ~MAC_FONT_TRAIT_ITALIC; 2373 mask_min &= ~kCTFontTraitItalic;
2394 if (FONT_WEIGHT_NUMERIC (spec) < 0) 2374 if (FONT_WEIGHT_NUMERIC (spec) < 0)
2395 mask_min &= ~MAC_FONT_TRAIT_BOLD; 2375 mask_min &= ~kCTFontTraitBold;
2396 2376
2397 mask_max = (synth_sym_traits & ~sym_traits); 2377 mask_max = (synth_sym_traits & ~sym_traits);
2398 /* Synthetic bold does not work for bitmap-only fonts on Mac 2378 /* Synthetic bold does not work for bitmap-only fonts on Mac
2399 OS X 10.6. */ 2379 OS X 10.6. */
2400 if ((mask_min ^ mask_max) & MAC_FONT_TRAIT_BOLD) 2380 if ((mask_min ^ mask_max) & kCTFontTraitBold)
2401 { 2381 {
2402 CFNumberRef format = 2382 CFNumberRef format =
2403 mac_font_descriptor_copy_attribute (desc, 2383 CTFontDescriptorCopyAttribute (desc, kCTFontFormatAttribute);
2404 MAC_FONT_FORMAT_ATTRIBUTE);
2405 2384
2406 if (format) 2385 if (format)
2407 { 2386 {
@@ -2409,24 +2388,24 @@ macfont_list (struct frame *f, Lisp_Object spec)
2409 2388
2410 if (CFNumberGetValue (format, kCFNumberSInt32Type, 2389 if (CFNumberGetValue (format, kCFNumberSInt32Type,
2411 &format_val) 2390 &format_val)
2412 && format_val == MAC_FONT_FORMAT_BITMAP) 2391 && format_val == kCTFontFormatBitmap)
2413 mask_max &= ~MAC_FONT_TRAIT_BOLD; 2392 mask_max &= ~kCTFontTraitBold;
2414 } 2393 }
2415 } 2394 }
2416 if (spacing >= 0) 2395 if (spacing >= 0)
2417 mask_min |= (mask_max & MAC_FONT_TRAIT_MONO_SPACE); 2396 mask_min |= (mask_max & kCTFontTraitMonoSpace);
2418 2397
2419 for (mmask = (mask_min & MAC_FONT_TRAIT_MONO_SPACE); 2398 for (mmask = (mask_min & kCTFontTraitMonoSpace);
2420 mmask <= (mask_max & MAC_FONT_TRAIT_MONO_SPACE); 2399 mmask <= (mask_max & kCTFontTraitMonoSpace);
2421 mmask += MAC_FONT_TRAIT_MONO_SPACE) 2400 mmask += kCTFontTraitMonoSpace)
2422 for (bmask = (mask_min & MAC_FONT_TRAIT_BOLD); 2401 for (bmask = (mask_min & kCTFontTraitBold);
2423 bmask <= (mask_max & MAC_FONT_TRAIT_BOLD); 2402 bmask <= (mask_max & kCTFontTraitBold);
2424 bmask += MAC_FONT_TRAIT_BOLD) 2403 bmask += kCTFontTraitBold)
2425 for (imask = (mask_min & MAC_FONT_TRAIT_ITALIC); 2404 for (imask = (mask_min & kCTFontTraitItalic);
2426 imask <= (mask_max & MAC_FONT_TRAIT_ITALIC); 2405 imask <= (mask_max & kCTFontTraitItalic);
2427 imask += MAC_FONT_TRAIT_ITALIC) 2406 imask += kCTFontTraitItalic)
2428 { 2407 {
2429 FontSymbolicTraits synth = (imask | bmask | mmask); 2408 CTFontSymbolicTraits synth = (imask | bmask | mmask);
2430 2409
2431 if (synth == 0 2410 if (synth == 0
2432 || macfont_closest_traits_index_p (traits_array, 2411 || macfont_closest_traits_index_p (traits_array,
@@ -2467,20 +2446,19 @@ macfont_match (struct frame * frame, Lisp_Object spec)
2467{ 2446{
2468 Lisp_Object entity = Qnil; 2447 Lisp_Object entity = Qnil;
2469 CFMutableDictionaryRef attributes; 2448 CFMutableDictionaryRef attributes;
2470 FontDescriptorRef pat_desc = NULL, desc = NULL; 2449 CTFontDescriptorRef pat_desc = NULL, desc = NULL;
2471 2450
2472 block_input (); 2451 block_input ();
2473 2452
2474 attributes = macfont_create_attributes_with_spec (spec); 2453 attributes = macfont_create_attributes_with_spec (spec);
2475 if (attributes) 2454 if (attributes)
2476 { 2455 {
2477 pat_desc = mac_font_descriptor_create_with_attributes (attributes); 2456 pat_desc = CTFontDescriptorCreateWithAttributes (attributes);
2478 CFRelease (attributes); 2457 CFRelease (attributes);
2479 } 2458 }
2480 if (pat_desc) 2459 if (pat_desc)
2481 { 2460 {
2482 desc = mac_font_descriptor_create_matching_font_descriptor (pat_desc, 2461 desc = CTFontDescriptorCreateMatchingFontDescriptor (pat_desc, NULL);
2483 NULL);
2484 CFRelease (pat_desc); 2462 CFRelease (pat_desc);
2485 } 2463 }
2486 if (desc) 2464 if (desc)
@@ -2538,8 +2516,8 @@ macfont_open (struct frame * f, Lisp_Object entity, int pixel_size)
2538 struct macfont_info *macfont_info = NULL; 2516 struct macfont_info *macfont_info = NULL;
2539 struct font *font; 2517 struct font *font;
2540 int size; 2518 int size;
2541 FontRef macfont; 2519 CTFontRef macfont;
2542 FontSymbolicTraits sym_traits; 2520 CTFontSymbolicTraits sym_traits;
2543 char name[256]; 2521 char name[256];
2544 int len, i, total_width; 2522 int len, i, total_width;
2545 CGGlyph glyph; 2523 CGGlyph glyph;
@@ -2558,7 +2536,7 @@ macfont_open (struct frame * f, Lisp_Object entity, int pixel_size)
2558 size = pixel_size; 2536 size = pixel_size;
2559 2537
2560 block_input (); 2538 block_input ();
2561 macfont = mac_font_create_with_name (font_name, size); 2539 macfont = CTFontCreateWithName (font_name, size, NULL);
2562 if (macfont) 2540 if (macfont)
2563 { 2541 {
2564 int fontsize = (int) [((NSFont *) macfont) pointSize]; 2542 int fontsize = (int) [((NSFont *) macfont) pointSize];
@@ -2579,7 +2557,7 @@ macfont_open (struct frame * f, Lisp_Object entity, int pixel_size)
2579 2557
2580 macfont_info = (struct macfont_info *) font; 2558 macfont_info = (struct macfont_info *) font;
2581 macfont_info->macfont = macfont; 2559 macfont_info->macfont = macfont;
2582 macfont_info->cgfont = mac_font_copy_graphics_font (macfont); 2560 macfont_info->cgfont = CTFontCopyGraphicsFont (macfont, NULL);
2583 2561
2584 val = assq_no_quit (QCdestination, AREF (entity, FONT_EXTRA_INDEX)); 2562 val = assq_no_quit (QCdestination, AREF (entity, FONT_EXTRA_INDEX));
2585 if (CONSP (val) && EQ (XCDR (val), make_number (1))) 2563 if (CONSP (val) && EQ (XCDR (val), make_number (1)))
@@ -2595,13 +2573,13 @@ macfont_open (struct frame * f, Lisp_Object entity, int pixel_size)
2595 macfont_info->synthetic_bold_p = 0; 2573 macfont_info->synthetic_bold_p = 0;
2596 macfont_info->spacing = MACFONT_SPACING_PROPORTIONAL; 2574 macfont_info->spacing = MACFONT_SPACING_PROPORTIONAL;
2597 macfont_info->antialias = MACFONT_ANTIALIAS_DEFAULT; 2575 macfont_info->antialias = MACFONT_ANTIALIAS_DEFAULT;
2598 if (!(sym_traits & MAC_FONT_TRAIT_ITALIC) 2576 if (!(sym_traits & kCTFontTraitItalic)
2599 && FONT_SLANT_NUMERIC (entity) == FONT_SLANT_SYNTHETIC_ITALIC) 2577 && FONT_SLANT_NUMERIC (entity) == FONT_SLANT_SYNTHETIC_ITALIC)
2600 macfont_info->synthetic_italic_p = 1; 2578 macfont_info->synthetic_italic_p = 1;
2601 if (!(sym_traits & MAC_FONT_TRAIT_BOLD) 2579 if (!(sym_traits & kCTFontTraitBold)
2602 && FONT_WEIGHT_NUMERIC (entity) == FONT_WEIGHT_SYNTHETIC_BOLD) 2580 && FONT_WEIGHT_NUMERIC (entity) == FONT_WEIGHT_SYNTHETIC_BOLD)
2603 macfont_info->synthetic_bold_p = 1; 2581 macfont_info->synthetic_bold_p = 1;
2604 if (sym_traits & MAC_FONT_TRAIT_MONO_SPACE) 2582 if (sym_traits & kCTFontTraitMonoSpace)
2605 macfont_info->spacing = MACFONT_SPACING_MONO; 2583 macfont_info->spacing = MACFONT_SPACING_MONO;
2606 else if (INTEGERP (AREF (entity, FONT_SPACING_INDEX)) 2584 else if (INTEGERP (AREF (entity, FONT_SPACING_INDEX))
2607 && (XINT (AREF (entity, FONT_SPACING_INDEX)) 2585 && (XINT (AREF (entity, FONT_SPACING_INDEX))
@@ -2617,7 +2595,7 @@ macfont_open (struct frame * f, Lisp_Object entity, int pixel_size)
2617 NILP (XCDR (val)) ? MACFONT_ANTIALIAS_OFF : MACFONT_ANTIALIAS_ON; 2595 NILP (XCDR (val)) ? MACFONT_ANTIALIAS_OFF : MACFONT_ANTIALIAS_ON;
2618 } 2596 }
2619 macfont_info->color_bitmap_p = 0; 2597 macfont_info->color_bitmap_p = 0;
2620 if (sym_traits & MAC_FONT_TRAIT_COLOR_GLYPHS) 2598 if (sym_traits & kCTFontTraitColorGlyphs)
2621 macfont_info->color_bitmap_p = 1; 2599 macfont_info->color_bitmap_p = 1;
2622 2600
2623 glyph = macfont_get_glyph_for_character (font, ' '); 2601 glyph = macfont_get_glyph_for_character (font, ' ');
@@ -2646,12 +2624,12 @@ macfont_open (struct frame * f, Lisp_Object entity, int pixel_size)
2646 { 2624 {
2647 CFStringRef family_name; 2625 CFStringRef family_name;
2648 2626
2649 ascent = mac_font_get_ascent (macfont); 2627 ascent = CTFontGetAscent (macfont);
2650 descent = mac_font_get_descent (macfont); 2628 descent = CTFontGetDescent (macfont);
2651 leading = mac_font_get_leading (macfont); 2629 leading = CTFontGetLeading (macfont);
2652 /* AppKit and WebKit do some adjustment to the heights of 2630 /* AppKit and WebKit do some adjustment to the heights of
2653 Courier, Helvetica, and Times. */ 2631 Courier, Helvetica, and Times. */
2654 family_name = mac_font_copy_family_name (macfont); 2632 family_name = CTFontCopyFamilyName (macfont);
2655 if (family_name) 2633 if (family_name)
2656 { 2634 {
2657 if (CFEqual (family_name, CFSTR ("Courier")) 2635 if (CFEqual (family_name, CFSTR ("Courier"))
@@ -2674,8 +2652,8 @@ macfont_open (struct frame * f, Lisp_Object entity, int pixel_size)
2674 font->descent = descent + leading + 0.5f; 2652 font->descent = descent + leading + 0.5f;
2675 font->height = font->ascent + font->descent; 2653 font->height = font->ascent + font->descent;
2676 2654
2677 font->underline_position = - mac_font_get_underline_position (macfont) + 0.5f; 2655 font->underline_position = - CTFontGetUnderlinePosition (macfont) + 0.5f;
2678 font->underline_thickness = mac_font_get_underline_thickness (macfont) + 0.5f; 2656 font->underline_thickness = CTFontGetUnderlineThickness (macfont) + 0.5f;
2679 2657
2680 unblock_input (); 2658 unblock_input ();
2681 2659
@@ -2798,7 +2776,7 @@ macfont_draw (struct glyph_string *s, int from, int to, int x, int y,
2798 CGPoint text_position; 2776 CGPoint text_position;
2799 CGGlyph *glyphs; 2777 CGGlyph *glyphs;
2800 CGPoint *positions; 2778 CGPoint *positions;
2801 CGFloat font_size = mac_font_get_size (macfont_info->macfont); 2779 CGFloat font_size = CTFontGetSize (macfont_info->macfont);
2802 bool no_antialias_p = 2780 bool no_antialias_p =
2803 (NILP (ns_antialias_text) 2781 (NILP (ns_antialias_text)
2804 || macfont_info->antialias == MACFONT_ANTIALIAS_OFF 2782 || macfont_info->antialias == MACFONT_ANTIALIAS_OFF
@@ -2913,7 +2891,7 @@ macfont_shape (Lisp_Object lgstring)
2913{ 2891{
2914 struct font *font = CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring)); 2892 struct font *font = CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring));
2915 struct macfont_info *macfont_info = (struct macfont_info *) font; 2893 struct macfont_info *macfont_info = (struct macfont_info *) font;
2916 FontRef macfont = macfont_info->macfont; 2894 CTFontRef macfont = macfont_info->macfont;
2917 ptrdiff_t glyph_len, len, i, j; 2895 ptrdiff_t glyph_len, len, i, j;
2918 CFIndex nonbmp_len; 2896 CFIndex nonbmp_len;
2919 UniChar *unichars; 2897 UniChar *unichars;
@@ -3110,11 +3088,12 @@ struct non_default_uvs_table
3110 found or ill-formatted, then return NULL. */ 3088 found or ill-formatted, then return NULL. */
3111 3089
3112static CFDataRef 3090static CFDataRef
3113mac_font_copy_uvs_table (FontRef font) 3091mac_font_copy_uvs_table (CTFontRef font)
3114{ 3092{
3115 CFDataRef cmap_table, uvs_table = NULL; 3093 CFDataRef cmap_table, uvs_table = NULL;
3116 3094
3117 cmap_table = mac_font_copy_non_synthetic_table (font, cmapFontTableTag); 3095 cmap_table = CTFontCopyTable (font, cmapFontTableTag,
3096 kCTFontTableOptionNoOptions);
3118 if (cmap_table) 3097 if (cmap_table)
3119 { 3098 {
3120 sfntCMapHeader *cmap = (sfntCMapHeader *) CFDataGetBytePtr (cmap_table); 3099 sfntCMapHeader *cmap = (sfntCMapHeader *) CFDataGetBytePtr (cmap_table);
@@ -3337,7 +3316,7 @@ static int
3337macfont_variation_glyphs (struct font *font, int c, unsigned variations[256]) 3316macfont_variation_glyphs (struct font *font, int c, unsigned variations[256])
3338{ 3317{
3339 CFDataRef uvs_table; 3318 CFDataRef uvs_table;
3340 CharacterCollection uvs_collection; 3319 CTCharacterCollection uvs_collection;
3341 int i, n = 0; 3320 int i, n = 0;
3342 3321
3343 block_input (); 3322 block_input ();
@@ -3357,7 +3336,7 @@ macfont_variation_glyphs (struct font *font, int c, unsigned variations[256])
3357 { 3336 {
3358 CGGlyph glyph = glyphs[i]; 3337 CGGlyph glyph = glyphs[i];
3359 3338
3360 if (uvs_collection != MAC_CHARACTER_COLLECTION_IDENTITY_MAPPING 3339 if (uvs_collection != kCTCharacterCollectionIdentityMapping
3361 && glyph != kCGFontIndexInvalid) 3340 && glyph != kCGFontIndexInvalid)
3362 glyph = macfont_get_glyph_for_cid (font, uvs_collection, glyph); 3341 glyph = macfont_get_glyph_for_cid (font, uvs_collection, glyph);
3363 if (glyph == kCGFontIndexInvalid) 3342 if (glyph == kCGFontIndexInvalid)
@@ -3395,8 +3374,8 @@ macfont_filter_properties (Lisp_Object font, Lisp_Object alist)
3395} 3374}
3396 3375
3397static Boolean 3376static Boolean
3398mac_ctfont_descriptor_supports_languages (CTFontDescriptorRef descriptor, 3377mac_font_descriptor_supports_languages (CTFontDescriptorRef descriptor,
3399 CFArrayRef languages) 3378 CFArrayRef languages)
3400{ 3379{
3401 Boolean result = true; 3380 Boolean result = true;
3402 CFArrayRef desc_languages = 3381 CFArrayRef desc_languages =
@@ -3425,7 +3404,7 @@ mac_ctfont_descriptor_supports_languages (CTFontDescriptorRef descriptor,
3425} 3404}
3426 3405
3427static CFStringRef 3406static CFStringRef
3428mac_ctfont_create_preferred_family_for_attributes (CFDictionaryRef attributes) 3407mac_font_create_preferred_family_for_attributes (CFDictionaryRef attributes)
3429{ 3408{
3430 CFStringRef result = NULL; 3409 CFStringRef result = NULL;
3431 CFStringRef charset_string = 3410 CFStringRef charset_string =
@@ -3443,7 +3422,7 @@ mac_ctfont_create_preferred_family_for_attributes (CFDictionaryRef attributes)
3443 CFTypeRef values[] = {NULL}; 3422 CFTypeRef values[] = {NULL};
3444 CFIndex num_values = 0; 3423 CFIndex num_values = 0;
3445 CFArrayRef languages 3424 CFArrayRef languages
3446 = CFDictionaryGetValue (attributes, MAC_FONT_LANGUAGES_ATTRIBUTE); 3425 = CFDictionaryGetValue (attributes, kCTFontLanguagesAttribute);
3447 3426
3448 if (languages && CFArrayGetCount (languages) > 0) 3427 if (languages && CFArrayGetCount (languages) > 0)
3449 { 3428 {
@@ -3452,8 +3431,7 @@ mac_ctfont_create_preferred_family_for_attributes (CFDictionaryRef attributes)
3452 else 3431 else
3453 { 3432 {
3454 CFCharacterSetRef charset = 3433 CFCharacterSetRef charset =
3455 CFDictionaryGetValue (attributes, 3434 CFDictionaryGetValue (attributes, kCTFontCharacterSetAttribute);
3456 MAC_FONT_CHARACTER_SET_ATTRIBUTE);
3457 3435
3458 result = mac_font_copy_default_name_for_charset_and_languages (charset, languages); 3436 result = mac_font_copy_default_name_for_charset_and_languages (charset, languages);
3459 } 3437 }
@@ -3499,8 +3477,8 @@ mac_ctfont_create_preferred_family_for_attributes (CFDictionaryRef attributes)
3499 break; 3477 break;
3500 if (i == 0) 3478 if (i == 0)
3501 font = font_in_run; 3479 font = font_in_run;
3502 else if (!mac_ctfont_equal_in_postscript_name (font, 3480 else if (!mac_font_equal_in_postscript_name (font,
3503 font_in_run)) 3481 font_in_run))
3504 break; 3482 break;
3505 } 3483 }
3506 if (nruns > 0 && i == nruns) 3484 if (nruns > 0 && i == nruns)
@@ -3514,63 +3492,50 @@ mac_ctfont_create_preferred_family_for_attributes (CFDictionaryRef attributes)
3514} 3492}
3515 3493
3516static inline double 3494static inline double
3517mac_ctfont_get_advance_width_for_glyph (CTFontRef font, CGGlyph glyph) 3495mac_font_get_advance_width_for_glyph (CTFontRef font, CGGlyph glyph)
3518{ 3496{
3519 return CTFontGetAdvancesForGlyphs (font, 3497 return CTFontGetAdvancesForGlyphs (font, kCTFontOrientationDefault,
3520#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
3521 kCTFontOrientationDefault,
3522#else
3523 kCTFontDefaultOrientation,
3524#endif
3525 &glyph, NULL, 1); 3498 &glyph, NULL, 1);
3526} 3499}
3527 3500
3528static inline CGRect 3501static inline CGRect
3529mac_ctfont_get_bounding_rect_for_glyph (CTFontRef font, CGGlyph glyph) 3502mac_font_get_bounding_rect_for_glyph (CTFontRef font, CGGlyph glyph)
3530{ 3503{
3531 return CTFontGetBoundingRectsForGlyphs (font, 3504 return CTFontGetBoundingRectsForGlyphs (font, kCTFontOrientationDefault,
3532#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
3533 kCTFontOrientationDefault,
3534#else
3535 kCTFontDefaultOrientation,
3536#endif
3537 &glyph, NULL, 1); 3505 &glyph, NULL, 1);
3538} 3506}
3539 3507
3540static CFArrayRef 3508static CFArrayRef
3541mac_ctfont_create_available_families (void) 3509mac_font_create_available_families (void)
3542{ 3510{
3543 CFMutableArrayRef families = NULL; 3511 CFMutableArrayRef families = NULL;
3512 CFArrayRef orig_families = CTFontManagerCopyAvailableFontFamilyNames ();
3544 3513
3514 if (orig_families)
3545 { 3515 {
3546 CFArrayRef orig_families = CTFontManagerCopyAvailableFontFamilyNames (); 3516 CFIndex i, count = CFArrayGetCount (orig_families);
3547
3548 if (orig_families)
3549 {
3550 CFIndex i, count = CFArrayGetCount (orig_families);
3551 3517
3552 families = CFArrayCreateMutable (NULL, count, &kCFTypeArrayCallBacks); 3518 families = CFArrayCreateMutable (NULL, count, &kCFTypeArrayCallBacks);
3553 if (families) 3519 if (families)
3554 for (i = 0; i < count; i++) 3520 for (i = 0; i < count; i++)
3555 { 3521 {
3556 CFStringRef family = CFArrayGetValueAtIndex (orig_families, i); 3522 CFStringRef family = CFArrayGetValueAtIndex (orig_families, i);
3557 3523
3558 if (!CFStringHasPrefix (family, CFSTR (".")) 3524 if (!CFStringHasPrefix (family, CFSTR ("."))
3559 && (CTFontManagerCompareFontFamilyNames (family, 3525 && (CTFontManagerCompareFontFamilyNames (family,
3560 CFSTR ("LastResort"), 3526 CFSTR ("LastResort"),
3561 NULL) 3527 NULL)
3562 != kCFCompareEqualTo)) 3528 != kCFCompareEqualTo))
3563 CFArrayAppendValue (families, family); 3529 CFArrayAppendValue (families, family);
3564 } 3530 }
3565 CFRelease (orig_families); 3531 CFRelease (orig_families);
3566 }
3567 } 3532 }
3568 3533
3569 return families; 3534 return families;
3570} 3535}
3571 3536
3572static Boolean 3537static Boolean
3573mac_ctfont_equal_in_postscript_name (CTFontRef font1, CTFontRef font2) 3538mac_font_equal_in_postscript_name (CTFontRef font1, CTFontRef font2)
3574{ 3539{
3575 Boolean result; 3540 Boolean result;
3576 CFStringRef name1, name2; 3541 CFStringRef name1, name2;
@@ -3595,8 +3560,8 @@ mac_ctfont_equal_in_postscript_name (CTFontRef font1, CTFontRef font2)
3595} 3560}
3596 3561
3597static CTLineRef 3562static CTLineRef
3598mac_ctfont_create_line_with_string_and_font (CFStringRef string, 3563mac_font_create_line_with_string_and_font (CFStringRef string,
3599 CTFontRef macfont) 3564 CTFontRef macfont)
3600{ 3565{
3601 CFStringRef keys[] = {kCTFontAttributeName, kCTKernAttributeName}; 3566 CFStringRef keys[] = {kCTFontAttributeName, kCTKernAttributeName};
3602 CFTypeRef values[] = {NULL, NULL}; 3567 CFTypeRef values[] = {NULL, NULL};
@@ -3645,7 +3610,7 @@ mac_ctfont_create_line_with_string_and_font (CFStringRef string,
3645 CFDictionaryGetValue (attributes, kCTFontAttributeName); 3610 CFDictionaryGetValue (attributes, kCTFontAttributeName);
3646 if (font_in_run == NULL) 3611 if (font_in_run == NULL)
3647 break; 3612 break;
3648 if (!mac_ctfont_equal_in_postscript_name (macfont, font_in_run)) 3613 if (!mac_font_equal_in_postscript_name (macfont, font_in_run))
3649 break; 3614 break;
3650 } 3615 }
3651 if (i < nruns) 3616 if (i < nruns)
@@ -3659,11 +3624,11 @@ mac_ctfont_create_line_with_string_and_font (CFStringRef string,
3659} 3624}
3660 3625
3661static CFIndex 3626static CFIndex
3662mac_ctfont_shape (CTFontRef font, CFStringRef string, 3627mac_font_shape (CTFontRef font, CFStringRef string,
3663 struct mac_glyph_layout *glyph_layouts, CFIndex glyph_len) 3628 struct mac_glyph_layout *glyph_layouts, CFIndex glyph_len)
3664{ 3629{
3665 CFIndex used, result = 0; 3630 CFIndex used, result = 0;
3666 CTLineRef ctline = mac_ctfont_create_line_with_string_and_font (string, font); 3631 CTLineRef ctline = mac_font_create_line_with_string_and_font (string, font);
3667 3632
3668 if (ctline == NULL) 3633 if (ctline == NULL)
3669 return 0; 3634 return 0;
@@ -3870,7 +3835,7 @@ mac_ctfont_get_glyph_for_cid (CTFontRef font, CTCharacterCollection collection,
3870 CFDictionaryGetValue (attributes, kCTFontAttributeName); 3835 CFDictionaryGetValue (attributes, kCTFontAttributeName);
3871 3836
3872 if (font_in_run 3837 if (font_in_run
3873 && mac_ctfont_equal_in_postscript_name (font_in_run, font)) 3838 && mac_font_equal_in_postscript_name (font_in_run, font))
3874 { 3839 {
3875 CTRunGetGlyphs (run, CFRangeMake (0, 1), &result); 3840 CTRunGetGlyphs (run, CFRangeMake (0, 1), &result);
3876 if (result >= CTFontGetGlyphCount (font)) 3841 if (result >= CTFontGetGlyphCount (font))
@@ -3940,7 +3905,7 @@ mac_font_copy_default_descriptors_for_language (CFStringRef language)
3940 CFDictionaryRef attributes = 3905 CFDictionaryRef attributes =
3941 CFDictionaryCreate (NULL, 3906 CFDictionaryCreate (NULL,
3942 ((const void **) 3907 ((const void **)
3943 &MAC_FONT_NAME_ATTRIBUTE), 3908 &kCTFontNameAttribute),
3944 ((const void **) 3909 ((const void **)
3945 &macfont_language_default_font_names[i].font_names[j]), 3910 &macfont_language_default_font_names[i].font_names[j]),
3946 1, &kCFTypeDictionaryKeyCallBacks, 3911 1, &kCFTypeDictionaryKeyCallBacks,
@@ -3948,13 +3913,13 @@ mac_font_copy_default_descriptors_for_language (CFStringRef language)
3948 3913
3949 if (attributes) 3914 if (attributes)
3950 { 3915 {
3951 FontDescriptorRef pat_desc = 3916 CTFontDescriptorRef pat_desc =
3952 mac_font_descriptor_create_with_attributes (attributes); 3917 CTFontDescriptorCreateWithAttributes (attributes);
3953 3918
3954 if (pat_desc) 3919 if (pat_desc)
3955 { 3920 {
3956 FontDescriptorRef descriptor = 3921 CTFontDescriptorRef descriptor =
3957 mac_font_descriptor_create_matching_font_descriptor (pat_desc, NULL); 3922 CTFontDescriptorCreateMatchingFontDescriptor (pat_desc, NULL);
3958 3923
3959 if (descriptor) 3924 if (descriptor)
3960 { 3925 {
@@ -3992,15 +3957,15 @@ mac_font_copy_default_name_for_charset_and_languages (CFCharacterSetRef charset,
3992 3957
3993 for (i = 0; i < count; i++) 3958 for (i = 0; i < count; i++)
3994 { 3959 {
3995 FontDescriptorRef descriptor = 3960 CTFontDescriptorRef descriptor =
3996 CFArrayGetValueAtIndex (descriptors, i); 3961 CFArrayGetValueAtIndex (descriptors, i);
3997 3962
3998 if (macfont_supports_charset_and_languages_p (descriptor, charset, 3963 if (macfont_supports_charset_and_languages_p (descriptor, charset,
3999 Qnil, languages)) 3964 Qnil, languages))
4000 { 3965 {
4001 CFStringRef family = 3966 CFStringRef family =
4002 mac_font_descriptor_copy_attribute (descriptor, 3967 CTFontDescriptorCopyAttribute (descriptor,
4003 MAC_FONT_FAMILY_NAME_ATTRIBUTE); 3968 kCTFontFamilyNameAttribute);
4004 if (family) 3969 if (family)
4005 { 3970 {
4006 if (!CFStringHasPrefix (family, CFSTR (".")) 3971 if (!CFStringHasPrefix (family, CFSTR ("."))
@@ -4024,7 +3989,7 @@ void *
4024macfont_get_nsctfont (struct font *font) 3989macfont_get_nsctfont (struct font *font)
4025{ 3990{
4026 struct macfont_info *macfont_info = (struct macfont_info *) font; 3991 struct macfont_info *macfont_info = (struct macfont_info *) font;
4027 FontRef macfont = macfont_info->macfont; 3992 CTFontRef macfont = macfont_info->macfont;
4028 3993
4029 return (void *) macfont; 3994 return (void *) macfont;
4030} 3995}
diff --git a/src/syntax.c b/src/syntax.c
index 30560affdf0..dc82210e79d 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -1129,7 +1129,7 @@ The first character of NEWENTRY should be one of the following:
1129 _ symbol constituent. . punctuation. 1129 _ symbol constituent. . punctuation.
1130 ( open-parenthesis. ) close-parenthesis. 1130 ( open-parenthesis. ) close-parenthesis.
1131 " string quote. \\ escape. 1131 " string quote. \\ escape.
1132 $ paired delimiter. ' expression quote or prefix operator. 1132 $ paired delimiter. \\=' expression quote or prefix operator.
1133 < comment starter. > comment ender. 1133 < comment starter. > comment ender.
1134 / character-quote. @ inherit from parent table. 1134 / character-quote. @ inherit from parent table.
1135 | generic string fence. ! generic comment fence. 1135 | generic string fence. ! generic comment fence.
diff --git a/src/w32.c b/src/w32.c
index b421667e241..cc55507919c 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -3399,30 +3399,41 @@ sys_readdir (DIR *dirp)
3399 /* If we aren't dir_finding, do a find-first, otherwise do a find-next. */ 3399 /* If we aren't dir_finding, do a find-first, otherwise do a find-next. */
3400 else if (dir_find_handle == INVALID_HANDLE_VALUE) 3400 else if (dir_find_handle == INVALID_HANDLE_VALUE)
3401 { 3401 {
3402 char filename[MAX_UTF8_PATH + 2]; 3402 char filename[MAX_UTF8_PATH];
3403 int ln; 3403 int ln;
3404 bool last_slash = true;
3404 3405
3406 /* Note: We don't need to worry about dir_pathname being longer
3407 than MAX_UTF8_PATH, as sys_opendir already took care of that
3408 when it called map_w32_filename: that function will put a "?"
3409 in its return value in that case, thus failing all the calls
3410 below. */
3405 strcpy (filename, dir_pathname); 3411 strcpy (filename, dir_pathname);
3406 ln = strlen (filename); 3412 ln = strlen (filename);
3407 if (!IS_DIRECTORY_SEP (filename[ln - 1])) 3413 if (!IS_DIRECTORY_SEP (filename[ln - 1]))
3408 filename[ln++] = '\\'; 3414 last_slash = false;
3409 strcpy (filename + ln, "*");
3410 3415
3411 /* Note: No need to resolve symlinks in FILENAME, because 3416 /* Note: No need to resolve symlinks in FILENAME, because
3412 FindFirst opens the directory that is the target of a 3417 FindFirst opens the directory that is the target of a
3413 symlink. */ 3418 symlink. */
3414 if (w32_unicode_filenames) 3419 if (w32_unicode_filenames)
3415 { 3420 {
3416 wchar_t fnw[MAX_PATH]; 3421 wchar_t fnw[MAX_PATH + 2];
3417 3422
3418 filename_to_utf16 (filename, fnw); 3423 filename_to_utf16 (filename, fnw);
3424 if (!last_slash)
3425 wcscat (fnw, L"\\");
3426 wcscat (fnw, L"*");
3419 dir_find_handle = FindFirstFileW (fnw, &dir_find_data_w); 3427 dir_find_handle = FindFirstFileW (fnw, &dir_find_data_w);
3420 } 3428 }
3421 else 3429 else
3422 { 3430 {
3423 char fna[MAX_PATH]; 3431 char fna[MAX_PATH + 2];
3424 3432
3425 filename_to_ansi (filename, fna); 3433 filename_to_ansi (filename, fna);
3434 if (!last_slash)
3435 strcat (fna, "\\");
3436 strcat (fna, "*");
3426 /* If FILENAME is not representable by the current ANSI 3437 /* If FILENAME is not representable by the current ANSI
3427 codepage, we don't want FindFirstFileA to interpret the 3438 codepage, we don't want FindFirstFileA to interpret the
3428 '?' characters as a wildcard. */ 3439 '?' characters as a wildcard. */
@@ -3815,7 +3826,7 @@ faccessat (int dirfd, const char * path, int mode, int flags)
3815 errno = EACCES; 3826 errno = EACCES;
3816 return -1; 3827 return -1;
3817 } 3828 }
3818 break; 3829 goto check_attrs;
3819 } 3830 }
3820 /* FALLTHROUGH */ 3831 /* FALLTHROUGH */
3821 case ERROR_FILE_NOT_FOUND: 3832 case ERROR_FILE_NOT_FOUND:
@@ -3828,6 +3839,8 @@ faccessat (int dirfd, const char * path, int mode, int flags)
3828 } 3839 }
3829 return -1; 3840 return -1;
3830 } 3841 }
3842
3843 check_attrs:
3831 if ((mode & X_OK) != 0 3844 if ((mode & X_OK) != 0
3832 && !(is_exec (path) || (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0)) 3845 && !(is_exec (path) || (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0))
3833 { 3846 {
@@ -3847,6 +3860,76 @@ faccessat (int dirfd, const char * path, int mode, int flags)
3847 return 0; 3860 return 0;
3848} 3861}
3849 3862
3863/* A special test for DIRNAME being a directory accessible by the
3864 current user. This is needed because the security permissions in
3865 directory's ACLs are not visible in the Posix-style mode bits
3866 returned by 'stat' and in attributes returned by GetFileAttributes.
3867 So a directory would seem like it's readable by the current user,
3868 but will in fact error out with EACCES when they actually try. */
3869int
3870w32_accessible_directory_p (const char *dirname, ptrdiff_t dirlen)
3871{
3872 char pattern[MAX_UTF8_PATH];
3873 bool last_slash = dirlen > 0 && IS_DIRECTORY_SEP (dirname[dirlen - 1]);
3874 HANDLE dh;
3875
3876 /* Network volumes need a different reading method. */
3877 if (is_unc_volume (dirname))
3878 {
3879 void *read_result = NULL;
3880 wchar_t fnw[MAX_PATH];
3881 char fna[MAX_PATH];
3882
3883 dh = open_unc_volume (dirname);
3884 if (dh != INVALID_HANDLE_VALUE)
3885 {
3886 read_result = read_unc_volume (dh, fnw, fna, MAX_PATH);
3887 close_unc_volume (dh);
3888 }
3889 /* Treat empty volumes as accessible. */
3890 return read_result != NULL || GetLastError () == ERROR_NO_MORE_ITEMS;
3891 }
3892
3893 /* Note: map_w32_filename makes sure DIRNAME is not longer than
3894 MAX_UTF8_PATH. */
3895 strcpy (pattern, map_w32_filename (dirname, NULL));
3896
3897 /* Note: No need to resolve symlinks in FILENAME, because FindFirst
3898 opens the directory that is the target of a symlink. */
3899 if (w32_unicode_filenames)
3900 {
3901 wchar_t pat_w[MAX_PATH + 2];
3902 WIN32_FIND_DATAW dfd_w;
3903
3904 filename_to_utf16 (pattern, pat_w);
3905 if (!last_slash)
3906 wcscat (pat_w, L"\\");
3907 wcscat (pat_w, L"*");
3908 dh = FindFirstFileW (pat_w, &dfd_w);
3909 }
3910 else
3911 {
3912 char pat_a[MAX_PATH + 2];
3913 WIN32_FIND_DATAA dfd_a;
3914
3915 filename_to_ansi (pattern, pat_a);
3916 if (!last_slash)
3917 strcpy (pat_a, "\\");
3918 strcat (pat_a, "*");
3919 /* In case DIRNAME cannot be expressed in characters from the
3920 current ANSI codepage. */
3921 if (_mbspbrk (pat_a, "?"))
3922 dh = INVALID_HANDLE_VALUE;
3923 else
3924 dh = FindFirstFileA (pat_a, &dfd_a);
3925 }
3926
3927 if (dh == INVALID_HANDLE_VALUE)
3928 return 0;
3929 FindClose (dh);
3930 return 1;
3931}
3932
3850/* A version of 'access' to be used locally with file names in 3933/* A version of 'access' to be used locally with file names in
3851 locale-specific encoding. Does not resolve symlinks and does not 3934 locale-specific encoding. Does not resolve symlinks and does not
3852 support file names on FAT12 and FAT16 volumes, but that's OK, since 3935 support file names on FAT12 and FAT16 volumes, but that's OK, since
diff --git a/src/w32.h b/src/w32.h
index 338cb06b193..2c711502593 100644
--- a/src/w32.h
+++ b/src/w32.h
@@ -195,6 +195,7 @@ extern int filename_to_utf16 (const char *, wchar_t *);
195extern int codepage_for_filenames (CPINFO *); 195extern int codepage_for_filenames (CPINFO *);
196extern Lisp_Object ansi_encode_filename (Lisp_Object); 196extern Lisp_Object ansi_encode_filename (Lisp_Object);
197extern int w32_copy_file (const char *, const char *, int, int, int); 197extern int w32_copy_file (const char *, const char *, int, int, int);
198extern int w32_accessible_directory_p (const char *, ptrdiff_t);
198 199
199extern BOOL init_winsock (int load_now); 200extern BOOL init_winsock (int load_now);
200extern void srandom (int); 201extern void srandom (int);
diff --git a/src/w32term.c b/src/w32term.c
index fbd31b15de2..82b05bffffe 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -6202,8 +6202,6 @@ x_set_window_size (struct frame *f, bool change_gravity,
6202 } 6202 }
6203 6203
6204 unblock_input (); 6204 unblock_input ();
6205
6206 do_pending_window_change (0);
6207} 6205}
6208 6206
6209/* Mouse warping. */ 6207/* Mouse warping. */
diff --git a/src/xterm.c b/src/xterm.c
index 4eb777f9dc3..9ee76e967e1 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -10515,8 +10515,6 @@ x_set_window_size (struct frame *f, bool change_gravity,
10515 cancel_mouse_face (f); 10515 cancel_mouse_face (f);
10516 10516
10517 unblock_input (); 10517 unblock_input ();
10518
10519 do_pending_window_change (false);
10520} 10518}
10521 10519
10522/* Move the mouse to position pixel PIX_X, PIX_Y relative to frame F. */ 10520/* Move the mouse to position pixel PIX_X, PIX_Y relative to frame F. */