diff options
| author | YAMAMOTO Mitsuharu | 2005-10-11 03:35:54 +0000 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2005-10-11 03:35:54 +0000 |
| commit | 71b7a47f7972000021bade3c1cab8e34a0ce9d0c (patch) | |
| tree | 90d1f9955b1442b4bf38418f1fd60950dc3cd097 /src | |
| parent | 3c02eaa7d35f169f2d17f0d02bfc5c41ea8ef9c9 (diff) | |
| download | emacs-71b7a47f7972000021bade3c1cab8e34a0ce9d0c.tar.gz emacs-71b7a47f7972000021bade3c1cab8e34a0ce9d0c.zip | |
(PER_CHAR_METRIC): Remove unused macro.
(fm_font_family_alist): New variable.
(syms_of_macterm): Initialize and staticpro it.
(decode_mac_font_name): Replace '-' in family name with '_' if it
occurs just once. Lower family name.
(parse_x_font_name): Rename from x_font_name_to_mac_font_name.
All uses changed. Remove argument MF and code conversion for it.
Add argument SIZE. Rename argument MF_DECODED to FAMILY, and CS
to CHARSET. Parse font size. Lower family name. Return integer
value for status of parsing.
(init_font_name_table) [USE_ATSUI]: Use decode_mac_font_name.
Don't use Fdowncase because family name is already lowered by
decode_mac_font_name.
(init_font_name_table): Always call decode_mac_font_name. Add
pair of family name and its reference to fm_font_family_alist.
(mac_clear_font_name_table): Clear fm_font_family_alist.
(XLoadQueryFont): Move font size parsing part to parse_x_font_name.
Lookup fm_font_family_alist to get font family reference.
(XLoadQueryFont) [USE_ATSUI]: Don't use Fdowncase because family
name is already lowered by parse_x_font_name.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 30 | ||||
| -rw-r--r-- | src/macterm.c | 496 |
2 files changed, 281 insertions, 245 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index f0c9084da54..c723c3ee9c1 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,26 @@ | |||
| 1 | 2005-10-11 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | ||
| 2 | |||
| 3 | * macterm.c (PER_CHAR_METRIC): Remove unused macro. | ||
| 4 | (fm_font_family_alist): New variable. | ||
| 5 | (syms_of_macterm): Initialize and staticpro it. | ||
| 6 | (decode_mac_font_name): Replace '-' in family name with '_' if it | ||
| 7 | occurs just once. Lower family name. | ||
| 8 | (parse_x_font_name): Rename from x_font_name_to_mac_font_name. | ||
| 9 | All uses changed. Remove argument MF and code conversion for it. | ||
| 10 | Add argument SIZE. Rename argument MF_DECODED to FAMILY, and CS | ||
| 11 | to CHARSET. Parse font size. Lower family name. Return integer | ||
| 12 | value for status of parsing. | ||
| 13 | (init_font_name_table) [USE_ATSUI]: Use decode_mac_font_name. | ||
| 14 | Don't use Fdowncase because family name is already lowered by | ||
| 15 | decode_mac_font_name. | ||
| 16 | (init_font_name_table): Always call decode_mac_font_name. Add | ||
| 17 | pair of family name and its reference to fm_font_family_alist. | ||
| 18 | (mac_clear_font_name_table): Clear fm_font_family_alist. | ||
| 19 | (XLoadQueryFont): Move font size parsing part to parse_x_font_name. | ||
| 20 | Lookup fm_font_family_alist to get font family reference. | ||
| 21 | (XLoadQueryFont) [USE_ATSUI]: Don't use Fdowncase because family | ||
| 22 | name is already lowered by parse_x_font_name. | ||
| 23 | |||
| 1 | 2005-10-11 Kim F. Storm <storm@cua.dk> | 24 | 2005-10-11 Kim F. Storm <storm@cua.dk> |
| 2 | 25 | ||
| 3 | * xterm.c (glyph_rect): Return 0 if position is outside text area. | 26 | * xterm.c (glyph_rect): Return 0 if position is outside text area. |
| @@ -52,7 +75,7 @@ | |||
| 52 | [MAC_OS_X_VERSION_MAX_ALLOWED < 1020]: Specify kATSLineFractDisable. | 75 | [MAC_OS_X_VERSION_MAX_ALLOWED < 1020]: Specify kATSLineFractDisable. |
| 53 | (mac_draw_string_common) [MAC_OSX && USE_ATSUI]: Clip to clipping | 76 | (mac_draw_string_common) [MAC_OSX && USE_ATSUI]: Clip to clipping |
| 54 | rectangles stored in gc. | 77 | rectangles stored in gc. |
| 55 | (XFreeGC): Dispose clipping region. | 78 | (XFreeGC): Dispose of clipping region. |
| 56 | (mac_set_clip_rectangles, mac_reset_clip_rectangles): New functions. | 79 | (mac_set_clip_rectangles, mac_reset_clip_rectangles): New functions. |
| 57 | (x_draw_fringe_bitmap, x_set_glyph_string_clipping) | 80 | (x_draw_fringe_bitmap, x_set_glyph_string_clipping) |
| 58 | (x_draw_relief_rect, x_draw_box_rect, x_draw_stretch_glyph_string) | 81 | (x_draw_relief_rect, x_draw_box_rect, x_draw_stretch_glyph_string) |
| @@ -3772,7 +3795,7 @@ | |||
| 3772 | [TARGET_API_MAC_CARBON] (Fx_file_dialog): Use MAXPATHLEN for size | 3795 | [TARGET_API_MAC_CARBON] (Fx_file_dialog): Use MAXPATHLEN for size |
| 3773 | of filename string. Set event callback function when creating | 3796 | of filename string. Set event callback function when creating |
| 3774 | dialog boxes. Add code conversions for filenames. Don't dispose | 3797 | dialog boxes. Add code conversions for filenames. Don't dispose |
| 3775 | apple event descriptor record if failed to create it. | 3798 | of apple event descriptor record if failed to create it. |
| 3776 | 3799 | ||
| 3777 | * macterm.c: Include sys/param.h. | 3800 | * macterm.c: Include sys/param.h. |
| 3778 | [USE_CARBON_EVENTS] (mac_handle_window_event): Add handler for | 3801 | [USE_CARBON_EVENTS] (mac_handle_window_event): Add handler for |
| @@ -6879,7 +6902,8 @@ | |||
| 6879 | (x_scroll_bar_handle_click): Set `(PORTION . WHOLE)' part in a | 6902 | (x_scroll_bar_handle_click): Set `(PORTION . WHOLE)' part in a |
| 6880 | scroll-bar click event. | 6903 | scroll-bar click event. |
| 6881 | (mac_define_frame_cursor): Change the pointer shape. | 6904 | (mac_define_frame_cursor): Change the pointer shape. |
| 6882 | (x_free_frame_resources): Reset tip_window to NULL when it is disposed. | 6905 | (x_free_frame_resources): Reset tip_window to NULL when it is |
| 6906 | disposed of. | ||
| 6883 | [!TARGET_API_MAC_CARBON] (arrow_cursor): New variable. | 6907 | [!TARGET_API_MAC_CARBON] (arrow_cursor): New variable. |
| 6884 | [!TARGET_API_MAC_CARBON] (do_init_managers): Initialize arrow_cursor. | 6908 | [!TARGET_API_MAC_CARBON] (do_init_managers): Initialize arrow_cursor. |
| 6885 | (do_window_update): Don't do anything if the updated window is the | 6909 | (do_window_update): Don't do anything if the updated window is the |
diff --git a/src/macterm.c b/src/macterm.c index 7d75e962e9c..2142698bbf4 100644 --- a/src/macterm.c +++ b/src/macterm.c | |||
| @@ -1766,19 +1766,6 @@ static XCharStruct *x_per_char_metric P_ ((XFontStruct *, XChar2b *)); | |||
| 1766 | static int mac_encode_char P_ ((int, XChar2b *, struct font_info *, int *)); | 1766 | static int mac_encode_char P_ ((int, XChar2b *, struct font_info *, int *)); |
| 1767 | 1767 | ||
| 1768 | 1768 | ||
| 1769 | /* Return a pointer to per-char metric information in FONT of a | ||
| 1770 | character pointed by B which is a pointer to an XChar2b. */ | ||
| 1771 | |||
| 1772 | #define PER_CHAR_METRIC(font, b) \ | ||
| 1773 | ((font)->per_char \ | ||
| 1774 | ? ((font)->per_char + (b)->byte2 - (font)->min_char_or_byte2 \ | ||
| 1775 | + (((font)->min_byte1 || (font)->max_byte1) \ | ||
| 1776 | ? (((b)->byte1 - (font)->min_byte1) \ | ||
| 1777 | * ((font)->max_char_or_byte2 - (font)->min_char_or_byte2 + 1)) \ | ||
| 1778 | : 0)) \ | ||
| 1779 | : &((font)->max_bounds)) | ||
| 1780 | |||
| 1781 | |||
| 1782 | /* Get metrics of character CHAR2B in FONT. Value is null if CHAR2B | 1769 | /* Get metrics of character CHAR2B in FONT. Value is null if CHAR2B |
| 1783 | is not contained in the font. */ | 1770 | is not contained in the font. */ |
| 1784 | 1771 | ||
| @@ -6843,7 +6830,13 @@ static char **font_name_table = NULL; | |||
| 6843 | static int font_name_table_size = 0; | 6830 | static int font_name_table_size = 0; |
| 6844 | static int font_name_count = 0; | 6831 | static int font_name_count = 0; |
| 6845 | 6832 | ||
| 6833 | /* Alist linking font family names to Font Manager font family | ||
| 6834 | references (which can also be used as QuickDraw font IDs). We use | ||
| 6835 | an alist because hash tables are not ready when the terminal frame | ||
| 6836 | for Mac OS Classic is created. */ | ||
| 6837 | static Lisp_Object fm_font_family_alist; | ||
| 6846 | #if USE_ATSUI | 6838 | #if USE_ATSUI |
| 6839 | /* Hash table linking font family names to ATSU font IDs. */ | ||
| 6847 | static Lisp_Object atsu_font_id_hash; | 6840 | static Lisp_Object atsu_font_id_hash; |
| 6848 | #endif | 6841 | #endif |
| 6849 | 6842 | ||
| @@ -6893,24 +6886,39 @@ decode_mac_font_name (name, size, coding_system) | |||
| 6893 | struct coding_system coding; | 6886 | struct coding_system coding; |
| 6894 | char *buf, *p; | 6887 | char *buf, *p; |
| 6895 | 6888 | ||
| 6896 | for (p = name; *p; p++) | 6889 | if (!NILP (coding_system) && !NILP (Fcoding_system_p (coding_system))) |
| 6897 | if (!isascii (*p) || iscntrl (*p)) | 6890 | { |
| 6898 | break; | 6891 | for (p = name; *p; p++) |
| 6892 | if (!isascii (*p) || iscntrl (*p)) | ||
| 6893 | break; | ||
| 6899 | 6894 | ||
| 6900 | if (*p == '\0' | 6895 | if (*p) |
| 6901 | || NILP (coding_system) || NILP (Fcoding_system_p (coding_system))) | 6896 | { |
| 6902 | return; | 6897 | setup_coding_system (coding_system, &coding); |
| 6898 | coding.src_multibyte = 0; | ||
| 6899 | coding.dst_multibyte = 1; | ||
| 6900 | coding.mode |= CODING_MODE_LAST_BLOCK; | ||
| 6901 | coding.composing = COMPOSITION_DISABLED; | ||
| 6902 | buf = (char *) alloca (size); | ||
| 6903 | |||
| 6904 | decode_coding (&coding, name, buf, strlen (name), size - 1); | ||
| 6905 | bcopy (buf, name, coding.produced); | ||
| 6906 | name[coding.produced] = '\0'; | ||
| 6907 | } | ||
| 6908 | } | ||
| 6903 | 6909 | ||
| 6904 | setup_coding_system (coding_system, &coding); | 6910 | /* If there's just one occurrence of '-' in the family name, it is |
| 6905 | coding.src_multibyte = 0; | 6911 | replaced with '_'. (More than one occurrence of '-' means a |
| 6906 | coding.dst_multibyte = 1; | 6912 | "FOUNDRY-FAMILY-CHARSET"-style name.) */ |
| 6907 | coding.mode |= CODING_MODE_LAST_BLOCK; | 6913 | p = strchr (name, '-'); |
| 6908 | coding.composing = COMPOSITION_DISABLED; | 6914 | if (p && strchr (p + 1, '-') == NULL) |
| 6909 | buf = (char *) alloca (size); | 6915 | *p = '_'; |
| 6910 | 6916 | ||
| 6911 | decode_coding (&coding, name, buf, strlen (name), size - 1); | 6917 | for (p = name; *p; p++) |
| 6912 | bcopy (buf, name, coding.produced); | 6918 | /* On Mac OS X 10.3, tolower also converts non-ASCII characters |
| 6913 | name[coding.produced] = '\0'; | 6919 | for some locales. */ |
| 6920 | if (isascii (*p)) | ||
| 6921 | *p = tolower (*p); | ||
| 6914 | } | 6922 | } |
| 6915 | 6923 | ||
| 6916 | 6924 | ||
| @@ -6949,32 +6957,46 @@ mac_to_x_fontname (name, size, style, charset) | |||
| 6949 | } | 6957 | } |
| 6950 | 6958 | ||
| 6951 | 6959 | ||
| 6952 | /* Convert an X font spec to the corresponding mac font name, which | 6960 | /* Parse fully-specified and instantiated X11 font spec XF, and store |
| 6953 | can then be passed to GetFNum after conversion to a Pascal string. | 6961 | the results to FAMILY, *SIZE, *STYLE, and CHARSET. Return 1 if the |
| 6954 | For ordinary Mac fonts, this should just be their names, like | 6962 | parsing succeeded, and 0 otherwise. For FAMILY and CHARSET, the |
| 6955 | "monaco", "Taipei", etc. Fonts converted from the GNU intlfonts | 6963 | caller must allocate at least 256 and 32 bytes respectively. For |
| 6956 | collection contain their charset designation in their names, like | 6964 | ordinary Mac fonts, the value stored to FAMILY should just be their |
| 6957 | "ETL-Fixed-iso8859-1", "ETL-Fixed-koi8-r", etc. Both types of font | 6965 | names, like "monaco", "Taipei", etc. Fonts converted from the GNU |
| 6958 | names are handled accordingly. */ | 6966 | intlfonts collection contain their charset designation in their |
| 6959 | static void | 6967 | names, like "ETL-Fixed-iso8859-1", "ETL-Fixed-koi8-r", etc. Both |
| 6960 | x_font_name_to_mac_font_name (xf, mf, mf_decoded, style, cs) | 6968 | types of font names are handled accordingly. */ |
| 6961 | char *xf, *mf, *mf_decoded; | 6969 | |
| 6970 | const int kDefaultFontSize = 12; | ||
| 6971 | |||
| 6972 | static int | ||
| 6973 | parse_x_font_name (xf, family, size, style, charset) | ||
| 6974 | char *xf, *family; | ||
| 6975 | int *size; | ||
| 6962 | Style *style; | 6976 | Style *style; |
| 6963 | char *cs; | 6977 | char *charset; |
| 6964 | { | 6978 | { |
| 6965 | Str31 foundry; | 6979 | Str31 foundry, weight; |
| 6966 | Str255 family; | 6980 | int point_size, avgwidth; |
| 6967 | char weight[20], slant[2], *p; | 6981 | char slant[2], *p; |
| 6968 | Lisp_Object charset_info, coding_system = Qnil; | ||
| 6969 | struct coding_system coding; | ||
| 6970 | 6982 | ||
| 6971 | strcpy (mf, ""); | 6983 | if (sscanf (xf, "-%31[^-]-%255[^-]-%31[^-]-%1[^-]-%*[^-]-%*[^-]-%d-%d-%*[^-]-%*[^-]-%*c-%d-%31s", |
| 6984 | foundry, family, weight, slant, size, | ||
| 6985 | &point_size, &avgwidth, charset) != 8 | ||
| 6986 | && sscanf (xf, "-%31[^-]-%255[^-]-%31[^-]-%1[^-]-%*[^-]--%d-%d-%*[^-]-%*[^-]-%*c-%d-%31s", | ||
| 6987 | foundry, family, weight, slant, size, | ||
| 6988 | &point_size, &avgwidth, charset) != 8) | ||
| 6989 | return 0; | ||
| 6972 | 6990 | ||
| 6973 | if (sscanf (xf, "-%31[^-]-%255[^-]-%19[^-]-%1[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%31s", | 6991 | if (*size == 0) |
| 6974 | foundry, family, weight, slant, cs) != 5 && | 6992 | { |
| 6975 | sscanf (xf, "-%31[^-]-%255[^-]-%19[^-]-%1[^-]-%*[^-]--%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%31s", | 6993 | if (point_size > 0) |
| 6976 | foundry, family, weight, slant, cs) != 5) | 6994 | *size = point_size / 10; |
| 6977 | return; | 6995 | else if (avgwidth > 0) |
| 6996 | *size = avgwidth / 10; | ||
| 6997 | } | ||
| 6998 | if (*size == 0) | ||
| 6999 | *size = kDefaultFontSize; | ||
| 6978 | 7000 | ||
| 6979 | *style = normal; | 7001 | *style = normal; |
| 6980 | if (strcmp (weight, "bold") == 0) | 7002 | if (strcmp (weight, "bold") == 0) |
| @@ -6982,32 +7004,31 @@ x_font_name_to_mac_font_name (xf, mf, mf_decoded, style, cs) | |||
| 6982 | if (*slant == 'i') | 7004 | if (*slant == 'i') |
| 6983 | *style |= italic; | 7005 | *style |= italic; |
| 6984 | 7006 | ||
| 6985 | charset_info = Fassoc (build_string (cs), Vmac_charset_info_alist); | 7007 | if (NILP (Fassoc (build_string (charset), Vmac_charset_info_alist))) |
| 6986 | if (!NILP (charset_info)) | ||
| 6987 | { | 7008 | { |
| 6988 | strcpy (mf_decoded, family); | 7009 | int foundry_len = strlen (foundry), family_len = strlen (family); |
| 6989 | coding_system = Fcar (Fcdr (Fcdr (charset_info))); | 7010 | |
| 7011 | if (foundry_len + family_len + strlen (charset) + 2 < sizeof (Str255)) | ||
| 7012 | { | ||
| 7013 | /* Like sprintf (family, "%s-%s-%s", foundry, family, charset), | ||
| 7014 | but take overlap into account. */ | ||
| 7015 | memmove (family + foundry_len + 1, family, family_len); | ||
| 7016 | memcpy (family, foundry, foundry_len); | ||
| 7017 | family[foundry_len] = '-'; | ||
| 7018 | family[foundry_len + 1 + family_len] = '-'; | ||
| 7019 | strcpy (family + foundry_len + 1 + family_len + 1, charset); | ||
| 7020 | } | ||
| 7021 | else | ||
| 7022 | return 0; | ||
| 6990 | } | 7023 | } |
| 6991 | else | ||
| 6992 | sprintf (mf_decoded, "%s-%s-%s", foundry, family, cs); | ||
| 6993 | 7024 | ||
| 6994 | for (p = mf_decoded; *p; p++) | 7025 | for (p = family; *p; p++) |
| 6995 | if (!isascii (*p) || iscntrl (*p)) | 7026 | /* On Mac OS X 10.3, tolower also converts non-ASCII characters |
| 6996 | break; | 7027 | for some locales. */ |
| 7028 | if (isascii (*p)) | ||
| 7029 | *p = tolower (*p); | ||
| 6997 | 7030 | ||
| 6998 | if (*p == '\0' | 7031 | return 1; |
| 6999 | || NILP (coding_system) || NILP (Fcoding_system_p (coding_system))) | ||
| 7000 | strcpy (mf, mf_decoded); | ||
| 7001 | else | ||
| 7002 | { | ||
| 7003 | setup_coding_system (coding_system, &coding); | ||
| 7004 | coding.src_multibyte = 1; | ||
| 7005 | coding.dst_multibyte = 0; | ||
| 7006 | coding.mode |= CODING_MODE_LAST_BLOCK; | ||
| 7007 | encode_coding (&coding, mf_decoded, mf, | ||
| 7008 | strlen (mf_decoded), sizeof (Str255) - 1); | ||
| 7009 | mf[coding.produced] = '\0'; | ||
| 7010 | } | ||
| 7011 | } | 7032 | } |
| 7012 | 7033 | ||
| 7013 | 7034 | ||
| @@ -7084,6 +7105,8 @@ init_font_name_table () | |||
| 7084 | kFontMacintoshPlatform, kFontNoScript, | 7105 | kFontMacintoshPlatform, kFontNoScript, |
| 7085 | kFontNoLanguage, name_len, name, | 7106 | kFontNoLanguage, name_len, name, |
| 7086 | NULL, NULL); | 7107 | NULL, NULL); |
| 7108 | if (err == noErr) | ||
| 7109 | decode_mac_font_name (name, name_len + 1, Qnil); | ||
| 7087 | if (err == noErr | 7110 | if (err == noErr |
| 7088 | && *name != '.' | 7111 | && *name != '.' |
| 7089 | && (prev_name == NULL | 7112 | && (prev_name == NULL |
| @@ -7099,7 +7122,7 @@ init_font_name_table () | |||
| 7099 | bold, cs)); | 7122 | bold, cs)); |
| 7100 | add_font_name_table_entry (mac_to_x_fontname (name, 0, | 7123 | add_font_name_table_entry (mac_to_x_fontname (name, 0, |
| 7101 | italic | bold, cs)); | 7124 | italic | bold, cs)); |
| 7102 | Fputhash (Fdowncase (make_unibyte_string (name, name_len)), | 7125 | Fputhash (make_unibyte_string (name, name_len), |
| 7103 | long_to_cons (font_ids[i]), atsu_font_id_hash); | 7126 | long_to_cons (font_ids[i]), atsu_font_id_hash); |
| 7104 | xfree (prev_name); | 7127 | xfree (prev_name); |
| 7105 | prev_name = name; | 7128 | prev_name = name; |
| @@ -7149,12 +7172,14 @@ init_font_name_table () | |||
| 7149 | sc = GetTextEncodingBase (encoding); | 7172 | sc = GetTextEncodingBase (encoding); |
| 7150 | text_encoding_info = assq_no_quit (make_number (sc), | 7173 | text_encoding_info = assq_no_quit (make_number (sc), |
| 7151 | text_encoding_info_alist); | 7174 | text_encoding_info_alist); |
| 7152 | if (!NILP (text_encoding_info)) | 7175 | if (NILP (text_encoding_info)) |
| 7153 | decode_mac_font_name (name, sizeof (name), | ||
| 7154 | XCAR (XCDR (text_encoding_info))); | ||
| 7155 | else | ||
| 7156 | text_encoding_info = assq_no_quit (make_number (kTextEncodingMacRoman), | 7176 | text_encoding_info = assq_no_quit (make_number (kTextEncodingMacRoman), |
| 7157 | text_encoding_info_alist); | 7177 | text_encoding_info_alist); |
| 7178 | decode_mac_font_name (name, sizeof (name), | ||
| 7179 | XCAR (XCDR (text_encoding_info))); | ||
| 7180 | fm_font_family_alist = Fcons (Fcons (build_string (name), | ||
| 7181 | make_number (ff)), | ||
| 7182 | fm_font_family_alist); | ||
| 7158 | 7183 | ||
| 7159 | /* Point the instance iterator at the current font family. */ | 7184 | /* Point the instance iterator at the current font family. */ |
| 7160 | if (FMResetFontFamilyInstanceIterator (ff, &ffii) != noErr) | 7185 | if (FMResetFontFamilyInstanceIterator (ff, &ffii) != noErr) |
| @@ -7233,12 +7258,14 @@ init_font_name_table () | |||
| 7233 | scriptcode = FontToScript (fontnum); | 7258 | scriptcode = FontToScript (fontnum); |
| 7234 | text_encoding_info = assq_no_quit (make_number (scriptcode), | 7259 | text_encoding_info = assq_no_quit (make_number (scriptcode), |
| 7235 | text_encoding_info_alist); | 7260 | text_encoding_info_alist); |
| 7236 | if (!NILP (text_encoding_info)) | 7261 | if (NILP (text_encoding_info)) |
| 7237 | decode_mac_font_name (name, sizeof (name), | ||
| 7238 | XCAR (XCDR (text_encoding_info))); | ||
| 7239 | else | ||
| 7240 | text_encoding_info = assq_no_quit (make_number (smRoman), | 7262 | text_encoding_info = assq_no_quit (make_number (smRoman), |
| 7241 | text_encoding_info_alist); | 7263 | text_encoding_info_alist); |
| 7264 | decode_mac_font_name (name, sizeof (name), | ||
| 7265 | XCAR (XCDR (text_encoding_info))); | ||
| 7266 | fm_font_family_alist = Fcons (Fcons (build_string (name), | ||
| 7267 | make_number (fontnum)), | ||
| 7268 | fm_font_family_alist); | ||
| 7242 | do | 7269 | do |
| 7243 | { | 7270 | { |
| 7244 | HLock (font_handle); | 7271 | HLock (font_handle); |
| @@ -7294,6 +7321,7 @@ mac_clear_font_name_table () | |||
| 7294 | xfree (font_name_table); | 7321 | xfree (font_name_table); |
| 7295 | font_name_table = NULL; | 7322 | font_name_table = NULL; |
| 7296 | font_name_table_size = font_name_count = 0; | 7323 | font_name_table_size = font_name_count = 0; |
| 7324 | fm_font_family_alist = Qnil; | ||
| 7297 | } | 7325 | } |
| 7298 | 7326 | ||
| 7299 | 7327 | ||
| @@ -7602,9 +7630,6 @@ is_fully_specified_xlfd (char *p) | |||
| 7602 | } | 7630 | } |
| 7603 | 7631 | ||
| 7604 | 7632 | ||
| 7605 | const int kDefaultFontSize = 12; | ||
| 7606 | |||
| 7607 | |||
| 7608 | /* XLoadQueryFont creates and returns an internal representation for a | 7633 | /* XLoadQueryFont creates and returns an internal representation for a |
| 7609 | font in a MacFontStruct struct. There is really no concept | 7634 | font in a MacFontStruct struct. There is really no concept |
| 7610 | corresponding to "loading" a font on the Mac. But we check its | 7635 | corresponding to "loading" a font on the Mac. But we check its |
| @@ -7614,12 +7639,9 @@ const int kDefaultFontSize = 12; | |||
| 7614 | static MacFontStruct * | 7639 | static MacFontStruct * |
| 7615 | XLoadQueryFont (Display *dpy, char *fontname) | 7640 | XLoadQueryFont (Display *dpy, char *fontname) |
| 7616 | { | 7641 | { |
| 7617 | int i, size, point_size, avgwidth, is_two_byte_font, char_width; | 7642 | int i, size, char_width; |
| 7618 | char *name; | 7643 | char *name; |
| 7619 | GrafPtr port; | 7644 | Str255 family; |
| 7620 | SInt16 old_fontnum, old_fontsize; | ||
| 7621 | Style old_fontface; | ||
| 7622 | Str255 mfontname, mfontname_decoded; | ||
| 7623 | Str31 charset; | 7645 | Str31 charset; |
| 7624 | SInt16 fontnum; | 7646 | SInt16 fontnum; |
| 7625 | #if USE_ATSUI | 7647 | #if USE_ATSUI |
| @@ -7633,10 +7655,6 @@ XLoadQueryFont (Display *dpy, char *fontname) | |||
| 7633 | short scriptcode; | 7655 | short scriptcode; |
| 7634 | #endif | 7656 | #endif |
| 7635 | MacFontStruct *font; | 7657 | MacFontStruct *font; |
| 7636 | FontInfo the_fontinfo; | ||
| 7637 | #ifdef MAC_OSX | ||
| 7638 | UInt32 old_flags, new_flags; | ||
| 7639 | #endif | ||
| 7640 | 7658 | ||
| 7641 | if (is_fully_specified_xlfd (fontname)) | 7659 | if (is_fully_specified_xlfd (fontname)) |
| 7642 | name = fontname; | 7660 | name = fontname; |
| @@ -7650,32 +7668,9 @@ XLoadQueryFont (Display *dpy, char *fontname) | |||
| 7650 | name = SDATA (XCAR (matched_fonts)); | 7668 | name = SDATA (XCAR (matched_fonts)); |
| 7651 | } | 7669 | } |
| 7652 | 7670 | ||
| 7653 | GetPort (&port); /* save the current font number used */ | 7671 | if (parse_x_font_name (name, family, &size, &fontface, charset) == 0) |
| 7654 | #if TARGET_API_MAC_CARBON | 7672 | return NULL; |
| 7655 | old_fontnum = GetPortTextFont (port); | ||
| 7656 | old_fontsize = GetPortTextSize (port); | ||
| 7657 | old_fontface = GetPortTextFace (port); | ||
| 7658 | #else | ||
| 7659 | old_fontnum = port->txFont; | ||
| 7660 | old_fontsize = port->txSize; | ||
| 7661 | old_fontface = port->txFace; | ||
| 7662 | #endif | ||
| 7663 | |||
| 7664 | if (sscanf (name, "-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]--%d-%d-%*[^-]-%*[^-]-%*c-%d-%*s", &size, &point_size, &avgwidth) != 3) | ||
| 7665 | size = 0; | ||
| 7666 | else | ||
| 7667 | { | ||
| 7668 | if (size == 0) | ||
| 7669 | if (point_size > 0) | ||
| 7670 | size = point_size / 10; | ||
| 7671 | else if (avgwidth > 0) | ||
| 7672 | size = avgwidth / 10; | ||
| 7673 | } | ||
| 7674 | if (size == 0) | ||
| 7675 | size = kDefaultFontSize; | ||
| 7676 | 7673 | ||
| 7677 | x_font_name_to_mac_font_name (name, mfontname, mfontname_decoded, | ||
| 7678 | &fontface, charset); | ||
| 7679 | #if USE_ATSUI | 7674 | #if USE_ATSUI |
| 7680 | if (strcmp (charset, "iso10646-1") == 0) /* XXX */ | 7675 | if (strcmp (charset, "iso10646-1") == 0) /* XXX */ |
| 7681 | { | 7676 | { |
| @@ -7693,9 +7688,7 @@ XLoadQueryFont (Display *dpy, char *fontname) | |||
| 7693 | ATSUFontFeatureSelector selectors[] = {kAllTypeFeaturesOffSelector}; | 7688 | ATSUFontFeatureSelector selectors[] = {kAllTypeFeaturesOffSelector}; |
| 7694 | Lisp_Object font_id_cons; | 7689 | Lisp_Object font_id_cons; |
| 7695 | 7690 | ||
| 7696 | font_id_cons = Fgethash (Fdowncase | 7691 | font_id_cons = Fgethash (make_unibyte_string (family, strlen (family)), |
| 7697 | (make_unibyte_string (mfontname, | ||
| 7698 | strlen (mfontname))), | ||
| 7699 | atsu_font_id_hash, Qnil); | 7692 | atsu_font_id_hash, Qnil); |
| 7700 | if (NILP (font_id_cons)) | 7693 | if (NILP (font_id_cons)) |
| 7701 | return NULL; | 7694 | return NULL; |
| @@ -7716,24 +7709,21 @@ XLoadQueryFont (Display *dpy, char *fontname) | |||
| 7716 | scriptcode = kTextEncodingMacUnicode; | 7709 | scriptcode = kTextEncodingMacUnicode; |
| 7717 | } | 7710 | } |
| 7718 | else | 7711 | else |
| 7719 | { | ||
| 7720 | #endif | 7712 | #endif |
| 7721 | c2pstr (mfontname); | 7713 | { |
| 7714 | Lisp_Object tmp = Fassoc (build_string (family), fm_font_family_alist); | ||
| 7715 | |||
| 7716 | if (NILP (tmp)) | ||
| 7717 | return NULL; | ||
| 7718 | fontnum = XINT (XCDR (tmp)); | ||
| 7722 | #if TARGET_API_MAC_CARBON | 7719 | #if TARGET_API_MAC_CARBON |
| 7723 | fontnum = FMGetFontFamilyFromName (mfontname); | 7720 | if (FMGetFontFamilyTextEncoding (fontnum, &encoding) != noErr) |
| 7724 | if (fontnum == kInvalidFontFamily | 7721 | return NULL; |
| 7725 | || FMGetFontFamilyTextEncoding (fontnum, &encoding) != noErr) | 7722 | scriptcode = GetTextEncodingBase (encoding); |
| 7726 | return NULL; | ||
| 7727 | scriptcode = GetTextEncodingBase (encoding); | ||
| 7728 | #else | 7723 | #else |
| 7729 | GetFNum (mfontname, &fontnum); | 7724 | scriptcode = FontToScript (fontnum); |
| 7730 | if (fontnum == 0) | ||
| 7731 | return NULL; | ||
| 7732 | scriptcode = FontToScript (fontnum); | ||
| 7733 | #endif | 7725 | #endif |
| 7734 | #if USE_ATSUI | ||
| 7735 | } | 7726 | } |
| 7736 | #endif | ||
| 7737 | 7727 | ||
| 7738 | font = (MacFontStruct *) xmalloc (sizeof (struct MacFontStruct)); | 7728 | font = (MacFontStruct *) xmalloc (sizeof (struct MacFontStruct)); |
| 7739 | 7729 | ||
| @@ -7752,7 +7742,7 @@ XLoadQueryFont (Display *dpy, char *fontname) | |||
| 7752 | if (scriptcode == smJapanese && strcmp (charset, "jisx0201.1976-0") == 0) | 7742 | if (scriptcode == smJapanese && strcmp (charset, "jisx0201.1976-0") == 0) |
| 7753 | font->mac_scriptcode = smRoman; | 7743 | font->mac_scriptcode = smRoman; |
| 7754 | 7744 | ||
| 7755 | font->full_name = mac_to_x_fontname (mfontname_decoded, size, fontface, charset); | 7745 | font->full_name = mac_to_x_fontname (family, size, fontface, charset); |
| 7756 | 7746 | ||
| 7757 | #if USE_ATSUI | 7747 | #if USE_ATSUI |
| 7758 | if (font->mac_style) | 7748 | if (font->mac_style) |
| @@ -7837,130 +7827,149 @@ XLoadQueryFont (Display *dpy, char *fontname) | |||
| 7837 | font->max_char_or_byte2 = 0xff; | 7827 | font->max_char_or_byte2 = 0xff; |
| 7838 | } | 7828 | } |
| 7839 | else | 7829 | else |
| 7830 | #endif | ||
| 7840 | { | 7831 | { |
| 7832 | GrafPtr port; | ||
| 7833 | SInt16 old_fontnum, old_fontsize; | ||
| 7834 | Style old_fontface; | ||
| 7835 | FontInfo the_fontinfo; | ||
| 7836 | int is_two_byte_font; | ||
| 7837 | |||
| 7838 | /* Save the current font number used. */ | ||
| 7839 | GetPort (&port); | ||
| 7840 | #if TARGET_API_MAC_CARBON | ||
| 7841 | old_fontnum = GetPortTextFont (port); | ||
| 7842 | old_fontsize = GetPortTextSize (port); | ||
| 7843 | old_fontface = GetPortTextFace (port); | ||
| 7844 | #else | ||
| 7845 | old_fontnum = port->txFont; | ||
| 7846 | old_fontsize = port->txSize; | ||
| 7847 | old_fontface = port->txFace; | ||
| 7841 | #endif | 7848 | #endif |
| 7842 | is_two_byte_font = font->mac_scriptcode == smJapanese || | ||
| 7843 | font->mac_scriptcode == smTradChinese || | ||
| 7844 | font->mac_scriptcode == smSimpChinese || | ||
| 7845 | font->mac_scriptcode == smKorean; | ||
| 7846 | 7849 | ||
| 7847 | TextFont (fontnum); | 7850 | TextFont (fontnum); |
| 7848 | TextSize (size); | 7851 | TextSize (size); |
| 7849 | TextFace (fontface); | 7852 | TextFace (fontface); |
| 7850 | 7853 | ||
| 7851 | GetFontInfo (&the_fontinfo); | 7854 | GetFontInfo (&the_fontinfo); |
| 7852 | 7855 | ||
| 7853 | font->ascent = the_fontinfo.ascent; | 7856 | font->ascent = the_fontinfo.ascent; |
| 7854 | font->descent = the_fontinfo.descent; | 7857 | font->descent = the_fontinfo.descent; |
| 7855 | 7858 | ||
| 7856 | if (is_two_byte_font) | 7859 | is_two_byte_font = (font->mac_scriptcode == smJapanese |
| 7857 | { | 7860 | || font->mac_scriptcode == smTradChinese |
| 7858 | font->min_byte1 = 0xa1; | 7861 | || font->mac_scriptcode == smSimpChinese |
| 7859 | font->max_byte1 = 0xfe; | 7862 | || font->mac_scriptcode == smKorean); |
| 7860 | font->min_char_or_byte2 = 0xa1; | ||
| 7861 | font->max_char_or_byte2 = 0xfe; | ||
| 7862 | 7863 | ||
| 7863 | /* Use the width of an "ideographic space" of that font because | 7864 | if (is_two_byte_font) |
| 7864 | the_fontinfo.widMax returns the wrong width for some fonts. */ | 7865 | { |
| 7865 | switch (font->mac_scriptcode) | 7866 | font->min_byte1 = 0xa1; |
| 7866 | { | 7867 | font->max_byte1 = 0xfe; |
| 7867 | case smJapanese: | 7868 | font->min_char_or_byte2 = 0xa1; |
| 7868 | font->min_byte1 = 0x81; | 7869 | font->max_char_or_byte2 = 0xfe; |
| 7869 | font->max_byte1 = 0xfc; | 7870 | |
| 7870 | font->min_char_or_byte2 = 0x40; | 7871 | /* Use the width of an "ideographic space" of that font |
| 7871 | font->max_char_or_byte2 = 0xfc; | 7872 | because the_fontinfo.widMax returns the wrong width for |
| 7872 | char_width = StringWidth("\p\x81\x40"); | 7873 | some fonts. */ |
| 7873 | break; | 7874 | switch (font->mac_scriptcode) |
| 7874 | case smTradChinese: | 7875 | { |
| 7875 | font->min_char_or_byte2 = 0x40; | 7876 | case smJapanese: |
| 7876 | char_width = StringWidth("\p\xa1\x40"); | 7877 | font->min_byte1 = 0x81; |
| 7877 | break; | 7878 | font->max_byte1 = 0xfc; |
| 7878 | case smSimpChinese: | 7879 | font->min_char_or_byte2 = 0x40; |
| 7879 | char_width = StringWidth("\p\xa1\xa1"); | 7880 | font->max_char_or_byte2 = 0xfc; |
| 7880 | break; | 7881 | char_width = StringWidth("\p\x81\x40"); |
| 7881 | case smKorean: | 7882 | break; |
| 7882 | char_width = StringWidth("\p\xa1\xa1"); | 7883 | case smTradChinese: |
| 7883 | break; | 7884 | font->min_char_or_byte2 = 0x40; |
| 7884 | } | 7885 | char_width = StringWidth("\p\xa1\x40"); |
| 7885 | } | 7886 | break; |
| 7886 | else | 7887 | case smSimpChinese: |
| 7887 | { | 7888 | char_width = StringWidth("\p\xa1\xa1"); |
| 7888 | font->min_byte1 = font->max_byte1 = 0; | 7889 | break; |
| 7889 | font->min_char_or_byte2 = 0x20; | 7890 | case smKorean: |
| 7890 | font->max_char_or_byte2 = 0xff; | 7891 | char_width = StringWidth("\p\xa1\xa1"); |
| 7892 | break; | ||
| 7893 | } | ||
| 7894 | } | ||
| 7895 | else | ||
| 7896 | { | ||
| 7897 | font->min_byte1 = font->max_byte1 = 0; | ||
| 7898 | font->min_char_or_byte2 = 0x20; | ||
| 7899 | font->max_char_or_byte2 = 0xff; | ||
| 7891 | 7900 | ||
| 7892 | /* Do this instead of use the_fontinfo.widMax, which incorrectly | 7901 | /* Do this instead of use the_fontinfo.widMax, which |
| 7893 | returns 15 for 12-point Monaco! */ | 7902 | incorrectly returns 15 for 12-point Monaco! */ |
| 7894 | char_width = CharWidth ('m'); | 7903 | char_width = CharWidth ('m'); |
| 7895 | } | 7904 | } |
| 7896 | 7905 | ||
| 7897 | if (is_two_byte_font) | 7906 | if (is_two_byte_font) |
| 7898 | { | 7907 | { |
| 7899 | font->per_char = NULL; | 7908 | font->per_char = NULL; |
| 7900 | 7909 | ||
| 7901 | if (fontface & italic) | 7910 | if (fontface & italic) |
| 7902 | font->max_bounds.rbearing = char_width + 1; | 7911 | font->max_bounds.rbearing = char_width + 1; |
| 7903 | else | 7912 | else |
| 7904 | font->max_bounds.rbearing = char_width; | 7913 | font->max_bounds.rbearing = char_width; |
| 7905 | font->max_bounds.lbearing = 0; | 7914 | font->max_bounds.lbearing = 0; |
| 7906 | font->max_bounds.width = char_width; | 7915 | font->max_bounds.width = char_width; |
| 7907 | font->max_bounds.ascent = the_fontinfo.ascent; | 7916 | font->max_bounds.ascent = the_fontinfo.ascent; |
| 7908 | font->max_bounds.descent = the_fontinfo.descent; | 7917 | font->max_bounds.descent = the_fontinfo.descent; |
| 7909 | 7918 | ||
| 7910 | font->min_bounds = font->max_bounds; | 7919 | font->min_bounds = font->max_bounds; |
| 7911 | } | 7920 | } |
| 7912 | else | 7921 | else |
| 7913 | { | 7922 | { |
| 7914 | int c, min_width, max_width; | 7923 | int c, min_width, max_width; |
| 7915 | Rect char_bounds, min_bounds, max_bounds; | 7924 | Rect char_bounds, min_bounds, max_bounds; |
| 7916 | char ch; | 7925 | char ch; |
| 7917 | 7926 | ||
| 7918 | font->per_char = xmalloc (sizeof (XCharStruct) * (0xff - 0x20 + 1)); | 7927 | font->per_char = xmalloc (sizeof (XCharStruct) * (0xff - 0x20 + 1)); |
| 7928 | bzero (font->per_char, sizeof (XCharStruct) * (0xff - 0x20 + 1)); | ||
| 7919 | 7929 | ||
| 7920 | min_width = max_width = char_width; | 7930 | min_width = max_width = char_width; |
| 7921 | SetRect (&min_bounds, -32767, -32767, 32767, 32767); | 7931 | SetRect (&min_bounds, -32767, -32767, 32767, 32767); |
| 7922 | SetRect (&max_bounds, 0, 0, 0, 0); | 7932 | SetRect (&max_bounds, 0, 0, 0, 0); |
| 7923 | for (c = 0x20; c <= 0xff; c++) | 7933 | for (c = 0x20; c <= 0xff; c++) |
| 7924 | { | ||
| 7925 | ch = c; | ||
| 7926 | char_width = CharWidth (ch); | ||
| 7927 | QDTextBounds (1, &ch, &char_bounds); | ||
| 7928 | STORE_XCHARSTRUCT (font->per_char[c - 0x20], | ||
| 7929 | char_width, char_bounds); | ||
| 7930 | /* Some Japanese fonts (in SJIS encoding) return 0 as the | ||
| 7931 | character width of 0x7f. */ | ||
| 7932 | if (char_width > 0) | ||
| 7933 | { | 7934 | { |
| 7934 | min_width = min (min_width, char_width); | 7935 | ch = c; |
| 7935 | max_width = max (max_width, char_width); | 7936 | char_width = CharWidth (ch); |
| 7937 | QDTextBounds (1, &ch, &char_bounds); | ||
| 7938 | STORE_XCHARSTRUCT (font->per_char[c - 0x20], | ||
| 7939 | char_width, char_bounds); | ||
| 7940 | /* Some Japanese fonts (in SJIS encoding) return 0 as | ||
| 7941 | the character width of 0x7f. */ | ||
| 7942 | if (char_width > 0) | ||
| 7943 | { | ||
| 7944 | min_width = min (min_width, char_width); | ||
| 7945 | max_width = max (max_width, char_width); | ||
| 7946 | } | ||
| 7947 | if (!EmptyRect (&char_bounds)) | ||
| 7948 | { | ||
| 7949 | SetRect (&min_bounds, | ||
| 7950 | max (min_bounds.left, char_bounds.left), | ||
| 7951 | max (min_bounds.top, char_bounds.top), | ||
| 7952 | min (min_bounds.right, char_bounds.right), | ||
| 7953 | min (min_bounds.bottom, char_bounds.bottom)); | ||
| 7954 | UnionRect (&max_bounds, &char_bounds, &max_bounds); | ||
| 7955 | } | ||
| 7936 | } | 7956 | } |
| 7937 | if (!EmptyRect (&char_bounds)) | 7957 | STORE_XCHARSTRUCT (font->min_bounds, min_width, min_bounds); |
| 7958 | STORE_XCHARSTRUCT (font->max_bounds, max_width, max_bounds); | ||
| 7959 | if (min_width == max_width | ||
| 7960 | && max_bounds.left >= 0 && max_bounds.right <= max_width) | ||
| 7938 | { | 7961 | { |
| 7939 | SetRect (&min_bounds, | 7962 | /* Fixed width and no overhangs. */ |
| 7940 | max (min_bounds.left, char_bounds.left), | 7963 | xfree (font->per_char); |
| 7941 | max (min_bounds.top, char_bounds.top), | 7964 | font->per_char = NULL; |
| 7942 | min (min_bounds.right, char_bounds.right), | ||
| 7943 | min (min_bounds.bottom, char_bounds.bottom)); | ||
| 7944 | UnionRect (&max_bounds, &char_bounds, &max_bounds); | ||
| 7945 | } | 7965 | } |
| 7946 | } | 7966 | } |
| 7947 | STORE_XCHARSTRUCT (font->min_bounds, min_width, min_bounds); | ||
| 7948 | STORE_XCHARSTRUCT (font->max_bounds, max_width, max_bounds); | ||
| 7949 | if (min_width == max_width | ||
| 7950 | && max_bounds.left >= 0 && max_bounds.right <= max_width) | ||
| 7951 | { | ||
| 7952 | /* Fixed width and no overhangs. */ | ||
| 7953 | xfree (font->per_char); | ||
| 7954 | font->per_char = NULL; | ||
| 7955 | } | ||
| 7956 | } | ||
| 7957 | 7967 | ||
| 7958 | TextFont (old_fontnum); /* restore previous font number, size and face */ | 7968 | /* Restore previous font number, size and face. */ |
| 7959 | TextSize (old_fontsize); | 7969 | TextFont (old_fontnum); |
| 7960 | TextFace (old_fontface); | 7970 | TextSize (old_fontsize); |
| 7961 | #if USE_ATSUI | 7971 | TextFace (old_fontface); |
| 7962 | } | 7972 | } |
| 7963 | #endif | ||
| 7964 | 7973 | ||
| 7965 | return font; | 7974 | return font; |
| 7966 | } | 7975 | } |
| @@ -10988,14 +10997,17 @@ syms_of_macterm () | |||
| 10988 | staticpro (&Qreverse); | 10997 | staticpro (&Qreverse); |
| 10989 | Qreverse = intern ("reverse"); | 10998 | Qreverse = intern ("reverse"); |
| 10990 | 10999 | ||
| 11000 | staticpro (&Qmac_ready_for_drag_n_drop); | ||
| 11001 | Qmac_ready_for_drag_n_drop = intern ("mac-ready-for-drag-n-drop"); | ||
| 11002 | |||
| 10991 | staticpro (&x_display_name_list); | 11003 | staticpro (&x_display_name_list); |
| 10992 | x_display_name_list = Qnil; | 11004 | x_display_name_list = Qnil; |
| 10993 | 11005 | ||
| 10994 | staticpro (&last_mouse_scroll_bar); | 11006 | staticpro (&last_mouse_scroll_bar); |
| 10995 | last_mouse_scroll_bar = Qnil; | 11007 | last_mouse_scroll_bar = Qnil; |
| 10996 | 11008 | ||
| 10997 | Qmac_ready_for_drag_n_drop = intern ("mac-ready-for-drag-n-drop"); | 11009 | staticpro (&fm_font_family_alist); |
| 10998 | staticpro (&Qmac_ready_for_drag_n_drop); | 11010 | fm_font_family_alist = Qnil; |
| 10999 | 11011 | ||
| 11000 | #if USE_ATSUI | 11012 | #if USE_ATSUI |
| 11001 | staticpro (&atsu_font_id_hash); | 11013 | staticpro (&atsu_font_id_hash); |