X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/f315b69922db769f3358e15616aa76c965be8a89..be5e9348dc137d06655676e686f153cf33de4f28:/src/w32font.c diff --git a/src/w32font.c b/src/w32font.c index 895931843b..77994593c6 100644 --- a/src/w32font.c +++ b/src/w32font.c @@ -1,5 +1,5 @@ /* Font backend for the Microsoft Windows API. - Copyright (C) 2007-2014 Free Software Foundation, Inc. + Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -57,51 +57,6 @@ along with GNU Emacs. If not, see . */ #define JOHAB_CHARSET 130 #endif -Lisp_Object Qgdi; -Lisp_Object Quniscribe; -static Lisp_Object QCformat; -static Lisp_Object Qmonospace, Qsansserif, Qmono, Qsans, Qsans_serif; -static Lisp_Object Qserif, Qscript, Qdecorative; -static Lisp_Object Qraster, Qoutline, Qunknown; - -/* antialiasing */ -static Lisp_Object Qstandard, Qsubpixel, Qnatural; - -/* languages */ -static Lisp_Object Qzh; - -/* scripts */ -static Lisp_Object Qgreek, Qcoptic, Qcyrillic, Qarmenian, Qhebrew; -static Lisp_Object Qarabic, Qsyriac, Qnko, Qthaana, Qdevanagari, Qbengali; -static Lisp_Object Qgurmukhi, Qgujarati, Qoriya, Qtamil, Qtelugu; -static Lisp_Object Qkannada, Qmalayalam, Qsinhala, Qthai, Qlao; -static Lisp_Object Qtibetan, Qmyanmar, Qgeorgian, Qhangul, Qethiopic; -static Lisp_Object Qcherokee, Qcanadian_aboriginal, Qogham, Qrunic; -static Lisp_Object Qkhmer, Qmongolian, Qbraille, Qhan; -static Lisp_Object Qideographic_description, Qcjk_misc, Qkana, Qbopomofo; -static Lisp_Object Qkanbun, Qyi, Qbyzantine_musical_symbol; -static Lisp_Object Qmusical_symbol, Qmathematical, Qcham, Qphonetic; -/* Not defined in characters.el, but referenced in fontset.el. */ -static Lisp_Object Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot; -static Lisp_Object Qdeseret, Qglagolitic, Qgothic, Qhanunoo, Qkharoshthi; -static Lisp_Object Qlimbu, Qlinear_b, Qold_italic, Qold_persian, Qosmanya; -static Lisp_Object Qphags_pa, Qphoenician, Qshavian, Qsyloti_nagri; -static Lisp_Object Qtagalog, Qtagbanwa, Qtai_le, Qtifinagh, Qugaritic; - -/* W32 charsets: for use in Vw32_charset_info_alist. */ -static Lisp_Object Qw32_charset_ansi, Qw32_charset_default; -static Lisp_Object Qw32_charset_symbol, Qw32_charset_shiftjis; -static Lisp_Object Qw32_charset_hangeul, Qw32_charset_gb2312; -static Lisp_Object Qw32_charset_chinesebig5, Qw32_charset_oem; -static Lisp_Object Qw32_charset_easteurope, Qw32_charset_turkish; -static Lisp_Object Qw32_charset_baltic, Qw32_charset_russian; -static Lisp_Object Qw32_charset_arabic, Qw32_charset_greek; -static Lisp_Object Qw32_charset_hebrew, Qw32_charset_vietnamese; -static Lisp_Object Qw32_charset_thai, Qw32_charset_johab, Qw32_charset_mac; - -/* Font spacing symbols - defined in font.c. */ -extern Lisp_Object Qc, Qp, Qm; - static void fill_in_logfont (struct frame *, LOGFONT *, Lisp_Object); static BYTE w32_antialias_type (Lisp_Object); @@ -140,7 +95,7 @@ struct font_callback_data /* The list to add matches to. */ Lisp_Object list; /* Whether to match only opentype fonts. */ - int opentype_only; + bool opentype_only; }; /* Handles the problem that EnumFontFamiliesEx will not return all @@ -291,7 +246,7 @@ intern_font_name (char * string) Lisp_Object obarray = check_obarray (Vobarray); Lisp_Object tem = oblookup (obarray, SDATA (str), len, len); /* This code is similar to intern function from lread.c. */ - return SYMBOLP (tem) ? tem : intern_driver (str, obarray, XINT (tem)); + return SYMBOLP (tem) ? tem : intern_driver (str, obarray, tem); } /* w32 implementation of get_cache for font backend. @@ -791,7 +746,8 @@ w32font_otf_drive (struct font *font, Lisp_Object features, Additional parameter opentype_only restricts the returned fonts to opentype fonts, which can be used with the Uniscribe backend. */ Lisp_Object -w32font_list_internal (struct frame *f, Lisp_Object font_spec, int opentype_only) +w32font_list_internal (struct frame *f, Lisp_Object font_spec, + bool opentype_only) { struct font_callback_data match_data; HDC dc; @@ -843,7 +799,8 @@ w32font_list_internal (struct frame *f, Lisp_Object font_spec, int opentype_only Additional parameter opentype_only restricts the returned fonts to opentype fonts, which can be used with the Uniscribe backend. */ Lisp_Object -w32font_match_internal (struct frame *f, Lisp_Object font_spec, int opentype_only) +w32font_match_internal (struct frame *f, Lisp_Object font_spec, + bool opentype_only) { struct font_callback_data match_data; HDC dc; @@ -1115,11 +1072,11 @@ w32_enumfont_pattern_entity (Lisp_Object frame, truetype so that this information is not any worse than we could have obtained later. */ if (EQ (backend, Quniscribe) && (full_type & NTMFLAGS_OPENTYPE)) - tem = intern ("opentype"); + tem = Qopentype; else if (font_type & TRUETYPE_FONTTYPE) tem = intern ("truetype"); else if (full_type & NTM_PS_OPENTYPE) - tem = intern ("postscript"); + tem = Qpostscript; else if (full_type & NTM_TYPE1) tem = intern ("type1"); else if (font_type & RASTER_FONTTYPE) @@ -1918,10 +1875,10 @@ static Lisp_Object w32_to_fc_weight (int n) { if (n >= FW_EXTRABOLD) return intern ("black"); - if (n >= FW_BOLD) return intern ("bold"); + if (n >= FW_BOLD) return Qbold; if (n >= FW_SEMIBOLD) return intern ("demibold"); if (n >= FW_NORMAL) return intern ("medium"); - return intern ("light"); + return Qlight; } /* Fill in all the available details of LOGFONT from FONT_SPEC. */ @@ -2170,9 +2127,18 @@ font_supported_scripts (FONTSIGNATURE * sig) supported = Fcons ((sym), supported) SUBRANGE (0, Qlatin); - /* The following count as latin too, ASCII should be present in these fonts, - so don't need to mark them separately. */ /* 1: Latin-1 supplement, 2: Latin Extended A, 3: Latin Extended B. */ + /* Most fonts that support Latin will have good coverage of the + Extended blocks, so in practice marking them below is not really + needed, or useful: if a font claims support for, say, Latin + Extended-B, but does not contain glyphs for some of the + characters in the range, the user will have to augment her + fontset to display those few characters. But we mark these + subranges here anyway, for the marginal use cases where they + might make a difference. */ + SUBRANGE (1, Qlatin); + SUBRANGE (2, Qlatin); + SUBRANGE (3, Qlatin); SUBRANGE (4, Qphonetic); /* 5: Spacing and tone modifiers, 6: Combining Diacritical Marks. */ SUBRANGE (7, Qgreek); @@ -2180,7 +2146,12 @@ font_supported_scripts (FONTSIGNATURE * sig) SUBRANGE (9, Qcyrillic); SUBRANGE (10, Qarmenian); SUBRANGE (11, Qhebrew); - /* 12: Vai. */ + /* Bit 12 is rather useless if the user has Hebrew fonts installed, + because apparently at some point in the past bit 12 was "Hebrew + Extended", and many Hebrew fonts still have this bit set. The + only workaround is to customize fontsets to use fonts like Ebrima + or Quivira. */ + SUBRANGE (12, Qvai); SUBRANGE (13, Qarabic); SUBRANGE (14, Qnko); SUBRANGE (15, Qdevanagari); @@ -2196,8 +2167,11 @@ font_supported_scripts (FONTSIGNATURE * sig) SUBRANGE (25, Qlao); SUBRANGE (26, Qgeorgian); SUBRANGE (27, Qbalinese); - /* 28: Hangul Jamo. */ - /* 29: Latin Extended, 30: Greek Extended, 31: Punctuation. */ + /* 28: Hangul Jamo -- covered by the default fontset. */ + /* 29: Latin Extended, 30: Greek Extended -- covered above. */ + /* 31: Supplemental Punctuation -- most probably be masked by + Courier New, so fontset customization is needed. */ + SUBRANGE (31, Qsymbol); /* 32-47: Symbols (defined below). */ SUBRANGE (48, Qcjk_misc); /* Match either 49: katakana or 50: hiragana for kana. */ @@ -2212,6 +2186,9 @@ font_supported_scripts (FONTSIGNATURE * sig) SUBRANGE (59, Qhan); /* There are others, but this is the main one. */ SUBRANGE (59, Qideographic_description); /* Windows lumps this in. */ SUBRANGE (59, Qkanbun); /* And this. */ + /* These are covered well either by the default Courier New or by + CJK fonts that are set up specially in the default fontset. So + marking them here wouldn't be useful. */ /* 60: Private use, 61: CJK strokes and compatibility. */ /* 62: Alphabetic Presentation, 63: Arabic Presentation A. */ /* 64: Combining half marks, 65: Vertical and CJK compatibility. */ @@ -2240,31 +2217,54 @@ font_supported_scripts (FONTSIGNATURE * sig) SUBRANGE (87, Qdeseret); SUBRANGE (88, Qbyzantine_musical_symbol); SUBRANGE (88, Qmusical_symbol); /* Windows doesn't distinguish these. */ - SUBRANGE (89, Qmathematical); + SUBRANGE (89, Qmathematical_bold); /* See fontset.el:setup-default-fontset. */ + SUBRANGE (89, Qmathematical_italic); + SUBRANGE (89, Qmathematical_bold_italic); + SUBRANGE (89, Qmathematical_script); + SUBRANGE (89, Qmathematical_bold_script); + SUBRANGE (89, Qmathematical_fraktur); + SUBRANGE (89, Qmathematical_double_struck); + SUBRANGE (89, Qmathematical_bold_fraktur); + SUBRANGE (89, Qmathematical_sans_serif); + SUBRANGE (89, Qmathematical_sans_serif_bold); + SUBRANGE (89, Qmathematical_sans_serif_italic); + SUBRANGE (89, Qmathematical_sans_serif_bold_italic); + SUBRANGE (89, Qmathematical_monospace); /* 90: Private use, 91: Variation selectors, 92: Tags. */ SUBRANGE (93, Qlimbu); SUBRANGE (94, Qtai_le); - /* 95: New Tai Le */ - SUBRANGE (90, Qbuginese); + SUBRANGE (95, Qtai_le); + SUBRANGE (96, Qbuginese); SUBRANGE (97, Qglagolitic); SUBRANGE (98, Qtifinagh); /* 99: Yijing Hexagrams. */ + SUBRANGE (99, Qhan); SUBRANGE (100, Qsyloti_nagri); SUBRANGE (101, Qlinear_b); - /* 102: Ancient Greek Numbers. */ + SUBRANGE (102, Qancient_greek_number); SUBRANGE (103, Qugaritic); SUBRANGE (104, Qold_persian); SUBRANGE (105, Qshavian); SUBRANGE (106, Qosmanya); SUBRANGE (107, Qcypriot); SUBRANGE (108, Qkharoshthi); - /* 109: Tai Xuan Jing. */ + SUBRANGE (109, Qtai_xuan_jing_symbol); SUBRANGE (110, Qcuneiform); - /* 111: Counting Rods, 112: Sundanese, 113: Lepcha, 114: Ol Chiki. */ - /* 115: Saurashtra, 116: Kayah Li, 117: Rejang. */ + SUBRANGE (111, Qcounting_rod_numeral); + SUBRANGE (112, Qsundanese); + SUBRANGE (113, Qlepcha); + SUBRANGE (114, Qol_chiki); + SUBRANGE (115, Qsaurashtra); + SUBRANGE (116, Qkayah_li); + SUBRANGE (117, Qrejang); SUBRANGE (118, Qcham); - /* 119: Ancient symbols, 120: Phaistos Disc. */ - /* 121: Carian, Lycian, Lydian, 122: Dominoes, Mahjong tiles. */ + SUBRANGE (119, Qancient_symbol); + SUBRANGE (120, Qphaistos_disc); + SUBRANGE (121, Qlycian); + SUBRANGE (121, Qcarian); + SUBRANGE (121, Qlydian); + SUBRANGE (122, Qdomino_tile); + SUBRANGE (122, Qmahjong_tile); /* 123-127: Reserved. */ /* There isn't really a main symbol range, so include symbol if any @@ -2504,7 +2504,7 @@ w32font_filter_properties (Lisp_Object font, Lisp_Object alist) struct font_driver w32font_driver = { LISP_INITIALLY_ZERO, /* Qgdi */ - 0, /* case insensitive */ + false, /* case insensitive */ w32font_get_cache, w32font_list, w32font_match, @@ -2573,6 +2573,7 @@ syms_of_w32font (void) DEFSYM (Qcyrillic, "cyrillic"); DEFSYM (Qarmenian, "armenian"); DEFSYM (Qhebrew, "hebrew"); + DEFSYM (Qvai, "vai"); DEFSYM (Qarabic, "arabic"); DEFSYM (Qsyriac, "syriac"); DEFSYM (Qnko, "nko"); @@ -2610,7 +2611,19 @@ syms_of_w32font (void) DEFSYM (Qyi, "yi"); DEFSYM (Qbyzantine_musical_symbol, "byzantine-musical-symbol"); DEFSYM (Qmusical_symbol, "musical-symbol"); - DEFSYM (Qmathematical, "mathematical"); + DEFSYM (Qmathematical_bold, "mathematical-bold"); + DEFSYM (Qmathematical_italic, "mathematical-italic"); + DEFSYM (Qmathematical_bold_italic, "mathematical-bold-italic"); + DEFSYM (Qmathematical_script, "mathematical-script"); + DEFSYM (Qmathematical_bold_script, "mathematical-bold-script"); + DEFSYM (Qmathematical_fraktur, "mathematical-fraktur"); + DEFSYM (Qmathematical_double_struck, "mathematical-double-struck"); + DEFSYM (Qmathematical_bold_fraktur, "mathematical-bold-fraktur"); + DEFSYM (Qmathematical_sans_serif, "mathematical-sans-serif"); + DEFSYM (Qmathematical_sans_serif_bold, "mathematical-sans-serif-bold"); + DEFSYM (Qmathematical_sans_serif_italic, "mathematical-sans-serif-italic"); + DEFSYM (Qmathematical_sans_serif_bold_italic, "mathematical-sans-serif-bold-italic"); + DEFSYM (Qmathematical_monospace, "mathematical-monospace"); DEFSYM (Qcham, "cham"); DEFSYM (Qphonetic, "phonetic"); DEFSYM (Qbalinese, "balinese"); @@ -2637,6 +2650,22 @@ syms_of_w32font (void) DEFSYM (Qtai_le, "tai_le"); DEFSYM (Qtifinagh, "tifinagh"); DEFSYM (Qugaritic, "ugaritic"); + DEFSYM (Qlycian, "lycian"); + DEFSYM (Qcarian, "carian"); + DEFSYM (Qlydian, "lydian"); + DEFSYM (Qdomino_tile, "domino-tile"); + DEFSYM (Qmahjong_tile, "mahjong-tile"); + DEFSYM (Qtai_xuan_jing_symbol, "tai-xuan-jing-symbol"); + DEFSYM (Qcounting_rod_numeral, "counting-rod-numeral"); + DEFSYM (Qancient_symbol, "ancient-symbol"); + DEFSYM (Qphaistos_disc, "phaistos-disc"); + DEFSYM (Qancient_greek_number, "ancient-greek-number"); + DEFSYM (Qsundanese, "sundanese"); + DEFSYM (Qlepcha, "lepcha"); + DEFSYM (Qol_chiki, "ol-chiki"); + DEFSYM (Qsaurashtra, "saurashtra"); + DEFSYM (Qkayah_li, "kayah-li"); + DEFSYM (Qrejang, "rejang"); /* W32 font encodings. */ DEFVAR_LISP ("w32-charset-info-alist",