Mercurial > emacs
annotate src/nsfont.m @ 107343:d4567b4f2db3
Improve documentation for setting buffer-local vars (Bug#5688).
* custom.texi (Init Examples): Add xref to Locals.
* major.texi (Choosing Modes): Mention usage of setq-default for
setting the default value of major-mode (Bug#5688).
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sat, 06 Mar 2010 14:02:49 -0500 |
parents | 0255e27f26c9 |
children | ad09f2bfce51 376148b31b5e |
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 |
106815 | 3 Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
96676
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 |
96692
6fad3f85eab7
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
96689
diff
changeset
|
7 GNU Emacs is free software: you can redistribute it and/or modify |
96676
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 |
96692
6fad3f85eab7
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
96689
diff
changeset
|
9 the Free Software Foundation, either version 3 of the License, or |
6fad3f85eab7
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
96689
diff
changeset
|
10 (at your option) any later version. |
96676
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 |
96692
6fad3f85eab7
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
96689
diff
changeset
|
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
19 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
20 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
|
21 */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
22 |
99904
ba4876d944bc
Fix bug #1362. * image.c (x_clear_image_1): Do not free background under HAVE_NS, it is not an indexed color. * nsterm.m (free_indexed_color): Add argument checking. * nsfns.m: Move config.h to before system includes (advised by Dan N.).
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
98451
diff
changeset
|
23 /* This should be the first include, as it may set up #defines affecting |
ba4876d944bc
Fix bug #1362. * image.c (x_clear_image_1): Do not free background under HAVE_NS, it is not an indexed color. * nsterm.m (free_indexed_color): Add argument checking. * nsfns.m: Move config.h to before system includes (advised by Dan N.).
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
98451
diff
changeset
|
24 interpretation of even the system includes. */ |
96676
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" |
105676 | 26 #include <setjmp.h> |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
27 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
28 #include "lisp.h" |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
29 #include "dispextern.h" |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
30 #include "composite.h" |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
31 #include "blockinput.h" |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
32 #include "charset.h" |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
33 #include "frame.h" |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
34 #include "window.h" |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
35 #include "fontset.h" |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
36 #include "nsterm.h" |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
37 #include "frame.h" |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
38 #include "character.h" |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
39 #include "font.h" |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
40 |
105160
8f8d95750940
* nsfont.m (ns_glyph_metrics): Remove GNUstep conditional for
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105156
diff
changeset
|
41 /* TODO: Drop once we can assume gnustep-gui 0.17.1. */ |
104048
712697e0dfcc
* nsfont.m (NSFontDescriptor.h): Explicitly include under GNUstep.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103990
diff
changeset
|
42 #ifdef NS_IMPL_GNUSTEP |
712697e0dfcc
* nsfont.m (NSFontDescriptor.h): Explicitly include under GNUstep.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103990
diff
changeset
|
43 #import <AppKit/NSFontDescriptor.h> |
712697e0dfcc
* nsfont.m (NSFontDescriptor.h): Explicitly include under GNUstep.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103990
diff
changeset
|
44 #endif |
712697e0dfcc
* nsfont.m (NSFontDescriptor.h): Explicitly include under GNUstep.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103990
diff
changeset
|
45 |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
46 #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
|
47 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
48 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
|
49 extern Lisp_Object Qnormal, Qbold, Qitalic, Qcondensed, Qexpanded; |
105156
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
50 static Lisp_Object Vns_reg_to_script; |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
51 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
|
52 extern Lisp_Object Qappend; |
107229
0255e27f26c9
* nsfont.m (nsfont_draw): ns_antialias_text should be a Lisp_Object (Bug#4736).
Chong Yidong <cyd@stupidchicken.com>
parents:
107114
diff
changeset
|
53 extern Lisp_Object ns_antialias_text; |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
54 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
|
55 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
|
56 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
|
57 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
58 /* 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
|
59 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
|
60 unsigned char block); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
61 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
|
62 unsigned char block); |
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 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
67 Utilities |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
68 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
69 ========================================================================== */ |
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 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
72 /* 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
|
73 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
|
74 static void |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
75 ns_escape_name (char *name) |
96676
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 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
|
78 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
|
79 if (name[i] == ' ') |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
80 name[i] = '_'; |
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 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
83 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
84 /* 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
|
85 static void |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
86 ns_unescape_name (char *name) |
96676
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 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
|
89 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
|
90 if (name[i] == '_') |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
91 name[i] = ' '; |
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 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
94 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
95 /* 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
|
96 static NSString * |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
97 ns_get_family (Lisp_Object font_spec) |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
98 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
99 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
|
100 if (NILP (tem)) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
101 return nil; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
102 else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
103 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
104 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
|
105 NSString *family; |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
106 ns_unescape_name (tmp); |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
107 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
|
108 free (tmp); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
109 return family; |
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 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
113 |
103422
591af7ba061b
* nsfont.m (ns_attribute_value): Remove.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103343
diff
changeset
|
114 /* Return 0 if attr not set, else value (which might also be 0). |
591af7ba061b
* nsfont.m (ns_attribute_value): Remove.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103343
diff
changeset
|
115 On Leopard 0 gets returned even on descriptors where the attribute |
591af7ba061b
* nsfont.m (ns_attribute_value): Remove.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103343
diff
changeset
|
116 was never set, so there's no way to distinguish between unspecified |
591af7ba061b
* nsfont.m (ns_attribute_value): Remove.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103343
diff
changeset
|
117 and set to not have. Callers should assume 0 means unspecified. */ |
591af7ba061b
* nsfont.m (ns_attribute_value): Remove.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103343
diff
changeset
|
118 static float |
591af7ba061b
* nsfont.m (ns_attribute_value): Remove.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103343
diff
changeset
|
119 ns_attribute_fvalue (NSFontDescriptor *fdesc, NSString *trait) |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
120 { |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
121 NSDictionary *tdict = [fdesc objectForKey: NSFontTraitsAttribute]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
122 NSNumber *val = [tdict objectForKey: trait]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
123 return val == nil ? 0.0 : [val floatValue]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
124 } |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
125 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
126 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
127 /* Converts FONT_WEIGHT, FONT_SLANT, FONT_WIDTH, plus family and script/lang |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
128 to NSFont descriptor. Information under extra only needed for matching. */ |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
129 #define STYLE_REF 100 |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
130 static NSFontDescriptor |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
131 *ns_spec_to_descriptor(Lisp_Object font_spec) |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
132 { |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
133 NSFontDescriptor *fdesc; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
134 NSMutableDictionary *fdAttrs = [NSMutableDictionary new]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
135 NSMutableDictionary *tdict = [NSMutableDictionary new]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
136 NSString *family = ns_get_family (font_spec); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
137 float n; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
138 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
139 /* add each attr in font_spec to fdAttrs.. */ |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
140 n = min (FONT_WEIGHT_NUMERIC (font_spec), 200); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
141 if (n != -1 && n != STYLE_REF) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
142 [tdict setObject: [NSNumber numberWithFloat: (n - 100.0) / 100.0] |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
143 forKey: NSFontWeightTrait]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
144 n = min (FONT_SLANT_NUMERIC (font_spec), 200); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
145 if (n != -1 && n != STYLE_REF) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
146 [tdict setObject: [NSNumber numberWithFloat: (n - 100.0) / 100.0] |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
147 forKey: NSFontSlantTrait]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
148 n = min (FONT_WIDTH_NUMERIC (font_spec), 200); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
149 if (n > -1 && (n > STYLE_REF + 10 || n < STYLE_REF - 10)) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
150 [tdict setObject: [NSNumber numberWithFloat: (n - 100.0) / 100.0] |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
151 forKey: NSFontWidthTrait]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
152 if ([tdict count] > 0) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
153 [fdAttrs setObject: tdict forKey: NSFontTraitsAttribute]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
154 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
155 fdesc = [NSFontDescriptor fontDescriptorWithFontAttributes: fdAttrs]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
156 if (family != nil) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
157 fdesc = [fdesc fontDescriptorWithFamily: family]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
158 return fdesc; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
159 } |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
160 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
161 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
162 /* Converts NSFont descriptor to FONT_WEIGHT, FONT_SLANT, FONT_WIDTH, etc.. */ |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
163 static Lisp_Object |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
164 ns_descriptor_to_entity (NSFontDescriptor *desc, Lisp_Object extra, char *style) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
165 { |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
166 Lisp_Object font_entity = font_make_entity (); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
167 /* NSString *psName = [desc postscriptName]; */ |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
168 NSString *family = [desc objectForKey: NSFontFamilyAttribute]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
169 unsigned int traits = [desc symbolicTraits]; |
104123
132eb17eec1d
* nsfont.m (ns_descriptor_to_entity): Handle case when descriptor has no family set. (nsfont_open): Handle case when entity has no family.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
104107
diff
changeset
|
170 char *escapedFamily; |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
171 |
104123
132eb17eec1d
* nsfont.m (ns_descriptor_to_entity): Handle case when descriptor has no family set. (nsfont_open): Handle case when entity has no family.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
104107
diff
changeset
|
172 /* Shouldn't happen, but on Tiger fallback desc gets name but no family. */ |
132eb17eec1d
* nsfont.m (ns_descriptor_to_entity): Handle case when descriptor has no family set. (nsfont_open): Handle case when entity has no family.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
104107
diff
changeset
|
173 if (family == nil) |
132eb17eec1d
* nsfont.m (ns_descriptor_to_entity): Handle case when descriptor has no family set. (nsfont_open): Handle case when entity has no family.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
104107
diff
changeset
|
174 family = [desc objectForKey: NSFontNameAttribute]; |
132eb17eec1d
* nsfont.m (ns_descriptor_to_entity): Handle case when descriptor has no family set. (nsfont_open): Handle case when entity has no family.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
104107
diff
changeset
|
175 if (family == nil) |
132eb17eec1d
* nsfont.m (ns_descriptor_to_entity): Handle case when descriptor has no family set. (nsfont_open): Handle case when entity has no family.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
104107
diff
changeset
|
176 family = [[NSFont userFixedPitchFontOfSize: 0] familyName]; |
132eb17eec1d
* nsfont.m (ns_descriptor_to_entity): Handle case when descriptor has no family set. (nsfont_open): Handle case when entity has no family.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
104107
diff
changeset
|
177 |
132eb17eec1d
* nsfont.m (ns_descriptor_to_entity): Handle case when descriptor has no family set. (nsfont_open): Handle case when entity has no family.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
104107
diff
changeset
|
178 escapedFamily = strdup ([family UTF8String]); |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
179 ns_escape_name (escapedFamily); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
180 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
181 ASET (font_entity, FONT_TYPE_INDEX, Qns); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
182 ASET (font_entity, FONT_FOUNDRY_INDEX, Qapple); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
183 ASET (font_entity, FONT_FAMILY_INDEX, intern (escapedFamily)); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
184 ASET (font_entity, FONT_ADSTYLE_INDEX, style ? intern (style) : Qnil); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
185 ASET (font_entity, FONT_REGISTRY_INDEX, Qiso10646_1); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
186 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
187 FONT_SET_STYLE (font_entity, FONT_WEIGHT_INDEX, |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
188 traits & NSFontBoldTrait ? Qbold : Qmedium); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
189 /* FONT_SET_STYLE (font_entity, FONT_WEIGHT_INDEX, |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
190 make_number (100 + 100 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
191 * ns_attribute_fvalue (desc, NSFontWeightTrait)));*/ |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
192 FONT_SET_STYLE (font_entity, FONT_SLANT_INDEX, |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
193 traits & NSFontItalicTrait ? Qitalic : Qnormal); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
194 /* FONT_SET_STYLE (font_entity, FONT_SLANT_INDEX, |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
195 make_number (100 + 100 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
196 * ns_attribute_fvalue (desc, NSFontSlantTrait)));*/ |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
197 FONT_SET_STYLE (font_entity, FONT_WIDTH_INDEX, |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
198 traits & NSFontCondensedTrait ? Qcondensed : |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
199 traits & NSFontExpandedTrait ? Qexpanded : Qnormal); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
200 /* FONT_SET_STYLE (font_entity, FONT_WIDTH_INDEX, |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
201 make_number (100 + 100 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
202 * ns_attribute_fvalue (desc, NSFontWidthTrait)));*/ |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
203 |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
204 ASET (font_entity, FONT_SIZE_INDEX, make_number (0)); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
205 ASET (font_entity, FONT_AVGWIDTH_INDEX, make_number (0)); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
206 ASET (font_entity, FONT_SPACING_INDEX, |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
207 make_number([desc symbolicTraits] & NSFontMonoSpaceTrait |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
208 ? FONT_SPACING_MONO : FONT_SPACING_PROPORTIONAL)); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
209 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
210 ASET (font_entity, FONT_EXTRA_INDEX, extra); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
211 ASET (font_entity, FONT_OBJLIST_INDEX, Qnil); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
212 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
213 if (NSFONT_TRACE) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
214 { |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
215 fprintf (stderr, "created font_entity:\n "); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
216 debug_print (font_entity); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
217 } |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
218 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
219 free (escapedFamily); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
220 return font_entity; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
221 } |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
222 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
223 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
224 /* Default font entity. */ |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
225 static Lisp_Object |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
226 ns_fallback_entity () |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
227 { |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
228 return ns_descriptor_to_entity ([[NSFont userFixedPitchFontOfSize: 0] |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
229 fontDescriptor], Qnil, NULL); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
230 } |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
231 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
232 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
233 /* Utility: get width of a char c in screen font sfont */ |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
234 static float |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
235 ns_char_width (NSFont *sfont, int c) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
236 { |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
237 float w; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
238 NSString *cstr = [NSString stringWithFormat: @"%c", c]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
239 #ifdef NS_IMPL_COCOA |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
240 NSGlyph glyph = [sfont glyphWithName: cstr]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
241 if (glyph) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
242 { |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
243 float w = [sfont advancementForGlyph: glyph].width; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
244 if (w >= 1.5) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
245 return w; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
246 } |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
247 #endif |
105561
69741c366370
* nsfont.m (ns_char_width): Replace deprecated call (suggested by
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105160
diff
changeset
|
248 { |
69741c366370
* nsfont.m (ns_char_width): Replace deprecated call (suggested by
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105160
diff
changeset
|
249 NSDictionary *attrsDictionary = |
69741c366370
* nsfont.m (ns_char_width): Replace deprecated call (suggested by
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105160
diff
changeset
|
250 [NSDictionary dictionaryWithObject: sfont forKey: NSFontAttributeName]; |
69741c366370
* nsfont.m (ns_char_width): Replace deprecated call (suggested by
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105160
diff
changeset
|
251 w = [cstr sizeWithAttributes: attrsDictionary].width; |
69741c366370
* nsfont.m (ns_char_width): Replace deprecated call (suggested by
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105160
diff
changeset
|
252 } |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
253 return max (w, 2.0); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
254 } |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
255 |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
256 |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
257 /* Return whether set1 covers set2 to a reasonable extent given by pct. |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
258 We check, out of each 16 unicode char range containing chars in set2, |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
259 whether at least one character is present in set1. |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
260 This must be true for pct of the pairs to consider it covering. */ |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
261 static BOOL |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
262 ns_charset_covers(NSCharacterSet *set1, NSCharacterSet *set2, float pct) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
263 { |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
264 const unsigned short *bytes1 = [[set1 bitmapRepresentation] bytes]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
265 const unsigned short *bytes2 = [[set2 bitmapRepresentation] bytes]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
266 int i, off = 0, tot = 0; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
267 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
268 for (i=0; i<4096; i++, bytes1++, bytes2++) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
269 if (*bytes2) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
270 { |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
271 tot++; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
272 if (*bytes1 == 0) // *bytes1 & *bytes2 != *bytes2 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
273 off++; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
274 } |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
275 //fprintf(stderr, "off = %d\ttot = %d\n", off,tot); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
276 return (float)off / tot < 1.0 - pct; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
277 } |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
278 |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
279 |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
280 /* Convert :lang property to a script. Use of :lang property by font backend |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
281 seems to be limited for now (2009/05) to ja, zh, and ko. */ |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
282 static NSString |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
283 *ns_lang_to_script (Lisp_Object lang) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
284 { |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
285 if (!strcmp (SDATA (SYMBOL_NAME (lang)), "ja")) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
286 return @"han"; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
287 /* NOTE: ja given for any hanzi that's also a kanji, but Chinese fonts |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
288 have more characters. */ |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
289 else if (!strcmp (SDATA (SYMBOL_NAME (lang)), "zh")) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
290 return @"han"; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
291 else if (!strcmp (SDATA (SYMBOL_NAME (lang)), "ko")) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
292 return @"hangul"; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
293 else |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
294 return @""; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
295 } |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
296 |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
297 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
298 /* Convert OTF 4-letter script code to emacs script name. (Why can't |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
299 everyone just use some standard unicode names for these?) */ |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
300 static NSString |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
301 *ns_otf_to_script (Lisp_Object otf) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
302 { |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
303 Lisp_Object script = assq_no_quit (XCAR (otf), Votf_script_alist); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
304 return CONSP (script) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
305 ? [NSString stringWithUTF8String: SDATA (SYMBOL_NAME XCDR ((script)))] |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
306 : @""; |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
307 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
308 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
309 |
105156
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
310 /* Convert a font registry, such as */ |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
311 static NSString |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
312 *ns_registry_to_script (char *reg) |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
313 { |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
314 Lisp_Object script, r, rts = Vns_reg_to_script; |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
315 while CONSP (rts) |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
316 { |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
317 r = XCAR (XCAR (rts)); |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
318 if (!strncmp(SDATA(r), reg, strlen(SDATA(r)))) |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
319 { |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
320 script = XCDR (XCAR (rts)); |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
321 return [NSString stringWithUTF8String: SDATA (SYMBOL_NAME (script))]; |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
322 } |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
323 rts = XCDR (rts); |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
324 } |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
325 return @""; |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
326 } |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
327 |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
328 |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
329 /* Searches the :script, :lang, and :otf extra-bundle properties of the spec, |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
330 plus registry regular property, for something that can be mapped to a |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
331 unicode script. Empty string returned if no script spec found. */ |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
332 static NSString |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
333 *ns_get_req_script (Lisp_Object font_spec) |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
334 { |
105156
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
335 Lisp_Object reg = AREF (font_spec, FONT_REGISTRY_INDEX); |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
336 Lisp_Object extra = AREF (font_spec, FONT_EXTRA_INDEX); |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
337 |
105156
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
338 /* The extra-bundle properties have priority. */ |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
339 for ( ; CONSP (extra); extra = XCDR (extra)) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
340 { |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
341 Lisp_Object tmp = XCAR (extra); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
342 if (CONSP (tmp)) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
343 { |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
344 Lisp_Object key = XCAR (tmp), val = XCDR (tmp); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
345 if (EQ (key, QCscript) && SYMBOLP (val)) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
346 return [NSString stringWithUTF8String: |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
347 SDATA (SYMBOL_NAME (val))]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
348 if (EQ (key, QClang) && SYMBOLP (val)) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
349 return ns_lang_to_script (val); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
350 if (EQ (key, QCotf) && CONSP (val) && SYMBOLP (XCAR (val))) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
351 return ns_otf_to_script (val); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
352 } |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
353 } |
105156
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
354 |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
355 /* If we get here, check the charset portion of the registry. */ |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
356 if (! NILP (reg)) |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
357 { |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
358 /* XXX: iso10646 is passed in for non-ascii latin-1 characters |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
359 (which causes box rendering if we don't treat it like iso8858-1) |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
360 but also for ascii (which causes unnecessary font substitution). */ |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
361 #if 0 |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
362 if (EQ (reg, Qiso10646_1)) |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
363 reg = Qiso8859_1; |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
364 #endif |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
365 return ns_registry_to_script (SDATA (SYMBOL_NAME (reg))); |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
366 } |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
367 |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
368 return @""; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
369 } |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
370 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
371 |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
372 /* This small function is static in fontset.c. If it can be made public for |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
373 all ports, remove this, but otherwise it doesn't seem worth the ifdefs. */ |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
374 static void |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
375 accumulate_script_ranges (Lisp_Object arg, Lisp_Object range, Lisp_Object val) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
376 { |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
377 if (EQ (XCAR (arg), val)) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
378 { |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
379 if (CONSP (range)) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
380 XSETCDR (arg, Fcons (Fcons (XCAR (range), XCDR (range)), XCDR (arg))); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
381 else |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
382 XSETCDR (arg, Fcons (Fcons (range, range), XCDR (arg))); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
383 } |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
384 } |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
385 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
386 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
387 /* Use the unicode range information in Vchar_script_table to convert a script |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
388 name into an NSCharacterSet. */ |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
389 static NSCharacterSet |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
390 *ns_script_to_charset (NSString *scriptName) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
391 { |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
392 NSMutableCharacterSet *charset = [NSMutableCharacterSet new]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
393 Lisp_Object script = intern ([scriptName UTF8String]); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
394 Lisp_Object script_list = XCHAR_TABLE (Vchar_script_table)->extras[0]; |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
395 |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
396 if (! NILP (Fmemq (script, script_list))) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
397 { |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
398 Lisp_Object ranges, range_list; |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
399 |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
400 ranges = Fcons (script, Qnil); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
401 map_char_table (accumulate_script_ranges, Qnil, Vchar_script_table, |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
402 ranges); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
403 range_list = Fnreverse (XCDR (ranges)); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
404 if (! NILP (range_list)) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
405 { |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
406 for (; CONSP (range_list); range_list = XCDR (range_list)) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
407 { |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
408 int start = XINT (XCAR (XCAR (range_list))); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
409 int end = XINT (XCDR (XCAR (range_list))); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
410 if (NSFONT_TRACE) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
411 debug_print (XCAR (range_list)); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
412 if (end < 0x10000) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
413 [charset addCharactersInRange: |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
414 NSMakeRange (start, end-start)]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
415 } |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
416 } |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
417 } |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
418 return charset; |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
419 } |
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 |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
422 /* Return an array of font families containing characters for the given |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
423 script, for the given coverage criterion, including at least LastResort. |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
424 Results are cached by script for faster access. |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
425 If none are found, we reduce the percentage and try again, until 5%. |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
426 This provides a font with at least some characters if such can be found. |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
427 We don't use isSupersetOfSet: because (a) it doesn't work on Tiger, and |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
428 (b) need approximate match as fonts covering full unicode ranges are rare. */ |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
429 static NSSet |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
430 *ns_get_covering_families (NSString *script, float pct) |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
431 { |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
432 static NSMutableDictionary *scriptToFamilies = nil; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
433 NSMutableSet *families; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
434 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
435 if (NSFONT_TRACE) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
436 NSLog(@"Request covering families for script: '%@'", script); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
437 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
438 if (scriptToFamilies == nil) |
103426
3c179a4d2b8a
(ns_get_covering_families): Retain scriptToFamilies.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103422
diff
changeset
|
439 scriptToFamilies = [[NSMutableDictionary alloc] init]; |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
440 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
441 if ((families = [scriptToFamilies objectForKey: script]) == nil) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
442 { |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
443 NSFontManager *fontMgr = [NSFontManager sharedFontManager]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
444 NSArray *allFamilies = [fontMgr availableFontFamilies]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
445 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
446 if ([script length] == 0) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
447 families = [NSMutableSet setWithArray: allFamilies]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
448 else |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
449 { |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
450 NSCharacterSet *charset = ns_script_to_charset (script); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
451 NSString *family; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
452 families = [NSMutableSet setWithCapacity: 10]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
453 while (1) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
454 { |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
455 NSEnumerator *allFamiliesEnum = [allFamilies objectEnumerator]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
456 while (family = [allFamiliesEnum nextObject]) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
457 { |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
458 NSCharacterSet *fset = [[fontMgr fontWithFamily: family |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
459 traits: 0 weight: 5 size: 12.0] coveredCharacterSet]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
460 /* Some fonts on OS X, maybe many on GNUstep, return nil. */ |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
461 if (fset == nil) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
462 fset = [NSCharacterSet characterSetWithRange: |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
463 NSMakeRange (0, 127)]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
464 if (ns_charset_covers(fset, charset, pct)) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
465 [families addObject: family]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
466 } |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
467 pct -= 0.2; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
468 if ([families count] > 0 || pct < 0.05) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
469 break; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
470 } |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
471 } |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
472 #ifdef NS_IMPL_COCOA |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
473 if ([families count] == 0) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
474 [families addObject: @"LastResort"]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
475 #endif |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
476 [scriptToFamilies setObject: families forKey: script]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
477 } |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
478 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
479 if (NSFONT_TRACE) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
480 NSLog(@" returning %d families", [families count]); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
481 return families; |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
482 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
483 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
484 |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
485 /* Implementation for list() and match(). List() can return nil, match() |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
486 must return something. Strategy is to drop family name from attribute |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
487 matching set for match. */ |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
488 static Lisp_Object |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
489 ns_findfonts (Lisp_Object font_spec, BOOL isMatch) |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
490 { |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
491 Lisp_Object tem, list = Qnil; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
492 NSFontDescriptor *fdesc, *desc; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
493 NSMutableSet *fkeys; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
494 NSArray *matchingDescs; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
495 NSEnumerator *dEnum; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
496 NSString *family; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
497 NSSet *cFamilies; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
498 BOOL foundItal = NO; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
499 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
500 if (NSFONT_TRACE) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
501 { |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
502 fprintf (stderr, "nsfont: %s for fontspec:\n ", |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
503 (isMatch ? "match" : "list")); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
504 debug_print (font_spec); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
505 } |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
506 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
507 cFamilies = ns_get_covering_families (ns_get_req_script (font_spec), 0.90); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
508 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
509 fdesc = ns_spec_to_descriptor (font_spec); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
510 fkeys = [NSMutableSet setWithArray: [[fdesc fontAttributes] allKeys]]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
511 if (isMatch) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
512 [fkeys removeObject: NSFontFamilyAttribute]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
513 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
514 matchingDescs = [fdesc matchingFontDescriptorsWithMandatoryKeys: fkeys]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
515 if (NSFONT_TRACE) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
516 NSLog(@"Got desc %@ and found %d matching fonts from it: ", fdesc, |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
517 [matchingDescs count]); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
518 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
519 for (dEnum = [matchingDescs objectEnumerator]; desc = [dEnum nextObject]; ) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
520 { |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
521 if (![cFamilies containsObject: |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
522 [desc objectForKey: NSFontFamilyAttribute]]) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
523 continue; |
104107
6a6fc6d5dad8
* nsfont.m (ns_findfonts): Fix 2009-07-24 change to return only one element, not a list, for match case.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
104069
diff
changeset
|
524 tem = ns_descriptor_to_entity (desc, |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
525 AREF (font_spec, FONT_EXTRA_INDEX), |
104107
6a6fc6d5dad8
* nsfont.m (ns_findfonts): Fix 2009-07-24 change to return only one element, not a list, for match case.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
104069
diff
changeset
|
526 NULL); |
6a6fc6d5dad8
* nsfont.m (ns_findfonts): Fix 2009-07-24 change to return only one element, not a list, for match case.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
104069
diff
changeset
|
527 if (isMatch) |
6a6fc6d5dad8
* nsfont.m (ns_findfonts): Fix 2009-07-24 change to return only one element, not a list, for match case.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
104069
diff
changeset
|
528 return tem; |
6a6fc6d5dad8
* nsfont.m (ns_findfonts): Fix 2009-07-24 change to return only one element, not a list, for match case.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
104069
diff
changeset
|
529 list = Fcons (tem, list); |
103990
73ea181d96b6
* nsfont.m (ns_attribute_value): Remove.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103908
diff
changeset
|
530 if (fabs (ns_attribute_fvalue (desc, NSFontSlantTrait)) > 0.05) |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
531 foundItal = YES; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
532 } |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
533 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
534 /* Add synthItal member if needed. */ |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
535 family = [fdesc objectForKey: NSFontFamilyAttribute]; |
103422
591af7ba061b
* nsfont.m (ns_attribute_value): Remove.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103343
diff
changeset
|
536 if (family != nil && !foundItal && XINT (Flength (list)) > 0) |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
537 { |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
538 NSFontDescriptor *sDesc = [[[NSFontDescriptor new] |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
539 fontDescriptorWithSymbolicTraits: NSFontItalicTrait] |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
540 fontDescriptorWithFamily: family]; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
541 list = Fcons (ns_descriptor_to_entity (sDesc, |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
542 AREF (font_spec, FONT_EXTRA_INDEX), |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
543 "synthItal"), list); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
544 } |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
545 |
104058
85bf43e7dada
* nsfont.m (ns_findfonts): Correctly return fallback in match case.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
104048
diff
changeset
|
546 /* Return something if was a match and nothing found. */ |
104107
6a6fc6d5dad8
* nsfont.m (ns_findfonts): Fix 2009-07-24 change to return only one element, not a list, for match case.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
104069
diff
changeset
|
547 if (isMatch) |
6a6fc6d5dad8
* nsfont.m (ns_findfonts): Fix 2009-07-24 change to return only one element, not a list, for match case.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
104069
diff
changeset
|
548 return ns_fallback_entity (); |
104058
85bf43e7dada
* nsfont.m (ns_findfonts): Correctly return fallback in match case.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
104048
diff
changeset
|
549 |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
550 if (NSFONT_TRACE) |
105561
69741c366370
* nsfont.m (ns_char_width): Replace deprecated call (suggested by
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105160
diff
changeset
|
551 fprintf (stderr, " Returning %ld entities.\n", |
105579
f846b59ab251
Add space after casts in last change.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105561
diff
changeset
|
552 (long) XINT (Flength (list))); |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
553 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
554 return list; |
96676
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 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
557 |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
558 |
96676
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 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
561 Font driver implementation |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
562 |
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 |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
565 |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
566 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
|
567 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
|
568 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
|
569 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
|
570 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
|
571 int pixel_size); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
572 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
|
573 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
|
574 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
|
575 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
|
576 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
|
577 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
|
578 int with_background); |
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 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
|
581 { |
96759
1e2f7aab70ba
* Makefile.in: Undef LIB_STANDARD before defining it to silence warning
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
96692
diff
changeset
|
582 0, /* Qns */ |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
583 1, /* case sensitive */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
584 nsfont_get_cache, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
585 nsfont_list, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
586 nsfont_match, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
587 nsfont_list_family, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
588 NULL, /*free_entity */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
589 nsfont_open, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
590 nsfont_close, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
591 NULL, /* prepare_face */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
592 NULL, /* done_face */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
593 nsfont_has_char, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
594 nsfont_encode_char, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
595 nsfont_text_extents, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
596 nsfont_draw, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
597 /* 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
|
598 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
|
599 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
|
600 }; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
601 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
602 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
603 /* 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
|
604 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
|
605 static Lisp_Object |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
606 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
|
607 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
608 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
|
609 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
|
610 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
611 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
612 |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
613 /* List fonts exactly matching with FONT_SPEC on FRAME. The value is a |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
614 **list** of font-entities. This and match () are sole APIs that allocate |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
615 font-entities. Properties to be considered (2009/05/19) are: |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
616 regular: foundry, family, adstyle, registry |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
617 extended: script, lang, otf |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
618 "Extended" properties are not part of the vector but get stored as |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
619 lisp properties under FONT_EXTRA_INDEX. |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
620 |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
621 The returned entities should have type set (to 'ns), plus the following: |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
622 foundry, family, adstyle, registry, |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
623 weight, slant, width, size (0 if scalable), |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
624 dpi, spacing, avgwidth (0 if scalable) */ |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
625 static Lisp_Object |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
626 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
|
627 { |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
628 return ns_findfonts (font_spec, NO); |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
629 } |
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 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
632 /* 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
|
633 FRAME. The closeness is determined by the font backend, thus |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
634 `face-font-selection-order' is ignored here. |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
635 Properties to be considered are same as for list(). */ |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
636 static Lisp_Object |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
637 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
|
638 { |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
639 return ns_findfonts(font_spec, YES); |
96676
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 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
642 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
643 /* 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
|
644 (symbols). */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
645 static Lisp_Object |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
646 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
|
647 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
648 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
|
649 NSEnumerator *families = |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
650 [[[NSFontManager sharedFontManager] availableFontFamilies] |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
651 objectEnumerator]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
652 NSString *family; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
653 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
|
654 list = Fcons (intern ([family UTF8String]), list); |
96892
4aec559b9f05
NS cleanup: change 'PENDING' to 'FIXME'/'TODO'/'XXX'
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
96817
diff
changeset
|
655 /* FIXME: escape the name? */ |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
656 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
657 if (NSFONT_TRACE) |
105561
69741c366370
* nsfont.m (ns_char_width): Replace deprecated call (suggested by
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105160
diff
changeset
|
658 fprintf (stderr, "nsfont: list families returning %ld entries\n", |
105579
f846b59ab251
Add space after casts in last change.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105561
diff
changeset
|
659 (long) XINT (Flength (list))); |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
660 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
661 return list; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
662 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
663 |
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 /* 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
|
666 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
|
667 static Lisp_Object |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
668 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
|
669 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
670 BOOL synthItal; |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
671 unsigned int traits = 0; |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
672 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
|
673 struct font *font; |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
674 NSFontDescriptor *fontDesc = ns_spec_to_descriptor (font_entity); |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
675 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
|
676 NSString *family; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
677 NSFont *nsfont, *sfont; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
678 Lisp_Object tem; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
679 NSRect brect; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
680 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
|
681 int i; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
682 int fixLeopardBug; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
683 static NSMutableDictionary *fontCache = nil; |
98451
db015b441c0c
* nsfont.m (nsfont_spec_to_traits): Use UnXX masks only for non-normal styles. (nsfont_open): Reenable the cache.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
98399
diff
changeset
|
684 NSNumber *cached; |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
685 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
686 /* 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
|
687 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
|
688 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
|
689 avoid creating multiple struct font objects (with metrics cache, etc.) |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
690 for the same NSFont object. */ |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
691 if (fontCache == nil) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
692 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
|
693 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
694 if (NSFONT_TRACE) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
695 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
696 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
|
697 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
|
698 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
699 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
700 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
|
701 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
702 /* 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
|
703 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
|
704 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
|
705 } |
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 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
|
708 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
|
709 9); |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
710 family = ns_get_family (font_entity); |
104123
132eb17eec1d
* nsfont.m (ns_descriptor_to_entity): Handle case when descriptor has no family set. (nsfont_open): Handle case when entity has no family.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
104107
diff
changeset
|
711 if (family == nil) |
132eb17eec1d
* nsfont.m (ns_descriptor_to_entity): Handle case when descriptor has no family set. (nsfont_open): Handle case when entity has no family.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
104107
diff
changeset
|
712 family = [[NSFont userFixedPitchFontOfSize: 0] familyName]; |
103990
73ea181d96b6
* nsfont.m (ns_attribute_value): Remove.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103908
diff
changeset
|
713 /* Should be > 0.23 as some font descriptors (e.g. Terminus) set to that |
73ea181d96b6
* nsfont.m (ns_attribute_value): Remove.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103908
diff
changeset
|
714 when setting family in ns_spec_to_descriptor(). */ |
73ea181d96b6
* nsfont.m (ns_attribute_value): Remove.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103908
diff
changeset
|
715 if (ns_attribute_fvalue (fontDesc, NSFontWeightTrait) > 0.50) |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
716 traits |= NSBoldFontMask; |
103990
73ea181d96b6
* nsfont.m (ns_attribute_value): Remove.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103908
diff
changeset
|
717 if (fabs (ns_attribute_fvalue (fontDesc, NSFontSlantTrait) > 0.05)) |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
718 traits |= NSItalicFontMask; |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
719 |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
720 /* see http://cocoadev.com/forums/comments.php?DiscussionID=74 */ |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
721 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
|
722 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
|
723 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
|
724 size: pixel_size]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
725 /* if didn't find, try synthetic italic */ |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
726 if (nsfont == nil && synthItal) |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
727 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
728 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
|
729 traits: traits & ~NSItalicFontMask |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
730 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
|
731 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
732 #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
|
733 /* 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
|
734 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
|
735 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
|
736 #endif |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
737 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
738 if (nsfont == nil) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
739 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
740 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
|
741 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
|
742 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
|
743 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
744 |
98451
db015b441c0c
* nsfont.m (nsfont_spec_to_traits): Use UnXX masks only for non-normal styles. (nsfont_open): Reenable the cache.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
98399
diff
changeset
|
745 if (NSFONT_TRACE) |
db015b441c0c
* nsfont.m (nsfont_spec_to_traits): Use UnXX masks only for non-normal styles. (nsfont_open): Reenable the cache.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
98399
diff
changeset
|
746 NSLog (@"%@\n", nsfont); |
98399
6b3b02fd9846
* nsfont.m (nsfont_trait_distance): Fix bug. (nsfont_list): Return a list rather than a vector (syncs with Handa changes of 2008-05-14). (nsfont_open): Improve logging.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
98371
diff
changeset
|
747 |
98451
db015b441c0c
* nsfont.m (nsfont_spec_to_traits): Use UnXX masks only for non-normal styles. (nsfont_open): Reenable the cache.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
98399
diff
changeset
|
748 /* Check the cache */ |
db015b441c0c
* nsfont.m (nsfont_spec_to_traits): Use UnXX masks only for non-normal styles. (nsfont_open): Reenable the cache.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
98399
diff
changeset
|
749 cached = [fontCache objectForKey: nsfont]; |
db015b441c0c
* nsfont.m (nsfont_spec_to_traits): Use UnXX masks only for non-normal styles. (nsfont_open): Reenable the cache.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
98399
diff
changeset
|
750 if (cached != nil && !synthItal) |
db015b441c0c
* nsfont.m (nsfont_spec_to_traits): Use UnXX masks only for non-normal styles. (nsfont_open): Reenable the cache.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
98399
diff
changeset
|
751 { |
db015b441c0c
* nsfont.m (nsfont_spec_to_traits): Use UnXX masks only for non-normal styles. (nsfont_open): Reenable the cache.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
98399
diff
changeset
|
752 if (NSFONT_TRACE) |
db015b441c0c
* nsfont.m (nsfont_spec_to_traits): Use UnXX masks only for non-normal styles. (nsfont_open): Reenable the cache.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
98399
diff
changeset
|
753 fprintf(stderr, "*** nsfont_open CACHE HIT!\n"); |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
754 /* FIXME: Cast from (unsigned long) to Lisp_Object. */ |
102954
b5a34573cf82
* nsselect.m (symbol_to_nsstring, clean_local_selection_data)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
102560
diff
changeset
|
755 XHASH (font_object) = [cached unsignedLongValue]; |
b5a34573cf82
* nsselect.m (symbol_to_nsstring, clean_local_selection_data)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
102560
diff
changeset
|
756 return font_object; |
98451
db015b441c0c
* nsfont.m (nsfont_spec_to_traits): Use UnXX masks only for non-normal styles. (nsfont_open): Reenable the cache.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
98399
diff
changeset
|
757 } |
db015b441c0c
* nsfont.m (nsfont_spec_to_traits): Use UnXX masks only for non-normal styles. (nsfont_open): Reenable the cache.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
98399
diff
changeset
|
758 else |
db015b441c0c
* nsfont.m (nsfont_spec_to_traits): Use UnXX masks only for non-normal styles. (nsfont_open): Reenable the cache.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
98399
diff
changeset
|
759 { |
db015b441c0c
* nsfont.m (nsfont_spec_to_traits): Use UnXX masks only for non-normal styles. (nsfont_open): Reenable the cache.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
98399
diff
changeset
|
760 font_object = font_make_object (VECSIZE (struct nsfont_info), |
db015b441c0c
* nsfont.m (nsfont_spec_to_traits): Use UnXX masks only for non-normal styles. (nsfont_open): Reenable the cache.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
98399
diff
changeset
|
761 font_entity, pixel_size); |
db015b441c0c
* nsfont.m (nsfont_spec_to_traits): Use UnXX masks only for non-normal styles. (nsfont_open): Reenable the cache.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
98399
diff
changeset
|
762 if (!synthItal) |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
763 [fontCache setObject: [NSNumber numberWithUnsignedLong: |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
764 (unsigned long) XHASH (font_object)] |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
765 forKey: nsfont]; |
98451
db015b441c0c
* nsfont.m (nsfont_spec_to_traits): Use UnXX masks only for non-normal styles. (nsfont_open): Reenable the cache.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
98399
diff
changeset
|
766 } |
db015b441c0c
* nsfont.m (nsfont_spec_to_traits): Use UnXX masks only for non-normal styles. (nsfont_open): Reenable the cache.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
98399
diff
changeset
|
767 |
db015b441c0c
* nsfont.m (nsfont_spec_to_traits): Use UnXX masks only for non-normal styles. (nsfont_open): Reenable the cache.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
98399
diff
changeset
|
768 font_info = (struct nsfont_info *) XFONT_OBJECT (font_object); |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
769 font = (struct font *) font_info; |
98451
db015b441c0c
* nsfont.m (nsfont_spec_to_traits): Use UnXX masks only for non-normal styles. (nsfont_open): Reenable the cache.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
98399
diff
changeset
|
770 if (!font) |
db015b441c0c
* nsfont.m (nsfont_spec_to_traits): Use UnXX masks only for non-normal styles. (nsfont_open): Reenable the cache.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
98399
diff
changeset
|
771 return Qnil; /* FIXME: other terms do, but return Qnil causes segfault */ |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
772 |
97198
cf43f4e3ecc8
clear warnings and clean up NS port
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
96892
diff
changeset
|
773 font_info->glyphs = (unsigned short **) |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
774 xmalloc (0x100 * sizeof (unsigned short *)); |
97198
cf43f4e3ecc8
clear warnings and clean up NS port
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
96892
diff
changeset
|
775 font_info->metrics = (struct font_metrics **) |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
776 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
|
777 if (!font_info->glyphs || !font_info->metrics) |
96759
1e2f7aab70ba
* Makefile.in: Undef LIB_STANDARD before defining it to silence warning
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
96692
diff
changeset
|
778 return Qnil; |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
779 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
|
780 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
|
781 |
98451
db015b441c0c
* nsfont.m (nsfont_spec_to_traits): Use UnXX masks only for non-normal styles. (nsfont_open): Reenable the cache.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
98399
diff
changeset
|
782 BLOCK_INPUT; |
96676
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 /* for metrics */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
785 sfont = [nsfont screenFont]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
786 if (sfont == nil) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
787 sfont = nsfont; |
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 /* 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
|
790 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
|
791 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
|
792 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
|
793 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
|
794 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
|
795 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
|
796 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
|
797 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
|
798 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
|
799 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
|
800 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
|
801 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
802 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
|
803 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
|
804 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
805 { |
103082
a9a213b44de2
nsfont.m (nsfont_open): remove unused variable shrink. Remove commented-out code.
David Reitter <david.reitter@gmail.com>
parents:
102954
diff
changeset
|
806 double expand, hshrink; |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
807 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
|
808 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
|
809 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
|
810 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
811 #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
|
812 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
|
813 #else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
814 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
|
815 #endif |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
816 [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
|
817 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
818 /* set up ns_font (defined in nsgui.h) */ |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
819 font_info->name = (char *)xmalloc (strlen (fontName) + 1); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
820 bcopy (fontName, font_info->name, strlen (fontName) + 1); |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
821 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
|
822 font_info->ital = |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
823 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
|
824 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
825 /* 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
|
826 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
|
827 font_info->width = ([sfont numberOfGlyphs] > 2000) ? |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
828 [sfont maximumAdvancement].width : ns_char_width (sfont, '0'); |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
829 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
830 brect = [sfont boundingRectForFont]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
831 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
|
832 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
|
833 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
|
834 |
102560
291f6c889881
Unify shutdown handling under NS, via ns-power-off key event (where appropriate) and save-buffers-kill-emacs.
David Reitter <david.reitter@gmail.com>
parents:
102400
diff
changeset
|
835 /* standard height, similar to Carbon. Emacs.app: was 0.5 by default. */ |
103082
a9a213b44de2
nsfont.m (nsfont_open): remove unused variable shrink. Remove commented-out code.
David Reitter <david.reitter@gmail.com>
parents:
102954
diff
changeset
|
836 expand = 0.0; |
102560
291f6c889881
Unify shutdown handling under NS, via ns-power-off key event (where appropriate) and save-buffers-kill-emacs.
David Reitter <david.reitter@gmail.com>
parents:
102400
diff
changeset
|
837 hshrink = 1.0; |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
838 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
839 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
|
840 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
|
841 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
|
842 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
|
843 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
844 /* max bounds */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
845 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
|
846 lrint (hshrink * [sfont ascender] + expand * hd/2); |
107114
e5188f4e7403
* nsfont.m (nsfont_open): The system's value for the font descent
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
847 /* [sfont descender] is usually negative. Use floor to avoid |
e5188f4e7403
* nsfont.m (nsfont_open): The system's value for the font descent
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
848 clipping descenders. */ |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
849 font_info->max_bounds.descent = |
107114
e5188f4e7403
* nsfont.m (nsfont_open): The system's value for the font descent
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
850 -lrint (floor(hshrink* [sfont descender] - expand*hd/2)); |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
851 font_info->height = |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
852 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
|
853 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
|
854 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
|
855 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
|
856 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
|
857 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
858 #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
|
859 /* 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
|
860 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
|
861 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
862 ATSFontRef atsFont = ATSFontFindFromPostScriptName |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
863 ((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
|
864 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
865 if (atsFont == kATSFontRefUnspecified) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
866 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
867 /* 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
|
868 atsFont = ATSFontFindFromPostScriptName ((CFStringRef) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
869 [[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
|
870 fontName], kATSOptionFlagsDefault); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
871 if (atsFont != kATSFontRefUnspecified) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
872 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
|
873 else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
874 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
875 /* last resort fallback */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
876 atsFont = ATSFontFindFromPostScriptName |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
877 ((CFStringRef)@"Monaco", kATSOptionFlagsDefault); |
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 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
880 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
|
881 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
882 #endif |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
883 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
884 /* set up metrics portion of font struct */ |
107114
e5188f4e7403
* nsfont.m (nsfont_open): The system's value for the font descent
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
885 font->ascent = lrint([sfont ascender]); |
e5188f4e7403
* nsfont.m (nsfont_open): The system's value for the font descent
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
886 font->descent = -lrint(floor([sfont descender])); |
105561
69741c366370
* nsfont.m (ns_char_width): Replace deprecated call (suggested by
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105160
diff
changeset
|
887 font->min_width = ns_char_width(sfont, '|'); |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
888 font->space_width = lrint (ns_char_width (sfont, ' ')); |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
889 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
|
890 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
|
891 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
|
892 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
|
893 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
|
894 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
895 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
|
896 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
|
897 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
|
898 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
899 UNBLOCK_INPUT; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
900 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
901 return font_object; |
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 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
904 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
905 /* 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
|
906 static void |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
907 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
|
908 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
909 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
|
910 int i; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
911 |
96892
4aec559b9f05
NS cleanup: change 'PENDING' to 'FIXME'/'TODO'/'XXX'
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
96817
diff
changeset
|
912 /* FIXME: this occurs apparently due to same failure to detect same font |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
913 that causes need for cache in nsfont_open () */ |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
914 if (!font_info) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
915 return; |
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 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
|
918 { |
103624
3e06f0e66062
Remove useless if-before-xfree tests.
Jim Meyering <jim@meyering.net>
parents:
103426
diff
changeset
|
919 xfree (font_info->glyphs[i]); |
3e06f0e66062
Remove useless if-before-xfree tests.
Jim Meyering <jim@meyering.net>
parents:
103426
diff
changeset
|
920 xfree (font_info->metrics[i]); |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
921 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
922 [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
|
923 #ifdef NS_IMPL_COCOA |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
924 CGFontRelease (font_info->cgfont); |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
925 #endif |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
926 xfree (font_info->name); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
927 xfree (font_info); |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
928 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
929 |
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 /* 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
|
932 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
|
933 it, return -1. */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
934 static int |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
935 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
|
936 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
937 return -1; |
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 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
940 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
941 /* 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
|
942 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
|
943 static unsigned int |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
944 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
|
945 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
946 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
|
947 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
|
948 unsigned short g; |
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 (c > 0xFFFF) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
951 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
|
952 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
953 /* 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
|
954 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
|
955 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
|
956 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
957 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
|
958 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
|
959 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
960 |
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 /* 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
|
963 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
|
964 CODE (length NGLYPHS). */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
965 static int |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
966 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
|
967 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
|
968 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
969 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
|
970 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
|
971 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
|
972 int totalWidth = 0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
973 int i; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
974 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
975 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
|
976 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
977 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
|
978 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
979 /* get metrics for this glyph, filling cache if need be */ |
96892
4aec559b9f05
NS cleanup: change 'PENDING' to 'FIXME'/'TODO'/'XXX'
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
96817
diff
changeset
|
980 /* TODO: get metrics for whole string from an NSLayoutManager |
4aec559b9f05
NS cleanup: change 'PENDING' to 'FIXME'/'TODO'/'XXX'
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
96817
diff
changeset
|
981 (if not too slow) */ |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
982 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
|
983 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
|
984 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
|
985 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
|
986 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
|
987 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
988 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
|
989 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
|
990 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
|
991 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
|
992 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
|
993 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
|
994 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
|
995 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
|
996 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
997 totalWidth += pcm->width; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
998 } |
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 metrics->width = totalWidth; |
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 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
|
1003 } |
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 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1006 /* 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
|
1007 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
|
1008 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
|
1009 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
|
1010 static int |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1011 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
|
1012 int with_background) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1013 /* 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
|
1014 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
|
1015 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1016 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
|
1017 char *c = cbuf; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1018 #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
|
1019 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
|
1020 float *adv = advances; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1021 #else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1022 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
|
1023 CGSize *adv = advances; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1024 #endif |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1025 struct face *face; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1026 NSRect r; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1027 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
|
1028 NSColor *col, *bgCol; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1029 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
|
1030 int i, len; |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
1031 char isComposite = s->first_glyph->type == COMPOSITE_GLYPH; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
1032 int end = isComposite ? s->cmp_to : s->nchars; |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1033 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1034 /* 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
|
1035 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
|
1036 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1037 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
|
1038 face = s->face; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1039 break; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1040 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
|
1041 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
|
1042 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
|
1043 if (!face) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1044 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
|
1045 break; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1046 default: |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1047 face = s->face; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1048 } |
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 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
|
1051 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
|
1052 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
|
1053 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1054 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
|
1055 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
|
1056 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1057 /* 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
|
1058 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
|
1059 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
|
1060 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1061 XCharStruct *cs; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1062 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
|
1063 int hi, lo; |
96892
4aec559b9f05
NS cleanup: change 'PENDING' to 'FIXME'/'TODO'/'XXX'
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
96817
diff
changeset
|
1064 /* FIXME: composition: no vertical displacement is considered. */ |
98371
713cc05ca791
* nsfont.m (nsfont_draw): Fix up composition rendering.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
98073
diff
changeset
|
1065 t += s->cmp_from; /* advance into composition */ |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
1066 for (i = s->cmp_from; i < end; i++, t++) |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1067 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1068 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
|
1069 lo = *t & 0x00FF; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1070 if (isComposite) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1071 { |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
1072 if (!s->first_glyph->u.cmp.automatic) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
1073 cwidth = s->cmp->offsets[i * 2] /* (H offset) */ - twidth; |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
1074 else |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
1075 { |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
1076 Lisp_Object gstring = composition_gstring_from_id (s->cmp_id); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
1077 Lisp_Object glyph = LGSTRING_GLYPH (gstring, i); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
1078 if (NILP (LGLYPH_ADJUSTMENT (glyph))) |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
1079 cwidth = LGLYPH_WIDTH (glyph); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
1080 else |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
1081 { |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
1082 cwidth = LGLYPH_WADJUST (glyph); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
1083 #ifdef NS_IMPL_GNUSTEP |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
1084 *(adv-1) += LGLYPH_XOFF (glyph); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
1085 #else |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
1086 (*(adv-1)).width += LGLYPH_XOFF (glyph); |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
1087 #endif |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
1088 } |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
1089 } |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1090 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1091 else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1092 { |
96892
4aec559b9f05
NS cleanup: change 'PENDING' to 'FIXME'/'TODO'/'XXX'
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
96817
diff
changeset
|
1093 if (!font->metrics[hi]) /* FIXME: why/how can we need this now? */ |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1094 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
|
1095 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
|
1096 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1097 twidth += cwidth; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1098 #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
|
1099 *adv++ = cwidth; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1100 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
|
1101 #else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1102 (*adv++).width = cwidth; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1103 #endif |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1104 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1105 len = adv - advances; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1106 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
|
1107 *c = 0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1108 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1109 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1110 /* fill background if requested */ |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
1111 if (with_background && !isComposite) |
96676
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 NSRect br = r; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1114 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
|
1115 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
|
1116 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1117 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
|
1118 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1119 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
|
1120 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1121 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
|
1122 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
|
1123 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1124 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
|
1125 <= fibw+1) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1126 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
|
1127 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1128 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
|
1129 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1130 /* 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
|
1131 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
|
1132 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1133 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
|
1134 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
|
1135 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1136 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1137 else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1138 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1139 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
|
1140 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
|
1141 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
|
1142 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
|
1143 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
|
1144 } |
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 if (!s->face->stipple) |
96812
eb46d3216494
apply fix from Chong Yidong to NS port ns_set_background_color(), and clean up comparison use of result from NS_FACE_BACKGROUND
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
96759
diff
changeset
|
1147 [(NS_FACE_BACKGROUND (face) != 0 |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1148 ? 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
|
1149 : 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
|
1150 else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1151 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1152 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
|
1153 [[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
|
1154 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1155 NSRectFill (br); |
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 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1158 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1159 /* 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
|
1160 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
|
1161 |
97198
cf43f4e3ecc8
clear warnings and clean up NS port
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
96892
diff
changeset
|
1162 col = (NS_FACE_FOREGROUND (face) != 0 |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1163 ? 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
|
1164 : FRAME_FOREGROUND_COLOR (s->f)); |
96892
4aec559b9f05
NS cleanup: change 'PENDING' to 'FIXME'/'TODO'/'XXX'
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
96817
diff
changeset
|
1165 /* FIXME: find another way to pass this */ |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1166 bgCol = (ns_tmp_flags != NS_DUMPGLYPH_FOREGROUND ? nil |
96812
eb46d3216494
apply fix from Chong Yidong to NS port ns_set_background_color(), and clean up comparison use of result from NS_FACE_BACKGROUND
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
96759
diff
changeset
|
1167 : (NS_FACE_BACKGROUND (face) != 0 |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1168 ? 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
|
1169 : 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
|
1170 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1171 /* 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
|
1172 #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
|
1173 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1174 NSGraphicsContext *context = GSCurrentContext (); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1175 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1176 DPSgsave (context); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1177 [font->nsfont set]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1178 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1179 /* 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
|
1180 if (bgCol != nil) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1181 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1182 [bgCol set]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1183 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
|
1184 /*[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
|
1185 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
|
1186 DPSstroke (context); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1187 [col set]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1188 /*[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
|
1189 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1190 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1191 /* do underline */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1192 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
|
1193 { |
97584
06f7d5858c5a
* nsfns.m (ns-read-file-name): Add casts to avoid warning. (ns-convert-utf8-nfd-to-nfc): Warn if cannot execute correctly. * nsfont.m (nsfont_draw): Compare indexed colors to 0, not nil. * nsterm.h (EmacsView-unlockFocusNeedsFlush:): Add declaration. (EmacsApp-cursor_blink_handler): Remove declaration. * nsterm.m (ns_draw_glyph_string): Update first conditional body to match 01 Feb 2008 changes in xterm.c. (ns_read_socket): Add cast to avoid warning. (EmacsApp-application:openFiles:): Don't call replyToOpenOrPrint: on GNUstep.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
97198
diff
changeset
|
1194 if (face->underline_color != 0) |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1195 [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
|
1196 else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1197 [col set]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1198 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
|
1199 DPSlineto (context, r.origin.x+r.size.width, r.origin.y+font->underpos); |
97584
06f7d5858c5a
* nsfns.m (ns-read-file-name): Add casts to avoid warning. (ns-convert-utf8-nfd-to-nfc): Warn if cannot execute correctly. * nsfont.m (nsfont_draw): Compare indexed colors to 0, not nil. * nsterm.h (EmacsView-unlockFocusNeedsFlush:): Add declaration. (EmacsApp-cursor_blink_handler): Remove declaration. * nsterm.m (ns_draw_glyph_string): Update first conditional body to match 01 Feb 2008 changes in xterm.c. (ns_read_socket): Add cast to avoid warning. (EmacsApp-application:openFiles:): Don't call replyToOpenOrPrint: on GNUstep.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
97198
diff
changeset
|
1200 if (face->underline_color != 0) |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1201 [col set]; |
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 else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1204 [col set]; |
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 /* draw with DPSxshow () */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1207 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
|
1208 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
|
1209 DPSstroke (context); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1210 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1211 DPSgrestore (context); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1212 return to-from; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1213 } |
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 #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
|
1216 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1217 CGContextRef gcontext = |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1218 [[NSGraphicsContext currentContext] graphicsPort]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1219 static CGAffineTransform fliptf; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1220 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
|
1221 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1222 if (firstTime) |
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 firstTime = NO; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1225 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
|
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 CGContextSaveGState (gcontext); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1229 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1230 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
|
1231 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1232 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
|
1233 CGContextSetFontSize (gcontext, font->size); |
107229
0255e27f26c9
* nsfont.m (nsfont_draw): ns_antialias_text should be a Lisp_Object (Bug#4736).
Chong Yidong <cyd@stupidchicken.com>
parents:
107114
diff
changeset
|
1234 if (NILP (ns_antialias_text) || font->size <= ns_antialias_threshold) |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1235 CGContextSetShouldAntialias (gcontext, 0); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1236 else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1237 CGContextSetShouldAntialias (gcontext, 1); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1238 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1239 CGContextSetTextMatrix (gcontext, fliptf); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1240 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1241 if (bgCol != nil) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1242 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1243 /* 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
|
1244 [bgCol set]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1245 CGContextSetTextDrawingMode (gcontext, kCGTextFillStroke); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1246 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
|
1247 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
|
1248 CGContextSetTextDrawingMode (gcontext, kCGTextFill); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1249 } |
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 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
|
1252 { |
97198
cf43f4e3ecc8
clear warnings and clean up NS port
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
96892
diff
changeset
|
1253 if (face->underline_color != 0) |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1254 [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
|
1255 else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1256 [col set]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1257 CGContextBeginPath (gcontext); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1258 CGContextMoveToPoint (gcontext, |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1259 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
|
1260 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
|
1261 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
|
1262 CGContextStrokePath (gcontext); |
97198
cf43f4e3ecc8
clear warnings and clean up NS port
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
96892
diff
changeset
|
1263 if (face->underline_color != 0) |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1264 [col set]; |
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 else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1267 [col set]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1268 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1269 CGContextSetTextPosition (gcontext, r.origin.x, r.origin.y); |
98073
e77a63e6f983
* nsfont.m (nsfont_draw): Fix the references to missing gidx data
Teodor Zlatanov <tzz@lifelogs.com>
parents:
97584
diff
changeset
|
1270 CGContextShowGlyphsWithAdvances (gcontext, s->char2b + s->cmp_from, |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1271 advances, len); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1272 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1273 if (face->overstrike) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1274 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1275 CGContextSetTextPosition (gcontext, r.origin.x+0.5, r.origin.y); |
98073
e77a63e6f983
* nsfont.m (nsfont_draw): Fix the references to missing gidx data
Teodor Zlatanov <tzz@lifelogs.com>
parents:
97584
diff
changeset
|
1276 CGContextShowGlyphsWithAdvances (gcontext, s->char2b + s->cmp_from, |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1277 advances, len); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1278 } |
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 CGContextRestoreGState (gcontext); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1281 return; |
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 #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
|
1284 |
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 |
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 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1289 /* ========================================================================== |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1290 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1291 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
|
1292 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1293 ========================================================================== */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1294 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1295 /* 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
|
1296 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
|
1297 static void |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1298 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
|
1299 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1300 #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
|
1301 static EmacsGlyphStorage *glyphStorage; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1302 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
|
1303 #endif |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1304 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
|
1305 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
|
1306 unsigned short *glyphs; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1307 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1308 if (NSFONT_TRACE) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1309 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
|
1310 font_info, block); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1311 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1312 BLOCK_INPUT; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1313 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1314 #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
|
1315 if (firstTime) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1316 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1317 firstTime = 0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1318 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
|
1319 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1320 #endif |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1321 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1322 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
|
1323 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
|
1324 abort (); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1325 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1326 /* 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
|
1327 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
|
1328 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
|
1329 unichars[i] = idx; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1330 else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1331 unichars[i] = 0xFEFF; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1332 unichars[0x100] = 0; |
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 #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
|
1336 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
|
1337 initWithCharactersNoCopy: unichars |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1338 length: 0x100 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1339 freeWhenDone: NO]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1340 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
|
1341 /*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
|
1342 unsigned int numGlyphs = [font_info->nsfont numberOfGlyphs]; |
105561
69741c366370
* nsfont.m (ns_char_width): Replace deprecated call (suggested by
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105160
diff
changeset
|
1343 NSUInteger gInd =0, cInd =0; |
96676
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 [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
|
1346 [glyphGenerator generateGlyphsForGlyphStorage: glyphStorage |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1347 desiredNumberOfCharacters: glyphStorage->maxChar |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1348 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
|
1349 #endif |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1350 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
|
1351 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
|
1352 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1353 #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
|
1354 g = unichars[i]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1355 #else |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1356 g = glyphStorage->cglyphs[i]; |
96892
4aec559b9f05
NS cleanup: change 'PENDING' to 'FIXME'/'TODO'/'XXX'
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
96817
diff
changeset
|
1357 /* TODO: is this a good check? maybe need to use coveredChars.. */ |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1358 if (g > numGlyphs) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1359 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
|
1360 #endif |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1361 *glyphs = g; |
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 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1364 #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
|
1365 [allChars release]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1366 #endif |
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 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1369 UNBLOCK_INPUT; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1370 xfree (unichars); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1371 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1372 |
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 /* 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
|
1375 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
|
1376 static void |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1377 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
|
1378 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1379 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
|
1380 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
|
1381 NSFont *sfont; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1382 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
|
1383 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1384 if (NSFONT_TRACE) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1385 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
|
1386 font_info, block); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1387 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1388 #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
|
1389 /* 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
|
1390 if (numGlyphs == 0) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1391 numGlyphs = 0x10000; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1392 #endif |
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 BLOCK_INPUT; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1395 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
|
1396 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1397 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
|
1398 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
|
1399 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
|
1400 abort (); |
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 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
|
1403 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
|
1404 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1405 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
|
1406 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
|
1407 |
105160
8f8d95750940
* nsfont.m (ns_glyph_metrics): Remove GNUstep conditional for
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105156
diff
changeset
|
1408 w = max ([sfont advancementForGlyph: g].width, 2.0); |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1409 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
|
1410 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1411 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
|
1412 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
|
1413 if (lb < 0) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1414 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
|
1415 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
|
1416 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
|
1417 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
|
1418 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1419 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
|
1420 /*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
|
1421 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
|
1422 /*-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
|
1423 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1424 UNBLOCK_INPUT; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1425 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1426 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1427 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1428 #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
|
1429 /* 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
|
1430 @implementation EmacsGlyphStorage |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1431 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1432 - init |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1433 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1434 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
|
1435 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1436 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1437 - 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
|
1438 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1439 self = [super init]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1440 maxChar = 0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1441 maxGlyph = 0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1442 dict = [NSMutableDictionary new]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1443 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
|
1444 return self; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1445 } |
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 - (void) dealloc |
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 if (attrStr != nil) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1450 [attrStr release]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1451 [dict release]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1452 xfree (cglyphs); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1453 [super dealloc]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1454 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1455 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1456 - (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
|
1457 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1458 [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
|
1459 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
|
1460 maxChar = [str length]; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1461 maxGlyph = 0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1462 } |
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 /* NSGlyphStorage protocol */ |
105561
69741c366370
* nsfont.m (ns_char_width): Replace deprecated call (suggested by
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105160
diff
changeset
|
1465 - (NSUInteger)layoutOptions |
96676
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 return 0; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1468 } |
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 - (NSAttributedString *)attributedString |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1471 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1472 return attrStr; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1473 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1474 |
105561
69741c366370
* nsfont.m (ns_char_width): Replace deprecated call (suggested by
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105160
diff
changeset
|
1475 - (void)insertGlyphs: (const NSGlyph *)glyphs length: (NSUInteger)length |
69741c366370
* nsfont.m (ns_char_width): Replace deprecated call (suggested by
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105160
diff
changeset
|
1476 forStartingGlyphAtIndex: (NSUInteger)glyphIndex |
69741c366370
* nsfont.m (ns_char_width): Replace deprecated call (suggested by
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105160
diff
changeset
|
1477 characterIndex: (NSUInteger)charIndex |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1478 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1479 len = glyphIndex+length; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1480 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
|
1481 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
|
1482 if (len > maxGlyph) |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1483 maxGlyph = len; |
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 |
105561
69741c366370
* nsfont.m (ns_char_width): Replace deprecated call (suggested by
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105160
diff
changeset
|
1486 - (void)setIntAttribute: (NSInteger)attributeTag value: (NSInteger)val |
69741c366370
* nsfont.m (ns_char_width): Replace deprecated call (suggested by
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105160
diff
changeset
|
1487 forGlyphAtIndex: (NSUInteger)glyphIndex |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1488 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1489 return; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1490 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1491 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1492 @end |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1493 #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
|
1494 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1495 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1496 /* Debugging */ |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1497 void |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
1498 ns_dump_glyphstring (struct glyph_string *s) |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1499 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1500 int i; |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1501 |
103343
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
1502 fprintf (stderr, "Glyph string len = %d at (%d, %d) overhang (%d, %d)," |
83dbc377f674
Changes to support :script/:lang/:otf in NS font driver.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
103245
diff
changeset
|
1503 "overlap = %d, bg_filled = %d:", |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1504 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
|
1505 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
|
1506 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
|
1507 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
|
1508 fprintf (stderr, "\n"); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1509 } |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1510 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1511 |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1512 void |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1513 syms_of_nsfont () |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1514 { |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1515 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
|
1516 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
|
1517 DEFSYM (Qapple, "apple"); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1518 DEFSYM (Qroman, "roman"); |
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1519 DEFSYM (Qmedium, "medium"); |
105156
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
1520 DEFVAR_LISP ("ns-reg-to-script", &Vns_reg_to_script, |
25063db12150
* nsfont.m (Vns_reg_to_script): New lisp variable.
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
105084
diff
changeset
|
1521 doc: /* Internal use: maps font registry to unicode script. */); |
96676
336d4f3f5eca
adding forgotten file src/nsfont.m for emacs.app merge
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
diff
changeset
|
1522 } |
96685 | 1523 |
96689
f34c4d928d39
Use nicer comment syntax for arch taglines in Objective-C files
Miles Bader <miles@gnu.org>
parents:
96685
diff
changeset
|
1524 // arch-tag: d6c3c6f0-62de-4978-8b1e-b7966fe02cae |