annotate src/w32font.c @ 96348:ecd6143014da

Remove unneeded -Defines in the compiler command line (MinGW and MSVC). * nt/nmake.defs: * nt/gmake.defs (FONT_CFLAGS): Remove. (EMACS_EXTRA_C_FLAGS): Don't include FONT_CFLAGS. (CFLAGS): Don't include WIN32_LEAN_AND_MEAN, _WIN32_WINNT, -D$(ARCH) and _CRTAPI1. (ARCH_FLAGS): Don't include _X86_. * nt/config.nt (_WIN32_WINNT, WIN32_LEAN_AND_MEAN): Define. * src/makefile.w32-in (LOCAL_FLAGS): Don't include WINDOWSNT, DOS_NT and _UCHAR_T. * src/sysdep.c (_spawnlp, _getpid): Declare with explicit _cdecl instead of _CRTAPI1. * src/editfns.c (Fget_internal_run_time): Check for WINDOWSNT with #ifdef, not #if.
author Juanma Barranquero <lekktu@gmail.com>
date Thu, 26 Jun 2008 22:33:33 +0000
parents 5c8f2b7d28ae
children 01647003e227
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1 /* Font backend for the Microsoft W32 API.
91447
15ea95e2d57b Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents: 91264
diff changeset
2 Copyright (C) 2007, 2008 Free Software Foundation, Inc.
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
3
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
4 This file is part of GNU Emacs.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
5
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94914
diff changeset
6 GNU Emacs is free software: you can redistribute it and/or modify
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94914
diff changeset
8 the Free Software Foundation, either version 3 of the License, or
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94914
diff changeset
9 (at your option) any later version.
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
10
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
14 GNU General Public License for more details.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
15
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94914
diff changeset
17 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
18
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
19 #include <config.h>
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
20 #include <windows.h>
92413
dc438f2fa078 Include math.h.
Juanma Barranquero <lekktu@gmail.com>
parents: 92411
diff changeset
21 #include <math.h>
95846
cb4bf2ae5ac2 Include ctype.h.
Juanma Barranquero <lekktu@gmail.com>
parents: 95828
diff changeset
22 #include <ctype.h>
95894
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
23 #include <commdlg.h>
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
24
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
25 #include "lisp.h"
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
26 #include "w32term.h"
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
27 #include "frame.h"
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
28 #include "dispextern.h"
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
29 #include "character.h"
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
30 #include "charset.h"
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
31 #include "fontset.h"
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
32 #include "font.h"
91208
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
33 #include "w32font.h"
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
34
91124
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
35 /* Cleartype available on Windows XP, cleartype_natural from XP SP1.
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
36 The latter does not try to fit cleartype smoothed fonts into the
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
37 same bounding box as the non-antialiased version of the font.
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
38 */
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
39 #ifndef CLEARTYPE_QUALITY
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
40 #define CLEARTYPE_QUALITY 5
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
41 #endif
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
42 #ifndef CLEARTYPE_NATURAL_QUALITY
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
43 #define CLEARTYPE_NATURAL_QUALITY 6
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
44 #endif
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
45
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
46 extern struct font_driver w32font_driver;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
47
91124
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
48 Lisp_Object Qgdi;
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
49 Lisp_Object Quniscribe;
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
50 static Lisp_Object QCformat;
91260
75f89f349f70 (w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents: 91259
diff changeset
51 static Lisp_Object Qmonospace, Qsansserif, Qmono, Qsans, Qsans_serif;
75f89f349f70 (w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents: 91259
diff changeset
52 static Lisp_Object Qserif, Qscript, Qdecorative;
75f89f349f70 (w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents: 91259
diff changeset
53 static Lisp_Object Qraster, Qoutline, Qunknown;
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
54
91124
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
55 /* antialiasing */
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
56 extern Lisp_Object QCantialias, QCotf, QClang; /* defined in font.c */
91124
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
57 extern Lisp_Object Qnone; /* reuse from w32fns.c */
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
58 static Lisp_Object Qstandard, Qsubpixel, Qnatural;
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
59
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
60 /* languages */
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
61 static Lisp_Object Qja, Qko, Qzh;
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
62
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
63 /* scripts */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
64 static Lisp_Object Qlatin, Qgreek, Qcoptic, Qcyrillic, Qarmenian, Qhebrew;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
65 static Lisp_Object Qarabic, Qsyriac, Qnko, Qthaana, Qdevanagari, Qbengali;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
66 static Lisp_Object Qgurmukhi, Qgujarati, Qoriya, Qtamil, Qtelugu;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
67 static Lisp_Object Qkannada, Qmalayalam, Qsinhala, Qthai, Qlao;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
68 static Lisp_Object Qtibetan, Qmyanmar, Qgeorgian, Qhangul, Qethiopic;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
69 static Lisp_Object Qcherokee, Qcanadian_aboriginal, Qogham, Qrunic;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
70 static Lisp_Object Qkhmer, Qmongolian, Qsymbol, Qbraille, Qhan;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
71 static Lisp_Object Qideographic_description, Qcjk_misc, Qkana, Qbopomofo;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
72 static Lisp_Object Qkanbun, Qyi, Qbyzantine_musical_symbol;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
73 static Lisp_Object Qmusical_symbol, Qmathematical;
93598
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
74 /* Not defined in characters.el, but referenced in fontset.el. */
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
75 static Lisp_Object Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot;
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
76 static Lisp_Object Qdeseret, Qglagolitic, Qgothic, Qhanunoo, Qkharoshthi;
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
77 static Lisp_Object Qlimbu, Qlinear_b, Qold_italic, Qold_persian, Qosmanya;
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
78 static Lisp_Object Qphags_pa, Qphoenician, Qshavian, Qsyloti_nagri;
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
79 static Lisp_Object Qtagalog, Qtagbanwa, Qtai_le, Qtifinagh, Qugaritic;
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
80 /* Only defined here, but useful for distinguishing IPA capable fonts. */
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
81 static Lisp_Object Qphonetic;
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
82
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
83 /* Font spacing symbols - defined in font.c. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
84 extern Lisp_Object Qc, Qp, Qm;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
85
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
86 static void fill_in_logfont P_ ((FRAME_PTR, LOGFONT *, Lisp_Object));
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
87
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
88 static BYTE w32_antialias_type P_ ((Lisp_Object));
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
89 static Lisp_Object lispy_antialias_type P_ ((BYTE));
91124
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
90
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
91 static Lisp_Object font_supported_scripts P_ ((FONTSIGNATURE *));
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
92 static int w32font_full_name P_ ((LOGFONT *, Lisp_Object, int, char *, int));
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
93 static void compute_metrics P_ ((HDC, struct w32font_info *, unsigned int,
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
94 struct w32_metric_cache *));
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
95 static void clear_cached_metrics P_ ((struct w32font_info *));
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
96
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
97 static Lisp_Object w32_registry P_ ((LONG, DWORD));
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
98
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
99 /* EnumFontFamiliesEx callbacks. */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
100 static int CALLBACK add_font_entity_to_list P_ ((ENUMLOGFONTEX *,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
101 NEWTEXTMETRICEX *,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
102 DWORD, LPARAM));
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
103 static int CALLBACK add_one_font_entity_to_list P_ ((ENUMLOGFONTEX *,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
104 NEWTEXTMETRICEX *,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
105 DWORD, LPARAM));
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
106 static int CALLBACK add_font_name_to_list P_ ((ENUMLOGFONTEX *,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
107 NEWTEXTMETRICEX *,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
108 DWORD, LPARAM));
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
109
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
110 /* struct passed in as LPARAM arg to EnumFontFamiliesEx, for keeping track
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
111 of what we really want. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
112 struct font_callback_data
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
113 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
114 /* The logfont we are matching against. EnumFontFamiliesEx only matches
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
115 face name and charset, so we need to manually match everything else
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
116 in the callback function. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
117 LOGFONT pattern;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
118 /* The original font spec or entity. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
119 Lisp_Object orig_font_spec;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
120 /* The frame the font is being loaded on. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
121 Lisp_Object frame;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
122 /* The list to add matches to. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
123 Lisp_Object list;
91208
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
124 /* Whether to match only opentype fonts. */
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
125 int opentype_only;
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
126 };
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
127
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
128 /* Handles the problem that EnumFontFamiliesEx will not return all
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
129 style variations if the font name is not specified. */
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
130 static void list_all_matching_fonts P_ ((struct font_callback_data *));
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
131
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
132 /* From old font code in w32fns.c */
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
133 char * w32_to_x_charset P_ ((int, char *));
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
134
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
135
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
136 static int
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
137 memq_no_quit (elt, list)
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
138 Lisp_Object elt, list;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
139 {
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
140 while (CONSP (list) && ! EQ (XCAR (list), elt))
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
141 list = XCDR (list);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
142 return (CONSP (list));
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
143 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
144
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
145 /* w32 implementation of get_cache for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
146 Return a cache of font-entities on FRAME. The cache must be a
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
147 cons whose cdr part is the actual cache area. */
91208
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
148 Lisp_Object
91246
3a1805edf0b5 (w32font_get_cache): Adjust the argument type.
Kenichi Handa <handa@m17n.org>
parents: 91211
diff changeset
149 w32font_get_cache (f)
3a1805edf0b5 (w32font_get_cache): Adjust the argument type.
Kenichi Handa <handa@m17n.org>
parents: 91211
diff changeset
150 FRAME_PTR f;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
151 {
91246
3a1805edf0b5 (w32font_get_cache): Adjust the argument type.
Kenichi Handa <handa@m17n.org>
parents: 91211
diff changeset
152 struct w32_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
153
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
154 return (dpyinfo->name_list_element);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
155 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
156
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
157 /* w32 implementation of list for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
158 List fonts exactly matching with FONT_SPEC on FRAME. The value
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
159 is a vector of font-entities. This is the sole API that
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
160 allocates font-entities. */
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
161 static Lisp_Object
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
162 w32font_list (frame, font_spec)
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
163 Lisp_Object frame, font_spec;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
164 {
96071
0f831953ffb8 Add font logging to list and match functions.
Jason Rumney <jasonr@gnu.org>
parents: 96005
diff changeset
165 Lisp_Object fonts = w32font_list_internal (frame, font_spec, 0);
0f831953ffb8 Add font logging to list and match functions.
Jason Rumney <jasonr@gnu.org>
parents: 96005
diff changeset
166 font_add_log ("w32font-list", font_spec, fonts);
0f831953ffb8 Add font logging to list and match functions.
Jason Rumney <jasonr@gnu.org>
parents: 96005
diff changeset
167 return fonts;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
168 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
169
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
170 /* w32 implementation of match for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
171 Return a font entity most closely matching with FONT_SPEC on
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
172 FRAME. The closeness is detemined by the font backend, thus
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
173 `face-font-selection-order' is ignored here. */
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
174 static Lisp_Object
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
175 w32font_match (frame, font_spec)
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
176 Lisp_Object frame, font_spec;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
177 {
96071
0f831953ffb8 Add font logging to list and match functions.
Jason Rumney <jasonr@gnu.org>
parents: 96005
diff changeset
178 Lisp_Object entity = w32font_match_internal (frame, font_spec, 0);
0f831953ffb8 Add font logging to list and match functions.
Jason Rumney <jasonr@gnu.org>
parents: 96005
diff changeset
179 font_add_log ("w32font-match", font_spec, entity);
0f831953ffb8 Add font logging to list and match functions.
Jason Rumney <jasonr@gnu.org>
parents: 96005
diff changeset
180 return entity;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
181 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
182
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
183 /* w32 implementation of list_family for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
184 List available families. The value is a list of family names
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
185 (symbols). */
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
186 static Lisp_Object
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
187 w32font_list_family (frame)
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
188 Lisp_Object frame;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
189 {
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
190 Lisp_Object list = Qnil;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
191 LOGFONT font_match_pattern;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
192 HDC dc;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
193 FRAME_PTR f = XFRAME (frame);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
194
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
195 bzero (&font_match_pattern, sizeof (font_match_pattern));
93598
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
196 font_match_pattern.lfCharSet = DEFAULT_CHARSET;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
197
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
198 dc = get_frame_dc (f);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
199
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
200 EnumFontFamiliesEx (dc, &font_match_pattern,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
201 (FONTENUMPROC) add_font_name_to_list,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
202 (LPARAM) &list, 0);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
203 release_frame_dc (f, dc);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
204
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
205 return list;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
206 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
207
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
208 /* w32 implementation of open for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
209 Open a font specified by FONT_ENTITY on frame F.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
210 If the font is scalable, open it with PIXEL_SIZE. */
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
211 static Lisp_Object
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
212 w32font_open (f, font_entity, pixel_size)
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
213 FRAME_PTR f;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
214 Lisp_Object font_entity;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
215 int pixel_size;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
216 {
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
217 Lisp_Object font_object;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
218
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
219 font_object = font_make_object (VECSIZE (struct w32font_info));
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
220
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
221 if (!w32font_open_internal (f, font_entity, pixel_size, font_object))
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
222 {
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
223 return Qnil;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
224 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
225
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
226 return font_object;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
227 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
228
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
229 /* w32 implementation of close for font_backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
230 Close FONT on frame F. */
91208
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
231 void
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
232 w32font_close (f, font)
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
233 FRAME_PTR f;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
234 struct font *font;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
235 {
96343
5c8f2b7d28ae * w32font.h (FONT_HANDLE, FONT_TEXTMETRIC): New macros.
Jason Rumney <jasonr@gnu.org>
parents: 96327
diff changeset
236 int i;
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
237 struct w32font_info *w32_font = (struct w32font_info *) font;
96343
5c8f2b7d28ae * w32font.h (FONT_HANDLE, FONT_TEXTMETRIC): New macros.
Jason Rumney <jasonr@gnu.org>
parents: 96327
diff changeset
238
5c8f2b7d28ae * w32font.h (FONT_HANDLE, FONT_TEXTMETRIC): New macros.
Jason Rumney <jasonr@gnu.org>
parents: 96327
diff changeset
239 /* Delete the GDI font object. */
96327
2fc5aff56d81 * w32bdf.c, w32bdf.h: Remove obsolete files.
Jason Rumney <jasonr@gnu.org>
parents: 96111
diff changeset
240 DeleteObject (w32_font->hfont);
96343
5c8f2b7d28ae * w32font.h (FONT_HANDLE, FONT_TEXTMETRIC): New macros.
Jason Rumney <jasonr@gnu.org>
parents: 96327
diff changeset
241
5c8f2b7d28ae * w32font.h (FONT_HANDLE, FONT_TEXTMETRIC): New macros.
Jason Rumney <jasonr@gnu.org>
parents: 96327
diff changeset
242 /* Free all the cached metrics. */
5c8f2b7d28ae * w32font.h (FONT_HANDLE, FONT_TEXTMETRIC): New macros.
Jason Rumney <jasonr@gnu.org>
parents: 96327
diff changeset
243 if (w32_font->cached_metrics)
5c8f2b7d28ae * w32font.h (FONT_HANDLE, FONT_TEXTMETRIC): New macros.
Jason Rumney <jasonr@gnu.org>
parents: 96327
diff changeset
244 {
5c8f2b7d28ae * w32font.h (FONT_HANDLE, FONT_TEXTMETRIC): New macros.
Jason Rumney <jasonr@gnu.org>
parents: 96327
diff changeset
245 for (i = 0; i < w32_font->n_cache_blocks; i++)
5c8f2b7d28ae * w32font.h (FONT_HANDLE, FONT_TEXTMETRIC): New macros.
Jason Rumney <jasonr@gnu.org>
parents: 96327
diff changeset
246 {
5c8f2b7d28ae * w32font.h (FONT_HANDLE, FONT_TEXTMETRIC): New macros.
Jason Rumney <jasonr@gnu.org>
parents: 96327
diff changeset
247 if (w32_font->cached_metrics[i])
5c8f2b7d28ae * w32font.h (FONT_HANDLE, FONT_TEXTMETRIC): New macros.
Jason Rumney <jasonr@gnu.org>
parents: 96327
diff changeset
248 xfree (w32_font->cached_metrics[i]);
5c8f2b7d28ae * w32font.h (FONT_HANDLE, FONT_TEXTMETRIC): New macros.
Jason Rumney <jasonr@gnu.org>
parents: 96327
diff changeset
249 }
5c8f2b7d28ae * w32font.h (FONT_HANDLE, FONT_TEXTMETRIC): New macros.
Jason Rumney <jasonr@gnu.org>
parents: 96327
diff changeset
250 xfree (w32_font->cached_metrics);
5c8f2b7d28ae * w32font.h (FONT_HANDLE, FONT_TEXTMETRIC): New macros.
Jason Rumney <jasonr@gnu.org>
parents: 96327
diff changeset
251 w32_font->cached_metrics = NULL;
5c8f2b7d28ae * w32font.h (FONT_HANDLE, FONT_TEXTMETRIC): New macros.
Jason Rumney <jasonr@gnu.org>
parents: 96327
diff changeset
252 }
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
253 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
254
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
255 /* w32 implementation of has_char for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
256 Optional.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
257 If FONT_ENTITY has a glyph for character C (Unicode code point),
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
258 return 1. If not, return 0. If a font must be opened to check
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
259 it, return -1. */
91208
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
260 int
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
261 w32font_has_char (entity, c)
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
262 Lisp_Object entity;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
263 int c;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
264 {
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
265 Lisp_Object supported_scripts, extra, script;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
266 DWORD mask;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
267
90887
aa7f1d212e78 (font_put_extra): Expose externally.
Jason Rumney <jasonr@gnu.org>
parents: 90879
diff changeset
268 extra = AREF (entity, FONT_EXTRA_INDEX);
aa7f1d212e78 (font_put_extra): Expose externally.
Jason Rumney <jasonr@gnu.org>
parents: 90879
diff changeset
269 if (!CONSP (extra))
aa7f1d212e78 (font_put_extra): Expose externally.
Jason Rumney <jasonr@gnu.org>
parents: 90879
diff changeset
270 return -1;
aa7f1d212e78 (font_put_extra): Expose externally.
Jason Rumney <jasonr@gnu.org>
parents: 90879
diff changeset
271
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
272 supported_scripts = assq_no_quit (QCscript, extra);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
273 if (!CONSP (supported_scripts))
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
274 return -1;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
275
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
276 supported_scripts = XCDR (supported_scripts);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
277
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
278 script = CHAR_TABLE_REF (Vchar_script_table, c);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
279
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
280 return (memq_no_quit (script, supported_scripts)) ? -1 : 0;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
281 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
282
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
283 /* w32 implementation of encode_char for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
284 Return a glyph code of FONT for characer C (Unicode code point).
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
285 If FONT doesn't have such a glyph, return FONT_INVALID_CODE. */
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
286 static unsigned
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
287 w32font_encode_char (font, c)
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
288 struct font *font;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
289 int c;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
290 {
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
291 struct frame *f;
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
292 HDC dc;
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
293 HFONT old_font;
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
294 DWORD retval;
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
295 GCP_RESULTSW result;
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
296 wchar_t in[2];
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
297 wchar_t out[2];
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
298 int len;
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
299 struct w32font_info *w32_font = (struct w32font_info *) font;
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
300
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
301 /* If glyph indexing is not working for this font, just return the
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
302 unicode code-point. */
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
303 if (!w32_font->glyph_idx)
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
304 return c;
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
305
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
306 if (c > 0xFFFF)
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
307 {
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
308 /* TODO: Encode as surrogate pair and lookup the glyph. */
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
309 return FONT_INVALID_CODE;
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
310 }
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
311 else
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
312 {
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
313 in[0] = (wchar_t) c;
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
314 len = 1;
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
315 }
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
316
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
317 bzero (&result, sizeof (result));
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
318 result.lStructSize = sizeof (result);
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
319 result.lpGlyphs = out;
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
320 result.nGlyphs = 2;
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
321
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
322 f = XFRAME (selected_frame);
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
323
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
324 dc = get_frame_dc (f);
96327
2fc5aff56d81 * w32bdf.c, w32bdf.h: Remove obsolete files.
Jason Rumney <jasonr@gnu.org>
parents: 96111
diff changeset
325 old_font = SelectObject (dc, w32_font->hfont);
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
326
95828
b5bea3387b5e (w32font_encode_char): Detect missing glyphs that are misreported as space.
Jason Rumney <jasonr@gnu.org>
parents: 95744
diff changeset
327 /* GetCharacterPlacement is used here rather than GetGlyphIndices because
b5bea3387b5e (w32font_encode_char): Detect missing glyphs that are misreported as space.
Jason Rumney <jasonr@gnu.org>
parents: 95744
diff changeset
328 it is supported on Windows NT 4 and 9x/ME. But it cannot reliably report
b5bea3387b5e (w32font_encode_char): Detect missing glyphs that are misreported as space.
Jason Rumney <jasonr@gnu.org>
parents: 95744
diff changeset
329 missing glyphs, see below for workaround. */
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
330 retval = GetCharacterPlacementW (dc, in, len, 0, &result, 0);
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
331
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
332 SelectObject (dc, old_font);
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
333 release_frame_dc (f, dc);
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
334
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
335 if (retval)
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
336 {
95828
b5bea3387b5e (w32font_encode_char): Detect missing glyphs that are misreported as space.
Jason Rumney <jasonr@gnu.org>
parents: 95744
diff changeset
337 if (result.nGlyphs != 1 || !result.lpGlyphs[0]
b5bea3387b5e (w32font_encode_char): Detect missing glyphs that are misreported as space.
Jason Rumney <jasonr@gnu.org>
parents: 95744
diff changeset
338 /* GetCharacterPlacementW seems to return 3, which seems to be
b5bea3387b5e (w32font_encode_char): Detect missing glyphs that are misreported as space.
Jason Rumney <jasonr@gnu.org>
parents: 95744
diff changeset
339 the space glyph in most/all truetype fonts, instead of 0
b5bea3387b5e (w32font_encode_char): Detect missing glyphs that are misreported as space.
Jason Rumney <jasonr@gnu.org>
parents: 95744
diff changeset
340 for unsupported glyphs. */
b5bea3387b5e (w32font_encode_char): Detect missing glyphs that are misreported as space.
Jason Rumney <jasonr@gnu.org>
parents: 95744
diff changeset
341 || (result.lpGlyphs[0] == 3 && !iswspace (in[0])))
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
342 return FONT_INVALID_CODE;
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
343 return result.lpGlyphs[0];
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
344 }
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
345 else
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
346 {
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
347 int i;
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
348 /* Mark this font as not supporting glyph indices. This can happen
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
349 on Windows9x, and maybe with non-Truetype fonts on NT etc. */
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
350 w32_font->glyph_idx = 0;
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
351 /* Clear metrics cache. */
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
352 clear_cached_metrics (w32_font);
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
353
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
354 return c;
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
355 }
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
356 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
357
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
358 /* w32 implementation of text_extents for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
359 Perform the size computation of glyphs of FONT and fillin members
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
360 of METRICS. The glyphs are specified by their glyph codes in
91034
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
361 CODE (length NGLYPHS). Apparently metrics can be NULL, in this
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
362 case just return the overall width. */
91208
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
363 int
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
364 w32font_text_extents (font, code, nglyphs, metrics)
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
365 struct font *font;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
366 unsigned *code;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
367 int nglyphs;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
368 struct font_metrics *metrics;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
369 {
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
370 int i;
92151
664a09af03dc (w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents: 91593
diff changeset
371 HFONT old_font = NULL;
664a09af03dc (w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents: 91593
diff changeset
372 HDC dc = NULL;
91208
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
373 struct frame * f;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
374 int total_width = 0;
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
375 WORD *wcode = NULL;
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
376 SIZE size;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
377
96327
2fc5aff56d81 * w32bdf.c, w32bdf.h: Remove obsolete files.
Jason Rumney <jasonr@gnu.org>
parents: 96111
diff changeset
378 struct w32font_info *w32_font = (struct w32font_info *) font;
2fc5aff56d81 * w32bdf.c, w32bdf.h: Remove obsolete files.
Jason Rumney <jasonr@gnu.org>
parents: 96111
diff changeset
379
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
380 if (metrics)
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
381 {
95307
7d02dd821410 (w32font_text_extents): Zero whole metrics struct first.
Jason Rumney <jasonr@gnu.org>
parents: 95190
diff changeset
382 bzero (metrics, sizeof (struct font_metrics));
93675
7fb9a5b86fa8 (w32font_text_extents): Use font's ascent and descent.
Jason Rumney <jasonr@gnu.org>
parents: 93598
diff changeset
383 metrics->ascent = font->ascent;
7fb9a5b86fa8 (w32font_text_extents): Use font's ascent and descent.
Jason Rumney <jasonr@gnu.org>
parents: 93598
diff changeset
384 metrics->descent = font->descent;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
385
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
386 for (i = 0; i < nglyphs; i++)
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
387 {
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
388 struct w32_metric_cache *char_metric;
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
389 int block = *(code + i) / CACHE_BLOCKSIZE;
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
390 int pos_in_block = *(code + i) % CACHE_BLOCKSIZE;
91593
3081b8f848bc * w32font.c (w32font_text_extents): Fill in lbearing metric.
Jason Rumney <jasonr@gnu.org>
parents: 91545
diff changeset
391
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
392 if (block >= w32_font->n_cache_blocks)
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
393 {
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
394 if (!w32_font->cached_metrics)
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
395 w32_font->cached_metrics
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
396 = xmalloc ((block + 1)
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
397 * sizeof (struct w32_cached_metric *));
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
398 else
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
399 w32_font->cached_metrics
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
400 = xrealloc (w32_font->cached_metrics,
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
401 (block + 1)
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
402 * sizeof (struct w32_cached_metric *));
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
403 bzero (w32_font->cached_metrics + w32_font->n_cache_blocks,
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
404 ((block + 1 - w32_font->n_cache_blocks)
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
405 * sizeof (struct w32_cached_metric *)));
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
406 w32_font->n_cache_blocks = block + 1;
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
407 }
91593
3081b8f848bc * w32font.c (w32font_text_extents): Fill in lbearing metric.
Jason Rumney <jasonr@gnu.org>
parents: 91545
diff changeset
408
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
409 if (!w32_font->cached_metrics[block])
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
410 {
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
411 w32_font->cached_metrics[block]
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
412 = xmalloc (CACHE_BLOCKSIZE * sizeof (struct font_metrics));
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
413 bzero (w32_font->cached_metrics[block],
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
414 CACHE_BLOCKSIZE * sizeof (struct font_metrics));
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
415 }
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
416
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
417 char_metric = w32_font->cached_metrics[block] + pos_in_block;
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
418
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
419 if (char_metric->status == W32METRIC_NO_ATTEMPT)
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
420 {
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
421 if (dc == NULL)
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
422 {
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
423 /* TODO: Frames can come and go, and their fonts
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
424 outlive them. So we can't cache the frame in the
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
425 font structure. Use selected_frame until the API
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
426 is updated to pass in a frame. */
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
427 f = XFRAME (selected_frame);
95341
5602389abb69 (compute_metrics): Rewrite an "else { if () ... else ... }"
Juanma Barranquero <lekktu@gmail.com>
parents: 95339
diff changeset
428
92151
664a09af03dc (w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents: 91593
diff changeset
429 dc = get_frame_dc (f);
96327
2fc5aff56d81 * w32bdf.c, w32bdf.h: Remove obsolete files.
Jason Rumney <jasonr@gnu.org>
parents: 96111
diff changeset
430 old_font = SelectObject (dc, w32_font->hfont);
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
431 }
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
432 compute_metrics (dc, w32_font, *(code + i), char_metric);
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
433 }
91034
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
434
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
435 if (char_metric->status == W32METRIC_SUCCESS)
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
436 {
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
437 metrics->lbearing = min (metrics->lbearing,
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
438 metrics->width + char_metric->lbearing);
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
439 metrics->rbearing = max (metrics->rbearing,
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
440 metrics->width + char_metric->rbearing);
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
441 metrics->width += char_metric->width;
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
442 }
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
443 else
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
444 /* If we couldn't get metrics for a char,
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
445 use alternative method. */
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
446 break;
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
447 }
91034
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
448 /* If we got through everything, return. */
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
449 if (i == nglyphs)
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
450 {
92151
664a09af03dc (w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents: 91593
diff changeset
451 if (dc != NULL)
664a09af03dc (w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents: 91593
diff changeset
452 {
664a09af03dc (w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents: 91593
diff changeset
453 /* Restore state and release DC. */
664a09af03dc (w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents: 91593
diff changeset
454 SelectObject (dc, old_font);
664a09af03dc (w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents: 91593
diff changeset
455 release_frame_dc (f, dc);
664a09af03dc (w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents: 91593
diff changeset
456 }
91034
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
457
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
458 return metrics->width;
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
459 }
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
460 }
91034
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
461
93598
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
462 /* For non-truetype fonts, GetGlyphOutlineW is not supported, so
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
463 fallback on other methods that will at least give some of the metric
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
464 information. */
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
465 if (!wcode) {
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
466 wcode = alloca (nglyphs * sizeof (WORD));
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
467 for (i = 0; i < nglyphs; i++)
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
468 {
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
469 if (code[i] < 0x10000)
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
470 wcode[i] = code[i];
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
471 else
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
472 {
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
473 /* TODO: Convert to surrogate, reallocating array if needed */
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
474 wcode[i] = 0xffff;
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
475 }
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
476 }
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
477 }
92151
664a09af03dc (w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents: 91593
diff changeset
478 if (dc == NULL)
664a09af03dc (w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents: 91593
diff changeset
479 {
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
480 /* TODO: Frames can come and go, and their fonts outlive
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
481 them. So we can't cache the frame in the font structure. Use
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
482 selected_frame until the API is updated to pass in a
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
483 frame. */
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
484 f = XFRAME (selected_frame);
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
485
92151
664a09af03dc (w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents: 91593
diff changeset
486 dc = get_frame_dc (f);
96327
2fc5aff56d81 * w32bdf.c, w32bdf.h: Remove obsolete files.
Jason Rumney <jasonr@gnu.org>
parents: 96111
diff changeset
487 old_font = SelectObject (dc, w32_font->hfont);
92151
664a09af03dc (w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents: 91593
diff changeset
488 }
664a09af03dc (w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents: 91593
diff changeset
489
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
490 if (GetTextExtentPoint32W (dc, wcode, nglyphs, &size))
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
491 {
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
492 total_width = size.cx;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
493 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
494
93598
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
495 /* On 95/98/ME, only some unicode functions are available, so fallback
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
496 on doing a dummy draw to find the total width. */
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
497 if (!total_width)
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
498 {
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
499 RECT rect;
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
500 rect.top = 0; rect.bottom = font->height; rect.left = 0; rect.right = 1;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
501 DrawTextW (dc, wcode, nglyphs, &rect,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
502 DT_CALCRECT | DT_NOPREFIX | DT_SINGLELINE);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
503 total_width = rect.right;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
504 }
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
505
93598
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
506 /* Give our best estimate of the metrics, based on what we know. */
91034
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
507 if (metrics)
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
508 {
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
509 metrics->width = total_width;
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
510 metrics->lbearing = 0;
96343
5c8f2b7d28ae * w32font.h (FONT_HANDLE, FONT_TEXTMETRIC): New macros.
Jason Rumney <jasonr@gnu.org>
parents: 96327
diff changeset
511 metrics->rbearing = total_width + w32_font->metrics.tmOverhang;
91034
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
512 }
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
513
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
514 /* Restore state and release DC. */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
515 SelectObject (dc, old_font);
91208
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
516 release_frame_dc (f, dc);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
517
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
518 return total_width;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
519 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
520
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
521 /* w32 implementation of draw for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
522 Optional.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
523 Draw glyphs between FROM and TO of S->char2b at (X Y) pixel
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
524 position of frame F with S->FACE and S->GC. If WITH_BACKGROUND
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
525 is nonzero, fill the background in advance. It is assured that
91182
bbdb7226d848 (add_font_entity_to_list): Compare only the beginning of full name.
Jason Rumney <jasonr@gnu.org>
parents: 91158
diff changeset
526 WITH_BACKGROUND is zero when (FROM > 0 || TO < S->nchars).
bbdb7226d848 (add_font_entity_to_list): Compare only the beginning of full name.
Jason Rumney <jasonr@gnu.org>
parents: 91158
diff changeset
527
bbdb7226d848 (add_font_entity_to_list): Compare only the beginning of full name.
Jason Rumney <jasonr@gnu.org>
parents: 91158
diff changeset
528 TODO: Currently this assumes that the colors and fonts are already
bbdb7226d848 (add_font_entity_to_list): Compare only the beginning of full name.
Jason Rumney <jasonr@gnu.org>
parents: 91158
diff changeset
529 set in the DC. This seems to be true now, but maybe only due to
bbdb7226d848 (add_font_entity_to_list): Compare only the beginning of full name.
Jason Rumney <jasonr@gnu.org>
parents: 91158
diff changeset
530 the old font code setting it up. It may be safer to resolve faces
bbdb7226d848 (add_font_entity_to_list): Compare only the beginning of full name.
Jason Rumney <jasonr@gnu.org>
parents: 91158
diff changeset
531 and fonts in here and set them explicitly
bbdb7226d848 (add_font_entity_to_list): Compare only the beginning of full name.
Jason Rumney <jasonr@gnu.org>
parents: 91158
diff changeset
532 */
bbdb7226d848 (add_font_entity_to_list): Compare only the beginning of full name.
Jason Rumney <jasonr@gnu.org>
parents: 91158
diff changeset
533
91208
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
534 int
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
535 w32font_draw (s, from, to, x, y, with_background)
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
536 struct glyph_string *s;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
537 int from, to, x, y, with_background;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
538 {
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
539 UINT options;
91030
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
540 HRGN orig_clip;
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
541 struct w32font_info *w32font = (struct w32font_info *) s->font;
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
542
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
543 options = w32font->glyph_idx;
91030
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
544
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
545 /* Save clip region for later restoration. */
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
546 GetClipRgn(s->hdc, orig_clip);
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
547
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
548 if (s->num_clips > 0)
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
549 {
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
550 HRGN new_clip = CreateRectRgnIndirect (s->clip);
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
551
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
552 if (s->num_clips > 1)
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
553 {
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
554 HRGN clip2 = CreateRectRgnIndirect (s->clip + 1);
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
555
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
556 CombineRgn (new_clip, new_clip, clip2, RGN_OR);
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
557 DeleteObject (clip2);
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
558 }
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
559
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
560 SelectClipRgn (s->hdc, new_clip);
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
561 DeleteObject (new_clip);
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
562 }
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
563
91128
8eb56b57e4a0 (w32font_draw): Fill background manually.
Jason Rumney <jasonr@gnu.org>
parents: 91124
diff changeset
564 /* Using OPAQUE background mode can clear more background than expected
8eb56b57e4a0 (w32font_draw): Fill background manually.
Jason Rumney <jasonr@gnu.org>
parents: 91124
diff changeset
565 when Cleartype is used. Draw the background manually to avoid this. */
8eb56b57e4a0 (w32font_draw): Fill background manually.
Jason Rumney <jasonr@gnu.org>
parents: 91124
diff changeset
566 SetBkMode (s->hdc, TRANSPARENT);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
567 if (with_background)
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
568 {
90908
523a5c7f67ea (w32font_open): Don't set font_idx.
Jason Rumney <jasonr@gnu.org>
parents: 90906
diff changeset
569 HBRUSH brush;
523a5c7f67ea (w32font_open): Don't set font_idx.
Jason Rumney <jasonr@gnu.org>
parents: 90906
diff changeset
570 RECT rect;
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
571 struct font *font = s->font;
90908
523a5c7f67ea (w32font_open): Don't set font_idx.
Jason Rumney <jasonr@gnu.org>
parents: 90906
diff changeset
572
523a5c7f67ea (w32font_open): Don't set font_idx.
Jason Rumney <jasonr@gnu.org>
parents: 90906
diff changeset
573 brush = CreateSolidBrush (s->gc->background);
523a5c7f67ea (w32font_open): Don't set font_idx.
Jason Rumney <jasonr@gnu.org>
parents: 90906
diff changeset
574 rect.left = x;
91128
8eb56b57e4a0 (w32font_draw): Fill background manually.
Jason Rumney <jasonr@gnu.org>
parents: 91124
diff changeset
575 rect.top = y - font->ascent;
90908
523a5c7f67ea (w32font_open): Don't set font_idx.
Jason Rumney <jasonr@gnu.org>
parents: 90906
diff changeset
576 rect.right = x + s->width;
91128
8eb56b57e4a0 (w32font_draw): Fill background manually.
Jason Rumney <jasonr@gnu.org>
parents: 91124
diff changeset
577 rect.bottom = y + font->descent;
90908
523a5c7f67ea (w32font_open): Don't set font_idx.
Jason Rumney <jasonr@gnu.org>
parents: 90906
diff changeset
578 FillRect (s->hdc, &rect, brush);
90915
9aac5aff0dda (w32font_draw): Delete brush after using it.
Jason Rumney <jasonr@gnu.org>
parents: 90908
diff changeset
579 DeleteObject (brush);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
580 }
90879
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
581
92187
b7277e09e943 (w32font_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 92151
diff changeset
582 if (s->padding_p)
b7277e09e943 (w32font_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 92151
diff changeset
583 {
b7277e09e943 (w32font_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 92151
diff changeset
584 int len = to - from, i;
b7277e09e943 (w32font_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 92151
diff changeset
585
b7277e09e943 (w32font_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 92151
diff changeset
586 for (i = 0; i < len; i++)
b7277e09e943 (w32font_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 92151
diff changeset
587 ExtTextOutW (s->hdc, x + i, y, options, NULL,
92199
8324a41d50a9 (w32font_draw): Draw one character at a time when padding.
Jason Rumney <jasonr@gnu.org>
parents: 92187
diff changeset
588 s->char2b + from + i, 1, NULL);
92187
b7277e09e943 (w32font_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 92151
diff changeset
589 }
b7277e09e943 (w32font_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 92151
diff changeset
590 else
b7277e09e943 (w32font_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 92151
diff changeset
591 ExtTextOutW (s->hdc, x, y, options, NULL, s->char2b + from, to - from, NULL);
91030
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
592
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
593 /* Restore clip region. */
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
594 if (s->num_clips > 0)
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
595 {
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
596 SelectClipRgn (s->hdc, orig_clip);
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
597 }
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
598 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
599
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
600 /* w32 implementation of free_entity for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
601 Optional (if FONT_EXTRA_INDEX is not Lisp_Save_Value).
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
602 Free FONT_EXTRA_INDEX field of FONT_ENTITY.
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
603 static void
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
604 w32font_free_entity (Lisp_Object entity);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
605 */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
606
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
607 /* w32 implementation of prepare_face for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
608 Optional (if FACE->extra is not used).
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
609 Prepare FACE for displaying characters by FONT on frame F by
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
610 storing some data in FACE->extra. If successful, return 0.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
611 Otherwise, return -1.
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
612 static int
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
613 w32font_prepare_face (FRAME_PTR f, struct face *face);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
614 */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
615 /* w32 implementation of done_face for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
616 Optional.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
617 Done FACE for displaying characters by FACE->font on frame F.
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
618 static void
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
619 w32font_done_face (FRAME_PTR f, struct face *face); */
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
620
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
621 /* w32 implementation of get_bitmap for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
622 Optional.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
623 Store bitmap data for glyph-code CODE of FONT in BITMAP. It is
90915
9aac5aff0dda (w32font_draw): Delete brush after using it.
Jason Rumney <jasonr@gnu.org>
parents: 90908
diff changeset
624 intended that this method is called from the other font-driver
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
625 for actual drawing.
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
626 static int
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
627 w32font_get_bitmap (struct font *font, unsigned code,
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
628 struct font_bitmap *bitmap, int bits_per_pixel);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
629 */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
630 /* w32 implementation of free_bitmap for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
631 Optional.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
632 Free bitmap data in BITMAP.
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
633 static void
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
634 w32font_free_bitmap (struct font *font, struct font_bitmap *bitmap);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
635 */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
636 /* w32 implementation of get_outline for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
637 Optional.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
638 Return an outline data for glyph-code CODE of FONT. The format
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
639 of the outline data depends on the font-driver.
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
640 static void *
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
641 w32font_get_outline (struct font *font, unsigned code);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
642 */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
643 /* w32 implementation of free_outline for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
644 Optional.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
645 Free OUTLINE (that is obtained by the above method).
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
646 static void
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
647 w32font_free_outline (struct font *font, void *outline);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
648 */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
649 /* w32 implementation of anchor_point for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
650 Optional.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
651 Get coordinates of the INDEXth anchor point of the glyph whose
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
652 code is CODE. Store the coordinates in *X and *Y. Return 0 if
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
653 the operations was successfull. Otherwise return -1.
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
654 static int
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
655 w32font_anchor_point (struct font *font, unsigned code,
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
656 int index, int *x, int *y);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
657 */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
658 /* w32 implementation of otf_capability for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
659 Optional.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
660 Return a list describing which scripts/languages FONT
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
661 supports by which GSUB/GPOS features of OpenType tables.
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
662 static Lisp_Object
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
663 w32font_otf_capability (struct font *font);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
664 */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
665 /* w32 implementation of otf_drive for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
666 Optional.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
667 Apply FONT's OTF-FEATURES to the glyph string.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
668
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
669 FEATURES specifies which OTF features to apply in this format:
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
670 (SCRIPT LANGSYS GSUB-FEATURE GPOS-FEATURE)
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
671 See the documentation of `font-drive-otf' for the detail.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
672
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
673 This method applies the specified features to the codes in the
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
674 elements of GSTRING-IN (between FROMth and TOth). The output
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
675 codes are stored in GSTRING-OUT at the IDXth element and the
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
676 following elements.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
677
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
678 Return the number of output codes. If none of the features are
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
679 applicable to the input data, return 0. If GSTRING-OUT is too
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
680 short, return -1.
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
681 static int
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
682 w32font_otf_drive (struct font *font, Lisp_Object features,
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
683 Lisp_Object gstring_in, int from, int to,
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
684 Lisp_Object gstring_out, int idx,
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
685 int alternate_subst);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
686 */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
687
91208
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
688 /* Internal implementation of w32font_list.
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
689 Additional parameter opentype_only restricts the returned fonts to
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
690 opentype fonts, which can be used with the Uniscribe backend. */
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
691 Lisp_Object
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
692 w32font_list_internal (frame, font_spec, opentype_only)
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
693 Lisp_Object frame, font_spec;
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
694 int opentype_only;
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
695 {
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
696 struct font_callback_data match_data;
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
697 HDC dc;
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
698 FRAME_PTR f = XFRAME (frame);
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
699
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
700 match_data.orig_font_spec = font_spec;
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
701 match_data.list = Qnil;
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
702 match_data.frame = frame;
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
703
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
704 bzero (&match_data.pattern, sizeof (LOGFONT));
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
705 fill_in_logfont (f, &match_data.pattern, font_spec);
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
706
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
707 match_data.opentype_only = opentype_only;
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
708 if (opentype_only)
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
709 match_data.pattern.lfOutPrecision = OUT_OUTLINE_PRECIS;
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
710
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
711 if (match_data.pattern.lfFaceName[0] == '\0')
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
712 {
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
713 /* EnumFontFamiliesEx does not take other fields into account if
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
714 font name is blank, so need to use two passes. */
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
715 list_all_matching_fonts (&match_data);
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
716 }
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
717 else
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
718 {
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
719 dc = get_frame_dc (f);
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
720
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
721 EnumFontFamiliesEx (dc, &match_data.pattern,
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
722 (FONTENUMPROC) add_font_entity_to_list,
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
723 (LPARAM) &match_data, 0);
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
724 release_frame_dc (f, dc);
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
725 }
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
726
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
727 return NILP (match_data.list) ? Qnil : match_data.list;
91208
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
728 }
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
729
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
730 /* Internal implementation of w32font_match.
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
731 Additional parameter opentype_only restricts the returned fonts to
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
732 opentype fonts, which can be used with the Uniscribe backend. */
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
733 Lisp_Object
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
734 w32font_match_internal (frame, font_spec, opentype_only)
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
735 Lisp_Object frame, font_spec;
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
736 int opentype_only;
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
737 {
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
738 struct font_callback_data match_data;
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
739 HDC dc;
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
740 FRAME_PTR f = XFRAME (frame);
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
741
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
742 match_data.orig_font_spec = font_spec;
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
743 match_data.frame = frame;
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
744 match_data.list = Qnil;
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
745
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
746 bzero (&match_data.pattern, sizeof (LOGFONT));
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
747 fill_in_logfont (f, &match_data.pattern, font_spec);
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
748
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
749 match_data.opentype_only = opentype_only;
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
750 if (opentype_only)
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
751 match_data.pattern.lfOutPrecision = OUT_OUTLINE_PRECIS;
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
752
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
753 dc = get_frame_dc (f);
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
754
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
755 EnumFontFamiliesEx (dc, &match_data.pattern,
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
756 (FONTENUMPROC) add_one_font_entity_to_list,
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
757 (LPARAM) &match_data, 0);
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
758 release_frame_dc (f, dc);
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
759
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
760 return NILP (match_data.list) ? Qnil : XCAR (match_data.list);
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
761 }
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
762
91211
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
763 int
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
764 w32font_open_internal (f, font_entity, pixel_size, font_object)
91211
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
765 FRAME_PTR f;
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
766 Lisp_Object font_entity;
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
767 int pixel_size;
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
768 Lisp_Object font_object;
91211
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
769 {
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
770 int len, size, i;
91211
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
771 LOGFONT logfont;
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
772 HDC dc;
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
773 HFONT hfont, old_font;
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
774 Lisp_Object val, extra;
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
775 struct w32font_info *w32_font;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
776 struct font * font;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
777 OUTLINETEXTMETRIC* metrics = NULL;
91211
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
778
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
779 w32_font = (struct w32font_info *) XFONT_OBJECT (font_object);
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
780 font = (struct font *) w32_font;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
781
91211
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
782 if (!font)
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
783 return 0;
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
784
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
785 /* Copy from font entity. */
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
786 for (i = 0; i < FONT_ENTITY_MAX; i++)
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
787 ASET (font_object, i, AREF (font_entity, i));
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
788 ASET (font_object, FONT_SIZE_INDEX, make_number (pixel_size));
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
789
91211
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
790 bzero (&logfont, sizeof (logfont));
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
791 fill_in_logfont (f, &logfont, font_entity);
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
792
95384
c510339c1817 (w32font_open_internal): Prefer truetype fonts unless
Jason Rumney <jasonr@gnu.org>
parents: 95341
diff changeset
793 /* Prefer truetype fonts, to avoid known problems with type1 fonts, and
c510339c1817 (w32font_open_internal): Prefer truetype fonts unless
Jason Rumney <jasonr@gnu.org>
parents: 95341
diff changeset
794 limitations in bitmap fonts. */
c510339c1817 (w32font_open_internal): Prefer truetype fonts unless
Jason Rumney <jasonr@gnu.org>
parents: 95341
diff changeset
795 val = AREF (font_entity, FONT_FOUNDRY_INDEX);
c510339c1817 (w32font_open_internal): Prefer truetype fonts unless
Jason Rumney <jasonr@gnu.org>
parents: 95341
diff changeset
796 if (!EQ (val, Qraster))
c510339c1817 (w32font_open_internal): Prefer truetype fonts unless
Jason Rumney <jasonr@gnu.org>
parents: 95341
diff changeset
797 logfont.lfOutPrecision = OUT_TT_PRECIS;
c510339c1817 (w32font_open_internal): Prefer truetype fonts unless
Jason Rumney <jasonr@gnu.org>
parents: 95341
diff changeset
798
91211
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
799 size = XINT (AREF (font_entity, FONT_SIZE_INDEX));
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
800 if (!size)
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
801 size = pixel_size;
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
802
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
803 logfont.lfHeight = -size;
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
804 hfont = CreateFontIndirect (&logfont);
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
805
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
806 if (hfont == NULL)
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
807 return 0;
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
808
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
809 /* Get the metrics for this font. */
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
810 dc = get_frame_dc (f);
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
811 old_font = SelectObject (dc, hfont);
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
812
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
813 /* Try getting the outline metrics (only works for truetype fonts). */
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
814 len = GetOutlineTextMetrics (dc, 0, NULL);
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
815 if (len)
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
816 {
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
817 metrics = (OUTLINETEXTMETRIC *) alloca (len);
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
818 if (GetOutlineTextMetrics (dc, len, metrics))
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
819 bcopy (&metrics->otmTextMetrics, &w32_font->metrics,
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
820 sizeof (TEXTMETRIC));
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
821 else
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
822 metrics = NULL;
95339
48f990d65758 (w32font_open_internal): Determine if glyph indices are likely to work here.
Jason Rumney <jasonr@gnu.org>
parents: 95315
diff changeset
823
48f990d65758 (w32font_open_internal): Determine if glyph indices are likely to work here.
Jason Rumney <jasonr@gnu.org>
parents: 95315
diff changeset
824 /* If it supports outline metrics, it should support Glyph Indices. */
48f990d65758 (w32font_open_internal): Determine if glyph indices are likely to work here.
Jason Rumney <jasonr@gnu.org>
parents: 95315
diff changeset
825 w32_font->glyph_idx = ETO_GLYPH_INDEX;
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
826 }
95339
48f990d65758 (w32font_open_internal): Determine if glyph indices are likely to work here.
Jason Rumney <jasonr@gnu.org>
parents: 95315
diff changeset
827
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
828 if (!metrics)
95339
48f990d65758 (w32font_open_internal): Determine if glyph indices are likely to work here.
Jason Rumney <jasonr@gnu.org>
parents: 95315
diff changeset
829 {
48f990d65758 (w32font_open_internal): Determine if glyph indices are likely to work here.
Jason Rumney <jasonr@gnu.org>
parents: 95315
diff changeset
830 GetTextMetrics (dc, &w32_font->metrics);
48f990d65758 (w32font_open_internal): Determine if glyph indices are likely to work here.
Jason Rumney <jasonr@gnu.org>
parents: 95315
diff changeset
831 w32_font->glyph_idx = 0;
48f990d65758 (w32font_open_internal): Determine if glyph indices are likely to work here.
Jason Rumney <jasonr@gnu.org>
parents: 95315
diff changeset
832 }
92712
fb1da73bc0c4 (w32font_full_name): Use floor to round.
Jason Rumney <jasonr@gnu.org>
parents: 92539
diff changeset
833
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
834 w32_font->cached_metrics = NULL;
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
835 w32_font->n_cache_blocks = 0;
92411
133560a77a09 (recompute_cached_metrics): Change font arg to w32font_info.
Jason Rumney <jasonr@gnu.org>
parents: 92409
diff changeset
836
91211
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
837 SelectObject (dc, old_font);
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
838 release_frame_dc (f, dc);
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
839
96327
2fc5aff56d81 * w32bdf.c, w32bdf.h: Remove obsolete files.
Jason Rumney <jasonr@gnu.org>
parents: 96111
diff changeset
840 w32_font->hfont = hfont;
91211
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
841
91496
d3d1ab7e6e35 (w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents: 91447
diff changeset
842 {
d3d1ab7e6e35 (w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents: 91447
diff changeset
843 char *name;
d3d1ab7e6e35 (w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents: 91447
diff changeset
844
d3d1ab7e6e35 (w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents: 91447
diff changeset
845 /* We don't know how much space we need for the full name, so start with
d3d1ab7e6e35 (w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents: 91447
diff changeset
846 96 bytes and go up in steps of 32. */
d3d1ab7e6e35 (w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents: 91447
diff changeset
847 len = 96;
96343
5c8f2b7d28ae * w32font.h (FONT_HANDLE, FONT_TEXTMETRIC): New macros.
Jason Rumney <jasonr@gnu.org>
parents: 96327
diff changeset
848 name = alloca (len);
92390
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
849 while (name && w32font_full_name (&logfont, font_entity, pixel_size,
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
850 name, len) < 0)
91496
d3d1ab7e6e35 (w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents: 91447
diff changeset
851 {
96343
5c8f2b7d28ae * w32font.h (FONT_HANDLE, FONT_TEXTMETRIC): New macros.
Jason Rumney <jasonr@gnu.org>
parents: 96327
diff changeset
852 len += 32;
5c8f2b7d28ae * w32font.h (FONT_HANDLE, FONT_TEXTMETRIC): New macros.
Jason Rumney <jasonr@gnu.org>
parents: 96327
diff changeset
853 name = alloca (len);
91496
d3d1ab7e6e35 (w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents: 91447
diff changeset
854 }
d3d1ab7e6e35 (w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents: 91447
diff changeset
855 if (name)
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
856 font->props[FONT_FULLNAME_INDEX]
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
857 = make_unibyte_string (name, strlen (name));
91496
d3d1ab7e6e35 (w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents: 91447
diff changeset
858 else
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
859 font->props[FONT_FULLNAME_INDEX] =
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
860 make_unibyte_string (logfont.lfFaceName, len);
91496
d3d1ab7e6e35 (w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents: 91447
diff changeset
861 }
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
862
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
863 font->max_width = w32_font->metrics.tmMaxCharWidth;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
864 font->height = w32_font->metrics.tmHeight
91211
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
865 + w32_font->metrics.tmExternalLeading;
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
866 font->space_width = font->average_width = w32_font->metrics.tmAveCharWidth;
91211
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
867
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
868 font->vertical_centering = 0;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
869 font->encoding_type = 0;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
870 font->baseline_offset = 0;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
871 font->relative_compose = 0;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
872 font->default_ascent = w32_font->metrics.tmAscent;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
873 font->font_encoder = NULL;
91211
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
874 font->pixel_size = size;
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
875 font->driver = &w32font_driver;
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
876 /* Use format cached during list, as the information we have access to
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
877 here is incomplete. */
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
878 extra = AREF (font_entity, FONT_EXTRA_INDEX);
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
879 if (CONSP (extra))
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
880 {
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
881 val = assq_no_quit (QCformat, extra);
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
882 if (CONSP (val))
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
883 font->props[FONT_FORMAT_INDEX] = XCDR (val);
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
884 else
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
885 font->props[FONT_FORMAT_INDEX] = Qunknown;
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
886 }
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
887 else
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
888 font->props[FONT_FORMAT_INDEX] = Qunknown;
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
889
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
890 font->props[FONT_FILE_INDEX] = Qnil;
91211
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
891 font->encoding_charset = -1;
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
892 font->repertory_charset = -1;
91545
572ea0c7c071 (w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents: 91521
diff changeset
893 /* TODO: do we really want the minimum width here, which could be negative? */
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
894 font->min_width = font->space_width;
91211
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
895 font->ascent = w32_font->metrics.tmAscent;
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
896 font->descent = w32_font->metrics.tmDescent;
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
897
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
898 if (metrics)
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
899 {
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
900 font->underline_thickness = metrics->otmsUnderscoreSize;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
901 font->underline_position = -metrics->otmsUnderscorePosition;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
902 }
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
903 else
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
904 {
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
905 font->underline_thickness = 0;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
906 font->underline_position = -1;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
907 }
91211
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
908
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
909 /* For temporary compatibility with legacy code that expects the
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
910 name to be usable in x-list-fonts. Eventually we expect to change
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
911 x-list-fonts and other places that use fonts so that this can be
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
912 an fcname or similar. */
95190
e2197409b952 *** empty log message ***
Kenichi Handa <handa@m17n.org>
parents: 95146
diff changeset
913 font->props[FONT_NAME_INDEX] = Ffont_xlfd_name (font_object, Qnil);
91545
572ea0c7c071 (w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents: 91521
diff changeset
914
91211
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
915 return 1;
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
916 }
abd06276f55a (w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents: 91208
diff changeset
917
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
918 /* Callback function for EnumFontFamiliesEx.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
919 * Adds the name of a font to a Lisp list (passed in as the lParam arg). */
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
920 static int CALLBACK
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
921 add_font_name_to_list (logical_font, physical_font, font_type, list_object)
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
922 ENUMLOGFONTEX *logical_font;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
923 NEWTEXTMETRICEX *physical_font;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
924 DWORD font_type;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
925 LPARAM list_object;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
926 {
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
927 Lisp_Object* list = (Lisp_Object *) list_object;
91070
2060802cc53f (add_font_name_to_list): Avoid vertical fonts.
Jason Rumney <jasonr@gnu.org>
parents: 91034
diff changeset
928 Lisp_Object family;
2060802cc53f (add_font_name_to_list): Avoid vertical fonts.
Jason Rumney <jasonr@gnu.org>
parents: 91034
diff changeset
929
2060802cc53f (add_font_name_to_list): Avoid vertical fonts.
Jason Rumney <jasonr@gnu.org>
parents: 91034
diff changeset
930 /* Skip vertical fonts (intended only for printing) */
2060802cc53f (add_font_name_to_list): Avoid vertical fonts.
Jason Rumney <jasonr@gnu.org>
parents: 91034
diff changeset
931 if (logical_font->elfLogFont.lfFaceName[0] == '@')
2060802cc53f (add_font_name_to_list): Avoid vertical fonts.
Jason Rumney <jasonr@gnu.org>
parents: 91034
diff changeset
932 return 1;
2060802cc53f (add_font_name_to_list): Avoid vertical fonts.
Jason Rumney <jasonr@gnu.org>
parents: 91034
diff changeset
933
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
934 family = font_intern_prop (logical_font->elfLogFont.lfFaceName,
95744
abc12b93e2dd (add_font_name_to_list): Adjusted for
Kenichi Handa <handa@m17n.org>
parents: 95468
diff changeset
935 strlen (logical_font->elfLogFont.lfFaceName), 1);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
936 if (! memq_no_quit (family, *list))
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
937 *list = Fcons (family, *list);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
938
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
939 return 1;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
940 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
941
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
942 static int w32_decode_weight P_ ((int));
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
943 static int w32_encode_weight P_ ((int));
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
944
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
945 /* Convert an enumerated Windows font to an Emacs font entity. */
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
946 static Lisp_Object
91124
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
947 w32_enumfont_pattern_entity (frame, logical_font, physical_font,
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
948 font_type, requested_font, backend)
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
949 Lisp_Object frame;
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
950 ENUMLOGFONTEX *logical_font;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
951 NEWTEXTMETRICEX *physical_font;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
952 DWORD font_type;
91124
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
953 LOGFONT *requested_font;
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
954 Lisp_Object backend;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
955 {
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
956 Lisp_Object entity, tem;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
957 LOGFONT *lf = (LOGFONT*) logical_font;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
958 BYTE generic_type;
93598
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
959 DWORD full_type = physical_font->ntmTm.ntmFlags;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
960
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
961 entity = font_make_entity ();
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
962
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
963 ASET (entity, FONT_TYPE_INDEX, backend);
92539
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
964 ASET (entity, FONT_REGISTRY_INDEX, w32_registry (lf->lfCharSet, font_type));
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
965 ASET (entity, FONT_OBJLIST_INDEX, Qnil);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
966
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
967 /* Foundry is difficult to get in readable form on Windows.
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
968 But Emacs crashes if it is not set, so set it to something more
95341
5602389abb69 (compute_metrics): Rewrite an "else { if () ... else ... }"
Juanma Barranquero <lekktu@gmail.com>
parents: 95339
diff changeset
969 generic. These values make xlfds compatible with Emacs 22. */
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
970 if (lf->lfOutPrecision == OUT_STRING_PRECIS)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
971 tem = Qraster;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
972 else if (lf->lfOutPrecision == OUT_STROKE_PRECIS)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
973 tem = Qoutline;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
974 else
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
975 tem = Qunknown;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
976
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
977 ASET (entity, FONT_FOUNDRY_INDEX, tem);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
978
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
979 /* Save the generic family in the extra info, as it is likely to be
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
980 useful to users looking for a close match. */
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
981 generic_type = physical_font->ntmTm.tmPitchAndFamily & 0xF0;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
982 if (generic_type == FF_DECORATIVE)
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
983 tem = Qdecorative;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
984 else if (generic_type == FF_MODERN)
91260
75f89f349f70 (w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents: 91259
diff changeset
985 tem = Qmono;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
986 else if (generic_type == FF_ROMAN)
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
987 tem = Qserif;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
988 else if (generic_type == FF_SCRIPT)
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
989 tem = Qscript;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
990 else if (generic_type == FF_SWISS)
91260
75f89f349f70 (w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents: 91259
diff changeset
991 tem = Qsans;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
992 else
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
993 tem = Qnil;
91260
75f89f349f70 (w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents: 91259
diff changeset
994
75f89f349f70 (w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents: 91259
diff changeset
995 ASET (entity, FONT_ADSTYLE_INDEX, tem);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
996
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
997 if (physical_font->ntmTm.tmPitchAndFamily & 0x01)
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
998 ASET (entity, FONT_SPACING_INDEX, make_number (FONT_SPACING_PROPORTIONAL));
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
999 else
95315
3d4da4481f75 (w32_weight_table): Remove unused variable.
Jason Rumney <jasonr@gnu.org>
parents: 95310
diff changeset
1000 ASET (entity, FONT_SPACING_INDEX, make_number (FONT_SPACING_CHARCELL));
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1001
91124
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1002 if (requested_font->lfQuality != DEFAULT_QUALITY)
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1003 {
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1004 font_put_extra (entity, QCantialias,
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1005 lispy_antialias_type (requested_font->lfQuality));
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1006 }
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1007 ASET (entity, FONT_FAMILY_INDEX,
95744
abc12b93e2dd (add_font_name_to_list): Adjusted for
Kenichi Handa <handa@m17n.org>
parents: 95468
diff changeset
1008 font_intern_prop (lf->lfFaceName, strlen (lf->lfFaceName), 1));
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1009
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1010 FONT_SET_STYLE (entity, FONT_WEIGHT_INDEX,
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1011 make_number (w32_decode_weight (lf->lfWeight)));
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1012 FONT_SET_STYLE (entity, FONT_SLANT_INDEX,
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1013 make_number (lf->lfItalic ? 200 : 100));
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1014 /* TODO: PANOSE struct has this info, but need to call GetOutlineTextMetrics
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1015 to get it. */
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1016 FONT_SET_STYLE (entity, FONT_WIDTH_INDEX, make_number (100));
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1017
90879
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
1018 if (font_type & RASTER_FONTTYPE)
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
1019 ASET (entity, FONT_SIZE_INDEX, make_number (physical_font->ntmTm.tmHeight));
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
1020 else
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
1021 ASET (entity, FONT_SIZE_INDEX, make_number (0));
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1022
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1023 /* Cache unicode codepoints covered by this font, as there is no other way
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1024 of getting this information easily. */
90879
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
1025 if (font_type & TRUETYPE_FONTTYPE)
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1026 {
95468
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1027 tem = font_supported_scripts (&physical_font->ntmFontSig);
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1028 if (!NILP (tem))
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1029 font_put_extra (entity, QCscript, tem);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1030 }
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1031
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
1032 /* This information is not fully available when opening fonts, so
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
1033 save it here. Only Windows 2000 and later return information
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
1034 about opentype and type1 fonts, so need a fallback for detecting
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
1035 truetype so that this information is not any worse than we could
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
1036 have obtained later. */
93598
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1037 if (EQ (backend, Quniscribe) && (full_type & NTMFLAGS_OPENTYPE))
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1038 tem = intern ("opentype");
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1039 else if (font_type & TRUETYPE_FONTTYPE)
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
1040 tem = intern ("truetype");
93598
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1041 else if (full_type & NTM_PS_OPENTYPE)
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1042 tem = intern ("postscript");
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
1043 else if (full_type & NTM_TYPE1)
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
1044 tem = intern ("type1");
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
1045 else if (font_type & RASTER_FONTTYPE)
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
1046 tem = intern ("w32bitmap");
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
1047 else
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
1048 tem = intern ("w32vector");
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
1049
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
1050 font_put_extra (entity, QCformat, tem);
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
1051
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1052 return entity;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1053 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1054
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1055
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1056 /* Convert generic families to the family portion of lfPitchAndFamily. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1057 BYTE
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1058 w32_generic_family (Lisp_Object name)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1059 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1060 /* Generic families. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1061 if (EQ (name, Qmonospace) || EQ (name, Qmono))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1062 return FF_MODERN;
91260
75f89f349f70 (w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents: 91259
diff changeset
1063 else if (EQ (name, Qsans) || EQ (name, Qsans_serif) || EQ (name, Qsansserif))
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1064 return FF_SWISS;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1065 else if (EQ (name, Qserif))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1066 return FF_ROMAN;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1067 else if (EQ (name, Qdecorative))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1068 return FF_DECORATIVE;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1069 else if (EQ (name, Qscript))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1070 return FF_SCRIPT;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1071 else
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1072 return FF_DONTCARE;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1073 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1074
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1075 static int
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1076 logfonts_match (font, pattern)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1077 LOGFONT *font, *pattern;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1078 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1079 /* Only check height for raster fonts. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1080 if (pattern->lfHeight && font->lfOutPrecision == OUT_STRING_PRECIS
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1081 && font->lfHeight != pattern->lfHeight)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1082 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1083
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1084 /* Have some flexibility with weights. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1085 if (pattern->lfWeight
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1086 && ((font->lfWeight < (pattern->lfWeight - 150))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1087 || font->lfWeight > (pattern->lfWeight + 150)))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1088 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1089
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1090 /* Charset and face should be OK. Italic has to be checked
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1091 against the original spec, in case we don't have any preference. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1092 return 1;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1093 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1094
96111
365321a44102 (font_matches_spec): Use csb bitfield from font signature to determine
Jason Rumney <jasonr@gnu.org>
parents: 96071
diff changeset
1095 /* Codepage Bitfields in FONTSIGNATURE struct. */
365321a44102 (font_matches_spec): Use csb bitfield from font signature to determine
Jason Rumney <jasonr@gnu.org>
parents: 96071
diff changeset
1096 #define CSB_JAPANESE (1 << 17)
365321a44102 (font_matches_spec): Use csb bitfield from font signature to determine
Jason Rumney <jasonr@gnu.org>
parents: 96071
diff changeset
1097 #define CSB_KOREAN ((1 << 19) | (1 << 21))
365321a44102 (font_matches_spec): Use csb bitfield from font signature to determine
Jason Rumney <jasonr@gnu.org>
parents: 96071
diff changeset
1098 #define CSB_CHINESE ((1 << 18) | (1 << 20))
365321a44102 (font_matches_spec): Use csb bitfield from font signature to determine
Jason Rumney <jasonr@gnu.org>
parents: 96071
diff changeset
1099
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1100 static int
93598
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1101 font_matches_spec (type, font, spec, backend, logfont)
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1102 DWORD type;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1103 NEWTEXTMETRICEX *font;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1104 Lisp_Object spec;
93598
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1105 Lisp_Object backend;
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1106 LOGFONT *logfont;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1107 {
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1108 Lisp_Object extra, val;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1109
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1110 /* Check italic. Can't check logfonts, since it is a boolean field,
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1111 so there is no difference between "non-italic" and "don't care". */
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1112 {
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1113 int slant = FONT_SLANT_NUMERIC (spec);
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1114
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1115 if (slant >= 0
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1116 && ((slant > 150 && !font->ntmTm.tmItalic)
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1117 || (slant <= 150 && font->ntmTm.tmItalic)))
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1118 return 0;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1119 }
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1120
91264
9112e263c11f (logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents: 91260
diff changeset
1121 /* Check adstyle against generic family. */
9112e263c11f (logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents: 91260
diff changeset
1122 val = AREF (spec, FONT_ADSTYLE_INDEX);
9112e263c11f (logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents: 91260
diff changeset
1123 if (!NILP (val))
9112e263c11f (logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents: 91260
diff changeset
1124 {
9112e263c11f (logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents: 91260
diff changeset
1125 BYTE family = w32_generic_family (val);
9112e263c11f (logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents: 91260
diff changeset
1126 if (family != FF_DONTCARE
9112e263c11f (logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents: 91260
diff changeset
1127 && family != (font->ntmTm.tmPitchAndFamily & 0xF0))
9112e263c11f (logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents: 91260
diff changeset
1128 return 0;
9112e263c11f (logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents: 91260
diff changeset
1129 }
9112e263c11f (logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents: 91260
diff changeset
1130
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1131 /* Check spacing */
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1132 val = AREF (spec, FONT_SPACING_INDEX);
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1133 if (INTEGERP (val))
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1134 {
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1135 int spacing = XINT (val);
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1136 int proportional = (spacing < FONT_SPACING_MONO);
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1137
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1138 if ((proportional && !(font->ntmTm.tmPitchAndFamily & 0x01))
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1139 || (!proportional && (font->ntmTm.tmPitchAndFamily & 0x01)))
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1140 return 0;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1141 }
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1142
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1143 /* Check extra parameters. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1144 for (extra = AREF (spec, FONT_EXTRA_INDEX);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1145 CONSP (extra); extra = XCDR (extra))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1146 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1147 Lisp_Object extra_entry;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1148 extra_entry = XCAR (extra);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1149 if (CONSP (extra_entry))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1150 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1151 Lisp_Object key = XCAR (extra_entry);
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1152
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1153 val = XCDR (extra_entry);
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1154 if (EQ (key, QCscript) && SYMBOLP (val))
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1155 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1156 /* Only truetype fonts will have information about what
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1157 scripts they support. This probably means the user
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1158 will have to force Emacs to use raster, postscript
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1159 or atm fonts for non-ASCII text. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1160 if (type & TRUETYPE_FONTTYPE)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1161 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1162 Lisp_Object support
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1163 = font_supported_scripts (&font->ntmFontSig);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1164 if (! memq_no_quit (val, support))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1165 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1166 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1167 else
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1168 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1169 /* Return specific matches, but play it safe. Fonts
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1170 that cover more than their charset would suggest
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1171 are likely to be truetype or opentype fonts,
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1172 covered above. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1173 if (EQ (val, Qlatin))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1174 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1175 /* Although every charset but symbol, thai and
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1176 arabic contains the basic ASCII set of latin
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1177 characters, Emacs expects much more. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1178 if (font->ntmTm.tmCharSet != ANSI_CHARSET)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1179 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1180 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1181 else if (EQ (val, Qsymbol))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1182 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1183 if (font->ntmTm.tmCharSet != SYMBOL_CHARSET)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1184 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1185 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1186 else if (EQ (val, Qcyrillic))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1187 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1188 if (font->ntmTm.tmCharSet != RUSSIAN_CHARSET)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1189 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1190 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1191 else if (EQ (val, Qgreek))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1192 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1193 if (font->ntmTm.tmCharSet != GREEK_CHARSET)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1194 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1195 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1196 else if (EQ (val, Qarabic))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1197 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1198 if (font->ntmTm.tmCharSet != ARABIC_CHARSET)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1199 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1200 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1201 else if (EQ (val, Qhebrew))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1202 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1203 if (font->ntmTm.tmCharSet != HEBREW_CHARSET)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1204 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1205 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1206 else if (EQ (val, Qthai))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1207 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1208 if (font->ntmTm.tmCharSet != THAI_CHARSET)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1209 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1210 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1211 else if (EQ (val, Qkana))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1212 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1213 if (font->ntmTm.tmCharSet != SHIFTJIS_CHARSET)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1214 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1215 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1216 else if (EQ (val, Qbopomofo))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1217 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1218 if (font->ntmTm.tmCharSet != CHINESEBIG5_CHARSET)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1219 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1220 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1221 else if (EQ (val, Qhangul))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1222 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1223 if (font->ntmTm.tmCharSet != HANGUL_CHARSET
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1224 && font->ntmTm.tmCharSet != JOHAB_CHARSET)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1225 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1226 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1227 else if (EQ (val, Qhan))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1228 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1229 if (font->ntmTm.tmCharSet != CHINESEBIG5_CHARSET
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1230 && font->ntmTm.tmCharSet != GB2312_CHARSET
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1231 && font->ntmTm.tmCharSet != HANGUL_CHARSET
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1232 && font->ntmTm.tmCharSet != JOHAB_CHARSET
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1233 && font->ntmTm.tmCharSet != SHIFTJIS_CHARSET)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1234 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1235 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1236 else
93598
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1237 /* Other scripts unlikely to be handled by non-truetype
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1238 fonts. */
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1239 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1240 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1241 }
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1242 else if (EQ (key, QClang) && SYMBOLP (val))
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1243 {
96111
365321a44102 (font_matches_spec): Use csb bitfield from font signature to determine
Jason Rumney <jasonr@gnu.org>
parents: 96071
diff changeset
1244 /* Just handle the CJK languages here, as the lang
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1245 parameter is used to select a font with appropriate
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1246 glyphs in the cjk unified ideographs block. Other fonts
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1247 support for a language can be solely determined by
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1248 its character coverage. */
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1249 if (EQ (val, Qja))
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1250 {
96111
365321a44102 (font_matches_spec): Use csb bitfield from font signature to determine
Jason Rumney <jasonr@gnu.org>
parents: 96071
diff changeset
1251 if (!(font->ntmFontSig.fsCsb[0] & CSB_JAPANESE))
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1252 return 0;
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1253 }
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1254 else if (EQ (val, Qko))
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1255 {
96111
365321a44102 (font_matches_spec): Use csb bitfield from font signature to determine
Jason Rumney <jasonr@gnu.org>
parents: 96071
diff changeset
1256 if (!(font->ntmFontSig.fsCsb[0] & CSB_KOREAN))
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1257 return 0;
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1258 }
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1259 else if (EQ (val, Qzh))
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1260 {
96111
365321a44102 (font_matches_spec): Use csb bitfield from font signature to determine
Jason Rumney <jasonr@gnu.org>
parents: 96071
diff changeset
1261 if (!(font->ntmFontSig.fsCsb[0] & CSB_CHINESE))
365321a44102 (font_matches_spec): Use csb bitfield from font signature to determine
Jason Rumney <jasonr@gnu.org>
parents: 96071
diff changeset
1262 return 0;
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1263 }
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1264 else
96111
365321a44102 (font_matches_spec): Use csb bitfield from font signature to determine
Jason Rumney <jasonr@gnu.org>
parents: 96071
diff changeset
1265 /* Any other language, we don't recognize it. Only the above
365321a44102 (font_matches_spec): Use csb bitfield from font signature to determine
Jason Rumney <jasonr@gnu.org>
parents: 96071
diff changeset
1266 currently appear in fontset.el, so it isn't worth
365321a44102 (font_matches_spec): Use csb bitfield from font signature to determine
Jason Rumney <jasonr@gnu.org>
parents: 96071
diff changeset
1267 creating a mapping table of codepages/scripts to languages
365321a44102 (font_matches_spec): Use csb bitfield from font signature to determine
Jason Rumney <jasonr@gnu.org>
parents: 96071
diff changeset
1268 or opening the font to see if there are any language tags
365321a44102 (font_matches_spec): Use csb bitfield from font signature to determine
Jason Rumney <jasonr@gnu.org>
parents: 96071
diff changeset
1269 in it that the W32 API does not expose. Fontset
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1270 spec should have a fallback, as some backends do
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1271 not recognize language at all. */
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1272 return 0;
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1273 }
93598
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1274 else if (EQ (key, QCotf) && CONSP (val))
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1275 {
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1276 /* OTF features only supported by the uniscribe backend. */
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1277 if (EQ (backend, Quniscribe))
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1278 {
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1279 if (!uniscribe_check_otf (logfont, val))
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1280 return 0;
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1281 }
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1282 else
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1283 return 0;
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1284 }
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1285 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1286 }
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1287 return 1;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1288 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1289
92539
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1290 static int
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1291 w32font_coverage_ok (coverage, charset)
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1292 FONTSIGNATURE * coverage;
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1293 BYTE charset;
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1294 {
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1295 DWORD subrange1 = coverage->fsUsb[1];
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1296
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1297 #define SUBRANGE1_HAN_MASK 0x08000000
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1298 #define SUBRANGE1_HANGEUL_MASK 0x01000000
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1299 #define SUBRANGE1_JAPANESE_MASK (0x00060000 | SUBRANGE1_HAN_MASK)
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1300
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1301 if (charset == GB2312_CHARSET || charset == CHINESEBIG5_CHARSET)
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1302 {
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1303 return (subrange1 & SUBRANGE1_HAN_MASK) == SUBRANGE1_HAN_MASK;
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1304 }
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1305 else if (charset == SHIFTJIS_CHARSET)
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1306 {
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1307 return (subrange1 & SUBRANGE1_JAPANESE_MASK) == SUBRANGE1_JAPANESE_MASK;
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1308 }
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1309 else if (charset == HANGEUL_CHARSET)
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1310 {
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1311 return (subrange1 & SUBRANGE1_HANGEUL_MASK) == SUBRANGE1_HANGEUL_MASK;
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1312 }
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1313
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1314 return 1;
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1315 }
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1316
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1317 /* Callback function for EnumFontFamiliesEx.
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1318 * Checks if a font matches everything we are trying to check agaist,
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1319 * and if so, adds it to a list. Both the data we are checking against
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1320 * and the list to which the fonts are added are passed in via the
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1321 * lparam argument, in the form of a font_callback_data struct. */
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
1322 static int CALLBACK
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1323 add_font_entity_to_list (logical_font, physical_font, font_type, lParam)
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
1324 ENUMLOGFONTEX *logical_font;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
1325 NEWTEXTMETRICEX *physical_font;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
1326 DWORD font_type;
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1327 LPARAM lParam;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1328 {
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1329 struct font_callback_data *match_data
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1330 = (struct font_callback_data *) lParam;
93598
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1331 Lisp_Object backend = match_data->opentype_only ? Quniscribe : Qgdi;
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1332
91208
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
1333 if ((!match_data->opentype_only
95388
68cbfe0d72fc (add_font_entity_to_list): Allow non-opentype truetype fonts back
Jason Rumney <jasonr@gnu.org>
parents: 95384
diff changeset
1334 || (((physical_font->ntmTm.ntmFlags & NTMFLAGS_OPENTYPE)
68cbfe0d72fc (add_font_entity_to_list): Allow non-opentype truetype fonts back
Jason Rumney <jasonr@gnu.org>
parents: 95384
diff changeset
1335 || (font_type & TRUETYPE_FONTTYPE))
68cbfe0d72fc (add_font_entity_to_list): Allow non-opentype truetype fonts back
Jason Rumney <jasonr@gnu.org>
parents: 95384
diff changeset
1336 /* For the uniscribe backend, only consider fonts that claim
68cbfe0d72fc (add_font_entity_to_list): Allow non-opentype truetype fonts back
Jason Rumney <jasonr@gnu.org>
parents: 95384
diff changeset
1337 to cover at least some part of Unicode. */
68cbfe0d72fc (add_font_entity_to_list): Allow non-opentype truetype fonts back
Jason Rumney <jasonr@gnu.org>
parents: 95384
diff changeset
1338 && (physical_font->ntmFontSig.fsUsb[3]
68cbfe0d72fc (add_font_entity_to_list): Allow non-opentype truetype fonts back
Jason Rumney <jasonr@gnu.org>
parents: 95384
diff changeset
1339 || physical_font->ntmFontSig.fsUsb[2]
68cbfe0d72fc (add_font_entity_to_list): Allow non-opentype truetype fonts back
Jason Rumney <jasonr@gnu.org>
parents: 95384
diff changeset
1340 || physical_font->ntmFontSig.fsUsb[1]
68cbfe0d72fc (add_font_entity_to_list): Allow non-opentype truetype fonts back
Jason Rumney <jasonr@gnu.org>
parents: 95384
diff changeset
1341 || (physical_font->ntmFontSig.fsUsb[0] & 0x3fffffff))))
91208
98329725c530 Include w32font.h.
Jason Rumney <jasonr@gnu.org>
parents: 91182
diff changeset
1342 && logfonts_match (&logical_font->elfLogFont, &match_data->pattern)
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1343 && font_matches_spec (font_type, physical_font,
93598
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1344 match_data->orig_font_spec, backend,
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1345 &logical_font->elfLogFont)
92539
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1346 && w32font_coverage_ok (&physical_font->ntmFontSig,
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1347 match_data->pattern.lfCharSet)
91264
9112e263c11f (logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents: 91260
diff changeset
1348 /* Avoid substitutions involving raster fonts (eg Helv -> MS Sans Serif)
9112e263c11f (logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents: 91260
diff changeset
1349 We limit this to raster fonts, because the test can catch some
9112e263c11f (logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents: 91260
diff changeset
1350 genuine fonts (eg the full name of DejaVu Sans Mono Light is actually
9112e263c11f (logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents: 91260
diff changeset
1351 DejaVu Sans Mono ExtraLight). Helvetica -> Arial substitution will
9112e263c11f (logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents: 91260
diff changeset
1352 therefore get through this test. Since full names can be prefixed
9112e263c11f (logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents: 91260
diff changeset
1353 by a foundry, we accept raster fonts if the font name is found
9112e263c11f (logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents: 91260
diff changeset
1354 anywhere within the full name. */
9112e263c11f (logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents: 91260
diff changeset
1355 && (logical_font->elfLogFont.lfOutPrecision != OUT_STRING_PRECIS
9112e263c11f (logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents: 91260
diff changeset
1356 || strstr (logical_font->elfFullName,
9112e263c11f (logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents: 91260
diff changeset
1357 logical_font->elfLogFont.lfFaceName)))
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1358 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1359 Lisp_Object entity
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1360 = w32_enumfont_pattern_entity (match_data->frame, logical_font,
91124
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1361 physical_font, font_type,
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
1362 &match_data->pattern,
93598
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1363 backend);
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1364 if (!NILP (entity))
95468
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1365 {
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1366 Lisp_Object spec_charset = AREF (match_data->orig_font_spec,
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1367 FONT_REGISTRY_INDEX);
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1368
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1369 /* If registry was specified as iso10646-1, only report
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1370 ANSI and DEFAULT charsets, as most unicode fonts will
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1371 contain one of those plus others. */
95828
b5bea3387b5e (w32font_encode_char): Detect missing glyphs that are misreported as space.
Jason Rumney <jasonr@gnu.org>
parents: 95744
diff changeset
1372 if ((EQ (spec_charset, Qiso10646_1)
b5bea3387b5e (w32font_encode_char): Detect missing glyphs that are misreported as space.
Jason Rumney <jasonr@gnu.org>
parents: 95744
diff changeset
1373 || EQ (spec_charset, Qunicode_bmp)
b5bea3387b5e (w32font_encode_char): Detect missing glyphs that are misreported as space.
Jason Rumney <jasonr@gnu.org>
parents: 95744
diff changeset
1374 || EQ (spec_charset, Qunicode_sip))
95468
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1375 && logical_font->elfLogFont.lfCharSet != DEFAULT_CHARSET
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1376 && logical_font->elfLogFont.lfCharSet != ANSI_CHARSET)
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1377 return 1;
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1378 /* If registry was specified, but did not map to a windows
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1379 charset, only report fonts that have unknown charsets.
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1380 This will still report fonts that don't match, but at
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1381 least it eliminates known definite mismatches. */
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1382 else if (!NILP (spec_charset)
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1383 && !EQ (spec_charset, Qiso10646_1)
95828
b5bea3387b5e (w32font_encode_char): Detect missing glyphs that are misreported as space.
Jason Rumney <jasonr@gnu.org>
parents: 95744
diff changeset
1384 && !EQ (spec_charset, Qunicode_bmp)
b5bea3387b5e (w32font_encode_char): Detect missing glyphs that are misreported as space.
Jason Rumney <jasonr@gnu.org>
parents: 95744
diff changeset
1385 && !EQ (spec_charset, Qunicode_sip)
95468
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1386 && match_data->pattern.lfCharSet == DEFAULT_CHARSET
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1387 && logical_font->elfLogFont.lfCharSet != DEFAULT_CHARSET)
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1388 return 1;
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1389
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1390 /* If registry was specified, ensure it is reported as the same. */
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1391 if (!NILP (spec_charset))
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1392 ASET (entity, FONT_REGISTRY_INDEX, spec_charset);
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1393
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1394 match_data->list = Fcons (entity, match_data->list);
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1395
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1396 /* If no registry specified, duplicate iso8859-1 truetype fonts
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1397 as iso10646-1. */
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1398 if (NILP (spec_charset)
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1399 && font_type == TRUETYPE_FONTTYPE
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1400 && logical_font->elfLogFont.lfCharSet == ANSI_CHARSET)
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1401 {
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1402 Lisp_Object tem = Fcopy_font_spec (entity);
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1403 ASET (tem, FONT_REGISTRY_INDEX, Qiso10646_1);
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1404 match_data->list = Fcons (tem, match_data->list);
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1405 }
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1406 }
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1407 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1408 return 1;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1409 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1410
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1411 /* Callback function for EnumFontFamiliesEx.
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1412 * Terminates the search once we have a match. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1413 static int CALLBACK
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1414 add_one_font_entity_to_list (logical_font, physical_font, font_type, lParam)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1415 ENUMLOGFONTEX *logical_font;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1416 NEWTEXTMETRICEX *physical_font;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1417 DWORD font_type;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1418 LPARAM lParam;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1419 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1420 struct font_callback_data *match_data
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1421 = (struct font_callback_data *) lParam;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1422 add_font_entity_to_list (logical_font, physical_font, font_type, lParam);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1423
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1424 /* If we have a font in the list, terminate the search. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1425 return !NILP (match_data->list);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1426 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1427
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1428 /* Convert a Lisp font registry (symbol) to a windows charset. */
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
1429 static LONG
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
1430 registry_to_w32_charset (charset)
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
1431 Lisp_Object charset;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1432 {
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1433 if (EQ (charset, Qiso10646_1) || EQ (charset, Qunicode_bmp)
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1434 || EQ (charset, Qunicode_sip))
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1435 return DEFAULT_CHARSET; /* UNICODE_CHARSET not defined in MingW32 */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1436 else if (EQ (charset, Qiso8859_1))
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1437 return ANSI_CHARSET;
90879
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
1438 else if (SYMBOLP (charset))
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
1439 return x_to_w32_charset (SDATA (SYMBOL_NAME (charset)));
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1440 else
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1441 return DEFAULT_CHARSET;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1442 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1443
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
1444 static Lisp_Object
92539
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1445 w32_registry (w32_charset, font_type)
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
1446 LONG w32_charset;
92539
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1447 DWORD font_type;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1448 {
95468
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1449 char *charset;
92539
d4cf72c99c2f (w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents: 92472
diff changeset
1450
95468
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1451 /* If charset is defaulted, charset is unicode or unknown, depending on
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1452 font type. */
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1453 if (w32_charset == DEFAULT_CHARSET)
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1454 return font_type == TRUETYPE_FONTTYPE ? Qiso10646_1 : Qunknown;
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1455
19ee88719d52 (w32_enumfont_pattern_entity): Use requested registry.
Jason Rumney <jasonr@gnu.org>
parents: 95388
diff changeset
1456 charset = w32_to_x_charset (w32_charset, NULL);
95744
abc12b93e2dd (add_font_name_to_list): Adjusted for
Kenichi Handa <handa@m17n.org>
parents: 95468
diff changeset
1457 return font_intern_prop (charset, strlen(charset), 1);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1458 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1459
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1460 static int
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1461 w32_decode_weight (fnweight)
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1462 int fnweight;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1463 {
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1464 if (fnweight >= FW_HEAVY) return 210;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1465 if (fnweight >= FW_EXTRABOLD) return 205;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1466 if (fnweight >= FW_BOLD) return 200;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1467 if (fnweight >= FW_SEMIBOLD) return 180;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1468 if (fnweight >= FW_NORMAL) return 100;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1469 if (fnweight >= FW_LIGHT) return 50;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1470 if (fnweight >= FW_EXTRALIGHT) return 40;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1471 if (fnweight > FW_THIN) return 20;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1472 return 0;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1473 }
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1474
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1475 static int
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1476 w32_encode_weight (n)
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1477 int n;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1478 {
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1479 if (n >= 210) return FW_HEAVY;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1480 if (n >= 205) return FW_EXTRABOLD;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1481 if (n >= 200) return FW_BOLD;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1482 if (n >= 180) return FW_SEMIBOLD;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1483 if (n >= 100) return FW_NORMAL;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1484 if (n >= 50) return FW_LIGHT;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1485 if (n >= 40) return FW_EXTRALIGHT;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1486 if (n >= 20) return FW_THIN;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1487 return 0;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1488 }
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1489
96005
66f0213be62a Fix crashing bug in use of bold fonts from x-select-font on W32.
Jason Rumney <jasonr@gnu.org>
parents: 95894
diff changeset
1490 /* Convert a Windows font weight into one of the weights supported
66f0213be62a Fix crashing bug in use of bold fonts from x-select-font on W32.
Jason Rumney <jasonr@gnu.org>
parents: 95894
diff changeset
1491 by fontconfig (see font.c:font_parse_fcname). */
66f0213be62a Fix crashing bug in use of bold fonts from x-select-font on W32.
Jason Rumney <jasonr@gnu.org>
parents: 95894
diff changeset
1492 static Lisp_Object
66f0213be62a Fix crashing bug in use of bold fonts from x-select-font on W32.
Jason Rumney <jasonr@gnu.org>
parents: 95894
diff changeset
1493 w32_to_fc_weight (n)
66f0213be62a Fix crashing bug in use of bold fonts from x-select-font on W32.
Jason Rumney <jasonr@gnu.org>
parents: 95894
diff changeset
1494 int n;
66f0213be62a Fix crashing bug in use of bold fonts from x-select-font on W32.
Jason Rumney <jasonr@gnu.org>
parents: 95894
diff changeset
1495 {
66f0213be62a Fix crashing bug in use of bold fonts from x-select-font on W32.
Jason Rumney <jasonr@gnu.org>
parents: 95894
diff changeset
1496 if (n >= FW_EXTRABOLD) return intern ("black");
66f0213be62a Fix crashing bug in use of bold fonts from x-select-font on W32.
Jason Rumney <jasonr@gnu.org>
parents: 95894
diff changeset
1497 if (n >= FW_BOLD) return intern ("bold");
66f0213be62a Fix crashing bug in use of bold fonts from x-select-font on W32.
Jason Rumney <jasonr@gnu.org>
parents: 95894
diff changeset
1498 if (n >= FW_SEMIBOLD) return intern ("demibold");
66f0213be62a Fix crashing bug in use of bold fonts from x-select-font on W32.
Jason Rumney <jasonr@gnu.org>
parents: 95894
diff changeset
1499 if (n >= FW_NORMAL) return intern ("medium");
66f0213be62a Fix crashing bug in use of bold fonts from x-select-font on W32.
Jason Rumney <jasonr@gnu.org>
parents: 95894
diff changeset
1500 return intern ("light");
66f0213be62a Fix crashing bug in use of bold fonts from x-select-font on W32.
Jason Rumney <jasonr@gnu.org>
parents: 95894
diff changeset
1501 }
66f0213be62a Fix crashing bug in use of bold fonts from x-select-font on W32.
Jason Rumney <jasonr@gnu.org>
parents: 95894
diff changeset
1502
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1503 /* Fill in all the available details of LOGFONT from FONT_SPEC. */
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
1504 static void
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
1505 fill_in_logfont (f, logfont, font_spec)
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
1506 FRAME_PTR f;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
1507 LOGFONT *logfont;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
1508 Lisp_Object font_spec;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1509 {
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1510 Lisp_Object tmp, extra;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1511 int dpi = FRAME_W32_DISPLAY_INFO (f)->resy;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1512
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1513 tmp = AREF (font_spec, FONT_DPI_INDEX);
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1514 if (INTEGERP (tmp))
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1515 {
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1516 dpi = XINT (tmp);
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1517 }
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1518 else if (FLOATP (tmp))
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1519 {
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1520 dpi = (int) (XFLOAT_DATA (tmp) + 0.5);
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1521 }
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1522
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1523 /* Height */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1524 tmp = AREF (font_spec, FONT_SIZE_INDEX);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1525 if (INTEGERP (tmp))
90879
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
1526 logfont->lfHeight = -1 * XINT (tmp);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1527 else if (FLOATP (tmp))
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1528 logfont->lfHeight = (int) (-1.0 * dpi * XFLOAT_DATA (tmp) / 72.27 + 0.5);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1529
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1530 /* Escapement */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1531
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1532 /* Orientation */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1533
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1534 /* Weight */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1535 tmp = AREF (font_spec, FONT_WEIGHT_INDEX);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1536 if (INTEGERP (tmp))
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1537 logfont->lfWeight = w32_encode_weight (FONT_WEIGHT_NUMERIC (font_spec));
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1538
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1539 /* Italic */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1540 tmp = AREF (font_spec, FONT_SLANT_INDEX);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1541 if (INTEGERP (tmp))
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1542 {
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1543 int slant = FONT_SLANT_NUMERIC (font_spec);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1544 logfont->lfItalic = slant > 150 ? 1 : 0;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1545 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1546
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1547 /* Underline */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1548
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1549 /* Strikeout */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1550
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1551 /* Charset */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1552 tmp = AREF (font_spec, FONT_REGISTRY_INDEX);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1553 if (! NILP (tmp))
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1554 logfont->lfCharSet = registry_to_w32_charset (tmp);
93598
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1555 else
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1556 logfont->lfCharSet = DEFAULT_CHARSET;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1557
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1558 /* Out Precision */
91124
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1559
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1560 /* Clip Precision */
91124
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1561
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1562 /* Quality */
90879
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
1563 logfont->lfQuality = DEFAULT_QUALITY;
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
1564
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1565 /* Generic Family and Face Name */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1566 logfont->lfPitchAndFamily = FF_DONTCARE | DEFAULT_PITCH;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1567
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1568 tmp = AREF (font_spec, FONT_FAMILY_INDEX);
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1569 if (! NILP (tmp))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1570 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1571 logfont->lfPitchAndFamily = w32_generic_family (tmp) | DEFAULT_PITCH;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1572 if ((logfont->lfPitchAndFamily & 0xF0) != FF_DONTCARE)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1573 ; /* Font name was generic, don't fill in font name. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1574 /* Font families are interned, but allow for strings also in case of
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1575 user input. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1576 else if (SYMBOLP (tmp))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1577 strncpy (logfont->lfFaceName, SDATA (SYMBOL_NAME (tmp)), LF_FACESIZE);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1578 }
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1579
91260
75f89f349f70 (w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents: 91259
diff changeset
1580 tmp = AREF (font_spec, FONT_ADSTYLE_INDEX);
75f89f349f70 (w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents: 91259
diff changeset
1581 if (!NILP (tmp))
75f89f349f70 (w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents: 91259
diff changeset
1582 {
75f89f349f70 (w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents: 91259
diff changeset
1583 /* Override generic family. */
75f89f349f70 (w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents: 91259
diff changeset
1584 BYTE family = w32_generic_family (tmp);
75f89f349f70 (w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents: 91259
diff changeset
1585 if (family != FF_DONTCARE)
75f89f349f70 (w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents: 91259
diff changeset
1586 logfont->lfPitchAndFamily = family | DEFAULT_PITCH;
75f89f349f70 (w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents: 91259
diff changeset
1587 }
75f89f349f70 (w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents: 91259
diff changeset
1588
95341
5602389abb69 (compute_metrics): Rewrite an "else { if () ... else ... }"
Juanma Barranquero <lekktu@gmail.com>
parents: 95339
diff changeset
1589
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1590 /* Set pitch based on the spacing property. */
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1591 tmp = AREF (font_spec, FONT_SPACING_INDEX);
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1592 if (INTEGERP (tmp))
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1593 {
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1594 int spacing = XINT (tmp);
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1595 if (spacing < FONT_SPACING_MONO)
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1596 logfont->lfPitchAndFamily
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1597 = logfont->lfPitchAndFamily & 0xF0 | VARIABLE_PITCH;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1598 else
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1599 logfont->lfPitchAndFamily
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1600 = logfont->lfPitchAndFamily & 0xF0 | FIXED_PITCH;
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1601 }
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1602
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1603 /* Process EXTRA info. */
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1604 for (extra = AREF (font_spec, FONT_EXTRA_INDEX);
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1605 CONSP (extra); extra = XCDR (extra))
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1606 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1607 tmp = XCAR (extra);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1608 if (CONSP (tmp))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1609 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1610 Lisp_Object key, val;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1611 key = XCAR (tmp), val = XCDR (tmp);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1612 /* Only use QCscript if charset is not provided, or is unicode
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1613 and a single script is specified. This is rather crude,
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1614 and is only used to narrow down the fonts returned where
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1615 there is a definite match. Some scripts, such as latin, han,
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1616 cjk-misc match multiple lfCharSet values, so we can't pre-filter
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1617 them. */
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
1618 if (EQ (key, QCscript)
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1619 && logfont->lfCharSet == DEFAULT_CHARSET
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1620 && SYMBOLP (val))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1621 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1622 if (EQ (val, Qgreek))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1623 logfont->lfCharSet = GREEK_CHARSET;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1624 else if (EQ (val, Qhangul))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1625 logfont->lfCharSet = HANGUL_CHARSET;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1626 else if (EQ (val, Qkana) || EQ (val, Qkanbun))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1627 logfont->lfCharSet = SHIFTJIS_CHARSET;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1628 else if (EQ (val, Qbopomofo))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1629 logfont->lfCharSet = CHINESEBIG5_CHARSET;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1630 /* GB 18030 supports tibetan, yi, mongolian,
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1631 fonts that support it should show up if we ask for
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1632 GB2312 fonts. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1633 else if (EQ (val, Qtibetan) || EQ (val, Qyi)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1634 || EQ (val, Qmongolian))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1635 logfont->lfCharSet = GB2312_CHARSET;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1636 else if (EQ (val, Qhebrew))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1637 logfont->lfCharSet = HEBREW_CHARSET;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1638 else if (EQ (val, Qarabic))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1639 logfont->lfCharSet = ARABIC_CHARSET;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1640 else if (EQ (val, Qthai))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1641 logfont->lfCharSet = THAI_CHARSET;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1642 else if (EQ (val, Qsymbol))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1643 logfont->lfCharSet = SYMBOL_CHARSET;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1644 }
91124
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1645 else if (EQ (key, QCantialias) && SYMBOLP (val))
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1646 {
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1647 logfont->lfQuality = w32_antialias_type (val);
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1648 }
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1649 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1650 }
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1651 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1652
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
1653 static void
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1654 list_all_matching_fonts (match_data)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1655 struct font_callback_data *match_data;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1656 {
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1657 HDC dc;
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1658 Lisp_Object families = w32font_list_family (match_data->frame);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1659 struct frame *f = XFRAME (match_data->frame);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1660
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1661 dc = get_frame_dc (f);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1662
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1663 while (!NILP (families))
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1664 {
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1665 /* TODO: Use the Unicode versions of the W32 APIs, so we can
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1666 handle non-ASCII font names. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1667 char *name;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1668 Lisp_Object family = CAR (families);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1669 families = CDR (families);
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1670 if (NILP (family))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1671 continue;
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1672 else if (SYMBOLP (family))
95341
5602389abb69 (compute_metrics): Rewrite an "else { if () ... else ... }"
Juanma Barranquero <lekktu@gmail.com>
parents: 95339
diff changeset
1673 name = SDATA (SYMBOL_NAME (family));
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1674 else
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1675 continue;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1676
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1677 strncpy (match_data->pattern.lfFaceName, name, LF_FACESIZE);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1678 match_data->pattern.lfFaceName[LF_FACESIZE - 1] = '\0';
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1679
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1680 EnumFontFamiliesEx (dc, &match_data->pattern,
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1681 (FONTENUMPROC) add_font_entity_to_list,
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1682 (LPARAM) match_data, 0);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1683 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1684
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1685 release_frame_dc (f, dc);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1686 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1687
91124
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1688 static Lisp_Object
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1689 lispy_antialias_type (type)
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1690 BYTE type;
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1691 {
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1692 Lisp_Object lispy;
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1693
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1694 switch (type)
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1695 {
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1696 case NONANTIALIASED_QUALITY:
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1697 lispy = Qnone;
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1698 break;
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1699 case ANTIALIASED_QUALITY:
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1700 lispy = Qstandard;
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1701 break;
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1702 case CLEARTYPE_QUALITY:
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1703 lispy = Qsubpixel;
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1704 break;
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1705 case CLEARTYPE_NATURAL_QUALITY:
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1706 lispy = Qnatural;
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1707 break;
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1708 default:
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1709 lispy = Qnil;
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1710 break;
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1711 }
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1712 return lispy;
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1713 }
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1714
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1715 /* Convert antialiasing symbols to lfQuality */
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1716 static BYTE
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1717 w32_antialias_type (type)
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1718 Lisp_Object type;
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1719 {
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1720 if (EQ (type, Qnone))
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1721 return NONANTIALIASED_QUALITY;
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1722 else if (EQ (type, Qstandard))
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1723 return ANTIALIASED_QUALITY;
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1724 else if (EQ (type, Qsubpixel))
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1725 return CLEARTYPE_QUALITY;
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1726 else if (EQ (type, Qnatural))
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1727 return CLEARTYPE_NATURAL_QUALITY;
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1728 else
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1729 return DEFAULT_QUALITY;
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1730 }
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
1731
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1732 /* Return a list of all the scripts that the font supports. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1733 static Lisp_Object
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1734 font_supported_scripts (FONTSIGNATURE * sig)
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1735 {
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1736 DWORD * subranges = sig->fsUsb;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1737 Lisp_Object supported = Qnil;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1738
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1739 /* Match a single subrange. SYM is set if bit N is set in subranges. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1740 #define SUBRANGE(n,sym) \
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1741 if (subranges[(n) / 32] & (1 << ((n) % 32))) \
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1742 supported = Fcons ((sym), supported)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1743
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1744 /* Match multiple subranges. SYM is set if any MASK bit is set in
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1745 subranges[0 - 3]. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1746 #define MASK_ANY(mask0,mask1,mask2,mask3,sym) \
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1747 if ((subranges[0] & (mask0)) || (subranges[1] & (mask1)) \
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1748 || (subranges[2] & (mask2)) || (subranges[3] & (mask3))) \
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1749 supported = Fcons ((sym), supported)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1750
93598
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1751 SUBRANGE (0, Qlatin);
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1752 /* The following count as latin too, ASCII should be present in these fonts,
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1753 so don't need to mark them separately. */
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1754 /* 1: Latin-1 supplement, 2: Latin Extended A, 3: Latin Extended B. */
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1755 SUBRANGE (4, Qphonetic);
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1756 /* 5: Spacing and tone modifiers, 6: Combining Diacriticals. */
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1757 SUBRANGE (7, Qgreek);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1758 SUBRANGE (8, Qcoptic);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1759 SUBRANGE (9, Qcyrillic);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1760 SUBRANGE (10, Qarmenian);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1761 SUBRANGE (11, Qhebrew);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1762 SUBRANGE (13, Qarabic);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1763 SUBRANGE (14, Qnko);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1764 SUBRANGE (15, Qdevanagari);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1765 SUBRANGE (16, Qbengali);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1766 SUBRANGE (17, Qgurmukhi);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1767 SUBRANGE (18, Qgujarati);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1768 SUBRANGE (19, Qoriya);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1769 SUBRANGE (20, Qtamil);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1770 SUBRANGE (21, Qtelugu);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1771 SUBRANGE (22, Qkannada);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1772 SUBRANGE (23, Qmalayalam);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1773 SUBRANGE (24, Qthai);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1774 SUBRANGE (25, Qlao);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1775 SUBRANGE (26, Qgeorgian);
93598
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1776 SUBRANGE (27, Qbalinese);
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1777 /* 28: Hangul Jamo. */
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1778 /* 29: Latin Extended, 30: Greek Extended, 31: Punctuation. */
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1779 /* 32-47: Symbols (defined below). */
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1780 SUBRANGE (48, Qcjk_misc);
93598
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1781 /* Match either 49: katakana or 50: hiragana for kana. */
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1782 MASK_ANY (0, 0x00060000, 0, 0, Qkana);
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1783 SUBRANGE (51, Qbopomofo);
93598
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1784 /* 52: Compatibility Jamo */
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1785 SUBRANGE (53, Qphags_pa);
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1786 /* 54: Enclosed CJK letters and months, 55: CJK Compatibility. */
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1787 SUBRANGE (56, Qhangul);
93598
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1788 /* 57: Surrogates. */
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1789 SUBRANGE (58, Qphoenician);
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1790 SUBRANGE (59, Qhan); /* There are others, but this is the main one. */
93598
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1791 SUBRANGE (59, Qideographic_description); /* Windows lumps this in. */
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1792 SUBRANGE (59, Qkanbun); /* And this. */
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1793 /* 60: Private use, 61: CJK strokes and compatibility. */
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1794 /* 62: Alphabetic Presentation, 63: Arabic Presentation A. */
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1795 /* 64: Combining half marks, 65: Vertical and CJK compatibility. */
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1796 /* 66: Small forms, 67: Arabic Presentation B, 68: Half and Full width. */
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1797 /* 69: Specials. */
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1798 SUBRANGE (70, Qtibetan);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1799 SUBRANGE (71, Qsyriac);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1800 SUBRANGE (72, Qthaana);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1801 SUBRANGE (73, Qsinhala);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1802 SUBRANGE (74, Qmyanmar);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1803 SUBRANGE (75, Qethiopic);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1804 SUBRANGE (76, Qcherokee);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1805 SUBRANGE (77, Qcanadian_aboriginal);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1806 SUBRANGE (78, Qogham);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1807 SUBRANGE (79, Qrunic);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1808 SUBRANGE (80, Qkhmer);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1809 SUBRANGE (81, Qmongolian);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1810 SUBRANGE (82, Qbraille);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1811 SUBRANGE (83, Qyi);
93598
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1812 SUBRANGE (84, Qbuhid);
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1813 SUBRANGE (84, Qhanunoo);
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1814 SUBRANGE (84, Qtagalog);
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1815 SUBRANGE (84, Qtagbanwa);
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1816 SUBRANGE (85, Qold_italic);
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1817 SUBRANGE (86, Qgothic);
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1818 SUBRANGE (87, Qdeseret);
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1819 SUBRANGE (88, Qbyzantine_musical_symbol);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1820 SUBRANGE (88, Qmusical_symbol); /* Windows doesn't distinguish these. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1821 SUBRANGE (89, Qmathematical);
93598
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1822 /* 90: Private use, 91: Variation selectors, 92: Tags. */
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1823 SUBRANGE (93, Qlimbu);
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1824 SUBRANGE (94, Qtai_le);
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1825 /* 95: New Tai Le */
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1826 SUBRANGE (90, Qbuginese);
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1827 SUBRANGE (97, Qglagolitic);
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1828 SUBRANGE (98, Qtifinagh);
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1829 /* 99: Yijing Hexagrams. */
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1830 SUBRANGE (100, Qsyloti_nagri);
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1831 SUBRANGE (101, Qlinear_b);
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1832 /* 102: Ancient Greek Numbers. */
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1833 SUBRANGE (103, Qugaritic);
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1834 SUBRANGE (104, Qold_persian);
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1835 SUBRANGE (105, Qshavian);
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1836 SUBRANGE (106, Qosmanya);
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1837 SUBRANGE (107, Qcypriot);
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1838 SUBRANGE (108, Qkharoshthi);
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1839 /* 109: Tai Xuan Jing. */
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1840 SUBRANGE (110, Qcuneiform);
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1841 /* 111: Counting Rods. */
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1842
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1843 /* There isn't really a main symbol range, so include symbol if any
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1844 relevant range is set. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1845 MASK_ANY (0x8000000, 0x0000FFFF, 0, 0, Qsymbol);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1846
93598
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
1847 /* Missing: Tai Viet (U+AA80) and Cham (U+AA00) . */
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1848 #undef SUBRANGE
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1849 #undef MASK_ANY
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1850
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1851 return supported;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1852 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1853
92390
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1854 /* Generate a full name for a Windows font.
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1855 The full name is in fcname format, with weight, slant and antialiasing
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1856 specified if they are not "normal". */
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1857 static int
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1858 w32font_full_name (font, font_obj, pixel_size, name, nbytes)
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1859 LOGFONT * font;
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1860 Lisp_Object font_obj;
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1861 int pixel_size;
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1862 char *name;
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1863 int nbytes;
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1864 {
92394
7701acfc2ec5 (w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents: 92390
diff changeset
1865 int len, height, outline;
92390
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1866 char *p;
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1867 Lisp_Object antialiasing, weight = Qnil;
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1868
92394
7701acfc2ec5 (w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents: 92390
diff changeset
1869 len = strlen (font->lfFaceName);
7701acfc2ec5 (w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents: 92390
diff changeset
1870
7701acfc2ec5 (w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents: 92390
diff changeset
1871 outline = EQ (AREF (font_obj, FONT_FOUNDRY_INDEX), Qoutline);
7701acfc2ec5 (w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents: 92390
diff changeset
1872
7701acfc2ec5 (w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents: 92390
diff changeset
1873 /* Represent size of scalable fonts by point size. But use pixelsize for
7701acfc2ec5 (w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents: 92390
diff changeset
1874 raster fonts to indicate that they are exactly that size. */
7701acfc2ec5 (w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents: 92390
diff changeset
1875 if (outline)
7701acfc2ec5 (w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents: 92390
diff changeset
1876 len += 11; /* -SIZE */
7701acfc2ec5 (w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents: 92390
diff changeset
1877 else
95894
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1878 len += 21;
92390
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1879
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1880 if (font->lfItalic)
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1881 len += 7; /* :italic */
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1882
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1883 if (font->lfWeight && font->lfWeight != FW_NORMAL)
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1884 {
96005
66f0213be62a Fix crashing bug in use of bold fonts from x-select-font on W32.
Jason Rumney <jasonr@gnu.org>
parents: 95894
diff changeset
1885 weight = w32_to_fc_weight (font->lfWeight);
66f0213be62a Fix crashing bug in use of bold fonts from x-select-font on W32.
Jason Rumney <jasonr@gnu.org>
parents: 95894
diff changeset
1886 len += 1 + SBYTES (SYMBOL_NAME (weight)); /* :WEIGHT */
92390
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1887 }
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1888
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1889 antialiasing = lispy_antialias_type (font->lfQuality);
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1890 if (! NILP (antialiasing))
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1891 len += 11 + SBYTES (SYMBOL_NAME (antialiasing)); /* :antialias=NAME */
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1892
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1893 /* Check that the buffer is big enough */
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1894 if (len > nbytes)
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1895 return -1;
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1896
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1897 p = name;
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1898 p += sprintf (p, "%s", font->lfFaceName);
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1899
92394
7701acfc2ec5 (w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents: 92390
diff changeset
1900 height = font->lfHeight ? eabs (font->lfHeight) : pixel_size;
7701acfc2ec5 (w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents: 92390
diff changeset
1901
7701acfc2ec5 (w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents: 92390
diff changeset
1902 if (height > 0)
7701acfc2ec5 (w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents: 92390
diff changeset
1903 {
7701acfc2ec5 (w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents: 92390
diff changeset
1904 if (outline)
7701acfc2ec5 (w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents: 92390
diff changeset
1905 {
7701acfc2ec5 (w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents: 92390
diff changeset
1906 float pointsize = height * 72.0 / one_w32_display_info.resy;
92712
fb1da73bc0c4 (w32font_full_name): Use floor to round.
Jason Rumney <jasonr@gnu.org>
parents: 92539
diff changeset
1907 /* Round to nearest half point. floor is used, since round is not
fb1da73bc0c4 (w32font_full_name): Use floor to round.
Jason Rumney <jasonr@gnu.org>
parents: 92539
diff changeset
1908 supported in MS library. */
fb1da73bc0c4 (w32font_full_name): Use floor to round.
Jason Rumney <jasonr@gnu.org>
parents: 92539
diff changeset
1909 pointsize = floor (pointsize * 2 + 0.5) / 2;
92394
7701acfc2ec5 (w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents: 92390
diff changeset
1910 p += sprintf (p, "-%1.1f", pointsize);
7701acfc2ec5 (w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents: 92390
diff changeset
1911 }
7701acfc2ec5 (w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents: 92390
diff changeset
1912 else
7701acfc2ec5 (w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents: 92390
diff changeset
1913 p += sprintf (p, ":pixelsize=%d", height);
7701acfc2ec5 (w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents: 92390
diff changeset
1914 }
92390
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1915
96005
66f0213be62a Fix crashing bug in use of bold fonts from x-select-font on W32.
Jason Rumney <jasonr@gnu.org>
parents: 95894
diff changeset
1916 if (SYMBOLP (weight) && ! NILP (weight))
66f0213be62a Fix crashing bug in use of bold fonts from x-select-font on W32.
Jason Rumney <jasonr@gnu.org>
parents: 95894
diff changeset
1917 p += sprintf (p, ":%s", SDATA (SYMBOL_NAME (weight)));
66f0213be62a Fix crashing bug in use of bold fonts from x-select-font on W32.
Jason Rumney <jasonr@gnu.org>
parents: 95894
diff changeset
1918
92390
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1919 if (font->lfItalic)
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1920 p += sprintf (p, ":italic");
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1921
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1922 if (SYMBOLP (antialiasing) && ! NILP (antialiasing))
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1923 p += sprintf (p, ":antialias=%s", SDATA (SYMBOL_NAME (antialiasing)));
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1924
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1925 return (p - name);
9b14fb0bae09 (w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 92199
diff changeset
1926 }
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1927
95894
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1928 /* Convert a logfont and point size into a fontconfig style font name.
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1929 POINTSIZE is in tenths of points.
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1930 If SIZE indicates the size of buffer FCNAME, into which the font name
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1931 is written. If the buffer is not large enough to contain the name,
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1932 the function returns -1, otherwise it returns the number of bytes
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1933 written to FCNAME. */
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1934 static int logfont_to_fcname(font, pointsize, fcname, size)
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1935 LOGFONT* font;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1936 int pointsize;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1937 char *fcname;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1938 int size;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1939 {
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1940 int len, height;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1941 char *p = fcname;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1942 Lisp_Object weight = Qnil;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1943
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1944 len = strlen (font->lfFaceName) + 2;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1945 height = pointsize / 10;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1946 while (height /= 10)
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1947 len++;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1948
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1949 if (pointsize % 10)
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1950 len += 2;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1951
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1952 if (font->lfItalic)
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1953 len += 7; /* :italic */
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1954 if (font->lfWeight && font->lfWeight != FW_NORMAL)
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1955 {
96005
66f0213be62a Fix crashing bug in use of bold fonts from x-select-font on W32.
Jason Rumney <jasonr@gnu.org>
parents: 95894
diff changeset
1956 weight = w32_to_fc_weight (font->lfWeight);
66f0213be62a Fix crashing bug in use of bold fonts from x-select-font on W32.
Jason Rumney <jasonr@gnu.org>
parents: 95894
diff changeset
1957 len += SBYTES (SYMBOL_NAME (weight)) + 1;
95894
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1958 }
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1959
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1960 if (len > size)
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1961 return -1;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1962
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1963 p += sprintf (p, "%s-%d", font->lfFaceName, pointsize / 10);
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1964 if (pointsize % 10)
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1965 p += sprintf (p, ".%d", pointsize % 10);
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1966
96005
66f0213be62a Fix crashing bug in use of bold fonts from x-select-font on W32.
Jason Rumney <jasonr@gnu.org>
parents: 95894
diff changeset
1967 if (SYMBOLP (weight) && !NILP (weight))
66f0213be62a Fix crashing bug in use of bold fonts from x-select-font on W32.
Jason Rumney <jasonr@gnu.org>
parents: 95894
diff changeset
1968 p += sprintf (p, ":%s", SDATA (SYMBOL_NAME (weight)));
66f0213be62a Fix crashing bug in use of bold fonts from x-select-font on W32.
Jason Rumney <jasonr@gnu.org>
parents: 95894
diff changeset
1969
95894
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1970 if (font->lfItalic)
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1971 p += sprintf (p, ":italic");
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1972
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1973 return (p - fcname);
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
1974 }
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
1975
95341
5602389abb69 (compute_metrics): Rewrite an "else { if () ... else ... }"
Juanma Barranquero <lekktu@gmail.com>
parents: 95339
diff changeset
1976 static void
5602389abb69 (compute_metrics): Rewrite an "else { if () ... else ... }"
Juanma Barranquero <lekktu@gmail.com>
parents: 95339
diff changeset
1977 compute_metrics (dc, w32_font, code, metrics)
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
1978 HDC dc;
92411
133560a77a09 (recompute_cached_metrics): Change font arg to w32font_info.
Jason Rumney <jasonr@gnu.org>
parents: 92409
diff changeset
1979 struct w32font_info *w32_font;
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1980 unsigned int code;
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1981 struct w32_metric_cache *metrics;
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
1982 {
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
1983 GLYPHMETRICS gm;
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
1984 MAT2 transform;
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1985 unsigned int options = GGO_METRICS;
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1986
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1987 if (w32_font->glyph_idx)
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1988 options |= GGO_GLYPH_INDEX;
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
1989
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
1990 bzero (&transform, sizeof (transform));
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
1991 transform.eM11.value = 1;
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
1992 transform.eM22.value = 1;
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
1993
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1994 if (GetGlyphOutlineW (dc, code, options, &gm, 0, NULL, &transform)
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1995 != GDI_ERROR)
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1996 {
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1997 metrics->lbearing = gm.gmptGlyphOrigin.x;
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1998 metrics->rbearing = gm.gmptGlyphOrigin.x + gm.gmBlackBoxX;
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
1999 metrics->width = gm.gmCellIncX;
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
2000 metrics->status = W32METRIC_SUCCESS;
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
2001 }
95341
5602389abb69 (compute_metrics): Rewrite an "else { if () ... else ... }"
Juanma Barranquero <lekktu@gmail.com>
parents: 95339
diff changeset
2002 else if (w32_font->glyph_idx)
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
2003 {
95341
5602389abb69 (compute_metrics): Rewrite an "else { if () ... else ... }"
Juanma Barranquero <lekktu@gmail.com>
parents: 95339
diff changeset
2004 /* Can't use glyph indexes after all.
5602389abb69 (compute_metrics): Rewrite an "else { if () ... else ... }"
Juanma Barranquero <lekktu@gmail.com>
parents: 95339
diff changeset
2005 Avoid it in future, and clear any metrics that were based on
5602389abb69 (compute_metrics): Rewrite an "else { if () ... else ... }"
Juanma Barranquero <lekktu@gmail.com>
parents: 95339
diff changeset
2006 glyph indexes. */
5602389abb69 (compute_metrics): Rewrite an "else { if () ... else ... }"
Juanma Barranquero <lekktu@gmail.com>
parents: 95339
diff changeset
2007 w32_font->glyph_idx = 0;
5602389abb69 (compute_metrics): Rewrite an "else { if () ... else ... }"
Juanma Barranquero <lekktu@gmail.com>
parents: 95339
diff changeset
2008 clear_cached_metrics (w32_font);
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
2009 }
95341
5602389abb69 (compute_metrics): Rewrite an "else { if () ... else ... }"
Juanma Barranquero <lekktu@gmail.com>
parents: 95339
diff changeset
2010 else
5602389abb69 (compute_metrics): Rewrite an "else { if () ... else ... }"
Juanma Barranquero <lekktu@gmail.com>
parents: 95339
diff changeset
2011 metrics->status = W32METRIC_FAIL;
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
2012 }
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
2013
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
2014 static void
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
2015 clear_cached_metrics (w32_font)
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
2016 struct w32font_info *w32_font;
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
2017 {
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
2018 int i;
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
2019 for (i = 0; i < w32_font->n_cache_blocks; i++)
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
2020 {
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
2021 if (w32_font->cached_metrics[i])
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
2022 bzero (w32_font->cached_metrics[i],
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
2023 CACHE_BLOCKSIZE * sizeof (struct font_metrics));
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
2024 }
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
2025 }
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
2026
95894
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2027 DEFUN ("x-select-font", Fx_select_font, Sx_select_font, 0, 2, 0,
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2028 doc: /* Read a font name using a W32 font selection dialog.
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2029 Return fontconfig style font string corresponding to the selection.
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2030
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2031 If FRAME is omitted or nil, it defaults to the selected frame.
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2032 If INCLUDE-PROPORTIONAL is non-nil, include proportional fonts
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2033 in the font selection dialog. */)
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2034 (frame, include_proportional)
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2035 Lisp_Object frame, include_proportional;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2036 {
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2037 FRAME_PTR f = check_x_frame (frame);
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2038 CHOOSEFONT cf;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2039 LOGFONT lf;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2040 TEXTMETRIC tm;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2041 HDC hdc;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2042 HANDLE oldobj;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2043 char buf[100];
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2044
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2045 bzero (&cf, sizeof (cf));
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2046 bzero (&lf, sizeof (lf));
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2047
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2048 cf.lStructSize = sizeof (cf);
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2049 cf.hwndOwner = FRAME_W32_WINDOW (f);
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2050 cf.Flags = CF_FORCEFONTEXIST | CF_SCREENFONTS | CF_NOVERTFONTS;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2051
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2052 /* Unless include_proportional is non-nil, limit the selection to
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2053 monospaced fonts. */
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2054 if (NILP (include_proportional))
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2055 cf.Flags |= CF_FIXEDPITCHONLY;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2056
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2057 cf.lpLogFont = &lf;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2058
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2059 /* Initialize as much of the font details as we can from the current
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2060 default font. */
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2061 hdc = GetDC (FRAME_W32_WINDOW (f));
96343
5c8f2b7d28ae * w32font.h (FONT_HANDLE, FONT_TEXTMETRIC): New macros.
Jason Rumney <jasonr@gnu.org>
parents: 96327
diff changeset
2062 oldobj = SelectObject (hdc, FONT_HANDLE (FRAME_FONT (f)));
95894
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2063 GetTextFace (hdc, LF_FACESIZE, lf.lfFaceName);
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2064 if (GetTextMetrics (hdc, &tm))
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2065 {
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2066 lf.lfHeight = tm.tmInternalLeading - tm.tmHeight;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2067 lf.lfWeight = tm.tmWeight;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2068 lf.lfItalic = tm.tmItalic;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2069 lf.lfUnderline = tm.tmUnderlined;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2070 lf.lfStrikeOut = tm.tmStruckOut;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2071 lf.lfCharSet = tm.tmCharSet;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2072 cf.Flags |= CF_INITTOLOGFONTSTRUCT;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2073 }
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2074 SelectObject (hdc, oldobj);
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2075 ReleaseDC (FRAME_W32_WINDOW (f), hdc);
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2076
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2077 if (!ChooseFont (&cf)
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2078 || logfont_to_fcname (&lf, cf.iPointSize, buf, 100) < 0)
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2079 return Qnil;
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2080
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2081 return build_string (buf);
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2082 }
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2083
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2084 struct font_driver w32font_driver =
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2085 {
90964
269d87dc10d9 (Qgdi): Rename from Qw32.
Jason Rumney <jasonr@gnu.org>
parents: 90933
diff changeset
2086 0, /* Qgdi */
94914
73c093f08fa0 Throughout the file, delete all USE_FONT_BACKEND
Kenichi Handa <handa@m17n.org>
parents: 94082
diff changeset
2087 0, /* case insensitive */
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2088 w32font_get_cache,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2089 w32font_list,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2090 w32font_match,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2091 w32font_list_family,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2092 NULL, /* free_entity */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2093 w32font_open,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2094 w32font_close,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2095 NULL, /* prepare_face */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2096 NULL, /* done_face */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2097 w32font_has_char,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2098 w32font_encode_char,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2099 w32font_text_extents,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2100 w32font_draw,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2101 NULL, /* get_bitmap */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2102 NULL, /* free_bitmap */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2103 NULL, /* get_outline */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2104 NULL, /* free_outline */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2105 NULL, /* anchor_point */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2106 NULL, /* otf_capability */
91158
5e7347695108 (w32font_driver): Add new fields.
Jason Rumney <jasonr@gnu.org>
parents: 91128
diff changeset
2107 NULL, /* otf_drive */
5e7347695108 (w32font_driver): Add new fields.
Jason Rumney <jasonr@gnu.org>
parents: 91128
diff changeset
2108 NULL, /* start_for_frame */
5e7347695108 (w32font_driver): Add new fields.
Jason Rumney <jasonr@gnu.org>
parents: 91128
diff changeset
2109 NULL, /* end_for_frame */
5e7347695108 (w32font_driver): Add new fields.
Jason Rumney <jasonr@gnu.org>
parents: 91128
diff changeset
2110 NULL /* shape */
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2111 };
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2112
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2113
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2114 /* Initialize state that does not change between invocations. This is only
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2115 called when Emacs is dumped. */
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
2116 void
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
2117 syms_of_w32font ()
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2118 {
90964
269d87dc10d9 (Qgdi): Rename from Qw32.
Jason Rumney <jasonr@gnu.org>
parents: 90933
diff changeset
2119 DEFSYM (Qgdi, "gdi");
92409
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
2120 DEFSYM (Quniscribe, "uniscribe");
8171649adf8a (Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 92394
diff changeset
2121 DEFSYM (QCformat, ":format");
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2122
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2123 /* Generic font families. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2124 DEFSYM (Qmonospace, "monospace");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2125 DEFSYM (Qserif, "serif");
91260
75f89f349f70 (w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents: 91259
diff changeset
2126 DEFSYM (Qsansserif, "sansserif");
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2127 DEFSYM (Qscript, "script");
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2128 DEFSYM (Qdecorative, "decorative");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2129 /* Aliases. */
91260
75f89f349f70 (w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents: 91259
diff changeset
2130 DEFSYM (Qsans_serif, "sans_serif");
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2131 DEFSYM (Qsans, "sans");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2132 DEFSYM (Qmono, "mono");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2133
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2134 /* Fake foundries. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2135 DEFSYM (Qraster, "raster");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2136 DEFSYM (Qoutline, "outline");
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2137 DEFSYM (Qunknown, "unknown");
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2138
91124
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
2139 /* Antialiasing. */
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
2140 DEFSYM (Qstandard, "standard");
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
2141 DEFSYM (Qsubpixel, "subpixel");
b656aee8436b (CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents: 91070
diff changeset
2142 DEFSYM (Qnatural, "natural");
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2143
93856
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
2144 /* Languages */
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
2145 DEFSYM (Qja, "ja");
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
2146 DEFSYM (Qko, "ko");
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
2147 DEFSYM (Qzh, "zh");
833bbf13f09d (Qja, Qko, Qzh): New symbols.
Jason Rumney <jasonr@gnu.org>
parents: 93675
diff changeset
2148
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2149 /* Scripts */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2150 DEFSYM (Qlatin, "latin");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2151 DEFSYM (Qgreek, "greek");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2152 DEFSYM (Qcoptic, "coptic");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2153 DEFSYM (Qcyrillic, "cyrillic");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2154 DEFSYM (Qarmenian, "armenian");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2155 DEFSYM (Qhebrew, "hebrew");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2156 DEFSYM (Qarabic, "arabic");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2157 DEFSYM (Qsyriac, "syriac");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2158 DEFSYM (Qnko, "nko");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2159 DEFSYM (Qthaana, "thaana");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2160 DEFSYM (Qdevanagari, "devanagari");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2161 DEFSYM (Qbengali, "bengali");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2162 DEFSYM (Qgurmukhi, "gurmukhi");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2163 DEFSYM (Qgujarati, "gujarati");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2164 DEFSYM (Qoriya, "oriya");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2165 DEFSYM (Qtamil, "tamil");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2166 DEFSYM (Qtelugu, "telugu");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2167 DEFSYM (Qkannada, "kannada");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2168 DEFSYM (Qmalayalam, "malayalam");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2169 DEFSYM (Qsinhala, "sinhala");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2170 DEFSYM (Qthai, "thai");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2171 DEFSYM (Qlao, "lao");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2172 DEFSYM (Qtibetan, "tibetan");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2173 DEFSYM (Qmyanmar, "myanmar");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2174 DEFSYM (Qgeorgian, "georgian");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2175 DEFSYM (Qhangul, "hangul");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2176 DEFSYM (Qethiopic, "ethiopic");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2177 DEFSYM (Qcherokee, "cherokee");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2178 DEFSYM (Qcanadian_aboriginal, "canadian-aboriginal");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2179 DEFSYM (Qogham, "ogham");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2180 DEFSYM (Qrunic, "runic");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2181 DEFSYM (Qkhmer, "khmer");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2182 DEFSYM (Qmongolian, "mongolian");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2183 DEFSYM (Qsymbol, "symbol");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2184 DEFSYM (Qbraille, "braille");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2185 DEFSYM (Qhan, "han");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2186 DEFSYM (Qideographic_description, "ideographic-description");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2187 DEFSYM (Qcjk_misc, "cjk-misc");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2188 DEFSYM (Qkana, "kana");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2189 DEFSYM (Qbopomofo, "bopomofo");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2190 DEFSYM (Qkanbun, "kanbun");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2191 DEFSYM (Qyi, "yi");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2192 DEFSYM (Qbyzantine_musical_symbol, "byzantine-musical-symbol");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2193 DEFSYM (Qmusical_symbol, "musical-symbol");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2194 DEFSYM (Qmathematical, "mathematical");
93598
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
2195 DEFSYM (Qphonetic, "phonetic");
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
2196 DEFSYM (Qbalinese, "balinese");
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
2197 DEFSYM (Qbuginese, "buginese");
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
2198 DEFSYM (Qbuhid, "buhid");
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
2199 DEFSYM (Qcuneiform, "cuneiform");
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
2200 DEFSYM (Qcypriot, "cypriot");
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
2201 DEFSYM (Qdeseret, "deseret");
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
2202 DEFSYM (Qglagolitic, "glagolitic");
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
2203 DEFSYM (Qgothic, "gothic");
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
2204 DEFSYM (Qhanunoo, "hanunoo");
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
2205 DEFSYM (Qkharoshthi, "kharoshthi");
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
2206 DEFSYM (Qlimbu, "limbu");
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
2207 DEFSYM (Qlinear_b, "linear_b");
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
2208 DEFSYM (Qold_italic, "old_italic");
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
2209 DEFSYM (Qold_persian, "old_persian");
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
2210 DEFSYM (Qosmanya, "osmanya");
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
2211 DEFSYM (Qphags_pa, "phags-pa");
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
2212 DEFSYM (Qphoenician, "phoenician");
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
2213 DEFSYM (Qshavian, "shavian");
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
2214 DEFSYM (Qsyloti_nagri, "syloti_nagri");
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
2215 DEFSYM (Qtagalog, "tagalog");
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
2216 DEFSYM (Qtagbanwa, "tagbanwa");
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
2217 DEFSYM (Qtai_le, "tai_le");
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
2218 DEFSYM (Qtifinagh, "tifinagh");
6b92cdd67bfb (Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot)
Jason Rumney <jasonr@gnu.org>
parents: 92712
diff changeset
2219 DEFSYM (Qugaritic, "ugaritic");
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
2220
95894
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2221 defsubr (&Sx_select_font);
76261fd18708 * w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents: 95846
diff changeset
2222
90964
269d87dc10d9 (Qgdi): Rename from Qw32.
Jason Rumney <jasonr@gnu.org>
parents: 90933
diff changeset
2223 w32font_driver.type = Qgdi;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2224 register_font_driver (&w32font_driver, NULL);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2225 }
90898
4d94a4dbcf99 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 90894
diff changeset
2226
4d94a4dbcf99 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 90894
diff changeset
2227 /* arch-tag: 65b8a3cd-46aa-4c0d-a1f3-99e75b9c07ee
4d94a4dbcf99 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 90894
diff changeset
2228 (do not change this comment) */