Mercurial > emacs
annotate src/nsfont.m @ 96676:336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
author | Adrian Robert <Adrian.B.Robert@gmail.com> |
---|---|
date | Tue, 15 Jul 2008 18:35:28 +0000 |
parents | |
children | e869d0172660 |
rev | line source |
---|---|
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1 /* Font back-end driver for the NeXT/Open/GNUstep and MacOSX window system. |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
2 See font.h |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
3 Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc. |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
4 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
5 This file is part of GNU Emacs. |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
6 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
7 GNU Emacs is free software; you can redistribute it and/or modify |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
8 it under the terms of the GNU General Public License as published by |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
9 the Free Software Foundation; either version 3, or (at your option) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
10 any later version. |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
11 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
12 GNU Emacs is distributed in the hope that it will be useful, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
15 GNU General Public License for more details. |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
16 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
18 along with GNU Emacs; see the file COPYING. If not, write to |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
20 Boston, MA 02110-1301, USA. |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
21 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
22 Author: Adrian Robert (arobert@cogsci.ucsd.edu) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
23 */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
24 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
25 #include "config.h" |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
26 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
27 #include "lisp.h" |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
28 #include "dispextern.h" |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
29 #include "composite.h" |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
30 #include "blockinput.h" |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
31 #include "charset.h" |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
32 #include "frame.h" |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
33 #include "window.h" |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
34 #include "fontset.h" |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
35 #include "nsterm.h" |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
36 #include "frame.h" |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
37 #include "character.h" |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
38 #include "font.h" |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
39 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
40 #define NSFONT_TRACE 0 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
41 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
42 extern Lisp_Object Qns; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
43 extern Lisp_Object Qnormal, Qbold, Qitalic, Qcondensed, Qexpanded; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
44 static Lisp_Object Qapple, Qroman, Qmedium; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
45 extern Lisp_Object ns_expand_space; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
46 extern Lisp_Object Qappend; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
47 extern int ns_antialias_text, ns_use_qd_smoothing; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
48 extern float ns_antialias_threshold; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
49 extern int ns_tmp_flags; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
50 extern struct nsfont_info *ns_tmp_font; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
51 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
52 /* font glyph and metrics caching functions, implemented at end */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
53 static void ns_uni_to_glyphs (struct nsfont_info *font_info, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
54 unsigned char block); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
55 static void ns_glyph_metrics (struct nsfont_info *font_info, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
56 unsigned char block); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
57 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
58 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
59 /* ========================================================================== |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
60 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
61 Utilities |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
62 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
63 ========================================================================== */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
64 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
65 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
66 /* Replace spaces w/another character so emacs core font parsing routines |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
67 aren't thrown off. */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
68 static void |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
69 nsfont_escape_name (char *name) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
70 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
71 int i =0, len =strlen (name); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
72 for ( ; i<len; i++) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
73 if (name[i] == ' ') |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
74 name[i] = '_'; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
75 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
76 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
77 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
78 /* Reconstruct spaces in a font family name passed through emacs. */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
79 static void |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
80 nsfont_unescape_name (char *name) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
81 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
82 int i =0, len =strlen (name); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
83 for ( ; i<len; i++) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
84 if (name[i] == '_') |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
85 name[i] = ' '; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
86 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
87 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
88 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
89 /* Extract family name from a font spec. */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
90 static NSString * |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
91 nsfont_get_family (Lisp_Object font_spec) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
92 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
93 Lisp_Object tem = AREF (font_spec, FONT_FAMILY_INDEX); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
94 if (NILP (tem)) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
95 return nil; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
96 else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
97 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
98 char *tmp = strdup (SDATA (SYMBOL_NAME (tem))); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
99 NSString *family; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
100 nsfont_unescape_name (tmp); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
101 /* PENDING: this seems to be needed only for font names that are |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
102 hard-coded into emacs, like 'helvetica' for splash screen */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
103 if (tmp) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
104 tmp[0] = toupper (tmp[0]); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
105 family = [NSString stringWithUTF8String: tmp]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
106 free (tmp); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
107 return family; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
108 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
109 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
110 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
111 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
112 /* Converts FONT_WEIGHT, FONT_SLANT, FONT_WIDTH to NSFont traits. */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
113 /* PENDING (20080601): The font backend's strategy for handling font |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
114 styles continues to evolve. When/if this stabilizes, we |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
115 can change the code here to be more sophisticated and accurate. |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
116 For now, we rely on "normal/plain" style being numeric 100. */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
117 #define STYLE_REF 100 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
118 static unsigned int |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
119 nsfont_spec_to_traits (Lisp_Object font_spec) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
120 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
121 unsigned int traits = 0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
122 int n; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
123 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
124 n = FONT_WEIGHT_NUMERIC (font_spec); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
125 if (n != -1) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
126 traits |= (n > STYLE_REF) ? NSBoldFontMask : NSUnboldFontMask; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
127 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
128 n = FONT_SLANT_NUMERIC (font_spec); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
129 if (n != -1) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
130 traits |= (n > STYLE_REF) ? NSItalicFontMask : NSUnitalicFontMask; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
131 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
132 n = FONT_WIDTH_NUMERIC (font_spec); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
133 if (n > -1) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
134 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
135 if (n < STYLE_REF - 10) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
136 traits |= NSCondensedFontMask; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
137 else if (n > STYLE_REF + 10) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
138 traits |= NSExpandedFontMask; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
139 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
140 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
141 /*fprintf (stderr, " returning traits = %u\n", traits); */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
142 return traits; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
143 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
144 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
145 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
146 /* Converts NSArray of PS name, non-family part, weight, and traits to a |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
147 font backend font-entity. */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
148 static Lisp_Object |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
149 nsfont_fmember_to_entity (NSString *family, NSArray *famMember) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
150 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
151 Lisp_Object font_entity = font_make_entity (); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
152 unsigned int traits = [[famMember objectAtIndex: 3] unsignedIntValue]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
153 /* NSString *psName = [famMember objectAtIndex: 0]; */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
154 NSMutableString *suffix = [[famMember objectAtIndex: 1] mutableCopy]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
155 char *escapedFamily = [family UTF8String]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
156 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
157 nsfont_escape_name (escapedFamily); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
158 [suffix replaceOccurrencesOfString: @" " withString: @"" options: 0 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
159 range: NSMakeRange (0, [suffix length])]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
160 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
161 ASET (font_entity, FONT_TYPE_INDEX, Qns); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
162 ASET (font_entity, FONT_FOUNDRY_INDEX, Qapple); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
163 ASET (font_entity, FONT_FAMILY_INDEX, intern (escapedFamily)); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
164 ASET (font_entity, FONT_ADSTYLE_INDEX, intern ([suffix UTF8String])); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
165 ASET (font_entity, FONT_REGISTRY_INDEX, Qiso10646_1); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
166 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
167 FONT_SET_STYLE (font_entity, FONT_WEIGHT_INDEX, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
168 traits & NSBoldFontMask ? Qbold : Qmedium); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
169 FONT_SET_STYLE (font_entity, FONT_SLANT_INDEX, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
170 traits & NSItalicFontMask ? Qitalic : Qnormal); /*XXX: should be Qroman */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
171 FONT_SET_STYLE (font_entity, FONT_WIDTH_INDEX, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
172 traits & NSCondensedFontMask ? Qcondensed : |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
173 traits & NSExpandedFontMask ? Qexpanded : Qnormal); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
174 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
175 ASET (font_entity, FONT_SIZE_INDEX, make_number (0)); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
176 ASET (font_entity, FONT_EXTRA_INDEX, Qnil); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
177 ASET (font_entity, FONT_OBJLIST_INDEX, Qnil); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
178 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
179 if (NSFONT_TRACE) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
180 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
181 fprintf (stderr, "created font_entity:\n "); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
182 debug_print (font_entity); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
183 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
184 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
185 [suffix release]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
186 return font_entity; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
187 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
188 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
189 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
190 /* Computes Hamming distance btwn two "vectors" of 0's and 1's. */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
191 static int |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
192 nsfont_trait_distance (unsigned int traits1, unsigned int traits2) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
193 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
194 int i, d =0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
195 for (i =0; i<sizeof (unsigned int)*8; i++) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
196 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
197 d += (traits1 & 0x1) ^ (traits2 & 0x1); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
198 traits1 >> 1; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
199 traits2 >> 1; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
200 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
201 return d; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
202 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
203 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
204 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
205 /* Default font entity based on Monaco. */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
206 static Lisp_Object |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
207 nsfont_fallback_entity () |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
208 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
209 NSString *family = [[NSFont userFixedPitchFontOfSize: 0] familyName]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
210 NSArray *famMemberSpec = [NSArray arrayWithObjects: family, @"", |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
211 [NSNumber numberWithUnsignedInt: 5], |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
212 [NSNumber numberWithUnsignedInt: 0], nil]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
213 return nsfont_fmember_to_entity (family, famMemberSpec); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
214 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
215 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
216 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
217 /* ========================================================================== |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
218 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
219 Font driver implementation |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
220 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
221 ========================================================================== */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
222 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
223 static Lisp_Object nsfont_get_cache (FRAME_PTR frame); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
224 static Lisp_Object nsfont_list (Lisp_Object frame, Lisp_Object font_spec); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
225 static Lisp_Object nsfont_match (Lisp_Object frame, Lisp_Object font_spec); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
226 static Lisp_Object nsfont_list_family (Lisp_Object frame); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
227 static Lisp_Object nsfont_open (FRAME_PTR f, Lisp_Object font_entity, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
228 int pixel_size); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
229 static void nsfont_close (FRAME_PTR f, struct font *font); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
230 static int nsfont_has_char (Lisp_Object entity, int c); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
231 static unsigned int nsfont_encode_char (struct font *font, int c); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
232 static int nsfont_text_extents (struct font *font, unsigned int *code, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
233 int nglyphs, struct font_metrics *metrics); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
234 static int nsfont_draw (struct glyph_string *s, int from, int to, int x, int y, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
235 int with_background); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
236 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
237 struct font_driver nsfont_driver = |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
238 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
239 (Lisp_Object) NULL, /* Qns */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
240 1, /* case sensitive */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
241 nsfont_get_cache, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
242 nsfont_list, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
243 nsfont_match, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
244 nsfont_list_family, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
245 NULL, /*free_entity */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
246 nsfont_open, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
247 nsfont_close, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
248 NULL, /* prepare_face */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
249 NULL, /* done_face */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
250 nsfont_has_char, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
251 nsfont_encode_char, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
252 nsfont_text_extents, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
253 nsfont_draw, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
254 /* excluded: get_bitmap, free_bitmap, get_outline, free_outline, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
255 anchor_point, otf_capability, otf_driver, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
256 start_for_frame, end_for_frame, shape */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
257 }; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
258 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
259 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
260 /* Return a cache of font-entities on FRAME. The cache must be a |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
261 cons whose cdr part is the actual cache area. */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
262 static Lisp_Object |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
263 nsfont_get_cache (FRAME_PTR frame) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
264 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
265 Display_Info *dpyinfo = FRAME_NS_DISPLAY_INFO (frame); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
266 return (dpyinfo->name_list_element); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
267 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
268 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
269 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
270 /* List fonts exactly matching with FONT_SPEC on FRAME. The value |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
271 is a vector of font-entities. This is the sole API that |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
272 allocates font-entities. */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
273 static Lisp_Object |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
274 nsfont_list (Lisp_Object frame, Lisp_Object font_spec) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
275 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
276 Lisp_Object list = Qnil; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
277 Lisp_Object tem; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
278 NSString *family; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
279 NSArray *families; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
280 NSEnumerator *famEnum; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
281 NSFontManager *fontMgr; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
282 unsigned int traits = nsfont_spec_to_traits (font_spec); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
283 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
284 if (NSFONT_TRACE) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
285 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
286 fprintf (stderr, "nsfont: list for fontspec:\n "); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
287 debug_print (font_spec); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
288 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
289 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
290 /* if has non-unicode registry, give up */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
291 tem = AREF (font_spec, FONT_REGISTRY_INDEX); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
292 if (!EQ (tem, Qiso10646_1) && !EQ (tem, Qunicode_bmp)) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
293 return Qnil; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
294 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
295 fontMgr = [NSFontManager sharedFontManager]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
296 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
297 family = nsfont_get_family (font_spec); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
298 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
299 if (family != nil) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
300 families = [NSArray arrayWithObject: family]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
301 else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
302 families = [fontMgr availableFontFamilies]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
303 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
304 for (famEnum = [families objectEnumerator]; family = [famEnum nextObject]; ) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
305 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
306 NSEnumerator *fm; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
307 NSArray *fmember, *firstMember = nil; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
308 unsigned int mtraits; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
309 BOOL foundItal = NO || (traits & NSUnitalicFontMask); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
310 NSArray *famMembers = [fontMgr availableMembersOfFontFamily: family]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
311 #ifdef NS_IMPL_COCOA |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
312 /* LastResort is special: not a family but a font name only */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
313 if ([@"LastResort" isEqualToString: family] && [famMembers count] == 0) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
314 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
315 famMembers = [NSArray arrayWithObject: [NSArray arrayWithObjects: |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
316 @"LastResort", @"", [NSNumber numberWithUnsignedInt: 5], |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
317 [NSNumber numberWithUnsignedInt: 0], nil]]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
318 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
319 #endif |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
320 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
321 /* fmember = [postscriptName style weight traits] */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
322 fm = [famMembers objectEnumerator]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
323 while (fmember = [fm nextObject]) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
324 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
325 mtraits = [[fmember objectAtIndex: 3] unsignedIntValue]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
326 if ((mtraits & traits) == traits) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
327 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
328 list = Fcons (nsfont_fmember_to_entity (family, fmember), list); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
329 if (mtraits & NSItalicFontMask) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
330 foundItal = YES; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
331 if (firstMember == nil) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
332 firstMember = fmember; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
333 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
334 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
335 if (foundItal == NO && firstMember != nil) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
336 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
337 /* no italic member found; add a synthesized one */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
338 NSMutableArray *smember = [firstMember mutableCopy]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
339 [smember replaceObjectAtIndex: 1 withObject: @"synthItal" ]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
340 mtraits = [[fmember objectAtIndex: 3] unsignedIntValue]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
341 mtraits |= NSItalicFontMask; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
342 [smember replaceObjectAtIndex: 3 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
343 withObject: [NSNumber numberWithUnsignedInt: mtraits]]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
344 /*NSLog (@"-- adding synthItal member: %@", smember); */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
345 list = Fcons (nsfont_fmember_to_entity (family, smember), list); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
346 [smember release]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
347 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
348 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
349 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
350 if (NSFONT_TRACE) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
351 fprintf (stderr, " Returning %d entities.\n", XINT (Flength (list))); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
352 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
353 return (NILP (list) ? Qnil : Fvconcat (1, &list));/* Qnil was null_vector */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
354 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
355 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
356 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
357 /* Return a font entity most closely maching with FONT_SPEC on |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
358 FRAME. The closeness is determined by the font backend, thus |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
359 `face-font-selection-order' is ignored here. */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
360 static Lisp_Object |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
361 nsfont_match (Lisp_Object frame, Lisp_Object font_spec) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
362 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
363 long traits = nsfont_spec_to_traits (font_spec); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
364 NSFontManager *fontMgr = [NSFontManager sharedFontManager]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
365 NSString *family; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
366 Lisp_Object tem; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
367 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
368 if (NSFONT_TRACE) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
369 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
370 fprintf (stderr, "nsfont: match for fontspec:\n "); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
371 debug_print (font_spec); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
372 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
373 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
374 /* if has non-unicode registry, just return fallback */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
375 #if 0 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
376 tem = AREF (font_spec, FONT_ADSTYLE_INDEX); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
377 if (!NILP (tem)) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
378 fprintf (stderr, "adstyle: '%s'\n", SDATA (tem)); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
379 #endif |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
380 tem = AREF (font_spec, FONT_REGISTRY_INDEX); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
381 if (!EQ (tem, Qiso10646_1) && !EQ (tem, Qunicode_bmp)) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
382 return nsfont_fallback_entity (); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
383 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
384 family = nsfont_get_family (font_spec); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
385 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
386 if (family != nil) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
387 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
388 /* try to find close font in family */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
389 NSArray *famMembers = [fontMgr availableMembersOfFontFamily: family]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
390 NSEnumerator *fm = [famMembers objectEnumerator]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
391 NSArray *fmember; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
392 int minDist = sizeof (unsigned int) * 8 + 1; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
393 int bestMatchIdx = -1; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
394 int i; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
395 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
396 for (i =0; fmember = [fm nextObject]; i++) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
397 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
398 unsigned int mtraits = [[fmember objectAtIndex: 3] unsignedIntValue]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
399 int dist = nsfont_trait_distance ((mtraits & traits), traits); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
400 if (dist < minDist) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
401 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
402 bestMatchIdx = i; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
403 minDist = dist; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
404 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
405 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
406 if (bestMatchIdx != -1) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
407 return nsfont_fmember_to_entity |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
408 (family, [famMembers objectAtIndex: bestMatchIdx]); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
409 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
410 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
411 /* no family that had members was given; find any font matching traits */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
412 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
413 NSArray *fontNames = [fontMgr availableFontNamesWithTraits: traits]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
414 if (fontNames && [fontNames count] > 0) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
415 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
416 NSString *fontName = [fontNames objectAtIndex: 0]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
417 /*PENDING: is there a more efficient way to get family name? */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
418 NSFont *font = [NSFont fontWithName: fontName size: 0]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
419 if (font != nil) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
420 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
421 /* now need to get suffix part of name.. */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
422 NSString *family = [font familyName]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
423 NSEnumerator *fm = [[fontMgr availableMembersOfFontFamily: family] |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
424 objectEnumerator]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
425 NSArray *fmember; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
426 while (fmember = [fm nextObject]) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
427 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
428 unsigned int mtraits = |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
429 [[fmember objectAtIndex: 3] unsignedIntValue]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
430 if (mtraits & traits == traits) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
431 return nsfont_fmember_to_entity (family, fmember); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
432 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
433 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
434 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
435 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
436 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
437 /* if we get here, return the fallback */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
438 if (NSFONT_TRACE) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
439 fprintf (stderr, " *** returning fallback\n"); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
440 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
441 return nsfont_fallback_entity (); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
442 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
443 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
444 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
445 /* List available families. The value is a list of family names |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
446 (symbols). */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
447 static Lisp_Object |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
448 nsfont_list_family (Lisp_Object frame) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
449 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
450 Lisp_Object list = Qnil; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
451 NSEnumerator *families = |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
452 [[[NSFontManager sharedFontManager] availableFontFamilies] |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
453 objectEnumerator]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
454 NSString *family; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
455 while (family = [families nextObject]) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
456 list = Fcons (intern ([family UTF8String]), list); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
457 /*PENDING: escape the name? */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
458 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
459 if (NSFONT_TRACE) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
460 fprintf (stderr, "nsfont: list families returning %d entries\n", |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
461 XINT (Flength (list))); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
462 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
463 return list; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
464 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
465 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
466 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
467 /* utility: get width of a char c in screen font sfont */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
468 static float |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
469 nsfont_char_width (NSFont *sfont, int c) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
470 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
471 float w; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
472 NSString *cstr = [NSString stringWithFormat: @"%c", c]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
473 #ifdef NS_IMPL_COCOA |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
474 NSGlyph glyph = [sfont glyphWithName: cstr]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
475 if (glyph) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
476 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
477 float w = [sfont advancementForGlyph: glyph].width; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
478 if (w >= 1.5) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
479 return w; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
480 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
481 #endif |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
482 w = [sfont widthOfString: cstr]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
483 return max (w, 2.0); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
484 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
485 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
486 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
487 /* Open a font specified by FONT_ENTITY on frame F. If the font is |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
488 scalable, open it with PIXEL_SIZE. */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
489 static Lisp_Object |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
490 nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
491 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
492 BOOL synthItal; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
493 struct nsfont_info *font_info; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
494 struct font *font; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
495 unsigned int traits = nsfont_spec_to_traits (font_entity); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
496 NSFontManager *fontMgr = [NSFontManager sharedFontManager]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
497 NSString *family; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
498 NSFont *nsfont, *sfont; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
499 Lisp_Object tem; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
500 NSRect brect; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
501 Lisp_Object font_object; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
502 int i; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
503 int fixLeopardBug; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
504 #if 0 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
505 static NSMutableDictionary *fontCache = nil; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
506 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
507 /* 2008/03/08: The same font may end up being requested for different |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
508 entities, due to small differences in numeric values or other issues, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
509 or for different copies of the same entity. Therefore we cache to |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
510 avoid creating multiple struct font objects (with metrics cache, etc.) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
511 for the same NSFont object. |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
512 2008/06/01: This is still an issue, but after font backend refactoring |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
513 caching will be more difficult, needs to be reworked before enabling. */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
514 if (fontCache == nil) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
515 fontCache = [[NSMutableDictionary alloc] init]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
516 #endif |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
517 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
518 font_object = font_make_object (VECSIZE (struct nsfont_info), font_entity, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
519 pixel_size); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
520 font_info = (struct nsfont_info *) XFONT_OBJECT (font_object); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
521 font = (struct font *)font_info; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
522 if (!font) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
523 return NULL; /*PENDING: this copies w32, but causes a segfault */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
524 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
525 if (NSFONT_TRACE) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
526 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
527 fprintf (stderr, "nsfont: open size %d of fontentity:\n ", pixel_size); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
528 debug_print (font_entity); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
529 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
530 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
531 if (pixel_size <= 0) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
532 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
533 /* try to get it out of frame params */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
534 Lisp_Object tem = get_frame_param (f, Qfontsize); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
535 pixel_size = NILP (tem) ? 0 : XFASTINT (tem); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
536 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
537 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
538 tem = AREF (font_entity, FONT_ADSTYLE_INDEX); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
539 synthItal = !NILP (tem) && !strncmp ("synthItal", SDATA (SYMBOL_NAME (tem)), |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
540 9); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
541 family = nsfont_get_family (font_entity); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
542 if (NSFONT_TRACE) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
543 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
544 fprintf (stderr, "family: '%s'\ttraits = %ld\tbold = %d\n", |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
545 [family UTF8String], traits, traits & NSBoldFontMask); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
546 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
547 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
548 /* see http://cocoadev.com/forums/comments.php?DiscussionID =74 */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
549 fixLeopardBug = traits & NSBoldFontMask ? 10 : 5; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
550 nsfont = [fontMgr fontWithFamily: family |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
551 traits: traits weight: fixLeopardBug |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
552 size: pixel_size]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
553 /* if didn't find, try synthetic italic */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
554 if (nsfont == nil && synthItal && (traits & NSItalicFontMask)) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
555 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
556 nsfont = [fontMgr fontWithFamily: family |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
557 traits: traits & ~NSItalicFontMask |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
558 weight: fixLeopardBug size: pixel_size]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
559 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
560 #ifdef NS_IMPL_COCOA |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
561 /* LastResort not really a family */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
562 if (nsfont == nil && [@"LastResort" isEqualToString: family]) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
563 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
564 nsfont = [NSFont fontWithName: @"LastResort" size: pixel_size]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
565 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
566 #endif |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
567 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
568 if (nsfont == nil) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
569 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
570 message_with_string ("*** Warning: font in family '%s' not found", |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
571 build_string ([family UTF8String]), 1); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
572 nsfont = [NSFont userFixedPitchFontOfSize: pixel_size]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
573 if (!nsfont) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
574 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
575 fprintf (stderr, "*** Emacs.app: unable to load backup font\n"); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
576 return NULL; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
577 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
578 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
579 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
580 #if 0 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
581 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
582 NSNumber *cached = [fontCache objectForKey: nsfont]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
583 if (cached != nil && !synthItal) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
584 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
585 fprintf (stderr, "*** CACHE HIT!\n"); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
586 struct font_info *existing = |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
587 (struct nsfont_info *)[cached unsignedLongValue]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
588 /* ... */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
589 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
590 else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
591 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
592 if (!synthItal) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
593 [fontCache |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
594 setObject: [NSNumber numberWithUnsignedLong: |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
595 (unsigned long)font_info] |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
596 forKey: nsfont]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
597 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
598 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
599 #endif |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
600 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
601 font_info->glyphs = (unsigned short *) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
602 xmalloc (0x100 * sizeof (unsigned short *)); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
603 font_info->metrics = (struct font_metrics *) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
604 xmalloc (0x100 * sizeof (struct font_metrics *)); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
605 if (!font_info->glyphs || !font_info->metrics) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
606 return NULL; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
607 bzero (font_info->glyphs, 0x100 * sizeof (unsigned short *)); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
608 bzero (font_info->metrics, 0x100 * sizeof (struct font_metrics *)); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
609 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
610 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
611 BLOCK_INPUT; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
612 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
613 /* for metrics */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
614 sfont = [nsfont screenFont]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
615 if (sfont == nil) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
616 sfont = nsfont; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
617 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
618 /* non-metric backend font struct fields */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
619 font = (struct font *) font_info; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
620 font->pixel_size = [sfont pointSize]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
621 font->driver = &nsfont_driver; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
622 font->encoding_type = FONT_ENCODING_NOT_DECIDED; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
623 font->encoding_charset = -1; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
624 font->repertory_charset = -1; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
625 font->default_ascent = 0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
626 font->vertical_centering = 0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
627 font->baseline_offset = 0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
628 font->relative_compose = 0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
629 font->font_encoder = NULL; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
630 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
631 /*PENDING: does anything care about this? */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
632 font->props[FONT_FORMAT_INDEX] = Qns; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
633 font->props[FONT_FILE_INDEX] = Qnil; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
634 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
635 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
636 double expand, shrink, hshrink; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
637 float full_height, min_height, hd; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
638 const char *fontName = [[nsfont fontName] UTF8String]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
639 int len = strlen (fontName); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
640 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
641 #ifdef NS_IMPL_GNUSTEP |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
642 font_info->nsfont = sfont; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
643 #else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
644 font_info->nsfont = nsfont; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
645 #endif |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
646 [font_info->nsfont retain]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
647 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
648 /* set up ns_font (defined in nsgui.h) */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
649 font_info->name = (char *)xmalloc (strlen (fontName)+1); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
650 bcopy (fontName, font_info->name, strlen (fontName)+1); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
651 font_info->bold = [fontMgr traitsOfFont: nsfont] & NSBoldFontMask; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
652 font_info->ital = |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
653 synthItal || ([fontMgr traitsOfFont: nsfont] & NSItalicFontMask); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
654 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
655 /* Metrics etc.; some fonts return an unusually large max advance, so we |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
656 only use it for fonts that have wide characters. */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
657 font_info->width = ([sfont numberOfGlyphs] > 2000) ? |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
658 [sfont maximumAdvancement].width : nsfont_char_width (sfont, '0'); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
659 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
660 brect = [sfont boundingRectForFont]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
661 full_height = brect.size.height; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
662 min_height = [sfont ascender] - [sfont descender]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
663 hd = full_height - min_height; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
664 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
665 if (!NUMBERP (ns_expand_space)) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
666 error ("No expand space defined"); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
667 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
668 /* ns_expand_space = 0.0 is use standard height; less shrink, more expand */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
669 expand = XFLOATINT (ns_expand_space) + 0.5; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
670 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
671 if (expand < 0.0) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
672 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
673 shrink = 1 + expand; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
674 hshrink = 1 + expand / 2.0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
675 expand = 0.0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
676 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
677 else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
678 shrink = hshrink = 1.0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
679 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
680 font_info->underpos = 2; /*[sfont underlinePosition] is often clipped out */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
681 font_info->underwidth = [sfont underlineThickness]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
682 font_info->size = font->pixel_size; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
683 font_info->voffset = lrint (hshrink * [sfont ascender] + expand * hd / 2); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
684 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
685 /* max bounds */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
686 font_info->max_bounds.ascent = |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
687 lrint (hshrink * [sfont ascender] + expand * hd/2); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
688 font_info->max_bounds.descent = |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
689 -lrint (hshrink* [sfont descender] - expand*hd/2); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
690 font_info->height = |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
691 font_info->max_bounds.ascent + font_info->max_bounds.descent; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
692 font_info->max_bounds.width = lrint (font_info->width); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
693 font_info->max_bounds.lbearing = lrint (brect.origin.x); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
694 font_info->max_bounds.rbearing = |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
695 lrint (brect.size.width - font_info->width); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
696 /*font_info->width + (font_info->ital ? 0.2 * font_info->height : 0); */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
697 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
698 #ifdef NS_IMPL_COCOA |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
699 /* set up synthItal and the CG font */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
700 font_info->synthItal = synthItal; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
701 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
702 ATSFontRef atsFont = ATSFontFindFromPostScriptName |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
703 ((CFStringRef)[nsfont fontName], kATSOptionFlagsDefault); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
704 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
705 if (atsFont == kATSFontRefUnspecified) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
706 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
707 /* see if we can get it by dropping italic (then synthesizing) */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
708 atsFont = ATSFontFindFromPostScriptName ((CFStringRef) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
709 [[fontMgr convertFont: nsfont toNotHaveTrait: NSItalicFontMask] |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
710 fontName], kATSOptionFlagsDefault); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
711 if (atsFont != kATSFontRefUnspecified) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
712 font_info->synthItal = YES; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
713 else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
714 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
715 /* last resort fallback */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
716 atsFont = ATSFontFindFromPostScriptName |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
717 ((CFStringRef)@"Monaco", kATSOptionFlagsDefault); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
718 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
719 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
720 font_info->cgfont = CGFontCreateWithPlatformFont ((void*)&atsFont); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
721 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
722 #endif |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
723 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
724 /* set up metrics portion of font struct */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
725 font->ascent = [sfont ascender]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
726 font->descent = -[sfont descender]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
727 font->min_width = [sfont widthOfString: @"|"]; /* PENDING */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
728 font->space_width = lrint (nsfont_char_width (sfont, ' ')); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
729 font->average_width = lrint (font_info->width); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
730 font->max_width = lrint (font_info->max_bounds.width); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
731 font->height = lrint (font_info->height); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
732 font->underline_position = lrint (font_info->underpos); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
733 font->underline_thickness = lrint (font_info->underwidth); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
734 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
735 font->props[FONT_NAME_INDEX] = Ffont_xlfd_name (font_object, Qnil); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
736 font->props[FONT_FULLNAME_INDEX] = |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
737 make_unibyte_string (font_info->name, strlen (font_info->name)); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
738 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
739 UNBLOCK_INPUT; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
740 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
741 return font_object; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
742 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
743 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
744 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
745 /* Close FONT on frame F. */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
746 static void |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
747 nsfont_close (FRAME_PTR f, struct font *font) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
748 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
749 struct nsfont_info *font_info = (struct nsfont_info *)font; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
750 int i; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
751 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
752 /* PENDING: this occurs apparently due to same failure to detect same font |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
753 that causes need for cache in nsfont_open () |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
754 (came after unicode-2 -> trunk) */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
755 if (!font_info) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
756 return; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
757 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
758 for (i =0; i<0x100; i++) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
759 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
760 if (font_info->glyphs[i]) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
761 xfree (font_info->glyphs[i]); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
762 if (font_info->metrics[i]) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
763 xfree (font_info->metrics[i]); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
764 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
765 [font_info->nsfont release]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
766 #ifdef NS_IMPL_COCOA |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
767 CGFontRelease (font_info->cgfont); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
768 #endif |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
769 xfree (font_info->name); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
770 xfree (font_info); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
771 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
772 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
773 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
774 /* If FONT_ENTITY has a glyph for character C (Unicode code point), |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
775 return 1. If not, return 0. If a font must be opened to check |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
776 it, return -1. */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
777 static int |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
778 nsfont_has_char (Lisp_Object entity, int c) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
779 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
780 return -1; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
781 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
782 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
783 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
784 /* Return a glyph code of FONT for character C (Unicode code point). |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
785 If FONT doesn't have such a glyph, return FONT_INVALID_CODE. */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
786 static unsigned int |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
787 nsfont_encode_char (struct font *font, int c) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
788 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
789 struct nsfont_info *font_info = (struct nsfont_info *)font; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
790 unsigned char high = (c & 0xff00) >> 8, low = c & 0x00ff; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
791 unsigned short g; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
792 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
793 if (c > 0xFFFF) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
794 return FONT_INVALID_CODE; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
795 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
796 /* did we already cache this block? */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
797 if (!font_info->glyphs[high]) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
798 ns_uni_to_glyphs (font_info, high); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
799 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
800 g = font_info->glyphs[high][low]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
801 /*fprintf (stderr, "mapping char %d -> %d\n", c, g); */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
802 return g == 0xFFFF ? FONT_INVALID_CODE : g; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
803 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
804 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
805 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
806 /* Perform the size computation of glyphs of FONT and fill in members |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
807 of METRICS. The glyphs are specified by their glyph codes in |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
808 CODE (length NGLYPHS). */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
809 static int |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
810 nsfont_text_extents (struct font *font, unsigned int *code, int nglyphs, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
811 struct font_metrics *metrics) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
812 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
813 struct nsfont_info *font_info = (struct nsfont_info *)font; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
814 struct font_metrics *pcm; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
815 unsigned char high, low; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
816 int totalWidth = 0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
817 int i; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
818 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
819 bzero (metrics, sizeof (struct font_metrics)); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
820 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
821 for (i =0; i<nglyphs; i++) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
822 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
823 /* get metrics for this glyph, filling cache if need be */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
824 /* PENDING: get metrics for whole string from an NSLayoutManager |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
825 (if not too slow) */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
826 high = (code[i] & 0xFF00) >> 8; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
827 low = code[i] & 0x00FF; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
828 if (!font_info->metrics[high]) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
829 ns_glyph_metrics (font_info, high); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
830 pcm = &(font_info->metrics[high][low]); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
831 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
832 if (metrics->lbearing > totalWidth + pcm->lbearing) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
833 metrics->lbearing = totalWidth + pcm->lbearing; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
834 if (metrics->rbearing < totalWidth + pcm->rbearing) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
835 metrics->rbearing = totalWidth + pcm->rbearing; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
836 if (metrics->ascent < pcm->ascent) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
837 metrics->ascent = pcm->ascent; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
838 if (metrics->descent < pcm->descent) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
839 metrics->descent = pcm->descent; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
840 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
841 totalWidth += pcm->width; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
842 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
843 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
844 metrics->width = totalWidth; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
845 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
846 return totalWidth; /* not specified in doc, but xfont.c does it */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
847 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
848 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
849 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
850 /* Draw glyphs between FROM and TO of S->char2b at (X Y) pixel |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
851 position of frame F with S->FACE and S->GC. If WITH_BACKGROUND |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
852 is nonzero, fill the background in advance. It is assured that |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
853 WITH_BACKGROUND is zero when (FROM > 0 || TO < S->nchars). */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
854 static int |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
855 nsfont_draw (struct glyph_string *s, int from, int to, int x, int y, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
856 int with_background) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
857 /* NOTE: focus and clip must be set |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
858 also, currently assumed (true in nsterm.m call) from ==0, to ==nchars */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
859 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
860 static char cbuf[1024]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
861 char *c = cbuf; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
862 #ifdef NS_IMPL_GNUSTEP |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
863 static float advances[1024]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
864 float *adv = advances; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
865 #else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
866 static CGSize advances[1024]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
867 CGSize *adv = advances; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
868 #endif |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
869 struct face *face; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
870 NSRect r; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
871 struct nsfont_info *font = ns_tmp_font; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
872 NSColor *col, *bgCol; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
873 unsigned short *t = s->char2b; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
874 int i, len; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
875 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
876 /* Select face based on input flags */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
877 switch (ns_tmp_flags) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
878 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
879 case NS_DUMPGLYPH_CURSOR: |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
880 face = s->face; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
881 break; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
882 case NS_DUMPGLYPH_MOUSEFACE: |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
883 face = FACE_FROM_ID (s->f, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
884 FRAME_NS_DISPLAY_INFO (s->f)->mouse_face_face_id); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
885 if (!face) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
886 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
887 break; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
888 default: |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
889 face = s->face; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
890 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
891 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
892 r.origin.x = s->x; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
893 if (s->face->box != FACE_NO_BOX && s->first_glyph->left_box_line_p) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
894 r.origin.x += abs (s->face->box_line_width); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
895 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
896 r.origin.y = s->y; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
897 r.size.height = FONT_HEIGHT (font); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
898 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
899 /* Convert UTF-16 (?) to UTF-8 and determine advances. Note if we just ask |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
900 NS to render the string, it will come out differently from the individual |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
901 character widths added up because of layout processing. */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
902 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
903 XCharStruct *cs; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
904 int cwidth, twidth = 0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
905 int hi, lo; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
906 char isComposite = 0; /* s->first_glyph->type == COMPOSITE_GLYPH; */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
907 /* PENDING: composition: no vertical displacement is considered. */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
908 t+= s->gidx; /* advance into composition */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
909 for (i =0; i<s->nchars - s->gidx; i++, t++) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
910 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
911 hi = (*t & 0xFF00) >> 8; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
912 lo = *t & 0x00FF; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
913 if (isComposite) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
914 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
915 cwidth = s->cmp->offsets[s->gidx++ * 2] - twidth; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
916 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
917 else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
918 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
919 if (!font->metrics[hi]) /*PENDING: why/how can we need this now? */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
920 ns_glyph_metrics (font, hi); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
921 cwidth = font->metrics[hi][lo].width; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
922 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
923 twidth += cwidth; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
924 #ifdef NS_IMPL_GNUSTEP |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
925 *adv++ = cwidth; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
926 CHAR_STRING_ADVANCE (*t, c); /* this converts the char to UTF-8 */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
927 #else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
928 (*adv++).width = cwidth; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
929 #endif |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
930 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
931 len = adv - advances; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
932 r.size.width = twidth; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
933 *c = 0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
934 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
935 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
936 /* fill background if requested */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
937 if (with_background) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
938 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
939 NSRect br = r; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
940 int fibw = FRAME_INTERNAL_BORDER_WIDTH (s->f); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
941 int mbox_line_width = max (s->face->box_line_width, 0); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
942 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
943 if (s->row->full_width_p) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
944 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
945 if (br.origin.x <= fibw + 1 + mbox_line_width) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
946 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
947 br.size.width += br.origin.x - mbox_line_width; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
948 br.origin.x = mbox_line_width; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
949 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
950 if (FRAME_PIXEL_WIDTH (s->f) - (br.origin.x + br.size.width) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
951 <= fibw+1) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
952 br.size.width += fibw; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
953 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
954 if (s->face->box == FACE_NO_BOX) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
955 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
956 /* expand unboxed top row over internal border */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
957 if (br.origin.y <= fibw + 1 + mbox_line_width) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
958 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
959 br.size.height += br.origin.y; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
960 br.origin.y = 0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
961 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
962 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
963 else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
964 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
965 int correction = abs (s->face->box_line_width)+1; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
966 br.origin.y += correction; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
967 br.size.height -= 2*correction; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
968 br.origin.x += correction; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
969 br.size.width -= 2*correction; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
970 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
971 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
972 if (!s->face->stipple) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
973 [(NS_FACE_BACKGROUND (face) != nil |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
974 ? ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
975 : FRAME_BACKGROUND_COLOR (s->f)) set]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
976 else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
977 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
978 struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (s->f); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
979 [[dpyinfo->bitmaps[face->stipple-1].img stippleMask] set]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
980 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
981 NSRectFill (br); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
982 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
983 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
984 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
985 /* set up for character rendering */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
986 r.origin.y += font->voffset + (s->height - font->height)/2; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
987 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
988 col = (NS_FACE_FOREGROUND (face) != nil |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
989 ? ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
990 : FRAME_FOREGROUND_COLOR (s->f)); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
991 /*PENDING: find another way to pass this */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
992 bgCol = (ns_tmp_flags != NS_DUMPGLYPH_FOREGROUND ? nil |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
993 : (NS_FACE_BACKGROUND (face) != nil |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
994 ? ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
995 : FRAME_BACKGROUND_COLOR (s->f))); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
996 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
997 /* render under GNUstep using DPS */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
998 #ifdef NS_IMPL_GNUSTEP |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
999 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1000 NSGraphicsContext *context = GSCurrentContext (); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1001 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1002 DPSgsave (context); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1003 [font->nsfont set]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1004 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1005 /* do erase if "foreground" mode */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1006 if (bgCol != nil) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1007 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1008 [bgCol set]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1009 DPSmoveto (context, r.origin.x, r.origin.y); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1010 /*[context GSSetTextDrawingMode: GSTextFillStroke]; /// not implemented yet */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1011 DPSxshow (context, cbuf, advances, len); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1012 DPSstroke (context); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1013 [col set]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1014 /*[context GSSetTextDrawingMode: GSTextFill]; /// not implemented yet */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1015 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1016 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1017 /* do underline */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1018 if (face->underline_p) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1019 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1020 if (face->underline_color != nil) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1021 [ns_lookup_indexed_color (face->underline_color, s->f) set]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1022 else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1023 [col set]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1024 DPSmoveto (context, r.origin.x, r.origin.y + font->underpos); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1025 DPSlineto (context, r.origin.x+r.size.width, r.origin.y+font->underpos); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1026 if (face->underline_color != nil) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1027 [col set]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1028 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1029 else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1030 [col set]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1031 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1032 /* draw with DPSxshow () */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1033 DPSmoveto (context, r.origin.x, r.origin.y); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1034 DPSxshow (context, cbuf, advances, len); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1035 DPSstroke (context); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1036 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1037 DPSgrestore (context); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1038 return to-from; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1039 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1040 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1041 #else /* NS_IMPL_COCOA */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1042 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1043 CGContextRef gcontext = |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1044 [[NSGraphicsContext currentContext] graphicsPort]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1045 static CGAffineTransform fliptf; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1046 static BOOL firstTime = YES; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1047 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1048 if (firstTime) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1049 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1050 firstTime = NO; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1051 fliptf = CGAffineTransformMakeScale (1.0, -1.0); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1052 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1053 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1054 CGContextSaveGState (gcontext); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1055 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1056 fliptf.c = font->synthItal ? Fix2X (kATSItalicQDSkew) : 0.0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1057 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1058 CGContextSetFont (gcontext, font->cgfont); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1059 CGContextSetFontSize (gcontext, font->size); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1060 if (ns_antialias_text == NO || font->size <= ns_antialias_threshold) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1061 CGContextSetShouldAntialias (gcontext, 0); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1062 else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1063 CGContextSetShouldAntialias (gcontext, 1); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1064 if (ns_use_qd_smoothing) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1065 CGContextSetFontRenderingMode (gcontext, 2); /* 0 is Cocoa, 2 is QD */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1066 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1067 CGContextSetTextMatrix (gcontext, fliptf); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1068 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1069 if (bgCol != nil) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1070 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1071 /* foreground drawing; erase first to avoid overstrike */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1072 [bgCol set]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1073 CGContextSetTextDrawingMode (gcontext, kCGTextFillStroke); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1074 CGContextSetTextPosition (gcontext, r.origin.x, r.origin.y); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1075 CGContextShowGlyphsWithAdvances (gcontext, s->char2b, advances, len); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1076 CGContextSetTextDrawingMode (gcontext, kCGTextFill); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1077 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1078 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1079 if (face->underline_p) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1080 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1081 if (face->underline_color != nil) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1082 [ns_lookup_indexed_color (face->underline_color, s->f) set]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1083 else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1084 [col set]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1085 CGContextBeginPath (gcontext); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1086 CGContextMoveToPoint (gcontext, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1087 r.origin.x, r.origin.y + font->underpos); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1088 CGContextAddLineToPoint (gcontext, r.origin.x + r.size.width, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1089 r.origin.y + font->underpos); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1090 CGContextStrokePath (gcontext); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1091 if (face->underline_color != nil) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1092 [col set]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1093 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1094 else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1095 [col set]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1096 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1097 CGContextSetTextPosition (gcontext, r.origin.x, r.origin.y); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1098 CGContextShowGlyphsWithAdvances (gcontext, s->char2b + s->gidx, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1099 advances, len); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1100 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1101 if (face->overstrike) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1102 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1103 CGContextSetTextPosition (gcontext, r.origin.x+0.5, r.origin.y); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1104 CGContextShowGlyphsWithAdvances (gcontext, s->char2b + s->gidx, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1105 advances, len); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1106 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1107 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1108 CGContextRestoreGState (gcontext); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1109 return; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1110 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1111 #endif /* NS_IMPL_COCOA */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1112 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1113 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1114 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1115 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1116 /* Auto-creates a fontset built around the font in font_object, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1117 by creating an attributed string with characters from each |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1118 script, then requesting the NS text system to fix attributes |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1119 in range. */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1120 void nsfont_make_fontset_for_font (Lisp_Object name, Lisp_Object font_object) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1121 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1122 Lisp_Object script, famAndReg; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1123 struct nsfont_info *font_info = |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1124 (struct nsfont_info *)XFONT_OBJECT (font_object); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1125 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1126 /* NS text system (and char buf) init */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1127 static NSTextStorage *store; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1128 static NSLayoutManager *layout; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1129 static NSRange range; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1130 static NSMutableDictionary *attribs; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1131 static Lisp_Object *scripts; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1132 static int nscripts; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1133 static int *scriptsNchars; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1134 static BOOL firstTime = YES; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1135 Lisp_Object regString = build_string ("iso10646-1"); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1136 int i, j; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1137 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1138 if (firstTime == YES) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1139 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1140 nscripts = XINT (Flength (Vscript_representative_chars)); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1141 scriptsNchars = (int *) malloc (nscripts * sizeof (int)); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1142 unsigned char *buf = malloc (4*nscripts*sizeof (char)); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1143 Lisp_Object scriptsChars = Vscript_representative_chars; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1144 unsigned char *tpos = buf; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1145 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1146 scripts = (Lisp_Object *) malloc (nscripts * sizeof (Lisp_Object)); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1147 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1148 for (i =0; i<nscripts; i++) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1149 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1150 Lisp_Object sChars = XCAR (scriptsChars); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1151 Lisp_Object chars = XCDR (sChars); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1152 unsigned int ch, c =0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1153 scripts[i] = XCAR (sChars); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1154 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1155 while (CONSP (chars)) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1156 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1157 ch = XUINT (XCAR (chars)); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1158 chars = XCDR (chars); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1159 CHAR_STRING_ADVANCE (ch, tpos); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1160 c++; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1161 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1162 scriptsNchars[i] = c; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1163 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1164 scriptsChars = XCDR (scriptsChars); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1165 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1166 *tpos = '\0'; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1167 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1168 store = [[NSTextStorage alloc] init]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1169 layout = [[NSLayoutManager alloc] init]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1170 [store addLayoutManager: layout]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1171 [layout release]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1172 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1173 [store beginEditing]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1174 [[store mutableString] appendString: |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1175 [NSString stringWithUTF8String: buf]]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1176 [store endEditing]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1177 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1178 free (buf); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1179 range = NSMakeRange (0, [store length]); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1180 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1181 attribs = [[NSMutableDictionary alloc] init]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1182 firstTime = NO; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1183 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1184 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1185 /* set the fonts */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1186 [store beginEditing]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1187 [store removeAttribute: NSFontAttributeName range: range]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1188 [attribs setObject: font_info->nsfont forKey: NSFontAttributeName]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1189 [store addAttributes: attribs range: range]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1190 [store endEditing]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1191 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1192 /* read them out */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1193 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1194 NSMutableDictionary *map = |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1195 [NSMutableDictionary dictionaryWithCapacity: nscripts * 4]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1196 NSEnumerator *fonts; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1197 NSFont *cfont = nil, *tfont; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1198 NSNumber *n; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1199 int idx = 0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1200 int max; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1201 for (i =0; i<nscripts; i++) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1202 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1203 [map removeAllObjects]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1204 for (j =0; j<scriptsNchars[i]; j++) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1205 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1206 cfont = [store attribute: NSFontAttributeName atIndex: idx++ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1207 effectiveRange: NULL]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1208 n = [map objectForKey: cfont]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1209 if (n == nil) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1210 n = [NSNumber numberWithInt: 1]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1211 else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1212 n = [NSNumber numberWithInt: [n intValue] + 1]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1213 [map setObject: n forKey: cfont]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1214 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1215 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1216 /* majority rules */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1217 max = 0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1218 fonts = [map keyEnumerator]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1219 while (tfont = [fonts nextObject]) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1220 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1221 n = [map objectForKey: tfont]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1222 if ([n intValue] > max) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1223 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1224 cfont = tfont; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1225 max = [n intValue]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1226 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1227 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1228 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1229 if (cfont != nil) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1230 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1231 char *family = [[cfont familyName] UTF8String]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1232 Lisp_Object famAndReg; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1233 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1234 nsfont_escape_name (family); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1235 famAndReg = Fcons (build_string (family), regString); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1236 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1237 if (NSFONT_TRACE) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1238 fprintf (stderr, "%s fontset: use '%s' for script '%s'\n", |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1239 font_info->name, family, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1240 SDATA (SYMBOL_NAME (scripts[i]))); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1241 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1242 Fset_fontset_font (name, scripts[i], famAndReg, Qnil, Qnil); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1243 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1244 else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1245 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1246 fprintf (stderr, "%s fontset: none found for script '%s'\n", |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1247 font_info->name, SDATA (SYMBOL_NAME (scripts[i]))); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1248 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1249 } /* for i = script */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1250 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1251 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1252 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1253 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1254 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1255 /* ========================================================================== |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1256 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1257 Font glyph and metrics caching functions |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1258 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1259 ========================================================================== */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1260 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1261 /* Find and cache corresponding glyph codes for unicode values in given |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1262 hi-byte block of 256. */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1263 static void |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1264 ns_uni_to_glyphs (struct nsfont_info *font_info, unsigned char block) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1265 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1266 #ifdef NS_IMPL_COCOA |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1267 static EmacsGlyphStorage *glyphStorage; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1268 static char firstTime = 1; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1269 #endif |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1270 unichar *unichars = xmalloc (0x101 * sizeof (unichar)); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1271 unsigned int i, g, idx; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1272 unsigned short *glyphs; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1273 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1274 if (NSFONT_TRACE) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1275 fprintf (stderr, "%p\tFinding glyphs for glyphs in block %d\n", |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1276 font_info, block); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1277 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1278 BLOCK_INPUT; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1279 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1280 #ifdef NS_IMPL_COCOA |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1281 if (firstTime) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1282 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1283 firstTime = 0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1284 glyphStorage = [[EmacsGlyphStorage alloc] initWithCapacity: 0x100]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1285 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1286 #endif |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1287 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1288 font_info->glyphs[block] = xmalloc (0x100 * sizeof (unsigned short)); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1289 if (!unichars || !(font_info->glyphs[block])) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1290 abort (); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1291 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1292 /* create a string containing all unicode characters in this block */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1293 for (idx = block<<8, i =0; i<0x100; idx++, i++) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1294 if (idx < 0xD800 || idx > 0xDFFF) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1295 unichars[i] = idx; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1296 else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1297 unichars[i] = 0xFEFF; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1298 unichars[0x100] = 0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1299 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1300 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1301 #ifdef NS_IMPL_COCOA |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1302 NSString *allChars = [[NSString alloc] |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1303 initWithCharactersNoCopy: unichars |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1304 length: 0x100 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1305 freeWhenDone: NO]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1306 NSGlyphGenerator *glyphGenerator = [NSGlyphGenerator sharedGlyphGenerator]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1307 /*NSCharacterSet *coveredChars = [nsfont coveredCharacterSet]; */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1308 unsigned int numGlyphs = [font_info->nsfont numberOfGlyphs]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1309 unsigned int gInd =0, cInd =0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1310 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1311 [glyphStorage setString: allChars font: font_info->nsfont]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1312 [glyphGenerator generateGlyphsForGlyphStorage: glyphStorage |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1313 desiredNumberOfCharacters: glyphStorage->maxChar |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1314 glyphIndex: &gInd characterIndex: &cInd]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1315 #endif |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1316 glyphs = font_info->glyphs[block]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1317 for (i =0; i<0x100; i++, glyphs++) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1318 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1319 #ifdef NS_IMPL_GNUSTEP |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1320 g = unichars[i]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1321 #else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1322 g = glyphStorage->cglyphs[i]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1323 /*PENDING: is this a good check? maybe need to use coveredChars.. */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1324 if (g > numGlyphs) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1325 g = 0xFFFF; /* hopefully unused... */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1326 #endif |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1327 *glyphs = g; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1328 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1329 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1330 #ifdef NS_IMPL_COCOA |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1331 [allChars release]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1332 #endif |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1333 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1334 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1335 UNBLOCK_INPUT; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1336 xfree (unichars); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1337 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1338 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1339 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1340 /* Determine and cache metrics for corresponding glyph codes in given |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1341 hi-byte block of 256. */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1342 static void |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1343 ns_glyph_metrics (struct nsfont_info *font_info, unsigned char block) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1344 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1345 unsigned int i, g; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1346 unsigned int numGlyphs = [font_info->nsfont numberOfGlyphs]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1347 NSFont *sfont; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1348 struct font_metrics *metrics; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1349 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1350 if (NSFONT_TRACE) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1351 fprintf (stderr, "%p\tComputing metrics for glyphs in block %d\n", |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1352 font_info, block); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1353 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1354 #ifdef NS_IMPL_GNUSTEP |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1355 /* not implemented yet (as of startup 0.18), so punt */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1356 if (numGlyphs == 0) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1357 numGlyphs = 0x10000; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1358 #endif |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1359 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1360 BLOCK_INPUT; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1361 sfont = [font_info->nsfont screenFont]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1362 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1363 font_info->metrics[block] = xmalloc (0x100 * sizeof (struct font_metrics)); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1364 bzero (font_info->metrics[block], 0x100 * sizeof (struct font_metrics)); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1365 if (!(font_info->metrics[block])) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1366 abort (); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1367 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1368 metrics = font_info->metrics[block]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1369 for (g = block<<8, i =0; i<0x100 && g < numGlyphs; g++, i++, metrics++) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1370 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1371 float w, lb, rb; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1372 NSRect r = [sfont boundingRectForGlyph: g]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1373 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1374 #ifdef NS_IMPL_GNUSTEP |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1375 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1376 /* lord help us */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1377 NSString *s = [NSString stringWithFormat: @"%c", g]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1378 w = [sfont widthOfString: s]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1379 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1380 #else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1381 w = [sfont advancementForGlyph: g].width; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1382 #endif |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1383 w = max (w, 2.0); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1384 metrics->width = lrint (w); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1385 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1386 lb = r.origin.x; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1387 rb = r.size.width - w; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1388 if (lb < 0) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1389 metrics->lbearing = round (lb); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1390 if (font_info->ital) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1391 rb += 0.22 * font_info->height; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1392 metrics->rbearing = lrint (w + rb); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1393 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1394 metrics->descent = r.origin.y < 0 ? -r.origin.y : 0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1395 /*lrint (hshrink * [sfont ascender] + expand * hd/2); */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1396 metrics->ascent = r.size.height - metrics->descent; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1397 /*-lrint (hshrink* [sfont descender] - expand * hd/2); */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1398 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1399 UNBLOCK_INPUT; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1400 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1401 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1402 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1403 #ifdef NS_IMPL_COCOA |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1404 /* helper for font glyph setup */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1405 @implementation EmacsGlyphStorage |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1406 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1407 - init |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1408 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1409 return [self initWithCapacity: 1024]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1410 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1411 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1412 - initWithCapacity: (unsigned long) c |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1413 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1414 self = [super init]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1415 maxChar = 0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1416 maxGlyph = 0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1417 dict = [NSMutableDictionary new]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1418 cglyphs = (CGGlyph *)xmalloc (c * sizeof (CGGlyph)); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1419 return self; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1420 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1421 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1422 - (void) dealloc |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1423 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1424 if (attrStr != nil) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1425 [attrStr release]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1426 [dict release]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1427 xfree (cglyphs); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1428 [super dealloc]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1429 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1430 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1431 - (void) setString: (NSString *)str font: (NSFont *)font |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1432 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1433 [dict setObject: font forKey: NSFontAttributeName]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1434 attrStr = [[NSAttributedString alloc] initWithString: str attributes: dict]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1435 maxChar = [str length]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1436 maxGlyph = 0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1437 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1438 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1439 /* NSGlyphStorage protocol */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1440 - (unsigned int)layoutOptions |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1441 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1442 return 0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1443 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1444 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1445 - (NSAttributedString *)attributedString |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1446 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1447 return attrStr; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1448 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1449 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1450 - (void)insertGlyphs: (const NSGlyph *)glyphs length: (unsigned int)length |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1451 forStartingGlyphAtIndex: (unsigned int)glyphIndex |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1452 characterIndex: (unsigned int)charIndex |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1453 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1454 len = glyphIndex+length; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1455 for (i =glyphIndex; i<len; i++) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1456 cglyphs[i] = glyphs[i-glyphIndex]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1457 if (len > maxGlyph) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1458 maxGlyph = len; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1459 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1460 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1461 - (void)setIntAttribute: (int)attributeTag value: (int)val |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1462 forGlyphAtIndex: (unsigned)glyphIndex |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1463 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1464 return; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1465 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1466 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1467 @end |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1468 #endif /* NS_IMPL_COCOA */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1469 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1470 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1471 /* Debugging */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1472 void |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1473 dump_glyphstring (struct glyph_string *s) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1474 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1475 int i; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1476 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1477 fprintf (stderr, "Glyph string len = %d at (%d, %d) overhang (%d, %d), overlap = %d, bg_filled = %d:", |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1478 s->nchars, s->x, s->y, s->left_overhang, s->right_overhang, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1479 s->row->overlapping_p, s->background_filled_p); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1480 for (i =0; i<s->nchars; i++) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1481 fprintf (stderr, "%c", s->first_glyph[i].u.ch); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1482 fprintf (stderr, "\n"); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1483 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1484 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1485 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1486 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1487 void |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1488 syms_of_nsfont () |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1489 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1490 nsfont_driver.type = Qns; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1491 register_font_driver (&nsfont_driver, NULL); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1492 DEFSYM (Qapple, "apple"); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1493 DEFSYM (Qroman, "roman"); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1494 DEFSYM (Qmedium, "medium"); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1495 } |