annotate src/w32font.c @ 91044:762f55e106a2

xdisp.c (get_char_face_and_encoding): Add extra args to FACE_FOR_CHAR. Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-260
author Miles Bader <miles@gnu.org>
date Fri, 12 Oct 2007 01:09:38 +0000
parents fe9053c62d68
children 2060802cc53f
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.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
2 Copyright (C) 2007 Free Software Foundation, Inc.
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
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
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
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
9 any later version.
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
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
19 Boston, MA 02110-1301, USA. */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
20
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
21 #include <config.h>
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
22 #include <windows.h>
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
23
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
24 #include "lisp.h"
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
25 #include "w32term.h"
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
26 #include "frame.h"
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
27 #include "dispextern.h"
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
28 #include "character.h"
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
29 #include "charset.h"
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
30 #include "fontset.h"
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
31 #include "font.h"
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
32
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
33 /* The actual structure for a w32 font, that can be cast to struct font. */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
34 struct w32font_info
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
35 {
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
36 struct font font;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
37 TEXTMETRIC metrics;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
38 };
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
39
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
40 extern struct font_driver w32font_driver;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
41
90964
269d87dc10d9 (Qgdi): Rename from Qw32.
Jason Rumney <jasonr@gnu.org>
parents: 90933
diff changeset
42 Lisp_Object Qgdi, QCfamily;
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
43 static Lisp_Object Qmonospace, Qsans_serif, Qserif, Qmono, Qsans, Qsans__serif;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
44 static Lisp_Object Qscript, Qdecorative, Qraster, Qoutline, Qunknown;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
45
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
46 /* scripts */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
47 static Lisp_Object Qlatin, Qgreek, Qcoptic, Qcyrillic, Qarmenian, Qhebrew;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
48 static Lisp_Object Qarabic, Qsyriac, Qnko, Qthaana, Qdevanagari, Qbengali;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
49 static Lisp_Object Qgurmukhi, Qgujarati, Qoriya, Qtamil, Qtelugu;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
50 static Lisp_Object Qkannada, Qmalayalam, Qsinhala, Qthai, Qlao;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
51 static Lisp_Object Qtibetan, Qmyanmar, Qgeorgian, Qhangul, Qethiopic;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
52 static Lisp_Object Qcherokee, Qcanadian_aboriginal, Qogham, Qrunic;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
53 static Lisp_Object Qkhmer, Qmongolian, Qsymbol, Qbraille, Qhan;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
54 static Lisp_Object Qideographic_description, Qcjk_misc, Qkana, Qbopomofo;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
55 static Lisp_Object Qkanbun, Qyi, Qbyzantine_musical_symbol;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
56 static Lisp_Object Qmusical_symbol, Qmathematical;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
57
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
58 /* Font spacing symbols - defined in font.c. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
59 extern Lisp_Object Qc, Qp, Qm;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
60
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
61 static void fill_in_logfont P_ ((FRAME_PTR f, LOGFONT *logfont,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
62 Lisp_Object font_spec));
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
63
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
64 static Lisp_Object font_supported_scripts P_ ((FONTSIGNATURE * sig));
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
65
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
66 /* From old font code in w32fns.c */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
67 char * w32_to_x_charset P_ ((int charset, char * matching));
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
68
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
69 static Lisp_Object w32_registry P_ ((LONG w32_charset));
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
70
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
71 /* EnumFontFamiliesEx callbacks. */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
72 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
73 NEWTEXTMETRICEX *,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
74 DWORD, LPARAM));
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
75 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
76 NEWTEXTMETRICEX *,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
77 DWORD, LPARAM));
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
78 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
79 NEWTEXTMETRICEX *,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
80 DWORD, LPARAM));
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
81
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
82 /* 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
83 of what we really want. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
84 struct font_callback_data
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
85 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
86 /* The logfont we are matching against. EnumFontFamiliesEx only matches
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
87 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
88 in the callback function. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
89 LOGFONT pattern;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
90 /* The original font spec or entity. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
91 Lisp_Object orig_font_spec;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
92 /* The frame the font is being loaded on. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
93 Lisp_Object frame;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
94 /* The list to add matches to. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
95 Lisp_Object list;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
96 };
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
97
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
98 /* Handles the problem that EnumFontFamiliesEx will not return all
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
99 style variations if the font name is not specified. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
100 static void list_all_matching_fonts P_ ((struct font_callback_data *match_data));
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
101
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
102
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
103 /* MingW headers only define this when _WIN32_WINNT >= 0x0500, but we
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
104 target older versions. */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
105 #define GGI_MARK_NONEXISTING_GLYPHS 1
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
106
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
107 static int
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
108 memq_no_quit (elt, list)
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
109 Lisp_Object elt, list;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
110 {
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
111 while (CONSP (list) && ! EQ (XCAR (list), elt))
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
112 list = XCDR (list);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
113 return (CONSP (list));
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
114 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
115
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
116 /* w32 implementation of get_cache for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
117 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
118 cons whose cdr part is the actual cache area. */
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
119 static Lisp_Object
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
120 w32font_get_cache (frame)
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
121 Lisp_Object frame;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
122 {
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
123 struct w32_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (XFRAME (frame));
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
124
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
125 return (dpyinfo->name_list_element);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
126 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
127
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
128 /* w32 implementation of list for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
129 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
130 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
131 allocates font-entities. */
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
132 static Lisp_Object
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
133 w32font_list (frame, font_spec)
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
134 Lisp_Object frame, font_spec;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
135 {
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
136 Lisp_Object tem;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
137 struct font_callback_data match_data;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
138 HDC dc;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
139 FRAME_PTR f = XFRAME (frame);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
140
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
141 match_data.orig_font_spec = font_spec;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
142 match_data.list = Qnil;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
143 match_data.frame = frame;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
144 bzero (&match_data.pattern, sizeof (LOGFONT));
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
145 fill_in_logfont (f, &match_data.pattern, font_spec);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
146
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
147 if (match_data.pattern.lfFaceName[0] == '\0')
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
148 {
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
149 /* EnumFontFamiliesEx does not take other fields into account if
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
150 font name is blank, so need to use two passes. */
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
151 list_all_matching_fonts (&match_data);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
152 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
153 else
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
154 {
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
155 dc = get_frame_dc (f);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
156
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
157 EnumFontFamiliesEx (dc, &match_data.pattern,
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
158 (FONTENUMPROC) add_font_entity_to_list,
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
159 (LPARAM) &match_data, 0);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
160 release_frame_dc (f, dc);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
161 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
162
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
163 return NILP (match_data.list) ? null_vector : Fvconcat (1, &match_data.list);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
164 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
165
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
166 /* w32 implementation of match for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
167 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
168 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
169 `face-font-selection-order' is ignored here. */
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
170 static Lisp_Object
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
171 w32font_match (frame, font_spec)
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
172 Lisp_Object frame, font_spec;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
173 {
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
174 struct font_callback_data match_data;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
175 HDC dc;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
176 FRAME_PTR f = XFRAME (frame);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
177
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
178 match_data.orig_font_spec = font_spec;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
179 match_data.frame = frame;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
180 match_data.list = Qnil;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
181 bzero (&match_data.pattern, sizeof (LOGFONT));
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
182 fill_in_logfont (f, &match_data.pattern, font_spec);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
183
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
184 dc = get_frame_dc (f);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
185
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
186 EnumFontFamiliesEx (dc, &match_data.pattern,
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
187 (FONTENUMPROC) add_one_font_entity_to_list,
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
188 (LPARAM) &match_data, 0);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
189 release_frame_dc (f, dc);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
190
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
191 return NILP (match_data.list) ? Qnil : XCAR (match_data.list);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
192 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
193
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 /* w32 implementation of list_family for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
196 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
197 (symbols). */
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
198 static Lisp_Object
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
199 w32font_list_family (frame)
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
200 Lisp_Object frame;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
201 {
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
202 Lisp_Object list = Qnil;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
203 LOGFONT font_match_pattern;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
204 HDC dc;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
205 FRAME_PTR f = XFRAME (frame);
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 bzero (&font_match_pattern, sizeof (font_match_pattern));
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
208
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
209 dc = get_frame_dc (f);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
210
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
211 EnumFontFamiliesEx (dc, &font_match_pattern,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
212 (FONTENUMPROC) add_font_name_to_list,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
213 (LPARAM) &list, 0);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
214 release_frame_dc (f, dc);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
215
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
216 return list;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
217 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
218
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
219 /* w32 implementation of open for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
220 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
221 If the font is scalable, open it with PIXEL_SIZE. */
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
222 static struct font *
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
223 w32font_open (f, font_entity, pixel_size)
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
224 FRAME_PTR f;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
225 Lisp_Object font_entity;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
226 int pixel_size;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
227 {
90879
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
228 int len, size;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
229 LOGFONT logfont;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
230 HDC dc;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
231 HFONT hfont, old_font;
90887
aa7f1d212e78 (font_put_extra): Expose externally.
Jason Rumney <jasonr@gnu.org>
parents: 90879
diff changeset
232 Lisp_Object val, extra;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
233 /* For backwards compatibility. */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
234 W32FontStruct *compat_w32_font;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
235
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
236 struct w32font_info *w32_font = xmalloc (sizeof (struct w32font_info));
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
237
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
238 struct font * font = (struct font *) w32_font;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
239 if (!font)
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
240 return NULL;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
241
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
242 bzero (&logfont, sizeof (logfont));
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
243 fill_in_logfont (f, &logfont, font_entity);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
244
90879
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
245 size = XINT (AREF (font_entity, FONT_SIZE_INDEX));
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
246 if (!size)
90879
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
247 size = pixel_size;
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
248
90894
2f6131d7643f (w32font_open): Make lfHeight negative.
Jason Rumney <jasonr@gnu.org>
parents: 90889
diff changeset
249 logfont.lfHeight = -size;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
250 hfont = CreateFontIndirect (&logfont);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
251
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
252 if (hfont == NULL)
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 xfree (w32_font);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
255 return NULL;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
256 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
257
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
258 /* Get the metrics for this font. */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
259 dc = get_frame_dc (f);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
260 old_font = SelectObject (dc, hfont);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
261
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
262 GetTextMetrics (dc, &w32_font->metrics);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
263
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
264 SelectObject (dc, old_font);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
265 release_frame_dc (f, dc);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
266 /* W32FontStruct - we should get rid of this, and use the w32font_info
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
267 struct for any W32 specific fields. font->font.font can then be hfont. */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
268 font->font.font = xmalloc (sizeof (W32FontStruct));
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
269 compat_w32_font = (W32FontStruct *) font->font.font;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
270 bzero (compat_w32_font, sizeof (W32FontStruct));
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
271 compat_w32_font->font_type = UNICODE_FONT;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
272 /* Duplicate the text metrics. */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
273 bcopy (&w32_font->metrics, &compat_w32_font->tm, sizeof (TEXTMETRIC));
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
274 compat_w32_font->hfont = hfont;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
275
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
276 len = strlen (logfont.lfFaceName);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
277 font->font.name = (char *) xmalloc (len + 1);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
278 bcopy (logfont.lfFaceName, font->font.name, len);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
279 font->font.name[len] = '\0';
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
280 font->font.full_name = font->font.name;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
281 font->font.charset = 0;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
282 font->font.codepage = 0;
90879
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
283 font->font.size = w32_font->metrics.tmMaxCharWidth;
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
284 font->font.height = w32_font->metrics.tmHeight
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
285 + w32_font->metrics.tmExternalLeading;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
286 font->font.space_width = font->font.average_width
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
287 = w32_font->metrics.tmAveCharWidth;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
288
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
289 font->font.vertical_centering = 0;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
290 font->font.encoding_type = 0;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
291 font->font.baseline_offset = 0;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
292 font->font.relative_compose = 0;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
293 font->font.default_ascent = w32_font->metrics.tmAscent;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
294 font->font.font_encoder = NULL;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
295 font->entity = font_entity;
90879
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
296 font->pixel_size = size;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
297 font->driver = &w32font_driver;
90964
269d87dc10d9 (Qgdi): Rename from Qw32.
Jason Rumney <jasonr@gnu.org>
parents: 90933
diff changeset
298 font->format = Qgdi;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
299 font->file_name = NULL;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
300 font->encoding_charset = -1;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
301 font->repertory_charset = -1;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
302 font->min_width = 0;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
303 font->ascent = w32_font->metrics.tmAscent;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
304 font->descent = w32_font->metrics.tmDescent;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
305 font->scalable = w32_font->metrics.tmPitchAndFamily & TMPF_VECTOR;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
306
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
307 return font;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
308 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
309
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
310 /* w32 implementation of close for font_backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
311 Close FONT on frame F. */
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
312 static void
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
313 w32font_close (f, font)
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
314 FRAME_PTR f;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
315 struct font *font;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
316 {
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
317 if (font->font.font)
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
318 {
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
319 W32FontStruct *old_w32_font = (W32FontStruct *)font->font.font;
90933
bd1251472ab9 (w32font_close): Delete the GDI font object.
Jason Rumney <jasonr@gnu.org>
parents: 90915
diff changeset
320 DeleteObject (old_w32_font->hfont);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
321 xfree (old_w32_font);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
322 font->font.font = 0;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
323 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
324
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
325 if (font->font.name)
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
326 xfree (font->font.name);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
327 xfree (font);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
328 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
329
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
330 /* w32 implementation of has_char for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
331 Optional.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
332 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
333 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
334 it, return -1. */
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
335 static int
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
336 w32font_has_char (entity, c)
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
337 Lisp_Object entity;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
338 int c;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
339 {
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
340 Lisp_Object supported_scripts, extra, script;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
341 DWORD mask;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
342
90887
aa7f1d212e78 (font_put_extra): Expose externally.
Jason Rumney <jasonr@gnu.org>
parents: 90879
diff changeset
343 extra = AREF (entity, FONT_EXTRA_INDEX);
aa7f1d212e78 (font_put_extra): Expose externally.
Jason Rumney <jasonr@gnu.org>
parents: 90879
diff changeset
344 if (!CONSP (extra))
aa7f1d212e78 (font_put_extra): Expose externally.
Jason Rumney <jasonr@gnu.org>
parents: 90879
diff changeset
345 return -1;
aa7f1d212e78 (font_put_extra): Expose externally.
Jason Rumney <jasonr@gnu.org>
parents: 90879
diff changeset
346
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
347 supported_scripts = assq_no_quit (QCscript, extra);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
348 if (!CONSP (supported_scripts))
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
349 return -1;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
350
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
351 supported_scripts = XCDR (supported_scripts);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
352
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
353 script = CHAR_TABLE_REF (Vchar_script_table, c);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
354
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
355 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
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 encode_char for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
359 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
360 If FONT doesn't have such a glyph, return FONT_INVALID_CODE. */
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
361 static unsigned
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
362 w32font_encode_char (font, c)
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
363 struct font *font;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
364 int c;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
365 {
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
366 /* Avoid unneccesary conversion - all the Win32 APIs will take a unicode
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
367 character. */
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
368 return c;
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
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
371 /* w32 implementation of text_extents for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
372 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
373 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
374 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
375 case just return the overall width. */
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
376 static int
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
377 w32font_text_extents (font, code, nglyphs, metrics)
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
378 struct font *font;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
379 unsigned *code;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
380 int nglyphs;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
381 struct font_metrics *metrics;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
382 {
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
383 int i;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
384 HFONT old_font;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
385 /* FIXME: Be nice if we had a frame here, rather than getting the desktop's
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
386 device context to measure against... */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
387 HDC dc = GetDC (NULL);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
388 int total_width = 0;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
389 WORD *wcode = alloca(nglyphs * sizeof (WORD));
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
390 SIZE size;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
391
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
392 old_font = SelectObject (dc, ((W32FontStruct *)(font->font.font))->hfont);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
393
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
394 if (metrics)
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
395 {
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
396 GLYPHMETRICS gm;
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
397 MAT2 transform;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
398
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
399 /* Set transform to the identity matrix. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
400 bzero (&transform, sizeof (transform));
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
401 transform.eM11.value = 1;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
402 transform.eM22.value = 1;
91034
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
403 metrics->width = 0;
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
404 metrics->ascent = 0;
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
405 metrics->descent = 0;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
406
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
407 for (i = 0; i < nglyphs; i++)
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
408 {
91034
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
409 if (GetGlyphOutlineW (dc, *(code + i), GGO_METRICS, &gm, 0,
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
410 NULL, &transform) != GDI_ERROR)
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
411 {
91034
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
412 int new_val = metrics->width + gm.gmBlackBoxX
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
413 + gm.gmptGlyphOrigin.x;
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
414
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
415 metrics->rbearing = max (metrics->rbearing, new_val);
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
416 metrics->width += gm.gmCellIncX;
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
417 new_val = -gm.gmptGlyphOrigin.y;
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
418 metrics->ascent = max (metrics->ascent, new_val);
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
419 new_val = gm.gmBlackBoxY + gm.gmptGlyphOrigin.y;
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
420 metrics->descent = max (metrics->descent, new_val);
90908
523a5c7f67ea (w32font_open): Don't set font_idx.
Jason Rumney <jasonr@gnu.org>
parents: 90906
diff changeset
421 }
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
422 else
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
423 {
91034
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
424 /* Rely on an estimate based on the overall font metrics. */
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
425 break;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
426 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
427 }
91034
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
428
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
429 /* 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
430 if (i == nglyphs)
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
431 {
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
432 /* Restore state and release DC. */
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
433 SelectObject (dc, old_font);
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
434 ReleaseDC (NULL, dc);
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
435
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
436 return metrics->width;
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
437 }
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
438 }
91034
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
439
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
440 for (i = 0; i < nglyphs; i++)
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
441 {
91034
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
442 if (code[i] < 0x10000)
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
443 wcode[i] = code[i];
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
444 else
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
445 {
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
446 /* TODO: Convert to surrogate, reallocating array if needed */
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
447 wcode[i] = 0xffff;
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
448 }
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
449 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
450
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
451 if (GetTextExtentPoint32W (dc, wcode, nglyphs, &size))
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
452 {
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
453 total_width = size.cx;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
454 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
455
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
456 if (!total_width)
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
457 {
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
458 RECT rect;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
459 rect.top = 0; rect.bottom = font->font.height; rect.left = 0; rect.right = 1;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
460 DrawTextW (dc, wcode, nglyphs, &rect,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
461 DT_CALCRECT | DT_NOPREFIX | DT_SINGLELINE);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
462 total_width = rect.right;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
463 }
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
464
91034
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
465 if (metrics)
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
466 {
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
467 metrics->width = total_width;
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
468 metrics->ascent = font->ascent;
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
469 metrics->descent = font->descent;
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
470 metrics->lbearing = 0;
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
471 metrics->rbearing = total_width
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
472 + ((struct w32font_info *) font)->metrics.tmOverhang;
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
473 }
fe9053c62d68 (w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents: 91030
diff changeset
474
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
475 /* Restore state and release DC. */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
476 SelectObject (dc, old_font);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
477 ReleaseDC (NULL, dc);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
478
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
479 return total_width;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
480 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
481
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
482 /* w32 implementation of draw for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
483 Optional.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
484 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
485 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
486 is nonzero, fill the background in advance. It is assured that
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
487 WITH_BACKGROUND is zero when (FROM > 0 || TO < S->nchars). */
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
488 static int
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
489 w32font_draw (s, from, to, x, y, with_background)
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
490 struct glyph_string *s;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
491 int from, to, x, y, with_background;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
492 {
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
493 UINT options = 0;
91030
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
494 HRGN orig_clip;
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
495
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
496 /* Save clip region for later restoration. */
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
497 GetClipRgn(s->hdc, orig_clip);
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
498
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
499 if (s->num_clips > 0)
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
500 {
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
501 HRGN new_clip = CreateRectRgnIndirect (s->clip);
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
502
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
503 if (s->num_clips > 1)
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
504 {
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
505 HRGN clip2 = CreateRectRgnIndirect (s->clip + 1);
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
506
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
507 CombineRgn (new_clip, new_clip, clip2, RGN_OR);
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
508 DeleteObject (clip2);
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
509 }
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
510
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
511 SelectClipRgn (s->hdc, new_clip);
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
512 DeleteObject (new_clip);
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
513 }
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
514
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
515 if (with_background)
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
516 {
91030
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
517 SetBkColor (s->hdc, s->gc->background);
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
518 SetBkMode (s->hdc, OPAQUE);
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
519 #if 0
90908
523a5c7f67ea (w32font_open): Don't set font_idx.
Jason Rumney <jasonr@gnu.org>
parents: 90906
diff changeset
520 HBRUSH brush;
523a5c7f67ea (w32font_open): Don't set font_idx.
Jason Rumney <jasonr@gnu.org>
parents: 90906
diff changeset
521 RECT rect;
523a5c7f67ea (w32font_open): Don't set font_idx.
Jason Rumney <jasonr@gnu.org>
parents: 90906
diff changeset
522
523a5c7f67ea (w32font_open): Don't set font_idx.
Jason Rumney <jasonr@gnu.org>
parents: 90906
diff changeset
523 brush = CreateSolidBrush (s->gc->background);
523a5c7f67ea (w32font_open): Don't set font_idx.
Jason Rumney <jasonr@gnu.org>
parents: 90906
diff changeset
524 rect.left = x;
523a5c7f67ea (w32font_open): Don't set font_idx.
Jason Rumney <jasonr@gnu.org>
parents: 90906
diff changeset
525 rect.top = y - ((struct font *) (s->font_info->font))->ascent;
523a5c7f67ea (w32font_open): Don't set font_idx.
Jason Rumney <jasonr@gnu.org>
parents: 90906
diff changeset
526 rect.right = x + s->width;
523a5c7f67ea (w32font_open): Don't set font_idx.
Jason Rumney <jasonr@gnu.org>
parents: 90906
diff changeset
527 rect.bottom = y + ((struct font *) (s->font_info->font))->descent;
523a5c7f67ea (w32font_open): Don't set font_idx.
Jason Rumney <jasonr@gnu.org>
parents: 90906
diff changeset
528 FillRect (s->hdc, &rect, brush);
90915
9aac5aff0dda (w32font_draw): Delete brush after using it.
Jason Rumney <jasonr@gnu.org>
parents: 90908
diff changeset
529 DeleteObject (brush);
91030
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
530 #endif
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
531 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
532 else
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
533 SetBkMode (s->hdc, TRANSPARENT);
90879
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
534
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
535 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
536
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
537 /* Restore clip region. */
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
538 if (s->num_clips > 0)
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
539 {
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
540 SelectClipRgn (s->hdc, orig_clip);
8be09e8e2c97 (w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents: 90964
diff changeset
541 }
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
542 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
543
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
544 /* w32 implementation of free_entity for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
545 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
546 Free FONT_EXTRA_INDEX field of FONT_ENTITY.
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
547 static void
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
548 w32font_free_entity (Lisp_Object entity);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
549 */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
550
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
551 /* w32 implementation of prepare_face for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
552 Optional (if FACE->extra is not used).
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
553 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
554 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
555 Otherwise, return -1.
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
556 static int
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
557 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
558 */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
559 /* w32 implementation of done_face for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
560 Optional.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
561 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
562 static void
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
563 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
564
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
565 /* w32 implementation of get_bitmap for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
566 Optional.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
567 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
568 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
569 for actual drawing.
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
570 static int
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
571 w32font_get_bitmap (struct font *font, unsigned code,
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
572 struct font_bitmap *bitmap, int bits_per_pixel);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
573 */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
574 /* w32 implementation of free_bitmap for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
575 Optional.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
576 Free bitmap data in BITMAP.
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
577 static void
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
578 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
579 */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
580 /* w32 implementation of get_outline for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
581 Optional.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
582 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
583 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
584 static void *
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
585 w32font_get_outline (struct font *font, unsigned code);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
586 */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
587 /* w32 implementation of free_outline for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
588 Optional.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
589 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
590 static void
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
591 w32font_free_outline (struct font *font, void *outline);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
592 */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
593 /* w32 implementation of anchor_point for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
594 Optional.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
595 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
596 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
597 the operations was successfull. Otherwise return -1.
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
598 static int
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
599 w32font_anchor_point (struct font *font, unsigned code,
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
600 int index, int *x, int *y);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
601 */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
602 /* w32 implementation of otf_capability for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
603 Optional.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
604 Return a list describing which scripts/languages FONT
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
605 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
606 static Lisp_Object
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
607 w32font_otf_capability (struct font *font);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
608 */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
609 /* w32 implementation of otf_drive for font backend.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
610 Optional.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
611 Apply FONT's OTF-FEATURES to the glyph string.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
612
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
613 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
614 (SCRIPT LANGSYS GSUB-FEATURE GPOS-FEATURE)
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
615 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
616
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
617 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
618 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
619 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
620 following elements.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
621
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
622 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
623 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
624 short, return -1.
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
625 static int
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
626 w32font_otf_drive (struct font *font, Lisp_Object features,
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
627 Lisp_Object gstring_in, int from, int to,
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
628 Lisp_Object gstring_out, int idx,
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
629 int alternate_subst);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
630 */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
631
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
632 /* Callback function for EnumFontFamiliesEx.
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
633 * 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
634 static int CALLBACK
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
635 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
636 ENUMLOGFONTEX *logical_font;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
637 NEWTEXTMETRICEX *physical_font;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
638 DWORD font_type;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
639 LPARAM list_object;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
640 {
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
641 Lisp_Object* list = (Lisp_Object *) list_object;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
642 Lisp_Object family = intern_downcase (logical_font->elfLogFont.lfFaceName,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
643 strlen (logical_font->elfLogFont.lfFaceName));
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
644 if (! memq_no_quit (family, *list))
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
645 *list = Fcons (family, *list);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
646
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
647 return 1;
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
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
650 /* 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
651 static Lisp_Object
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
652 w32_enumfont_pattern_entity (frame, logical_font, physical_font, font_type)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
653 Lisp_Object frame;
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
654 ENUMLOGFONTEX *logical_font;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
655 NEWTEXTMETRICEX *physical_font;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
656 DWORD font_type;
90869
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 Lisp_Object entity, tem;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
659 LOGFONT *lf = (LOGFONT*) logical_font;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
660 BYTE generic_type;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
661
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
662 entity = Fmake_vector (make_number (FONT_ENTITY_MAX), Qnil);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
663
90964
269d87dc10d9 (Qgdi): Rename from Qw32.
Jason Rumney <jasonr@gnu.org>
parents: 90933
diff changeset
664 ASET (entity, FONT_TYPE_INDEX, Qgdi);
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
665 ASET (entity, FONT_FRAME_INDEX, frame);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
666 ASET (entity, FONT_REGISTRY_INDEX, w32_registry (lf->lfCharSet));
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
667 ASET (entity, FONT_OBJLIST_INDEX, Qnil);
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 /* 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
670 But Emacs crashes if it is not set, so set it to something more
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
671 generic. Thes values make xflds compatible with Emacs 22. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
672 if (lf->lfOutPrecision == OUT_STRING_PRECIS)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
673 tem = Qraster;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
674 else if (lf->lfOutPrecision == OUT_STROKE_PRECIS)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
675 tem = Qoutline;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
676 else
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
677 tem = Qunknown;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
678
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
679 ASET (entity, FONT_FOUNDRY_INDEX, tem);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
680
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
681 /* 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
682 useful to users looking for a close match. */
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
683 generic_type = physical_font->ntmTm.tmPitchAndFamily & 0xF0;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
684 if (generic_type == FF_DECORATIVE)
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
685 tem = Qdecorative;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
686 else if (generic_type == FF_MODERN)
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
687 tem = Qmonospace;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
688 else if (generic_type == FF_ROMAN)
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
689 tem = Qserif;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
690 else if (generic_type == FF_SCRIPT)
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
691 tem = Qscript;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
692 else if (generic_type == FF_SWISS)
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
693 tem = Qsans_serif;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
694 else
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
695 tem = Qnil;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
696
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
697 if (! NILP (tem))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
698 font_put_extra (entity, QCfamily, tem);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
699
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
700
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
701 if (physical_font->ntmTm.tmPitchAndFamily & 0x01)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
702 font_put_extra (entity, QCspacing, make_number (FONT_SPACING_PROPORTIONAL));
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
703 else
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
704 font_put_extra (entity, QCspacing, make_number (FONT_SPACING_MONO));
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
705
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
706 ASET (entity, FONT_FAMILY_INDEX,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
707 intern_downcase (lf->lfFaceName, strlen (lf->lfFaceName)));
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
708
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
709 ASET (entity, FONT_WEIGHT_INDEX, make_number (lf->lfWeight));
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
710 ASET (entity, FONT_SLANT_INDEX, make_number (lf->lfItalic ? 200 : 100));
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
711 /* 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
712 to get it. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
713 ASET (entity, FONT_WIDTH_INDEX, make_number (100));
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
714
90879
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
715 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
716 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
717 else
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
718 ASET (entity, FONT_SIZE_INDEX, make_number (0));
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
719
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
720 /* 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
721 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
722 if (font_type & TRUETYPE_FONTTYPE)
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
723 {
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
724 font_put_extra (entity, QCscript,
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
725 font_supported_scripts (&physical_font->ntmFontSig));
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
726 }
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
727
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
728 return entity;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
729 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
730
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
731
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
732 /* Convert generic families to the family portion of lfPitchAndFamily. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
733 BYTE
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
734 w32_generic_family (Lisp_Object name)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
735 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
736 /* Generic families. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
737 if (EQ (name, Qmonospace) || EQ (name, Qmono))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
738 return FF_MODERN;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
739 else if (EQ (name, Qsans_serif) || EQ (name, Qsans__serif)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
740 || EQ (name, Qsans))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
741 return FF_SWISS;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
742 else if (EQ (name, Qserif))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
743 return FF_ROMAN;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
744 else if (EQ (name, Qdecorative))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
745 return FF_DECORATIVE;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
746 else if (EQ (name, Qscript))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
747 return FF_SCRIPT;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
748 else
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
749 return FF_DONTCARE;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
750 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
751
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
752 static int
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
753 logfonts_match (font, pattern)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
754 LOGFONT *font, *pattern;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
755 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
756 /* Only check height for raster fonts. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
757 if (pattern->lfHeight && font->lfOutPrecision == OUT_STRING_PRECIS
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
758 && font->lfHeight != pattern->lfHeight)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
759 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
760
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
761 /* Have some flexibility with weights. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
762 if (pattern->lfWeight
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
763 && ((font->lfWeight < (pattern->lfWeight - 150))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
764 || font->lfWeight > (pattern->lfWeight + 150)))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
765 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
766
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
767 /* 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
768 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
769 return 1;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
770 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
771
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
772 static int
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
773 font_matches_spec (type, font, spec)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
774 DWORD type;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
775 NEWTEXTMETRICEX *font;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
776 Lisp_Object spec;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
777 {
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
778 Lisp_Object extra, val;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
779
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
780 /* 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
781 so there is no difference between "non-italic" and "don't care". */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
782 val = AREF (spec, FONT_SLANT_INDEX);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
783 if (INTEGERP (val))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
784 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
785 int slant = XINT (val);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
786 if ((slant > 150 && !font->ntmTm.tmItalic)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
787 || (slant <= 150 && font->ntmTm.tmItalic))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
788 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
789 OutputDebugString ("italic mismatch");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
790 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
791 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
792 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
793
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
794 /* Check extra parameters. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
795 for (extra = AREF (spec, FONT_EXTRA_INDEX);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
796 CONSP (extra); extra = XCDR (extra))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
797 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
798 Lisp_Object extra_entry;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
799 extra_entry = XCAR (extra);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
800 if (CONSP (extra_entry))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
801 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
802 Lisp_Object key = XCAR (extra_entry);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
803 val = XCDR (extra_entry);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
804 if (EQ (key, QCfamily))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
805 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
806 /* Generic family. Most useful when there is no font name
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
807 specified. eg, if a script does not exist in the default
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
808 font, we could look for a font with the same generic family
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
809 that does support the script. Full PANOSE support would
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
810 be better, but we need to open the font to get that. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
811 BYTE w32_family = w32_generic_family (val);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
812
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
813 /* Reject if FF_DONTCARE is returned, as it means the
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
814 font spec is bad. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
815 if (w32_family == FF_DONTCARE
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
816 || w32_family != (font->ntmTm.tmPitchAndFamily & 0xF0))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
817 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
818 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
819 else if (EQ (key, QCspacing))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
820 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
821 int proportional;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
822 if (INTEGERP (val))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
823 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
824 int spacing = XINT (val);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
825 proportional = (spacing < FONT_SPACING_MONO);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
826 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
827 else if (EQ (val, Qp))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
828 proportional = 1;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
829 else if (EQ (val, Qc) || EQ (val, Qm))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
830 proportional = 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
831 else
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
832 return 0; /* Bad font spec. */
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
833
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
834 if ((proportional && !(font->ntmTm.tmPitchAndFamily & 0x01))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
835 || (!proportional && (font->ntmTm.tmPitchAndFamily & 0x01)))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
836 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
837 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
838 else if (EQ (key, QCscript) && SYMBOLP (val))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
839 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
840 /* Only truetype fonts will have information about what
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
841 scripts they support. This probably means the user
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
842 will have to force Emacs to use raster, postscript
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
843 or atm fonts for non-ASCII text. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
844 if (type & TRUETYPE_FONTTYPE)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
845 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
846 Lisp_Object support
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
847 = font_supported_scripts (&font->ntmFontSig);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
848 if (! memq_no_quit (val, support))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
849 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
850 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
851 else
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
852 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
853 /* Return specific matches, but play it safe. Fonts
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
854 that cover more than their charset would suggest
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
855 are likely to be truetype or opentype fonts,
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
856 covered above. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
857 if (EQ (val, Qlatin))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
858 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
859 /* Although every charset but symbol, thai and
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
860 arabic contains the basic ASCII set of latin
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
861 characters, Emacs expects much more. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
862 if (font->ntmTm.tmCharSet != ANSI_CHARSET)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
863 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
864 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
865 else if (EQ (val, Qsymbol))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
866 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
867 if (font->ntmTm.tmCharSet != SYMBOL_CHARSET)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
868 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
869 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
870 else if (EQ (val, Qcyrillic))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
871 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
872 if (font->ntmTm.tmCharSet != RUSSIAN_CHARSET)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
873 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
874 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
875 else if (EQ (val, Qgreek))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
876 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
877 if (font->ntmTm.tmCharSet != GREEK_CHARSET)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
878 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
879 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
880 else if (EQ (val, Qarabic))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
881 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
882 if (font->ntmTm.tmCharSet != ARABIC_CHARSET)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
883 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
884 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
885 else if (EQ (val, Qhebrew))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
886 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
887 if (font->ntmTm.tmCharSet != HEBREW_CHARSET)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
888 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
889 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
890 else if (EQ (val, Qthai))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
891 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
892 if (font->ntmTm.tmCharSet != THAI_CHARSET)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
893 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
894 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
895 else if (EQ (val, Qkana))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
896 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
897 if (font->ntmTm.tmCharSet != SHIFTJIS_CHARSET)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
898 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
899 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
900 else if (EQ (val, Qbopomofo))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
901 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
902 if (font->ntmTm.tmCharSet != CHINESEBIG5_CHARSET)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
903 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
904 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
905 else if (EQ (val, Qhangul))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
906 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
907 if (font->ntmTm.tmCharSet != HANGUL_CHARSET
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
908 && font->ntmTm.tmCharSet != JOHAB_CHARSET)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
909 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
910 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
911 else if (EQ (val, Qhan))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
912 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
913 if (font->ntmTm.tmCharSet != CHINESEBIG5_CHARSET
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
914 && font->ntmTm.tmCharSet != GB2312_CHARSET
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
915 && font->ntmTm.tmCharSet != HANGUL_CHARSET
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
916 && font->ntmTm.tmCharSet != JOHAB_CHARSET
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
917 && font->ntmTm.tmCharSet != SHIFTJIS_CHARSET)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
918 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
919 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
920 else
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
921 /* Other scripts unlikely to be handled. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
922 return 0;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
923 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
924 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
925 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
926 }
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
927 return 1;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
928 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
929
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
930 /* Callback function for EnumFontFamiliesEx.
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
931 * 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
932 * 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
933 * 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
934 * 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
935 static int CALLBACK
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
936 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
937 ENUMLOGFONTEX *logical_font;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
938 NEWTEXTMETRICEX *physical_font;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
939 DWORD font_type;
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
940 LPARAM lParam;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
941 {
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
942 struct font_callback_data *match_data
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
943 = (struct font_callback_data *) lParam;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
944
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
945 if (logfonts_match (&logical_font->elfLogFont, &match_data->pattern)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
946 && font_matches_spec (font_type, physical_font,
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
947 match_data->orig_font_spec))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
948 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
949 Lisp_Object entity
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
950 = w32_enumfont_pattern_entity (match_data->frame, logical_font,
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
951 physical_font, font_type);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
952 if (!NILP (entity))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
953 match_data->list = Fcons (entity, match_data->list);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
954 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
955 return 1;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
956 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
957
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
958 /* Callback function for EnumFontFamiliesEx.
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
959 * Terminates the search once we have a match. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
960 static int CALLBACK
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
961 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
962 ENUMLOGFONTEX *logical_font;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
963 NEWTEXTMETRICEX *physical_font;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
964 DWORD font_type;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
965 LPARAM lParam;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
966 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
967 struct font_callback_data *match_data
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
968 = (struct font_callback_data *) lParam;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
969 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
970
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
971 /* 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
972 return !NILP (match_data->list);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
973 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
974
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
975 /* 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
976 static LONG
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
977 registry_to_w32_charset (charset)
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
978 Lisp_Object charset;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
979 {
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
980 if (EQ (charset, Qiso10646_1) || EQ (charset, Qunicode_bmp)
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
981 || EQ (charset, Qunicode_sip))
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
982 return DEFAULT_CHARSET; /* UNICODE_CHARSET not defined in MingW32 */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
983 else if (EQ (charset, Qiso8859_1))
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
984 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
985 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
986 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
987 else if (STRINGP (charset))
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
988 return x_to_w32_charset (SDATA (charset));
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
989 else
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
990 return DEFAULT_CHARSET;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
991 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
992
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
993 static Lisp_Object
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
994 w32_registry (w32_charset)
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
995 LONG w32_charset;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
996 {
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
997 if (w32_charset == ANSI_CHARSET)
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
998 return Qiso10646_1;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
999 else
90879
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
1000 {
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
1001 char * charset = w32_to_x_charset (w32_charset, NULL);
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
1002 return intern_downcase (charset, strlen(charset));
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
1003 }
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1004 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1005
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1006 /* 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
1007 static void
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
1008 fill_in_logfont (f, logfont, font_spec)
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
1009 FRAME_PTR f;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
1010 LOGFONT *logfont;
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
1011 Lisp_Object font_spec;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1012 {
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1013 Lisp_Object tmp, extra;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1014 int dpi = FRAME_W32_DISPLAY_INFO (f)->resy;
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1015
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1016 extra = AREF (font_spec, FONT_EXTRA_INDEX);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1017 /* Allow user to override dpi settings. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1018 if (CONSP (extra))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1019 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1020 tmp = assq_no_quit (QCdpi, extra);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1021 if (CONSP (tmp) && INTEGERP (XCDR (tmp)))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1022 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1023 dpi = XINT (XCDR (tmp));
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1024 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1025 else if (CONSP (tmp) && FLOATP (XCDR (tmp)))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1026 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1027 dpi = (int) (XFLOAT_DATA (XCDR (tmp)) + 0.5);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1028 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1029 }
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1030
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1031 /* Height */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1032 tmp = AREF (font_spec, FONT_SIZE_INDEX);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1033 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
1034 logfont->lfHeight = -1 * XINT (tmp);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1035 else if (FLOATP (tmp))
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1036 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
1037
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1038 /* Escapement */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1039
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1040 /* Orientation */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1041
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1042 /* Weight */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1043 tmp = AREF (font_spec, FONT_WEIGHT_INDEX);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1044 if (INTEGERP (tmp))
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1045 logfont->lfWeight = XINT (tmp);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1046
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1047 /* Italic */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1048 tmp = AREF (font_spec, FONT_SLANT_INDEX);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1049 if (INTEGERP (tmp))
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1050 {
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1051 int slant = XINT (tmp);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1052 logfont->lfItalic = slant > 150 ? 1 : 0;
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
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1055 /* Underline */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1056
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1057 /* Strikeout */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1058
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1059 /* Charset */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1060 tmp = AREF (font_spec, FONT_REGISTRY_INDEX);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1061 if (! NILP (tmp))
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1062 logfont->lfCharSet = registry_to_w32_charset (tmp);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1063
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1064 /* Out Precision */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1065 /* Clip Precision */
90879
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
1066 /* Quality TODO: Allow different quality to be specified, so user
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
1067 can enable/disable anti-aliasing for individual fonts. */
82b86c925f88 * w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents: 90869
diff changeset
1068 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
1069
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1070 /* Generic Family and Face Name */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1071 logfont->lfPitchAndFamily = FF_DONTCARE | DEFAULT_PITCH;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1072
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1073 tmp = AREF (font_spec, FONT_FAMILY_INDEX);
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1074 if (! NILP (tmp))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1075 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1076 logfont->lfPitchAndFamily = w32_generic_family (tmp) | DEFAULT_PITCH;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1077 if ((logfont->lfPitchAndFamily & 0xF0) != FF_DONTCARE)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1078 ; /* Font name was generic, don't fill in font name. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1079 /* 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
1080 user input. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1081 else if (SYMBOLP (tmp))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1082 strncpy (logfont->lfFaceName, SDATA (SYMBOL_NAME (tmp)), LF_FACESIZE);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1083 else if (STRINGP (tmp))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1084 strncpy (logfont->lfFaceName, SDATA (tmp), LF_FACESIZE);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1085 }
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1086
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1087 /* Process EXTRA info. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1088 for ( ; CONSP (extra); extra = XCDR (extra))
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 tmp = XCAR (extra);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1091 if (CONSP (tmp))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1092 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1093 Lisp_Object key, val;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1094 key = XCAR (tmp), val = XCDR (tmp);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1095 if (EQ (key, QCfamily))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1096 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1097 /* Override generic family. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1098 BYTE family = w32_generic_family (val);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1099 if (family != FF_DONTCARE)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1100 logfont->lfPitchAndFamily
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1101 = logfont->lfPitchAndFamily & 0x0F | family;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1102 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1103 else if (EQ (key, QCspacing))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1104 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1105 /* Set pitch based on the spacing property. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1106 if (INTEGERP (val))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1107 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1108 int spacing = XINT (val);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1109 if (spacing < FONT_SPACING_MONO)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1110 logfont->lfPitchAndFamily
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1111 = logfont->lfPitchAndFamily & 0xF0 | VARIABLE_PITCH;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1112 else
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1113 logfont->lfPitchAndFamily
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1114 = logfont->lfPitchAndFamily & 0xF0 | FIXED_PITCH;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1115 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1116 else if (EQ (val, Qp))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1117 logfont->lfPitchAndFamily
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1118 = logfont->lfPitchAndFamily & 0xF0 | VARIABLE_PITCH;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1119 else if (EQ (val, Qc) || EQ (val, Qm))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1120 logfont->lfPitchAndFamily
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1121 = logfont->lfPitchAndFamily & 0xF0 | FIXED_PITCH;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1122 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1123 /* 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
1124 and a single script is specified. This is rather crude,
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1125 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
1126 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
1127 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
1128 them. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1129 else if (EQ (key, QCscript)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1130 && logfont->lfCharSet == DEFAULT_CHARSET
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1131 && SYMBOLP (val))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1132 {
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1133 if (EQ (val, Qgreek))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1134 logfont->lfCharSet = GREEK_CHARSET;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1135 else if (EQ (val, Qhangul))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1136 logfont->lfCharSet = HANGUL_CHARSET;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1137 else if (EQ (val, Qkana) || EQ (val, Qkanbun))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1138 logfont->lfCharSet = SHIFTJIS_CHARSET;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1139 else if (EQ (val, Qbopomofo))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1140 logfont->lfCharSet = CHINESEBIG5_CHARSET;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1141 /* GB 18030 supports tibetan, yi, mongolian,
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1142 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
1143 GB2312 fonts. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1144 else if (EQ (val, Qtibetan) || EQ (val, Qyi)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1145 || EQ (val, Qmongolian))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1146 logfont->lfCharSet = GB2312_CHARSET;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1147 else if (EQ (val, Qhebrew))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1148 logfont->lfCharSet = HEBREW_CHARSET;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1149 else if (EQ (val, Qarabic))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1150 logfont->lfCharSet = ARABIC_CHARSET;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1151 else if (EQ (val, Qthai))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1152 logfont->lfCharSet = THAI_CHARSET;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1153 else if (EQ (val, Qsymbol))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1154 logfont->lfCharSet = SYMBOL_CHARSET;
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 }
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1157 }
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1158 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1159
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
1160 static void
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1161 list_all_matching_fonts (match_data)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1162 struct font_callback_data *match_data;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1163 {
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1164 HDC dc;
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1165 Lisp_Object families = w32font_list_family (match_data->frame);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1166 struct frame *f = XFRAME (match_data->frame);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1167
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1168 dc = get_frame_dc (f);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1169
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1170 while (!NILP (families))
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1171 {
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1172 /* 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
1173 handle non-ASCII font names. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1174 char *name;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1175 Lisp_Object family = CAR (families);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1176 families = CDR (families);
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1177 if (NILP (family))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1178 continue;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1179 else if (STRINGP (family))
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1180 name = SDATA (family);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1181 else
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1182 name = SDATA (SYMBOL_NAME (family));
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1183
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1184 strncpy (match_data->pattern.lfFaceName, name, LF_FACESIZE);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1185 match_data->pattern.lfFaceName[LF_FACESIZE - 1] = '\0';
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1186
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1187 EnumFontFamiliesEx (dc, &match_data->pattern,
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1188 (FONTENUMPROC) add_font_entity_to_list,
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1189 (LPARAM) match_data, 0);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1190 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1191
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1192 release_frame_dc (f, dc);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1193 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1194
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1195 /* 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
1196 static Lisp_Object
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1197 font_supported_scripts (FONTSIGNATURE * sig)
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1198 {
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1199 DWORD * subranges = sig->fsUsb;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1200 Lisp_Object supported = Qnil;
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1201
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1202 /* 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
1203 #define SUBRANGE(n,sym) \
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1204 if (subranges[(n) / 32] & (1 << ((n) % 32))) \
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1205 supported = Fcons ((sym), supported)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1206
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1207 /* 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
1208 subranges[0 - 3]. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1209 #define MASK_ANY(mask0,mask1,mask2,mask3,sym) \
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1210 if ((subranges[0] & (mask0)) || (subranges[1] & (mask1)) \
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1211 || (subranges[2] & (mask2)) || (subranges[3] & (mask3))) \
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1212 supported = Fcons ((sym), supported)
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1213
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1214 SUBRANGE (0, Qlatin); /* There are many others... */
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 SUBRANGE (7, Qgreek);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1217 SUBRANGE (8, Qcoptic);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1218 SUBRANGE (9, Qcyrillic);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1219 SUBRANGE (10, Qarmenian);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1220 SUBRANGE (11, Qhebrew);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1221 SUBRANGE (13, Qarabic);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1222 SUBRANGE (14, Qnko);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1223 SUBRANGE (15, Qdevanagari);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1224 SUBRANGE (16, Qbengali);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1225 SUBRANGE (17, Qgurmukhi);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1226 SUBRANGE (18, Qgujarati);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1227 SUBRANGE (19, Qoriya);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1228 SUBRANGE (20, Qtamil);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1229 SUBRANGE (21, Qtelugu);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1230 SUBRANGE (22, Qkannada);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1231 SUBRANGE (23, Qmalayalam);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1232 SUBRANGE (24, Qthai);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1233 SUBRANGE (25, Qlao);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1234 SUBRANGE (26, Qgeorgian);
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1235
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1236 SUBRANGE (48, Qcjk_misc);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1237 SUBRANGE (51, Qbopomofo);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1238 SUBRANGE (54, Qkanbun); /* Is this right? */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1239 SUBRANGE (56, Qhangul);
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 SUBRANGE (59, Qhan); /* There are others, but this is the main one. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1242 SUBRANGE (59, Qideographic_description); /* Windows lumps this in */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1243
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1244 SUBRANGE (70, Qtibetan);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1245 SUBRANGE (71, Qsyriac);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1246 SUBRANGE (72, Qthaana);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1247 SUBRANGE (73, Qsinhala);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1248 SUBRANGE (74, Qmyanmar);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1249 SUBRANGE (75, Qethiopic);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1250 SUBRANGE (76, Qcherokee);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1251 SUBRANGE (77, Qcanadian_aboriginal);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1252 SUBRANGE (78, Qogham);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1253 SUBRANGE (79, Qrunic);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1254 SUBRANGE (80, Qkhmer);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1255 SUBRANGE (81, Qmongolian);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1256 SUBRANGE (82, Qbraille);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1257 SUBRANGE (83, Qyi);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1258
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1259 SUBRANGE (88, Qbyzantine_musical_symbol);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1260 SUBRANGE (88, Qmusical_symbol); /* Windows doesn't distinguish these. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1261
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1262 SUBRANGE (89, Qmathematical);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1263
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1264 /* Match either katakana or hiragana for kana. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1265 MASK_ANY (0, 0x00060000, 0, 0, Qkana);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1266
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1267 /* 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
1268 relevant range is set. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1269 MASK_ANY (0x8000000, 0x0000FFFF, 0, 0, Qsymbol);
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1270
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1271 #undef SUBRANGE
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1272 #undef MASK_ANY
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1273
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1274 return supported;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1275 }
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1276
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1277
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1278 struct font_driver w32font_driver =
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1279 {
90964
269d87dc10d9 (Qgdi): Rename from Qw32.
Jason Rumney <jasonr@gnu.org>
parents: 90933
diff changeset
1280 0, /* Qgdi */
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1281 w32font_get_cache,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1282 w32font_list,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1283 w32font_match,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1284 w32font_list_family,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1285 NULL, /* free_entity */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1286 w32font_open,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1287 w32font_close,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1288 NULL, /* prepare_face */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1289 NULL, /* done_face */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1290 w32font_has_char,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1291 w32font_encode_char,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1292 w32font_text_extents,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1293 w32font_draw,
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1294 NULL, /* get_bitmap */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1295 NULL, /* free_bitmap */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1296 NULL, /* get_outline */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1297 NULL, /* free_outline */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1298 NULL, /* anchor_point */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1299 NULL, /* otf_capability */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1300 NULL /* otf_drive */
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1301 };
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1302
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1303
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1304 /* 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
1305 called when Emacs is dumped. */
90889
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
1306 void
0df73c71020b * w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents: 90887
diff changeset
1307 syms_of_w32font ()
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1308 {
90964
269d87dc10d9 (Qgdi): Rename from Qw32.
Jason Rumney <jasonr@gnu.org>
parents: 90933
diff changeset
1309 DEFSYM (Qgdi, "gdi");
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1310
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1311 /* Generic font families. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1312 DEFSYM (Qmonospace, "monospace");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1313 DEFSYM (Qserif, "serif");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1314 DEFSYM (Qsans_serif, "sans-serif");
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1315 DEFSYM (Qscript, "script");
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1316 DEFSYM (Qdecorative, "decorative");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1317 /* Aliases. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1318 DEFSYM (Qsans__serif, "sans_serif");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1319 DEFSYM (Qsans, "sans");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1320 DEFSYM (Qmono, "mono");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1321
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1322 /* Fake foundries. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1323 DEFSYM (Qraster, "raster");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1324 DEFSYM (Qoutline, "outline");
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1325 DEFSYM (Qunknown, "unknown");
90906
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1326
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1327 /* Indexes for extra info. */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1328 DEFSYM (QCfamily, ":family");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1329
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1330 /* Scripts */
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1331 DEFSYM (Qlatin, "latin");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1332 DEFSYM (Qgreek, "greek");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1333 DEFSYM (Qcoptic, "coptic");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1334 DEFSYM (Qcyrillic, "cyrillic");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1335 DEFSYM (Qarmenian, "armenian");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1336 DEFSYM (Qhebrew, "hebrew");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1337 DEFSYM (Qarabic, "arabic");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1338 DEFSYM (Qsyriac, "syriac");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1339 DEFSYM (Qnko, "nko");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1340 DEFSYM (Qthaana, "thaana");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1341 DEFSYM (Qdevanagari, "devanagari");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1342 DEFSYM (Qbengali, "bengali");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1343 DEFSYM (Qgurmukhi, "gurmukhi");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1344 DEFSYM (Qgujarati, "gujarati");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1345 DEFSYM (Qoriya, "oriya");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1346 DEFSYM (Qtamil, "tamil");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1347 DEFSYM (Qtelugu, "telugu");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1348 DEFSYM (Qkannada, "kannada");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1349 DEFSYM (Qmalayalam, "malayalam");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1350 DEFSYM (Qsinhala, "sinhala");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1351 DEFSYM (Qthai, "thai");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1352 DEFSYM (Qlao, "lao");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1353 DEFSYM (Qtibetan, "tibetan");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1354 DEFSYM (Qmyanmar, "myanmar");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1355 DEFSYM (Qgeorgian, "georgian");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1356 DEFSYM (Qhangul, "hangul");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1357 DEFSYM (Qethiopic, "ethiopic");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1358 DEFSYM (Qcherokee, "cherokee");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1359 DEFSYM (Qcanadian_aboriginal, "canadian-aboriginal");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1360 DEFSYM (Qogham, "ogham");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1361 DEFSYM (Qrunic, "runic");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1362 DEFSYM (Qkhmer, "khmer");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1363 DEFSYM (Qmongolian, "mongolian");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1364 DEFSYM (Qsymbol, "symbol");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1365 DEFSYM (Qbraille, "braille");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1366 DEFSYM (Qhan, "han");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1367 DEFSYM (Qideographic_description, "ideographic-description");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1368 DEFSYM (Qcjk_misc, "cjk-misc");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1369 DEFSYM (Qkana, "kana");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1370 DEFSYM (Qbopomofo, "bopomofo");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1371 DEFSYM (Qkanbun, "kanbun");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1372 DEFSYM (Qyi, "yi");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1373 DEFSYM (Qbyzantine_musical_symbol, "byzantine-musical-symbol");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1374 DEFSYM (Qmusical_symbol, "musical-symbol");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1375 DEFSYM (Qmathematical, "mathematical");
f8694254fa1d (w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents: 90898
diff changeset
1376
90964
269d87dc10d9 (Qgdi): Rename from Qw32.
Jason Rumney <jasonr@gnu.org>
parents: 90933
diff changeset
1377 w32font_driver.type = Qgdi;
90869
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1378 register_font_driver (&w32font_driver, NULL);
9a1ccf2dfd96 New file for w32 font backend.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1379 }
90898
4d94a4dbcf99 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 90894
diff changeset
1380
4d94a4dbcf99 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 90894
diff changeset
1381 /* arch-tag: 65b8a3cd-46aa-4c0d-a1f3-99e75b9c07ee
4d94a4dbcf99 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 90894
diff changeset
1382 (do not change this comment) */