annotate src/w32uniscribe.c @ 111951:027c7b917c8a

* net/gnutls.el (gnutls-negotiate): Fix setting of default trustfiles.
author Romain Francoise <romain@orebokech.com>
date Mon, 13 Dec 2010 23:20:32 +0100
parents b8fde5ef9e14
children 417b1e4d63cd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
1 /* Font backend for the Microsoft W32 Uniscribe API.
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105669
diff changeset
2 Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
3
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
4 This file is part of GNU Emacs.
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
5
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94911
diff changeset
6 GNU Emacs is free software: you can redistribute it and/or modify
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94911
diff changeset
8 the Free Software Foundation, either version 3 of the License, or
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94911
diff changeset
9 (at your option) any later version.
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
10
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
14 GNU General Public License for more details.
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
15
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94911
diff changeset
17 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
18
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
19
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
20 #include <config.h>
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
21 /* Override API version - Uniscribe is only available as standard since
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
22 Windows 2000, though most users of older systems will have it
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
23 since it installs with Internet Explorer 5.0 and other software.
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
24 We only enable the feature if it is available, so there is no chance
106837
855f55740303 Fix typos in comments.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
25 of calling non-existent functions. */
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
26 #undef _WIN32_WINNT
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
27 #define _WIN32_WINNT 0x500
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
28 #include <windows.h>
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
29 #include <usp10.h>
105669
68dd71358159 * alloc.c: Do not define struct catchtag.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 103544
diff changeset
30 #include <setjmp.h>
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
31
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
32 #include "lisp.h"
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
33 #include "w32term.h"
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
34 #include "frame.h"
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
35 #include "dispextern.h"
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
36 #include "character.h"
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
37 #include "charset.h"
97832
e33a2e6c1dab (struct uniscribe_font_info): Include composite.h.
Kenichi Handa <handa@m17n.org>
parents: 97135
diff changeset
38 #include "composite.h"
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
39 #include "fontset.h"
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
40 #include "font.h"
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
41 #include "w32font.h"
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
42
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
43 struct uniscribe_font_info
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
44 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
45 struct w32font_info w32_font;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
46 SCRIPT_CACHE cache;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
47 };
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
48
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
49 int uniscribe_available = 0;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
50
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
51 /* Defined in w32font.c, since it is required there as well. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
52 extern Lisp_Object Quniscribe;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
53 extern Lisp_Object Qopentype;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
54
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
55 extern int initialized;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
56
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
57 extern struct font_driver uniscribe_font_driver;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
58
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
59 /* EnumFontFamiliesEx callback. */
109100
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 107246
diff changeset
60 static int CALLBACK add_opentype_font_name_to_list (ENUMLOGFONTEX *,
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 107246
diff changeset
61 NEWTEXTMETRICEX *,
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 107246
diff changeset
62 DWORD, LPARAM);
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
63 /* Used by uniscribe_otf_capability. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
64 static Lisp_Object otf_features (HDC context, char *table);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
65
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
66 static int
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
67 memq_no_quit (Lisp_Object elt, Lisp_Object list)
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
68 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
69 while (CONSP (list) && ! EQ (XCAR (list), elt))
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
70 list = XCDR (list);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
71 return (CONSP (list));
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
72 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
73
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
74
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
75 /* Font backend interface implementation. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
76 static Lisp_Object
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
77 uniscribe_list (Lisp_Object frame, Lisp_Object font_spec)
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
78 {
96071
0f831953ffb8 Add font logging to list and match functions.
Jason Rumney <jasonr@gnu.org>
parents: 95800
diff changeset
79 Lisp_Object fonts = w32font_list_internal (frame, font_spec, 1);
103544
53abe6fc7e48 Change font_add_log to FONT_ADD_LOG.
Kenichi Handa <handa@m17n.org>
parents: 100951
diff changeset
80 FONT_ADD_LOG ("uniscribe-list", font_spec, fonts);
96071
0f831953ffb8 Add font logging to list and match functions.
Jason Rumney <jasonr@gnu.org>
parents: 95800
diff changeset
81 return fonts;
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
82 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
83
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
84 static Lisp_Object
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
85 uniscribe_match (Lisp_Object frame, Lisp_Object font_spec)
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
86 {
96071
0f831953ffb8 Add font logging to list and match functions.
Jason Rumney <jasonr@gnu.org>
parents: 95800
diff changeset
87 Lisp_Object entity = w32font_match_internal (frame, font_spec, 1);
103544
53abe6fc7e48 Change font_add_log to FONT_ADD_LOG.
Kenichi Handa <handa@m17n.org>
parents: 100951
diff changeset
88 FONT_ADD_LOG ("uniscribe-match", font_spec, entity);
96071
0f831953ffb8 Add font logging to list and match functions.
Jason Rumney <jasonr@gnu.org>
parents: 95800
diff changeset
89 return entity;
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
90 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
91
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
92 static Lisp_Object
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
93 uniscribe_list_family (Lisp_Object frame)
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
94 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
95 Lisp_Object list = Qnil;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
96 LOGFONT font_match_pattern;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
97 HDC dc;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
98 FRAME_PTR f = XFRAME (frame);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
99
109165
750db9f3e6d8 Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents: 109160
diff changeset
100 memset (&font_match_pattern, 0, sizeof (font_match_pattern));
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
101 /* Limit enumerated fonts to outline fonts to save time. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
102 font_match_pattern.lfOutPrecision = OUT_OUTLINE_PRECIS;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
103
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
104 dc = get_frame_dc (f);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
105
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
106 EnumFontFamiliesEx (dc, &font_match_pattern,
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
107 (FONTENUMPROC) add_opentype_font_name_to_list,
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
108 (LPARAM) &list, 0);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
109 release_frame_dc (f, dc);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
110
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
111 return list;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
112 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
113
94911
f29483946da4 Delete USE_FONT_BACKEND conditional.
Kenichi Handa <handa@m17n.org>
parents: 93863
diff changeset
114 static Lisp_Object
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
115 uniscribe_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size)
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
116 {
94911
f29483946da4 Delete USE_FONT_BACKEND conditional.
Kenichi Handa <handa@m17n.org>
parents: 93863
diff changeset
117 Lisp_Object font_object
96564
9ee160a11a03 (uniscribe_open): Adjust it for the change of
Kenichi Handa <handa@m17n.org>
parents: 96343
diff changeset
118 = font_make_object (VECSIZE (struct uniscribe_font_info),
9ee160a11a03 (uniscribe_open): Adjust it for the change of
Kenichi Handa <handa@m17n.org>
parents: 96343
diff changeset
119 font_entity, pixel_size);
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
120 struct uniscribe_font_info *uniscribe_font
94911
f29483946da4 Delete USE_FONT_BACKEND conditional.
Kenichi Handa <handa@m17n.org>
parents: 93863
diff changeset
121 = (struct uniscribe_font_info *) XFONT_OBJECT (font_object);
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
122
96937
7f7286fdbf06 * w32font.c (w32font_open): Set font type to gdi.
Jason Rumney <jasonr@gnu.org>
parents: 96564
diff changeset
123 ASET (font_object, FONT_TYPE_INDEX, Quniscribe);
7f7286fdbf06 * w32font.c (w32font_open): Set font type to gdi.
Jason Rumney <jasonr@gnu.org>
parents: 96564
diff changeset
124
94911
f29483946da4 Delete USE_FONT_BACKEND conditional.
Kenichi Handa <handa@m17n.org>
parents: 93863
diff changeset
125 if (!w32font_open_internal (f, font_entity, pixel_size, font_object))
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
126 {
94911
f29483946da4 Delete USE_FONT_BACKEND conditional.
Kenichi Handa <handa@m17n.org>
parents: 93863
diff changeset
127 return Qnil;
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
128 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
129
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
130 /* Initialize the cache for this font. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
131 uniscribe_font->cache = NULL;
97025
e72be8a4fdb8 (uniscribe_shape): Pass NULL for control arg to ScriptItemize. Clean
Jason Rumney <jasonr@gnu.org>
parents: 97004
diff changeset
132
97135
09abb4487286 * w32font.h (struct w32font_info): Use unicode version of textmetrics.
Jason Rumney <jasonr@gnu.org>
parents: 97112
diff changeset
133 /* Uniscribe backend uses glyph indices. */
09abb4487286 * w32font.h (struct w32font_info): Use unicode version of textmetrics.
Jason Rumney <jasonr@gnu.org>
parents: 97112
diff changeset
134 uniscribe_font->w32_font.glyph_idx = ETO_GLYPH_INDEX;
09abb4487286 * w32font.h (struct w32font_info): Use unicode version of textmetrics.
Jason Rumney <jasonr@gnu.org>
parents: 97112
diff changeset
135
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
136 /* Mark the format as opentype */
94911
f29483946da4 Delete USE_FONT_BACKEND conditional.
Kenichi Handa <handa@m17n.org>
parents: 93863
diff changeset
137 uniscribe_font->w32_font.font.props[FONT_FORMAT_INDEX] = Qopentype;
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
138 uniscribe_font->w32_font.font.driver = &uniscribe_font_driver;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
139
94911
f29483946da4 Delete USE_FONT_BACKEND conditional.
Kenichi Handa <handa@m17n.org>
parents: 93863
diff changeset
140 return font_object;
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
141 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
142
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
143 static void
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
144 uniscribe_close (FRAME_PTR f, struct font *font)
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
145 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
146 struct uniscribe_font_info *uniscribe_font
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
147 = (struct uniscribe_font_info *) font;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
148
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
149 if (uniscribe_font->cache)
97025
e72be8a4fdb8 (uniscribe_shape): Pass NULL for control arg to ScriptItemize. Clean
Jason Rumney <jasonr@gnu.org>
parents: 97004
diff changeset
150 ScriptFreeCache (&(uniscribe_font->cache));
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
151
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
152 w32font_close (f, font);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
153 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
154
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
155 /* Return a list describing which scripts/languages FONT supports by
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
156 which GSUB/GPOS features of OpenType tables. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
157 static Lisp_Object
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
158 uniscribe_otf_capability (struct font *font)
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
159 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
160 HDC context;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
161 HFONT old_font;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
162 struct frame *f;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
163 Lisp_Object capability = Fcons (Qnil, Qnil);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
164 Lisp_Object features;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
165
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
166 f = XFRAME (selected_frame);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
167 context = get_frame_dc (f);
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 110986
diff changeset
168 old_font = SelectObject (context, FONT_HANDLE (font));
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
169
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
170 features = otf_features (context, "GSUB");
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
171 XSETCAR (capability, features);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
172 features = otf_features (context, "GPOS");
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
173 XSETCDR (capability, features);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
174
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
175 SelectObject (context, old_font);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
176 release_frame_dc (f, context);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
177
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
178 return capability;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
179 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
180
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
181 /* Uniscribe implementation of shape for font backend.
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
182
110177
6d74afef6e68 Fix display of composed R2L text on MS-Windows.
Eli Zaretskii <eliz@gnu.org>
parents: 109165
diff changeset
183 Shape text in LGSTRING. See the docstring of
6d74afef6e68 Fix display of composed R2L text on MS-Windows.
Eli Zaretskii <eliz@gnu.org>
parents: 109165
diff changeset
184 `composition-get-gstring' for the format of LGSTRING. If the
6d74afef6e68 Fix display of composed R2L text on MS-Windows.
Eli Zaretskii <eliz@gnu.org>
parents: 109165
diff changeset
185 (N+1)th element of LGSTRING is nil, input of shaping is from the
6d74afef6e68 Fix display of composed R2L text on MS-Windows.
Eli Zaretskii <eliz@gnu.org>
parents: 109165
diff changeset
186 1st to (N)th elements. In each input glyph, FROM, TO, CHAR, and
6d74afef6e68 Fix display of composed R2L text on MS-Windows.
Eli Zaretskii <eliz@gnu.org>
parents: 109165
diff changeset
187 CODE are already set.
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
188
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
189 This function updates all fields of the input glyphs. If the
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
190 output glyphs (M) are more than the input glyphs (N), (N+1)th
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
191 through (M)th elements of LGSTRING are updated possibly by making
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
192 a new glyph object and storing it in LGSTRING. If (M) is greater
110177
6d74afef6e68 Fix display of composed R2L text on MS-Windows.
Eli Zaretskii <eliz@gnu.org>
parents: 109165
diff changeset
193 than the length of LGSTRING, nil should be returned. In that case,
6d74afef6e68 Fix display of composed R2L text on MS-Windows.
Eli Zaretskii <eliz@gnu.org>
parents: 109165
diff changeset
194 this function is called again with a larger LGSTRING. */
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
195 static Lisp_Object
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
196 uniscribe_shape (Lisp_Object lgstring)
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
197 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
198 struct font * font;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
199 struct uniscribe_font_info * uniscribe_font;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
200 EMACS_UINT nchars;
93762
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
201 int nitems, max_items, i, max_glyphs, done_glyphs;
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
202 wchar_t *chars;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
203 WORD *glyphs, *clusters;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
204 SCRIPT_ITEM *items;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
205 SCRIPT_VISATTR *attributes;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
206 int *advances;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
207 GOFFSET *offsets;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
208 ABC overall_metrics;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
209 HRESULT result;
97086
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
210 struct frame * f = NULL;
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
211 HDC context = NULL;
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
212 HFONT old_font = NULL;
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
213
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
214 CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring), font);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
215 uniscribe_font = (struct uniscribe_font_info *) font;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
216
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
217 /* Get the chars from lgstring in a form we can use with uniscribe. */
97832
e33a2e6c1dab (struct uniscribe_font_info): Include composite.h.
Kenichi Handa <handa@m17n.org>
parents: 97135
diff changeset
218 max_glyphs = nchars = LGSTRING_GLYPH_LEN (lgstring);
93762
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
219 done_glyphs = 0;
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
220 chars = (wchar_t *) alloca (nchars * sizeof (wchar_t));
110177
6d74afef6e68 Fix display of composed R2L text on MS-Windows.
Eli Zaretskii <eliz@gnu.org>
parents: 109165
diff changeset
221 /* FIXME: This loop assumes that characters in the input LGSTRING
6d74afef6e68 Fix display of composed R2L text on MS-Windows.
Eli Zaretskii <eliz@gnu.org>
parents: 109165
diff changeset
222 are all inside the BMP. Need to encode characters beyond the BMP
6d74afef6e68 Fix display of composed R2L text on MS-Windows.
Eli Zaretskii <eliz@gnu.org>
parents: 109165
diff changeset
223 as UTF-16. */
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
224 for (i = 0; i < nchars; i++)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
225 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
226 /* lgstring can be bigger than the number of characters in it, in
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
227 the case where more glyphs are required to display those characters.
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
228 If that is the case, note the real number of characters. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
229 if (NILP (LGSTRING_GLYPH (lgstring, i)))
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
230 nchars = i;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
231 else
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
232 chars[i] = LGLYPH_CHAR (LGSTRING_GLYPH (lgstring, i));
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
233 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
234
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
235 /* First we need to break up the glyph string into runs of glyphs that
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
236 can be treated together. First try a single run. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
237 max_items = 2;
93762
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
238 items = (SCRIPT_ITEM *) xmalloc (sizeof (SCRIPT_ITEM) * max_items + 1);
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
239
97025
e72be8a4fdb8 (uniscribe_shape): Pass NULL for control arg to ScriptItemize. Clean
Jason Rumney <jasonr@gnu.org>
parents: 97004
diff changeset
240 while ((result = ScriptItemize (chars, nchars, max_items, NULL, NULL,
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
241 items, &nitems)) == E_OUTOFMEMORY)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
242 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
243 /* If that wasn't enough, keep trying with one more run. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
244 max_items++;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
245 items = (SCRIPT_ITEM *) xrealloc (items,
93762
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
246 sizeof (SCRIPT_ITEM) * max_items + 1);
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
247 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
248
97086
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
249 if (FAILED (result))
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
250 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
251 xfree (items);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
252 return Qnil;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
253 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
254
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
255 glyphs = alloca (max_glyphs * sizeof (WORD));
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
256 clusters = alloca (nchars * sizeof (WORD));
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
257 attributes = alloca (max_glyphs * sizeof (SCRIPT_VISATTR));
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
258 advances = alloca (max_glyphs * sizeof (int));
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
259 offsets = alloca (max_glyphs * sizeof (GOFFSET));
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
260
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
261 for (i = 0; i < nitems; i++)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
262 {
110177
6d74afef6e68 Fix display of composed R2L text on MS-Windows.
Eli Zaretskii <eliz@gnu.org>
parents: 109165
diff changeset
263 int nglyphs, nchars_in_run;
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
264 nchars_in_run = items[i+1].iCharPos - items[i].iCharPos;
110177
6d74afef6e68 Fix display of composed R2L text on MS-Windows.
Eli Zaretskii <eliz@gnu.org>
parents: 109165
diff changeset
265 /* Force ScriptShape to generate glyphs in the same order as
6d74afef6e68 Fix display of composed R2L text on MS-Windows.
Eli Zaretskii <eliz@gnu.org>
parents: 109165
diff changeset
266 they are in the input LGSTRING, which is in the logical
6d74afef6e68 Fix display of composed R2L text on MS-Windows.
Eli Zaretskii <eliz@gnu.org>
parents: 109165
diff changeset
267 order. */
6d74afef6e68 Fix display of composed R2L text on MS-Windows.
Eli Zaretskii <eliz@gnu.org>
parents: 109165
diff changeset
268 items[i].a.fLogicalOrder = 1;
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
269
97086
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
270 /* Context may be NULL here, in which case the cache should be
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
271 used without needing to select the font. */
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
272 result = ScriptShape (context, &(uniscribe_font->cache),
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
273 chars + items[i].iCharPos, nchars_in_run,
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
274 max_glyphs - done_glyphs, &(items[i].a),
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
275 glyphs, clusters, attributes, &nglyphs);
97086
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
276
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
277 if (result == E_PENDING && !context)
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
278 {
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
279 /* This assumes the selected frame is on the same display as the
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
280 one we are drawing. It would be better for the frame to be
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
281 passed in. */
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
282 f = XFRAME (selected_frame);
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
283 context = get_frame_dc (f);
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 110986
diff changeset
284 old_font = SelectObject (context, FONT_HANDLE (font));
97086
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
285
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
286 result = ScriptShape (context, &(uniscribe_font->cache),
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
287 chars + items[i].iCharPos, nchars_in_run,
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
288 max_glyphs - done_glyphs, &(items[i].a),
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
289 glyphs, clusters, attributes, &nglyphs);
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
290 }
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
291
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
292 if (result == E_OUTOFMEMORY)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
293 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
294 /* Need a bigger lgstring. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
295 lgstring = Qnil;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
296 break;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
297 }
97086
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
298 else if (FAILED (result))
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
299 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
300 /* Can't shape this run - return results so far if any. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
301 break;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
302 }
93762
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
303 else if (items[i].a.fNoGlyphIndex)
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
304 {
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
305 /* Glyph indices not supported by this font (or OS), means we
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
306 can't really do any meaningful shaping. */
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
307 break;
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
308 }
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
309 else
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
310 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
311 result = ScriptPlace (context, &(uniscribe_font->cache),
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
312 glyphs, nglyphs, attributes, &(items[i].a),
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
313 advances, offsets, &overall_metrics);
97086
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
314 if (result == E_PENDING && !context)
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
315 {
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
316 /* Cache not complete... */
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
317 f = XFRAME (selected_frame);
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
318 context = get_frame_dc (f);
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 110986
diff changeset
319 old_font = SelectObject (context, FONT_HANDLE (font));
97086
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
320
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
321 result = ScriptPlace (context, &(uniscribe_font->cache),
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
322 glyphs, nglyphs, attributes, &(items[i].a),
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
323 advances, offsets, &overall_metrics);
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
324 }
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
325 if (SUCCEEDED (result))
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
326 {
93766
2382df5e230a (uniscribe_shape): Map char at FROM to current glyph.
Jason Rumney <jasonr@gnu.org>
parents: 93762
diff changeset
327 int j, nclusters, from, to;
2382df5e230a (uniscribe_shape): Map char at FROM to current glyph.
Jason Rumney <jasonr@gnu.org>
parents: 93762
diff changeset
328
110177
6d74afef6e68 Fix display of composed R2L text on MS-Windows.
Eli Zaretskii <eliz@gnu.org>
parents: 109165
diff changeset
329 from = 0;
93766
2382df5e230a (uniscribe_shape): Map char at FROM to current glyph.
Jason Rumney <jasonr@gnu.org>
parents: 93762
diff changeset
330 to = from;
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
331
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
332 for (j = 0; j < nglyphs; j++)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
333 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
334 int lglyph_index = j + done_glyphs;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
335 Lisp_Object lglyph = LGSTRING_GLYPH (lgstring, lglyph_index);
93762
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
336 ABC char_metric;
97848
d1e61da65cce (uniscribe_shape): Shut up compiler warning in LGLYPH_SET_CODE.
Eli Zaretskii <eliz@gnu.org>
parents: 97832
diff changeset
337 unsigned gl;
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
338
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
339 if (NILP (lglyph))
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
340 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
341 lglyph = Fmake_vector (make_number (LGLYPH_SIZE), Qnil);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
342 LGSTRING_SET_GLYPH (lgstring, lglyph_index, lglyph);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
343 }
97848
d1e61da65cce (uniscribe_shape): Shut up compiler warning in LGLYPH_SET_CODE.
Eli Zaretskii <eliz@gnu.org>
parents: 97832
diff changeset
344 /* Copy to a 32-bit data type to shut up the
d1e61da65cce (uniscribe_shape): Shut up compiler warning in LGLYPH_SET_CODE.
Eli Zaretskii <eliz@gnu.org>
parents: 97832
diff changeset
345 compiler warning in LGLYPH_SET_CODE about
d1e61da65cce (uniscribe_shape): Shut up compiler warning in LGLYPH_SET_CODE.
Eli Zaretskii <eliz@gnu.org>
parents: 97832
diff changeset
346 comparison being always false. */
d1e61da65cce (uniscribe_shape): Shut up compiler warning in LGLYPH_SET_CODE.
Eli Zaretskii <eliz@gnu.org>
parents: 97832
diff changeset
347 gl = glyphs[j];
d1e61da65cce (uniscribe_shape): Shut up compiler warning in LGLYPH_SET_CODE.
Eli Zaretskii <eliz@gnu.org>
parents: 97832
diff changeset
348 LGLYPH_SET_CODE (lglyph, gl);
93762
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
349
110177
6d74afef6e68 Fix display of composed R2L text on MS-Windows.
Eli Zaretskii <eliz@gnu.org>
parents: 109165
diff changeset
350 /* Detect clusters, for linking codes back to
6d74afef6e68 Fix display of composed R2L text on MS-Windows.
Eli Zaretskii <eliz@gnu.org>
parents: 109165
diff changeset
351 characters. */
93762
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
352 if (attributes[j].fClusterStart)
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
353 {
110177
6d74afef6e68 Fix display of composed R2L text on MS-Windows.
Eli Zaretskii <eliz@gnu.org>
parents: 109165
diff changeset
354 while (from < nchars_in_run && clusters[from] < j)
6d74afef6e68 Fix display of composed R2L text on MS-Windows.
Eli Zaretskii <eliz@gnu.org>
parents: 109165
diff changeset
355 from++;
6d74afef6e68 Fix display of composed R2L text on MS-Windows.
Eli Zaretskii <eliz@gnu.org>
parents: 109165
diff changeset
356 if (from >= nchars_in_run)
93766
2382df5e230a (uniscribe_shape): Map char at FROM to current glyph.
Jason Rumney <jasonr@gnu.org>
parents: 93762
diff changeset
357 from = to = nchars_in_run - 1;
93762
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
358 else
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
359 {
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
360 int k;
110177
6d74afef6e68 Fix display of composed R2L text on MS-Windows.
Eli Zaretskii <eliz@gnu.org>
parents: 109165
diff changeset
361 to = nchars_in_run - 1;
6d74afef6e68 Fix display of composed R2L text on MS-Windows.
Eli Zaretskii <eliz@gnu.org>
parents: 109165
diff changeset
362 for (k = from + 1; k < nchars_in_run; k++)
93762
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
363 {
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
364 if (clusters[k] > j)
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
365 {
93766
2382df5e230a (uniscribe_shape): Map char at FROM to current glyph.
Jason Rumney <jasonr@gnu.org>
parents: 93762
diff changeset
366 to = k - 1;
93762
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
367 break;
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
368 }
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
369 }
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
370 }
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
371 }
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
372
93766
2382df5e230a (uniscribe_shape): Map char at FROM to current glyph.
Jason Rumney <jasonr@gnu.org>
parents: 93762
diff changeset
373 LGLYPH_SET_CHAR (lglyph, chars[items[i].iCharPos
2382df5e230a (uniscribe_shape): Map char at FROM to current glyph.
Jason Rumney <jasonr@gnu.org>
parents: 93762
diff changeset
374 + from]);
2382df5e230a (uniscribe_shape): Map char at FROM to current glyph.
Jason Rumney <jasonr@gnu.org>
parents: 93762
diff changeset
375 LGLYPH_SET_FROM (lglyph, items[i].iCharPos + from);
2382df5e230a (uniscribe_shape): Map char at FROM to current glyph.
Jason Rumney <jasonr@gnu.org>
parents: 93762
diff changeset
376 LGLYPH_SET_TO (lglyph, items[i].iCharPos + to);
93762
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
377
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
378 /* Metrics. */
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
379 LGLYPH_SET_WIDTH (lglyph, advances[j]);
93762
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
380 LGLYPH_SET_ASCENT (lglyph, font->ascent);
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
381 LGLYPH_SET_DESCENT (lglyph, font->descent);
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
382
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
383 result = ScriptGetGlyphABCWidth (context,
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
384 &(uniscribe_font->cache),
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
385 glyphs[j], &char_metric);
97086
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
386 if (result == E_PENDING && !context)
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
387 {
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
388 /* Cache incomplete... */
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
389 f = XFRAME (selected_frame);
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
390 context = get_frame_dc (f);
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 110986
diff changeset
391 old_font = SelectObject (context, FONT_HANDLE (font));
97086
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
392 result = ScriptGetGlyphABCWidth (context,
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
393 &(uniscribe_font->cache),
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
394 glyphs[j], &char_metric);
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
395 }
93762
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
396
97025
e72be8a4fdb8 (uniscribe_shape): Pass NULL for control arg to ScriptItemize. Clean
Jason Rumney <jasonr@gnu.org>
parents: 97004
diff changeset
397 if (SUCCEEDED (result))
93762
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
398 {
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
399 LGLYPH_SET_LBEARING (lglyph, char_metric.abcA);
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
400 LGLYPH_SET_RBEARING (lglyph, (char_metric.abcA
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
401 + char_metric.abcB));
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
402 }
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
403 else
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
404 {
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
405 LGLYPH_SET_LBEARING (lglyph, 0);
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
406 LGLYPH_SET_RBEARING (lglyph, advances[j]);
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
407 }
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
408
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
409 if (offsets[j].du || offsets[j].dv)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
410 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
411 Lisp_Object vec;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
412 vec = Fmake_vector (make_number (3), Qnil);
93762
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
413 ASET (vec, 0, make_number (offsets[j].du));
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
414 ASET (vec, 1, make_number (offsets[j].dv));
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
415 /* Based on what ftfont.c does... */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
416 ASET (vec, 2, make_number (advances[j]));
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
417 LGLYPH_SET_ADJUSTMENT (lglyph, vec);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
418 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
419 else
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
420 LGLYPH_SET_ADJUSTMENT (lglyph, Qnil);
97086
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
421 }
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
422 }
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
423 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
424 done_glyphs += nglyphs;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
425 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
426
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
427 xfree (items);
97086
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
428
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
429 if (context)
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
430 {
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
431 SelectObject (context, old_font);
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
432 release_frame_dc (f, context);
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
433 }
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
434
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
435 if (NILP (lgstring))
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
436 return Qnil;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
437 else
93762
46d39c0f7bf9 (uniscribe_shape): Increase items buffer size.
Jason Rumney <jasonr@gnu.org>
parents: 93729
diff changeset
438 return make_number (done_glyphs);
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
439 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
440
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
441 /* Uniscribe implementation of encode_char for font backend.
110986
e0f89e89ed02 Fix typos in docstrings, comments and ChangeLogs.
Juanma Barranquero <lekktu@gmail.com>
parents: 107246
diff changeset
442 Return a glyph code of FONT for character C (Unicode code point).
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
443 If FONT doesn't have such a glyph, return FONT_INVALID_CODE. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
444 static unsigned
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
445 uniscribe_encode_char (struct font *font, int c)
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
446 {
97086
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
447 HDC context = NULL;
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
448 struct frame *f = NULL;
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
449 HFONT old_font = NULL;
97025
e72be8a4fdb8 (uniscribe_shape): Pass NULL for control arg to ScriptItemize. Clean
Jason Rumney <jasonr@gnu.org>
parents: 97004
diff changeset
450 unsigned code = FONT_INVALID_CODE;
97086
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
451 wchar_t ch[2];
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
452 int len;
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
453 SCRIPT_ITEM* items;
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
454 int nitems;
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
455 struct uniscribe_font_info *uniscribe_font
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
456 = (struct uniscribe_font_info *)font;
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
457
97025
e72be8a4fdb8 (uniscribe_shape): Pass NULL for control arg to ScriptItemize. Clean
Jason Rumney <jasonr@gnu.org>
parents: 97004
diff changeset
458 if (c < 0x10000)
e72be8a4fdb8 (uniscribe_shape): Pass NULL for control arg to ScriptItemize. Clean
Jason Rumney <jasonr@gnu.org>
parents: 97004
diff changeset
459 {
97086
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
460 ch[0] = (wchar_t) c;
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
461 len = 1;
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
462 }
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
463 else
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
464 {
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
465 DWORD surrogate = c - 0x10000;
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
466
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
467 /* High surrogate: U+D800 - U+DBFF. */
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
468 ch[0] = 0xD800 + ((surrogate >> 10) & 0x03FF);
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
469 /* Low surrogate: U+DC00 - U+DFFF. */
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
470 ch[1] = 0xDC00 + (surrogate & 0x03FF);
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
471 len = 2;
97025
e72be8a4fdb8 (uniscribe_shape): Pass NULL for control arg to ScriptItemize. Clean
Jason Rumney <jasonr@gnu.org>
parents: 97004
diff changeset
472 }
e72be8a4fdb8 (uniscribe_shape): Pass NULL for control arg to ScriptItemize. Clean
Jason Rumney <jasonr@gnu.org>
parents: 97004
diff changeset
473
e72be8a4fdb8 (uniscribe_shape): Pass NULL for control arg to ScriptItemize. Clean
Jason Rumney <jasonr@gnu.org>
parents: 97004
diff changeset
474 /* Non BMP characters must be handled by the uniscribe shaping
e72be8a4fdb8 (uniscribe_shape): Pass NULL for control arg to ScriptItemize. Clean
Jason Rumney <jasonr@gnu.org>
parents: 97004
diff changeset
475 engine as GDI functions (except blindly displaying lines of
e72be8a4fdb8 (uniscribe_shape): Pass NULL for control arg to ScriptItemize. Clean
Jason Rumney <jasonr@gnu.org>
parents: 97004
diff changeset
476 unicode text) and the promising looking ScriptGetCMap do not
e72be8a4fdb8 (uniscribe_shape): Pass NULL for control arg to ScriptItemize. Clean
Jason Rumney <jasonr@gnu.org>
parents: 97004
diff changeset
477 convert surrogate pairs to glyph indexes correctly. */
e72be8a4fdb8 (uniscribe_shape): Pass NULL for control arg to ScriptItemize. Clean
Jason Rumney <jasonr@gnu.org>
parents: 97004
diff changeset
478 {
e72be8a4fdb8 (uniscribe_shape): Pass NULL for control arg to ScriptItemize. Clean
Jason Rumney <jasonr@gnu.org>
parents: 97004
diff changeset
479 items = (SCRIPT_ITEM *) alloca (sizeof (SCRIPT_ITEM) * 2 + 1);
97086
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
480 if (SUCCEEDED (ScriptItemize (ch, len, 2, NULL, NULL, items, &nitems)))
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
481 {
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
482 HRESULT result;
100357
92ff8ff0a655 (uniscribe_encode_char): Increase glyph buffer size for surrogates.
Jason Rumney <jasonr@gnu.org>
parents: 99853
diff changeset
483 /* Surrogates seem to need 2 here, even though only one glyph is
92ff8ff0a655 (uniscribe_encode_char): Increase glyph buffer size for surrogates.
Jason Rumney <jasonr@gnu.org>
parents: 99853
diff changeset
484 returned. Indic characters can also produce 2 or more glyphs for
92ff8ff0a655 (uniscribe_encode_char): Increase glyph buffer size for surrogates.
Jason Rumney <jasonr@gnu.org>
parents: 99853
diff changeset
485 a single code point, but they need to use uniscribe_shape
92ff8ff0a655 (uniscribe_encode_char): Increase glyph buffer size for surrogates.
Jason Rumney <jasonr@gnu.org>
parents: 99853
diff changeset
486 above for correct display. */
92ff8ff0a655 (uniscribe_encode_char): Increase glyph buffer size for surrogates.
Jason Rumney <jasonr@gnu.org>
parents: 99853
diff changeset
487 WORD glyphs[2], clusters[2];
92ff8ff0a655 (uniscribe_encode_char): Increase glyph buffer size for surrogates.
Jason Rumney <jasonr@gnu.org>
parents: 99853
diff changeset
488 SCRIPT_VISATTR attrs[2];
97025
e72be8a4fdb8 (uniscribe_shape): Pass NULL for control arg to ScriptItemize. Clean
Jason Rumney <jasonr@gnu.org>
parents: 97004
diff changeset
489 int nglyphs;
e72be8a4fdb8 (uniscribe_shape): Pass NULL for control arg to ScriptItemize. Clean
Jason Rumney <jasonr@gnu.org>
parents: 97004
diff changeset
490
110177
6d74afef6e68 Fix display of composed R2L text on MS-Windows.
Eli Zaretskii <eliz@gnu.org>
parents: 109165
diff changeset
491 /* Force ScriptShape to generate glyphs in the logical
6d74afef6e68 Fix display of composed R2L text on MS-Windows.
Eli Zaretskii <eliz@gnu.org>
parents: 109165
diff changeset
492 order. */
6d74afef6e68 Fix display of composed R2L text on MS-Windows.
Eli Zaretskii <eliz@gnu.org>
parents: 109165
diff changeset
493 items[0].a.fLogicalOrder = 1;
6d74afef6e68 Fix display of composed R2L text on MS-Windows.
Eli Zaretskii <eliz@gnu.org>
parents: 109165
diff changeset
494
97086
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
495 result = ScriptShape (context, &(uniscribe_font->cache),
100357
92ff8ff0a655 (uniscribe_encode_char): Increase glyph buffer size for surrogates.
Jason Rumney <jasonr@gnu.org>
parents: 99853
diff changeset
496 ch, len, 2, &(items[0].a),
97086
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
497 glyphs, clusters, attrs, &nglyphs);
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
498
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
499 if (result == E_PENDING)
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
500 {
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
501 /* Use selected frame until API is updated to pass
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
502 the frame. */
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
503 f = XFRAME (selected_frame);
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
504 context = get_frame_dc (f);
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 110986
diff changeset
505 old_font = SelectObject (context, FONT_HANDLE (font));
97086
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
506 result = ScriptShape (context, &(uniscribe_font->cache),
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
507 ch, len, 2, &(items[0].a),
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
508 glyphs, clusters, attrs, &nglyphs);
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
509 }
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
510
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
511 if (SUCCEEDED (result) && nglyphs == 1)
97025
e72be8a4fdb8 (uniscribe_shape): Pass NULL for control arg to ScriptItemize. Clean
Jason Rumney <jasonr@gnu.org>
parents: 97004
diff changeset
512 {
100627
4159567b77d7 (uniscribe_encode_char): Return FONT_INVALID_CHAR
Jason Rumney <jasonr@gnu.org>
parents: 100409
diff changeset
513 /* Some fonts return .notdef glyphs instead of failing.
4159567b77d7 (uniscribe_encode_char): Return FONT_INVALID_CHAR
Jason Rumney <jasonr@gnu.org>
parents: 100409
diff changeset
514 (Truetype spec reserves glyph code 0 for .notdef) */
4159567b77d7 (uniscribe_encode_char): Return FONT_INVALID_CHAR
Jason Rumney <jasonr@gnu.org>
parents: 100409
diff changeset
515 if (glyphs[0])
4159567b77d7 (uniscribe_encode_char): Return FONT_INVALID_CHAR
Jason Rumney <jasonr@gnu.org>
parents: 100409
diff changeset
516 code = glyphs[0];
97025
e72be8a4fdb8 (uniscribe_shape): Pass NULL for control arg to ScriptItemize. Clean
Jason Rumney <jasonr@gnu.org>
parents: 97004
diff changeset
517 }
97086
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
518 else if (SUCCEEDED (result) || result == E_OUTOFMEMORY)
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
519 {
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
520 /* This character produces zero or more than one glyph
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
521 when shaped. But we still need the return from here
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
522 to be valid for the shaping engine to be invoked
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
523 later. */
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
524 result = ScriptGetCMap (context, &(uniscribe_font->cache),
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
525 ch, len, 0, glyphs);
100627
4159567b77d7 (uniscribe_encode_char): Return FONT_INVALID_CHAR
Jason Rumney <jasonr@gnu.org>
parents: 100409
diff changeset
526 if (SUCCEEDED (result) && glyphs[0])
99853
6a28cc2ace8a (uniscribe_encode_char): Ensure context is restored before returning.
Jason Rumney <jasonr@gnu.org>
parents: 97858
diff changeset
527 code = glyphs[0];
97086
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
528 }
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
529 }
97025
e72be8a4fdb8 (uniscribe_shape): Pass NULL for control arg to ScriptItemize. Clean
Jason Rumney <jasonr@gnu.org>
parents: 97004
diff changeset
530 }
97086
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
531 if (context)
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
532 {
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
533 SelectObject (context, old_font);
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
534 release_frame_dc (f, context);
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
535 }
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
536
97086
c38003f850b5 (uniscribe_shape): Avoid using context if cache
Jason Rumney <jasonr@gnu.org>
parents: 97025
diff changeset
537 return code;
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
538 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
539
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
540 /*
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
541 Shared with w32font:
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
542 Lisp_Object uniscribe_get_cache (Lisp_Object frame);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
543 void uniscribe_free_entity (Lisp_Object font_entity);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
544 int uniscribe_has_char (Lisp_Object entity, int c);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
545 int uniscribe_text_extents (struct font *font, unsigned *code,
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
546 int nglyphs, struct font_metrics *metrics);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
547 int uniscribe_draw (struct glyph_string *s, int from, int to,
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
548 int x, int y, int with_background);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
549
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
550 Unused:
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
551 int uniscribe_prepare_face (FRAME_PTR f, struct face *face);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
552 void uniscribe_done_face (FRAME_PTR f, struct face *face);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
553 int uniscribe_get_bitmap (struct font *font, unsigned code,
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
554 struct font_bitmap *bitmap, int bits_per_pixel);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
555 void uniscribe_free_bitmap (struct font *font, struct font_bitmap *bitmap);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
556 void * uniscribe_get_outline (struct font *font, unsigned code);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
557 void uniscribe_free_outline (struct font *font, void *outline);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
558 int uniscribe_anchor_point (struct font *font, unsigned code,
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
559 int index, int *x, int *y);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
560 int uniscribe_start_for_frame (FRAME_PTR f);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
561 int uniscribe_end_for_frame (FRAME_PTR f);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
562
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
563 */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
564
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
565
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
566 /* Callback function for EnumFontFamiliesEx.
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
567 Adds the name of opentype fonts to a Lisp list (passed in as the
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
568 lParam arg). */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
569 static int CALLBACK
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
570 add_opentype_font_name_to_list (ENUMLOGFONTEX *logical_font,
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
571 NEWTEXTMETRICEX *physical_font,
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
572 DWORD font_type, LPARAM list_object)
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
573 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
574 Lisp_Object* list = (Lisp_Object *) list_object;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
575 Lisp_Object family;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
576
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
577 /* Skip vertical fonts (intended only for printing) */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
578 if (logical_font->elfLogFont.lfFaceName[0] == '@')
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
579 return 1;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
580
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
581 /* Skip non opentype fonts. Count old truetype fonts as opentype,
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
582 as some of them do contain GPOS and GSUB data that Uniscribe
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
583 can make use of. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
584 if (!(physical_font->ntmTm.ntmFlags & NTMFLAGS_OPENTYPE)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
585 && font_type != TRUETYPE_FONTTYPE)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
586 return 1;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
587
95800
67f150b4adbe (add_opentype_font_name_to_list): Skip non unicode fonts.
Jason Rumney <jasonr@gnu.org>
parents: 95743
diff changeset
588 /* Skip fonts that have no unicode coverage. */
67f150b4adbe (add_opentype_font_name_to_list): Skip non unicode fonts.
Jason Rumney <jasonr@gnu.org>
parents: 95743
diff changeset
589 if (!physical_font->ntmFontSig.fsUsb[3]
67f150b4adbe (add_opentype_font_name_to_list): Skip non unicode fonts.
Jason Rumney <jasonr@gnu.org>
parents: 95743
diff changeset
590 && !physical_font->ntmFontSig.fsUsb[2]
67f150b4adbe (add_opentype_font_name_to_list): Skip non unicode fonts.
Jason Rumney <jasonr@gnu.org>
parents: 95743
diff changeset
591 && !physical_font->ntmFontSig.fsUsb[1]
67f150b4adbe (add_opentype_font_name_to_list): Skip non unicode fonts.
Jason Rumney <jasonr@gnu.org>
parents: 95743
diff changeset
592 && !(physical_font->ntmFontSig.fsUsb[0] & 0x3fffffff))
67f150b4adbe (add_opentype_font_name_to_list): Skip non unicode fonts.
Jason Rumney <jasonr@gnu.org>
parents: 95743
diff changeset
593 return 1;
67f150b4adbe (add_opentype_font_name_to_list): Skip non unicode fonts.
Jason Rumney <jasonr@gnu.org>
parents: 95743
diff changeset
594
100409
4be3711ceff9 * w32font.c (intern_font_name): New function.
Jason Rumney <jasonr@gnu.org>
parents: 100357
diff changeset
595 family = intern_font_name (logical_font->elfLogFont.lfFaceName);
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
596 if (! memq_no_quit (family, *list))
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
597 *list = Fcons (family, *list);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
598
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
599 return 1;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
600 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
601
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
602
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
603 /* :otf property handling.
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
604 Since the necessary Uniscribe APIs for getting font tag information
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
605 are only available in Vista, we need to parse the font data directly
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
606 according to the OpenType Specification. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
607
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
608 /* Push into DWORD backwards to cope with endianness. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
609 #define OTF_TAG(STR) \
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
610 ((STR[3] << 24) | (STR[2] << 16) | (STR[1] << 8) | STR[0])
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
611
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
612 #define OTF_INT16_VAL(TABLE, OFFSET, PTR) \
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
613 do { \
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
614 BYTE temp, data[2]; \
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
615 if (GetFontData (context, TABLE, OFFSET, data, 2) != 2) \
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
616 goto font_table_error; \
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
617 temp = data[0], data[0] = data[1], data[1] = temp; \
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
618 memcpy (PTR, data, 2); \
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
619 } while (0)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
620
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
621 /* Do not reverse the bytes, because we will compare with a OTF_TAG value
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
622 that has them reversed already. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
623 #define OTF_DWORDTAG_VAL(TABLE, OFFSET, PTR) \
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
624 do { \
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
625 if (GetFontData (context, TABLE, OFFSET, PTR, 4) != 4) \
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
626 goto font_table_error; \
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
627 } while (0)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
628
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
629 #define OTF_TAG_VAL(TABLE, OFFSET, STR) \
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
630 do { \
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
631 if (GetFontData (context, TABLE, OFFSET, STR, 4) != 4) \
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
632 goto font_table_error; \
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
633 STR[4] = '\0'; \
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
634 } while (0)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
635
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
636 static char* NOTHING = " ";
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
637
93863
f9841841f5a5 (SNAME): Extract only symbol name.
Jason Rumney <jasonr@gnu.org>
parents: 93766
diff changeset
638 #define SNAME(VAL) SDATA (SYMBOL_NAME (VAL))
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
639
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
640 /* Check if font supports the otf script/language/features specified.
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
641 OTF_SPEC is in the format
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
642 (script lang [(gsub_feature ...)|nil] [(gpos_feature ...)]?) */
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 110986
diff changeset
643 int
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
644 uniscribe_check_otf (LOGFONT *font, Lisp_Object otf_spec)
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
645 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
646 Lisp_Object script, lang, rest;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
647 Lisp_Object features[2];
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
648 DWORD feature_tables[2];
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
649 DWORD script_tag, default_script, lang_tag = 0;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
650 struct frame * f;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
651 HDC context;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
652 HFONT check_font, old_font;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
653 DWORD table;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
654 int i, retval = 0;
93659
f606935ea4be (uniscribe_check_otf): Add GC protection before consing.
Jason Rumney <jasonr@gnu.org>
parents: 93654
diff changeset
655 struct gcpro gcpro1;
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
656
93604
5476a4f5d2f2 (uniscribe_check_otf): Sanity check otf_spec.
Jason Rumney <jasonr@gnu.org>
parents: 93590
diff changeset
657 /* Check the spec is in the right format. */
107246
4cce9795bfd4 * w32uniscribe.c (uniscribe_check_otf): Fix length check.
Andreas Schwab <schwab@linux-m68k.org>
parents: 106837
diff changeset
658 if (!CONSP (otf_spec) || XINT (Flength (otf_spec)) < 3)
93604
5476a4f5d2f2 (uniscribe_check_otf): Sanity check otf_spec.
Jason Rumney <jasonr@gnu.org>
parents: 93590
diff changeset
659 return 0;
5476a4f5d2f2 (uniscribe_check_otf): Sanity check otf_spec.
Jason Rumney <jasonr@gnu.org>
parents: 93590
diff changeset
660
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
661 /* Break otf_spec into its components. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
662 script = XCAR (otf_spec);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
663 rest = XCDR (otf_spec);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
664
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
665 lang = XCAR (rest);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
666 rest = XCDR (rest);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
667
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
668 features[0] = XCAR (rest);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
669 rest = XCDR (rest);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
670 if (NILP (rest))
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
671 features[1] = Qnil;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
672 else
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
673 features[1] = XCAR (rest);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
674
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
675 /* Set up tags we will use in the search. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
676 feature_tables[0] = OTF_TAG ("GSUB");
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
677 feature_tables[1] = OTF_TAG ("GPOS");
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
678 default_script = OTF_TAG ("DFLT");
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
679 if (NILP (script))
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
680 script_tag = default_script;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
681 else
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
682 script_tag = OTF_TAG (SNAME (script));
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
683 if (!NILP (lang))
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
684 lang_tag = OTF_TAG (SNAME (lang));
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
685
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
686 /* Set up graphics context so we can use the font. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
687 f = XFRAME (selected_frame);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
688 context = get_frame_dc (f);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
689 check_font = CreateFontIndirect (font);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
690 old_font = SelectObject (context, check_font);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
691
93659
f606935ea4be (uniscribe_check_otf): Add GC protection before consing.
Jason Rumney <jasonr@gnu.org>
parents: 93654
diff changeset
692 /* Everything else is contained within otf_spec so should get
f606935ea4be (uniscribe_check_otf): Add GC protection before consing.
Jason Rumney <jasonr@gnu.org>
parents: 93654
diff changeset
693 marked along with it. */
f606935ea4be (uniscribe_check_otf): Add GC protection before consing.
Jason Rumney <jasonr@gnu.org>
parents: 93654
diff changeset
694 GCPRO1 (otf_spec);
f606935ea4be (uniscribe_check_otf): Add GC protection before consing.
Jason Rumney <jasonr@gnu.org>
parents: 93654
diff changeset
695
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
696 /* Scan GSUB and GPOS tables. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
697 for (i = 0; i < 2; i++)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
698 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
699 int j, n_match_features;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
700 unsigned short scriptlist_table, feature_table, n_scripts;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
701 unsigned short script_table, langsys_table, n_langs;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
702 unsigned short feature_index, n_features;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
703 DWORD tbl = feature_tables[i];
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
704
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
705 /* Skip if no features requested from this table. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
706 if (NILP (features[i]))
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
707 continue;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
708
93604
5476a4f5d2f2 (uniscribe_check_otf): Sanity check otf_spec.
Jason Rumney <jasonr@gnu.org>
parents: 93590
diff changeset
709 /* If features is not a cons, this font spec is messed up. */
5476a4f5d2f2 (uniscribe_check_otf): Sanity check otf_spec.
Jason Rumney <jasonr@gnu.org>
parents: 93590
diff changeset
710 if (!CONSP (features[i]))
5476a4f5d2f2 (uniscribe_check_otf): Sanity check otf_spec.
Jason Rumney <jasonr@gnu.org>
parents: 93590
diff changeset
711 goto no_support;
5476a4f5d2f2 (uniscribe_check_otf): Sanity check otf_spec.
Jason Rumney <jasonr@gnu.org>
parents: 93590
diff changeset
712
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
713 /* Read GPOS/GSUB header. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
714 OTF_INT16_VAL (tbl, 4, &scriptlist_table);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
715 OTF_INT16_VAL (tbl, 6, &feature_table);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
716 OTF_INT16_VAL (tbl, scriptlist_table, &n_scripts);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
717
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
718 /* Find the appropriate script table. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
719 script_table = 0;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
720 for (j = 0; j < n_scripts; j++)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
721 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
722 DWORD script_id;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
723 OTF_DWORDTAG_VAL (tbl, scriptlist_table + 2 + j * 6, &script_id);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
724 if (script_id == script_tag)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
725 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
726 OTF_INT16_VAL (tbl, scriptlist_table + 6 + j * 6, &script_table);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
727 break;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
728 }
97858
111763d689bf (uniscribe_check_otf): Don't fallback on DFLT script.
Jason Rumney <jasonr@gnu.org>
parents: 97848
diff changeset
729 #if 0 /* Causes false positives. */
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
730 /* If there is a DFLT script defined in the font, use it
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
731 if the specified script is not found. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
732 else if (script_id == default_script)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
733 OTF_INT16_VAL (tbl, scriptlist_table + 6 + j * 6, &script_table);
97858
111763d689bf (uniscribe_check_otf): Don't fallback on DFLT script.
Jason Rumney <jasonr@gnu.org>
parents: 97848
diff changeset
734 #endif
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
735 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
736 /* If no specific or default script table was found, then this font
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
737 does not support the script. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
738 if (!script_table)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
739 goto no_support;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
740
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
741 /* Offset is from beginning of scriptlist_table. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
742 script_table += scriptlist_table;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
743
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
744 /* Get default langsys table. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
745 OTF_INT16_VAL (tbl, script_table, &langsys_table);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
746
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
747 /* If lang was specified, see if font contains a specific entry. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
748 if (!NILP (lang))
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
749 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
750 OTF_INT16_VAL (tbl, script_table + 2, &n_langs);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
751
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
752 for (j = 0; j < n_langs; j++)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
753 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
754 DWORD lang_id;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
755 OTF_DWORDTAG_VAL (tbl, script_table + 4 + j * 6, &lang_id);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
756 if (lang_id == lang_tag)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
757 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
758 OTF_INT16_VAL (tbl, script_table + 8 + j * 6, &langsys_table);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
759 break;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
760 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
761 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
762 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
763
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
764 if (!langsys_table)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
765 goto no_support;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
766
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
767 /* Offset is from beginning of script table. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
768 langsys_table += script_table;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
769
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
770 /* Check the features. Features may contain nil according to
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
771 documentation in font_prop_validate_otf, so count them. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
772 n_match_features = 0;
93660
96c69ebb9cfa (uniscribe_check_otf): Rearrange loop for counting features.
Jason Rumney <jasonr@gnu.org>
parents: 93659
diff changeset
773 for (rest = features[i]; CONSP (rest); rest = XCDR (rest))
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
774 {
93660
96c69ebb9cfa (uniscribe_check_otf): Rearrange loop for counting features.
Jason Rumney <jasonr@gnu.org>
parents: 93659
diff changeset
775 Lisp_Object feature = XCAR (rest);
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
776 if (!NILP (feature))
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
777 n_match_features++;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
778 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
779
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
780 /* If there are no features to check, skip checking. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
781 if (!n_match_features)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
782 continue;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
783
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
784 /* First check required feature (if any). */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
785 OTF_INT16_VAL (tbl, langsys_table + 2, &feature_index);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
786 if (feature_index != 0xFFFF)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
787 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
788 char feature_id[5];
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
789 OTF_TAG_VAL (tbl, feature_table + 2 + feature_index * 6, feature_id);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
790 OTF_TAG_VAL (tbl, feature_table + 2 + feature_index * 6, feature_id);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
791 /* Assume no duplicates in the font table. This allows us to mark
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
792 the features off by simply decrementing a counter. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
793 if (!NILP (Fmemq (intern (feature_id), features[i])))
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
794 n_match_features--;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
795 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
796 /* Now check all the other features. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
797 OTF_INT16_VAL (tbl, langsys_table + 4, &n_features);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
798 for (j = 0; j < n_features; j++)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
799 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
800 char feature_id[5];
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
801 OTF_INT16_VAL (tbl, langsys_table + 6 + j * 2, &feature_index);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
802 OTF_TAG_VAL (tbl, feature_table + 2 + feature_index * 6, feature_id);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
803 /* Assume no duplicates in the font table. This allows us to mark
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
804 the features off by simply decrementing a counter. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
805 if (!NILP (Fmemq (intern (feature_id), features[i])))
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
806 n_match_features--;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
807 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
808
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
809 if (n_match_features > 0)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
810 goto no_support;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
811 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
812
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
813 retval = 1;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
814
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
815 no_support:
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
816 font_table_error:
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
817 /* restore graphics context. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
818 SelectObject (context, old_font);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
819 DeleteObject (check_font);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
820 release_frame_dc (f, context);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
821
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
822 return retval;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
823 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
824
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
825 static Lisp_Object
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
826 otf_features (HDC context, char *table)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
827 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
828 Lisp_Object script_list = Qnil;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
829 unsigned short scriptlist_table, n_scripts, feature_table;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
830 DWORD tbl = OTF_TAG (table);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
831 int i, j, k;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
832
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
833 /* Look for scripts in the table. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
834 OTF_INT16_VAL (tbl, 4, &scriptlist_table);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
835 OTF_INT16_VAL (tbl, 6, &feature_table);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
836 OTF_INT16_VAL (tbl, scriptlist_table, &n_scripts);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
837
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
838 for (i = 0; i < n_scripts; i++)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
839 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
840 char script[5], lang[5];
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
841 unsigned short script_table, lang_count, langsys_table, feature_count;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
842 Lisp_Object script_tag, langsys_list, langsys_tag, feature_list;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
843 unsigned short record_offset = scriptlist_table + 2 + i * 6;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
844 OTF_TAG_VAL (tbl, record_offset, script);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
845 OTF_INT16_VAL (tbl, record_offset + 4, &script_table);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
846
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
847 /* Offset is from beginning of script table. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
848 script_table += scriptlist_table;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
849
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
850 script_tag = intern (script);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
851 langsys_list = Qnil;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
852
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
853 /* Optional default lang. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
854 OTF_INT16_VAL (tbl, script_table, &langsys_table);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
855 if (langsys_table)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
856 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
857 /* Offset is from beginning of script table. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
858 langsys_table += script_table;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
859
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
860 langsys_tag = Qnil;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
861 feature_list = Qnil;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
862 OTF_INT16_VAL (tbl, langsys_table + 4, &feature_count);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
863 for (k = 0; k < feature_count; k++)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
864 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
865 char feature[5];
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
866 unsigned short index;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
867 OTF_INT16_VAL (tbl, langsys_table + 6 + k * 2, &index);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
868 OTF_TAG_VAL (tbl, feature_table + 2 + index * 6, feature);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
869 feature_list = Fcons (intern (feature), feature_list);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
870 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
871 langsys_list = Fcons (Fcons (langsys_tag, feature_list),
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
872 langsys_list);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
873 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
874
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
875 /* List of supported languages. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
876 OTF_INT16_VAL (tbl, script_table + 2, &lang_count);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
877
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
878 for (j = 0; j < lang_count; j++)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
879 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
880 record_offset = script_table + 4 + j * 6;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
881 OTF_TAG_VAL (tbl, record_offset, lang);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
882 OTF_INT16_VAL (tbl, record_offset + 4, &langsys_table);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
883
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
884 /* Offset is from beginning of script table. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
885 langsys_table += script_table;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
886
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
887 langsys_tag = intern (lang);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
888 feature_list = Qnil;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
889 OTF_INT16_VAL (tbl, langsys_table + 4, &feature_count);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
890 for (k = 0; k < feature_count; k++)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
891 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
892 char feature[5];
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
893 unsigned short index;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
894 OTF_INT16_VAL (tbl, langsys_table + 6 + k * 2, &index);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
895 OTF_TAG_VAL (tbl, feature_table + 2 + index * 6, feature);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
896 feature_list = Fcons (intern (feature), feature_list);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
897 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
898 langsys_list = Fcons (Fcons (langsys_tag, feature_list),
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
899 langsys_list);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
900
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
901 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
902
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
903 script_list = Fcons (Fcons (script_tag, langsys_list), script_list);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
904 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
905
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
906 return script_list;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
907
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
908 font_table_error:
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
909 return Qnil;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
910 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
911
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
912 #undef OTF_INT16_VAL
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
913 #undef OTF_TAG_VAL
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
914 #undef OTF_TAG
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
915
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
916
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
917 struct font_driver uniscribe_font_driver =
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
918 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
919 0, /* Quniscribe */
94911
f29483946da4 Delete USE_FONT_BACKEND conditional.
Kenichi Handa <handa@m17n.org>
parents: 93863
diff changeset
920 0, /* case insensitive */
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
921 w32font_get_cache,
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
922 uniscribe_list,
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
923 uniscribe_match,
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
924 uniscribe_list_family,
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
925 NULL, /* free_entity */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
926 uniscribe_open,
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
927 uniscribe_close,
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
928 NULL, /* prepare_face */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
929 NULL, /* done_face */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
930 w32font_has_char,
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
931 uniscribe_encode_char,
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
932 w32font_text_extents,
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
933 w32font_draw,
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
934 NULL, /* get_bitmap */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
935 NULL, /* free_bitmap */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
936 NULL, /* get_outline */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
937 NULL, /* free_outline */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
938 NULL, /* anchor_point */
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 110986
diff changeset
939 uniscribe_otf_capability, /* Defined so (font-get FONTOBJ :otf) works. */
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
940 NULL, /* otf_drive - use shape instead. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
941 NULL, /* start_for_frame */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
942 NULL, /* end_for_frame */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
943 uniscribe_shape
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
944 };
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
945
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
946 /* Note that this should be called at every startup, not just when dumping,
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
947 as it needs to test for the existence of the Uniscribe library. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
948 void
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
949 syms_of_w32uniscribe (void)
93590
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
950 {
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
951 HMODULE uniscribe;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
952
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
953 /* Don't init uniscribe when dumping */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
954 if (!initialized)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
955 return;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
956
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
957 /* Don't register if uniscribe is not available. */
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
958 uniscribe = GetModuleHandle ("usp10");
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
959 if (!uniscribe)
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
960 return;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
961
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
962 uniscribe_font_driver.type = Quniscribe;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
963 uniscribe_available = 1;
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
964
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
965 register_font_driver (&uniscribe_font_driver, NULL);
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
966 }
57eed2a0d99f Font backend implementation for Uniscribe on Windows 2000 and later.
Jason Rumney <jasonr@gnu.org>
parents:
diff changeset
967
93729
8dc921bd7171 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 93660
diff changeset
968 /* arch-tag: 9530f0e1-7471-47dd-a780-94330af87ea0
8dc921bd7171 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 93660
diff changeset
969 (do not change this comment) */