author | Claus Gittinger <cg@exept.de> |
Tue, 23 Apr 2019 16:30:55 +0200 | |
changeset 8674 | e29a561c0fbe |
parent 8652 | 5bc99411c4bd |
child 8702 | dac9fc1423a1 |
permissions | -rw-r--r-- |
7796 | 1 |
" |
2 |
COPYRIGHT (c) 2013 by Jan Vrany |
|
7941 | 3 |
COPYRIGHT (c) 2013 by Claus Gittinger / eXept Software AG |
8018 | 4 |
All Rights Reserved |
7796 | 5 |
|
6 |
This software is furnished under a license and may be used |
|
7 |
only in accordance with the terms of that license and with the |
|
8 |
inclusion of the above copyright notice. This software may not |
|
9 |
be provided or otherwise made available to, or used by, any |
|
10 |
other person. No title to or ownership of the software is |
|
11 |
hereby transferred. |
|
12 |
" |
|
6176 | 13 |
"{ Package: 'stx:libview' }" |
14 |
||
6833 | 15 |
"{ NameSpace: Smalltalk }" |
16 |
||
6176 | 17 |
FontDescription subclass:#XftFontDescription |
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
18 |
instanceVariableNames:'device fontId width minCode maxCode ascent descent height |
7342 | 19 |
fixedWidth' |
6184
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
20 |
classVariableNames:'FC_FAMILY FC_STYLE FC_SLANT FC_WEIGHT FC_SIZE FC_ASPECT |
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
21 |
FC_PIXEL_SIZE FC_SPACING FC_FOUNDRY FC_ANTIALIAS FC_HINTING |
6187
cfe33a9940ee
Memory/performance optimization - use stack-allocated XftColor.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6186
diff
changeset
|
22 |
FC_HINT_STYLE FC_VERTICAL_LAYOUT FC_AUTOHINT FC_WIDTH FC_FILE |
cfe33a9940ee
Memory/performance optimization - use stack-allocated XftColor.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6186
diff
changeset
|
23 |
FC_INDEX FC_FT_FACE FC_RASTERIZER FC_OUTLINE FC_SCALABLE FC_SCALE |
cfe33a9940ee
Memory/performance optimization - use stack-allocated XftColor.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6186
diff
changeset
|
24 |
FC_DPI FC_RGBA FC_MINSPACE FC_SOURCE FC_CHARSET FC_LANG |
cfe33a9940ee
Memory/performance optimization - use stack-allocated XftColor.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6186
diff
changeset
|
25 |
FC_FONTVERSION FC_FULLNAME FC_FAMILYLANG FC_STYLELANG |
cfe33a9940ee
Memory/performance optimization - use stack-allocated XftColor.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6186
diff
changeset
|
26 |
FC_FULLNAMELANG FC_CAPABILITY FC_FONTFORMAT FC_EMBOLDEN |
cfe33a9940ee
Memory/performance optimization - use stack-allocated XftColor.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6186
diff
changeset
|
27 |
FC_EMBEDDED_BITMAP FC_DECORATIVE FC_LCD_FILTER FC_NAMELANG |
6184
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
28 |
FC_CHAR_WIDTH FC_CHAR_HEIGHT FC_MATRIX FC_WEIGHT_THIN |
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
29 |
FC_WEIGHT_EXTRALIGHT FC_WEIGHT_ULTRALIGHT FC_WEIGHT_LIGHT |
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
30 |
FC_WEIGHT_BOOK FC_WEIGHT_REGULAR FC_WEIGHT_NORMAL |
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
31 |
FC_WEIGHT_MEDIUM FC_WEIGHT_DEMIBOLD FC_WEIGHT_SEMIBOLD |
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
32 |
FC_WEIGHT_BOLD FC_WEIGHT_EXTRABOLD FC_WEIGHT_ULTRABOLD |
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
33 |
FC_WEIGHT_BLACK FC_WEIGHT_HEAVY FC_WEIGHT_EXTRABLACK |
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
34 |
FC_WEIGHT_ULTRABLACK FC_SLANT_ROMAN FC_SLANT_ITALIC |
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
35 |
FC_SLANT_OBLIQUE FC_WIDTH_ULTRACONDENSED FC_WIDTH_EXTRACONDENSED |
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
36 |
FC_WIDTH_CONDENSED FC_WIDTH_SEMICONDENSED FC_WIDTH_NORMAL |
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
37 |
FC_WIDTH_SEMIEXPANDED FC_WIDTH_EXPANDED FC_WIDTH_EXTRAEXPANDED |
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
38 |
FC_WIDTH_ULTRAEXPANDED FC_PROPORTIONAL FC_DUAL FC_MONO |
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
39 |
FC_CHARCELL FC_RGBA_UNKNOWN FC_RGBA_RGB FC_RGBA_BGR FC_RGBA_VRGB |
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
40 |
FC_RGBA_VBGR FC_RGBA_NONE FC_HINT_NONE FC_HINT_SLIGHT |
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
41 |
FC_HINT_MEDIUM FC_HINT_FULL FC_LCD_NONE FC_LCD_DEFAULT |
6185
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
42 |
FC_LCD_LIGHT FC_LCD_LEGACY StXFace2FCWeightMap |
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
43 |
StXStyle2FCSlantMap FirstTimeCalled CachedFontList' |
6176 | 44 |
poolDictionaries:'' |
6185
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
45 |
category:'Graphics-Support' |
6176 | 46 |
! |
47 |
||
6263 | 48 |
Object subclass:#FCFontListParser |
49 |
instanceVariableNames:'pipeStream lineStream currentDescription' |
|
50 |
classVariableNames:'' |
|
51 |
poolDictionaries:'' |
|
52 |
privateIn:XftFontDescription |
|
53 |
! |
|
54 |
||
6188
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
55 |
ExternalAddress subclass:#FCPatternHandle |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
56 |
instanceVariableNames:'' |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
57 |
classVariableNames:'' |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
58 |
poolDictionaries:'' |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
59 |
privateIn:XftFontDescription |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
60 |
! |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
61 |
|
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
62 |
ExternalAddress subclass:#XftDrawHandle |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
63 |
instanceVariableNames:'' |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
64 |
classVariableNames:'' |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
65 |
poolDictionaries:'' |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
66 |
privateIn:XftFontDescription |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
67 |
! |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
68 |
|
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
69 |
ExternalAddress subclass:#XftFontHandle |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
70 |
instanceVariableNames:'' |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
71 |
classVariableNames:'' |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
72 |
poolDictionaries:'' |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
73 |
privateIn:XftFontDescription |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
74 |
! |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
75 |
|
6176 | 76 |
!XftFontDescription primitiveDefinitions! |
77 |
%{ |
|
78 |
/* |
|
79 |
* includes, defines, structure definitions |
|
80 |
* and typedefs come here. |
|
81 |
*/ |
|
82 |
||
83 |
#undef True |
|
84 |
#undef False |
|
6179 | 85 |
#undef Time |
6176 | 86 |
#define Time XTime |
87 |
||
6188
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
88 |
#ifdef XFT |
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
89 |
|
6936 | 90 |
extern OBJ __GLOBAL_GET_BY_NAME(char *); |
6188
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
91 |
|
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
92 |
# define __HANDLE_VAL(type, externalAddress) \ |
7221 | 93 |
((type)__externalAddressVal(externalAddress)) |
6489 | 94 |
|
6936 | 95 |
# define __HANDLE_NEW(ptr, __cls) \ |
7221 | 96 |
({ \ |
97 |
OBJ handle = __MKEXTERNALADDRESS(ptr); \ |
|
98 |
OBJ clsObj = __GLOBAL_GET_BY_NAME(__cls);\ |
|
99 |
__InstPtr(handle)->o_class = clsObj; \ |
|
100 |
__STORE(handle, clsObj); \ |
|
101 |
handle; \ |
|
102 |
}) |
|
6188
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
103 |
|
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
104 |
# define DISPLAY(x) __HANDLE_VAL(Display*, x) |
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
105 |
# define SCREEN(x) ((int)(__intVal(x))) |
6188
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
106 |
# define DRAWABLE(x) __HANDLE_VAL(Drawable, x) |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
107 |
# define GC(x) __HANDLE_VAL(GC, x) |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
108 |
# define VISUAL(x) __HANDLE_VAL(Visual*, x) |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
109 |
# define COLORMAP(x) __HANDLE_VAL(Colormap, x) |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
110 |
|
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
111 |
/* FontConfig objects */ |
6193 | 112 |
# define FC_PATTERN(x) __HANDLE_VAL(XftPattern*, x) |
113 |
# define FC_PATTERN_HANDLE_NEW(x) __HANDLE_NEW(x, "XftFontDescription::FCPatternHandle") |
|
6188
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
114 |
|
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
115 |
/* Xft Objects */ |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
116 |
|
6193 | 117 |
# define XFT_FONT(x) __HANDLE_VAL(XftFont*, x) |
6188
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
118 |
# define XFT_FONT_HANDLE_NEW(x) __HANDLE_NEW(x, "XftFontDescription::XftFontHandle") |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
119 |
|
6193 | 120 |
# define XFT_DRAW(x) __HANDLE_VAL(XftDraw*, x) |
6188
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
121 |
# define XFT_DRAW_HANDLE_NEW(x) __HANDLE_NEW(x, "XftFontDescription::XftDrawHandle") |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
122 |
|
6176 | 123 |
# include <X11/Xft/Xft.h> |
124 |
#endif |
|
125 |
%} |
|
126 |
! ! |
|
127 |
||
128 |
!XftFontDescription class methodsFor:'documentation'! |
|
129 |
||
7796 | 130 |
copyright |
131 |
" |
|
132 |
COPYRIGHT (c) 2013 by Jan Vrany |
|
7941 | 133 |
COPYRIGHT (c) 2013 by Claus Gittinger / eXept Software AG |
8018 | 134 |
All Rights Reserved |
7796 | 135 |
|
136 |
This software is furnished under a license and may be used |
|
137 |
only in accordance with the terms of that license and with the |
|
138 |
inclusion of the above copyright notice. This software may not |
|
139 |
be provided or otherwise made available to, or used by, any |
|
140 |
other person. No title to or ownership of the software is |
|
141 |
hereby transferred. |
|
142 |
||
143 |
" |
|
144 |
! |
|
145 |
||
6176 | 146 |
documentation |
147 |
" |
|
148 |
WARNING: Unfinished. |
|
149 |
||
150 |
Experimental implementation of custom font rendered using |
|
151 |
Xft library (UNIX / X Window only), To actually use it, |
|
152 |
add following definitions to the end of stx/configurations/myConf |
|
153 |
(works on Ubuntu 12.10) |
|
154 |
||
155 |
--- snip --- |
|
156 |
XDEFS+=-DXFT |
|
157 |
XINCLUDE+=$(shell pkg-config --cflags xft) |
|
158 |
LIB_XFT=-l:libXft.so.2 -l:libfontconfig.so.1 |
|
159 |
--- snip -- |
|
160 |
||
161 |
NOTE: This class should be named XftFont, however then |
|
162 |
there would be a name clash with XftFont structure |
|
163 |
defined in Xft.h - therefore the class is named |
|
164 |
XftFontDescription to avoid that name clash. |
|
165 |
||
166 |
||
167 |
[author:] |
|
6179 | 168 |
Jan Vrany <jan.vrany@fit.cvut.cz> |
6176 | 169 |
|
170 |
[instance variables:] |
|
171 |
||
172 |
[class variables:] |
|
173 |
||
174 |
[see also:] |
|
175 |
||
176 |
" |
|
177 |
! ! |
|
178 |
||
6184
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
179 |
!XftFontDescription class methodsFor:'initialization'! |
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
180 |
|
6327 | 181 |
flushListOfAvailableFonts |
182 |
CachedFontList := nil. |
|
183 |
||
184 |
" |
|
185 |
XftFontDescription flushListOfAvailableFonts |
|
186 |
" |
|
187 |
! |
|
188 |
||
6184
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
189 |
initialize |
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
190 |
"Invoked at system start or when the class is dynamically loaded." |
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
191 |
|
6185
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
192 |
" Taken from fontconfig,h " |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
193 |
|
8018 | 194 |
FC_FAMILY := 'family'. "/* String */ |
195 |
FC_STYLE := 'style'. "/* String */ |
|
196 |
FC_SLANT := 'slant'. "/* Int */ |
|
197 |
FC_WEIGHT := 'weight'. "/* Int */ |
|
198 |
FC_SIZE := 'size'. "/* Double */ |
|
199 |
FC_ASPECT := 'aspect'. "/* Double */ |
|
200 |
FC_PIXEL_SIZE := 'pixelsize'. "/* Double */ |
|
201 |
FC_SPACING := 'spacing'. "/* Int */ |
|
202 |
FC_FOUNDRY := 'foundry'. "/* String */ |
|
203 |
FC_ANTIALIAS := 'antialias'. "/* Bool (depends) */ |
|
204 |
FC_HINTING := 'hinting'. "/* Bool (true) */ |
|
205 |
FC_HINT_STYLE := 'hintstyle'. "/* Int */ |
|
206 |
FC_VERTICAL_LAYOUT := 'verticallayout'. "/* Bool (false) */ |
|
207 |
FC_AUTOHINT := 'autohint'. "/* Bool (false) */ |
|
208 |
FC_WIDTH := 'width'. "/* Int */ |
|
209 |
FC_FILE := 'file'. "/* String */ |
|
210 |
FC_INDEX := 'index'. "/* Int */ |
|
211 |
FC_FT_FACE := 'ftface'. "/* FT_Face */ |
|
212 |
FC_RASTERIZER := 'rasterizer'. "/* String */ |
|
213 |
FC_OUTLINE := 'outline'. "/* Bool */ |
|
214 |
FC_SCALABLE := 'scalable'. "/* Bool */ |
|
215 |
FC_SCALE := 'scale'. "/* double */ |
|
216 |
FC_DPI := 'dpi'. "/* double */ |
|
217 |
FC_RGBA := 'rgba'. "/* Int */ |
|
218 |
FC_MINSPACE := 'minspace'. "/* Bool use minimum line spacing */ |
|
219 |
FC_SOURCE := 'source'. "/* String (deprecated) */ |
|
220 |
FC_CHARSET := 'charset'. "/* CharSet */ |
|
221 |
FC_LANG := 'lang'. "/* String RFC 3066 langs */ |
|
222 |
FC_FONTVERSION := 'fontversion'. "/* Int from 'head'.table */ |
|
223 |
FC_FULLNAME := 'fullname'. "/* String */ |
|
224 |
FC_FAMILYLANG := 'familylang'. "/* String RFC 3066 langs */ |
|
225 |
FC_STYLELANG := 'stylelang'. "/* String RFC 3066 langs */ |
|
226 |
FC_FULLNAMELANG := 'fullnamelang'. "/* String RFC 3066 langs */ |
|
227 |
FC_CAPABILITY := 'capability'. "/* String */ |
|
228 |
FC_FONTFORMAT := 'fontformat'. "/* String */ |
|
229 |
FC_EMBOLDEN := 'embolden'. "/* Bool - true if emboldening needed*/ |
|
230 |
FC_EMBEDDED_BITMAP := 'embeddedbitmap'. "/* Bool - true to enable embedded bitmaps */ |
|
231 |
FC_DECORATIVE := 'decorative'. "/* Bool - true if style is a decorative variant */ |
|
232 |
FC_LCD_FILTER := 'lcdfilter'. "/* Int */ |
|
233 |
FC_NAMELANG := 'namelang'. "/* String RFC 3866 langs */ |
|
6185
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
234 |
|
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
235 |
|
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
236 |
"Adjust outline rasterizer" |
8018 | 237 |
FC_CHAR_WIDTH := 'charwidth'. "/* Int */ |
238 |
FC_CHAR_HEIGHT := 'charheight'. "/* Int */ |
|
239 |
FC_MATRIX := 'matrix'. "/* FcMatrix */ |
|
6185
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
240 |
|
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
241 |
FC_WEIGHT_THIN := 0. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
242 |
FC_WEIGHT_EXTRALIGHT := 40. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
243 |
FC_WEIGHT_ULTRALIGHT := FC_WEIGHT_EXTRALIGHT. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
244 |
FC_WEIGHT_LIGHT := 50. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
245 |
FC_WEIGHT_BOOK := 75. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
246 |
FC_WEIGHT_REGULAR := 80. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
247 |
FC_WEIGHT_NORMAL := FC_WEIGHT_REGULAR. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
248 |
FC_WEIGHT_MEDIUM := 100. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
249 |
FC_WEIGHT_DEMIBOLD := 180. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
250 |
FC_WEIGHT_SEMIBOLD := FC_WEIGHT_DEMIBOLD. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
251 |
FC_WEIGHT_BOLD := 200. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
252 |
FC_WEIGHT_EXTRABOLD := 205. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
253 |
FC_WEIGHT_ULTRABOLD := FC_WEIGHT_EXTRABOLD. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
254 |
FC_WEIGHT_BLACK := 210. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
255 |
FC_WEIGHT_HEAVY := FC_WEIGHT_BLACK. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
256 |
FC_WEIGHT_EXTRABLACK := 215. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
257 |
FC_WEIGHT_ULTRABLACK := FC_WEIGHT_EXTRABLACK. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
258 |
|
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
259 |
FC_SLANT_ROMAN := 0. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
260 |
FC_SLANT_ITALIC := 100. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
261 |
FC_SLANT_OBLIQUE := 110. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
262 |
|
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
263 |
FC_WIDTH_ULTRACONDENSED := 50. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
264 |
FC_WIDTH_EXTRACONDENSED := 63. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
265 |
FC_WIDTH_CONDENSED := 75. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
266 |
FC_WIDTH_SEMICONDENSED := 87. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
267 |
FC_WIDTH_NORMAL := 100. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
268 |
FC_WIDTH_SEMIEXPANDED := 113. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
269 |
FC_WIDTH_EXPANDED := 125. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
270 |
FC_WIDTH_EXTRAEXPANDED := 150. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
271 |
FC_WIDTH_ULTRAEXPANDED := 200. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
272 |
|
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
273 |
FC_PROPORTIONAL := 0. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
274 |
FC_DUAL := 90. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
275 |
FC_MONO := 100. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
276 |
FC_CHARCELL := 110. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
277 |
|
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
278 |
"sub-pixel order" |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
279 |
FC_RGBA_UNKNOWN := 0. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
280 |
FC_RGBA_RGB := 1. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
281 |
FC_RGBA_BGR := 2. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
282 |
FC_RGBA_VRGB := 3. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
283 |
FC_RGBA_VBGR := 4. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
284 |
FC_RGBA_NONE := 5. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
285 |
|
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
286 |
"hinting style" |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
287 |
FC_HINT_NONE := 0. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
288 |
FC_HINT_SLIGHT := 1. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
289 |
FC_HINT_MEDIUM := 2. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
290 |
FC_HINT_FULL := 3. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
291 |
|
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
292 |
"LCD filter" |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
293 |
FC_LCD_NONE := 0. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
294 |
FC_LCD_DEFAULT := 1. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
295 |
FC_LCD_LIGHT := 2. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
296 |
FC_LCD_LEGACY := 3. |
6184
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
297 |
|
8018 | 298 |
StXFace2FCWeightMap := |
299 |
Dictionary withKeysAndValues:{ |
|
300 |
#thin. FC_WEIGHT_THIN. |
|
301 |
#extralight. FC_WEIGHT_EXTRALIGHT. |
|
302 |
#ultralight. FC_WEIGHT_ULTRALIGHT. |
|
303 |
#light. FC_WEIGHT_LIGHT. |
|
304 |
#book. FC_WEIGHT_BOOK. |
|
305 |
#regular. FC_WEIGHT_REGULAR. |
|
306 |
#normal. FC_WEIGHT_NORMAL. |
|
307 |
#medium. FC_WEIGHT_MEDIUM. |
|
308 |
#demibold. FC_WEIGHT_DEMIBOLD. |
|
309 |
#semibold. FC_WEIGHT_SEMIBOLD. |
|
310 |
#bold. FC_WEIGHT_BOLD. |
|
311 |
#extrabold. FC_WEIGHT_EXTRABOLD. |
|
312 |
#ultrabold. FC_WEIGHT_ULTRABOLD. |
|
313 |
#black. FC_WEIGHT_BLACK. |
|
314 |
#heavy. FC_WEIGHT_HEAVY. |
|
315 |
#extrablack. FC_WEIGHT_EXTRABLACK. |
|
316 |
#ultrablack. FC_WEIGHT_ULTRABLACK. |
|
317 |
}. |
|
318 |
||
319 |
StXStyle2FCSlantMap := |
|
320 |
Dictionary withKeysAndValues:{ |
|
321 |
#roman. FC_SLANT_ROMAN. |
|
322 |
#italic. FC_SLANT_ITALIC. |
|
323 |
#oblique. FC_SLANT_OBLIQUE. |
|
324 |
}. |
|
6184
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
325 |
|
6185
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
326 |
"Modified: / 30-12-2013 / 19:48:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6184
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
327 |
! ! |
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
328 |
|
6325 | 329 |
!XftFontDescription class methodsFor:'instance creation'! |
330 |
||
6993 | 331 |
for:aFontOrFontDescription |
332 |
^ self |
|
7114 | 333 |
family:aFontOrFontDescription family |
334 |
face:aFontOrFontDescription face |
|
335 |
style:aFontOrFontDescription style |
|
336 |
size:aFontOrFontDescription size |
|
337 |
sizeUnit:#pt |
|
338 |
encoding:aFontOrFontDescription encoding |
|
6993 | 339 |
! |
340 |
||
6325 | 341 |
new |
6963 | 342 |
^ self basicNew initialize. |
6325 | 343 |
! ! |
344 |
||
6957 | 345 |
!XftFontDescription class methodsFor:'change & update'! |
346 |
||
347 |
aboutToDestroyViewWithDevice:aDevice id:aWindowId |
|
348 |
"a view is going to be destroyed. |
|
349 |
Have to disassociate the XftDrawId from the drawableId aWindowId" |
|
350 |
||
7567 | 351 |
"/ no longer used... |
352 |
"/ Lobby do:[:eachXftFont| |
|
353 |
"/ eachXftFont graphicsDevice == aDevice ifTrue:[ |
|
354 |
"/ eachXftFont disassociateXftDrawableFrom:aWindowId. |
|
355 |
"/ ]. |
|
356 |
"/ ]. |
|
6957 | 357 |
! ! |
358 |
||
6176 | 359 |
!XftFontDescription class methodsFor:'examples'! |
360 |
||
361 |
example1 |
|
362 |
" |
|
363 |
XftFontDescription example1 |
|
364 |
" |
|
365 |
|top textView| |
|
366 |
||
367 |
top := StandardSystemView new. |
|
368 |
top extent:300@200. |
|
369 |
||
370 |
textView := EditTextView new. |
|
371 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
6184
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
372 |
textView basicFont: (XftFontDescription family: 'DejaVu Sans' size: 16). |
6176 | 373 |
|
374 |
top addSubView:textView. |
|
375 |
||
6188
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
376 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile asText). |
6176 | 377 |
|
378 |
top open. |
|
379 |
||
380 |
"Created: / 20-12-2013 / 00:04:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
6184
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
381 |
"Modified: / 30-12-2013 / 19:11:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6185
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
382 |
! |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
383 |
|
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
384 |
example2 |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
385 |
" |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
386 |
XftFontDescription example2 |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
387 |
" |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
388 |
|top textView| |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
389 |
|
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
390 |
top := StandardSystemView new. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
391 |
top extent:300@200. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
392 |
|
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
393 |
textView := EditTextView new. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
394 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
395 |
textView basicFont: (XftFontDescription family: 'DejaVu Sans' size: 30) asItalic. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
396 |
|
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
397 |
top addSubView:textView. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
398 |
|
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
399 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
400 |
|
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
401 |
top open. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
402 |
|
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
403 |
"Created: / 30-12-2013 / 19:49:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6389 | 404 |
! |
405 |
||
406 |
example3 |
|
407 |
" |
|
408 |
XftFontDescription example2 |
|
409 |
" |
|
410 |
|top textView| |
|
411 |
||
412 |
top := StandardSystemView new. |
|
413 |
top extent:300@200. |
|
414 |
||
415 |
textView := EditTextView new. |
|
416 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
417 |
textView basicFont: (XftFontDescription family: 'Indie Flower' size: 30). |
|
418 |
||
419 |
top addSubView:textView. |
|
420 |
||
421 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
422 |
||
423 |
top open. |
|
424 |
||
425 |
"Created: / 30-12-2013 / 19:49:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
426 |
! ! |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
427 |
|
6936 | 428 |
!XftFontDescription class methodsFor:'primitives'! |
429 |
||
430 |
xftAvailable |
|
431 |
%{ |
|
432 |
#ifdef XFT |
|
433 |
RETURN ( true ) |
|
434 |
#endif |
|
435 |
%}. |
|
436 |
^ false |
|
437 |
||
438 |
"Created: / 20-12-2013 / 21:10:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
439 |
! |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
440 |
|
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
441 |
xftFontClose:fontIdArg displayId:displayId |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
442 |
| error | |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
443 |
|
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
444 |
%{ /* STACK: 64000 */ |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
445 |
#ifdef XFT |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
446 |
if ( ! __isExternalAddressLike(fontIdArg) ) { |
8018 | 447 |
error = @symbol(BadArg1); |
448 |
goto err; |
|
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
449 |
} |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
450 |
if ( ! __isExternalAddressLike(displayId) ) { |
8018 | 451 |
error = @symbol(BadArg2); |
452 |
goto err; |
|
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
453 |
} |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
454 |
XftFontClose (DISPLAY(displayId), XFT_FONT(fontIdArg)); |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
455 |
RETURN(self); |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
456 |
err:; |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
457 |
#endif |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
458 |
%}. |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
459 |
self primitiveFailed: error |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
460 |
! |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
461 |
|
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
462 |
xftFontGetAscent: fontIdArg |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
463 |
| error | |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
464 |
|
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
465 |
%{ /* STACK: 64000 */ |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
466 |
#ifdef XFT |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
467 |
if ( ! __isExternalAddressLike(fontIdArg) ) { |
8018 | 468 |
error = @symbol(BadArg1); |
469 |
goto err; |
|
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
470 |
} |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
471 |
RETURN ( __MKINT( XFT_FONT(fontIdArg)->ascent ) ); |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
472 |
err:; |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
473 |
#endif |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
474 |
%}. |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
475 |
self primitiveFailed: error |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
476 |
|
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
477 |
"Created: / 21-12-2013 / 00:56:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
478 |
! |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
479 |
|
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
480 |
xftFontGetDescent:fontIdArg |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
481 |
| error | |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
482 |
|
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
483 |
%{ /* STACK: 64000 */ |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
484 |
#ifdef XFT |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
485 |
if ( ! __isExternalAddressLike(fontIdArg) ) { |
8018 | 486 |
error = @symbol(BadArg1); |
487 |
goto err; |
|
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
488 |
} |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
489 |
RETURN ( __MKINT( XFT_FONT(fontIdArg)->descent ) ); |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
490 |
err:; |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
491 |
#endif |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
492 |
%}. |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
493 |
self primitiveFailed: error |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
494 |
|
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
495 |
"Created: / 21-12-2013 / 00:56:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
496 |
! |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
497 |
|
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
498 |
xftFontGetHeight: fontIdArg |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
499 |
| error | |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
500 |
|
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
501 |
%{ /* STACK: 64000 */ |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
502 |
#ifdef XFT |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
503 |
if ( ! __isExternalAddressLike(fontIdArg) ) { |
8018 | 504 |
error = @symbol(BadArg1); |
505 |
goto err; |
|
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
506 |
} |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
507 |
RETURN ( __MKINT( XFT_FONT(fontIdArg)->height ) ); |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
508 |
err:; |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
509 |
#endif |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
510 |
%}. |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
511 |
self primitiveFailed: error |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
512 |
|
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
513 |
"Created: / 21-12-2013 / 00:56:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
514 |
! |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
515 |
|
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
516 |
xftFontGetMaxAdvanceWidth: fontIdArg |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
517 |
| error | |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
518 |
|
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
519 |
%{ /* STACK: 64000 */ |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
520 |
#ifdef XFT |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
521 |
if ( ! __isExternalAddressLike(fontIdArg) ) { |
8018 | 522 |
error = @symbol(BadArg1); |
523 |
goto err; |
|
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
524 |
} |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
525 |
RETURN ( __MKINT( XFT_FONT(fontIdArg)->max_advance_width ) ); |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
526 |
err:; |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
527 |
#endif |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
528 |
%}. |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
529 |
self primitiveFailed: error |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
530 |
|
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
531 |
"Created: / 30-12-2013 / 20:02:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
532 |
! |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
533 |
|
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
534 |
xftFontGetPattern: fontIdArg |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
535 |
| error | |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
536 |
|
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
537 |
%{ /* STACK: 64000 */ |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
538 |
#ifdef XFT |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
539 |
XftPattern* p; |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
540 |
if ( ! __isExternalAddressLike(fontIdArg) ) { |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
541 |
error = @symbol(BadArg1); |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
542 |
goto err; |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
543 |
} |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
544 |
p = XFT_FONT(fontIdArg)->pattern; |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
545 |
if (p == NULL) { |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
546 |
RETURN ( nil ); |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
547 |
} else { |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
548 |
RETURN ( FC_PATTERN_HANDLE_NEW ( p ) ); |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
549 |
} |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
550 |
err:; |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
551 |
#endif |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
552 |
%}. |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
553 |
self primitiveFailed: error |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
554 |
|
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
555 |
"Created: / 21-12-2013 / 00:55:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6936 | 556 |
! ! |
557 |
||
6263 | 558 |
!XftFontDescription class methodsFor:'queries'! |
559 |
||
560 |
listOfAvailableFonts |
|
6264 | 561 |
"uses fc-list to get a list of available fontDescriptions" |
562 |
||
6263 | 563 |
CachedFontList isNil ifTrue:[ |
8018 | 564 |
CachedFontList := FCFontListParser new listOfAvailableFonts |
6263 | 565 |
]. |
566 |
^ CachedFontList |
|
567 |
||
568 |
" |
|
6337 | 569 |
XftFontDescription flushListOfAvailableFonts. |
6319 | 570 |
XftFontDescription listOfAvailableFonts |
6263 | 571 |
" |
572 |
! ! |
|
573 |
||
8370 | 574 |
!XftFontDescription class methodsFor:'utilities'! |
575 |
||
576 |
fixedLC_CTYPE |
|
577 |
"to suppress the disturbing warning messages from fontconfig, |
|
578 |
if LC_CTYPE is wrong (osx problem only?)" |
|
579 |
||
8615 | 580 |
|lc_CTYPE| |
8493 | 581 |
|
8370 | 582 |
lc_CTYPE := OperatingSystem getEnvironment:'LC_CTYPE'. |
8615 | 583 |
(lc_CTYPE isNil or:[lc_CTYPE = 'UTF-8']) ifTrue:[ |
584 |
^ Smalltalk language |
|
585 |
,'_',Smalltalk languageTerritory asUppercase |
|
586 |
,'.UTF-8'. |
|
8370 | 587 |
]. |
8615 | 588 |
^ lc_CTYPE |
8493 | 589 |
|
590 |
"Modified: / 09-10-2018 / 19:37:08 / Claus Gittinger" |
|
8615 | 591 |
"Modified: / 22-01-2019 / 11:39:03 / Stefan Vogel" |
8370 | 592 |
! ! |
593 |
||
6317 | 594 |
!XftFontDescription methodsFor:'accessing'! |
6190
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
595 |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
596 |
encoding |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
597 |
^ encoding ? #'iso10646-1' |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
598 |
! |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
599 |
|
6319 | 600 |
face |
601 |
^ face ? '' |
|
602 |
! |
|
603 |
||
604 |
fullName |
|
605 |
^ name ? (self userFriendlyName) |
|
606 |
! |
|
607 |
||
6317 | 608 |
graphicsDevice |
6190
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
609 |
^ device |
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
610 |
|
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
611 |
"Created: / 02-01-2014 / 23:22:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6319 | 612 |
! |
613 |
||
614 |
maxCode |
|
6323 | 615 |
^ maxCode ? 16rFFFF |
6319 | 616 |
! |
617 |
||
618 |
maxCode:something |
|
619 |
maxCode := something. |
|
620 |
! |
|
621 |
||
622 |
minCode |
|
6323 | 623 |
^ minCode ? 0 |
6319 | 624 |
! |
625 |
||
626 |
minCode:something |
|
627 |
minCode := something. |
|
628 |
! |
|
629 |
||
630 |
style |
|
631 |
^ style ? '' |
|
6391 | 632 |
! |
633 |
||
634 |
weight:aNumber |
|
7121 | 635 |
"set the weight. The face is the string representation of weight." |
6391 | 636 |
|
637 |
self assert:(self fontId isNil). "/ cannot change an instantiated font |
|
638 |
||
7121 | 639 |
weight := aNumber. |
640 |
||
641 |
aNumber == FC_WEIGHT_THIN ifTrue:[ face := #thin. ^ self]. |
|
642 |
aNumber == FC_WEIGHT_EXTRALIGHT ifTrue:[ face := #extralight. ^ self]. |
|
643 |
aNumber == FC_WEIGHT_LIGHT ifTrue:[ face := #light. ^ self]. |
|
644 |
aNumber == FC_WEIGHT_BOOK ifTrue:[ face := #book. ^ self]. |
|
645 |
aNumber == FC_WEIGHT_REGULAR ifTrue:[ face := #regular. ^ self]. |
|
646 |
aNumber == FC_WEIGHT_MEDIUM ifTrue:[ face := #medium. ^ self]. |
|
647 |
aNumber == FC_WEIGHT_DEMIBOLD ifTrue:[ face := #demibold. ^ self]. |
|
648 |
aNumber == FC_WEIGHT_BOLD ifTrue:[ face := #bold. ^ self]. |
|
649 |
aNumber == FC_WEIGHT_EXTRABOLD ifTrue:[ face := #extrabold. ^ self]. |
|
650 |
aNumber == FC_WEIGHT_BLACK ifTrue:[ face := #black. ^ self]. |
|
651 |
aNumber == FC_WEIGHT_EXTRABLACK ifTrue:[ face := #extrablack. ^ self]. |
|
6391 | 652 |
|
653 |
aNumber <= (FC_WEIGHT_EXTRALIGHT + FC_WEIGHT_LIGHT // 2) ifTrue:[ |
|
7221 | 654 |
face := #extralight. |
655 |
^ self. |
|
6391 | 656 |
]. |
657 |
aNumber <= (FC_WEIGHT_LIGHT + FC_WEIGHT_BOOK // 2) ifTrue:[ |
|
7221 | 658 |
face := #light. |
659 |
^ self. |
|
6391 | 660 |
]. |
661 |
aNumber <= (FC_WEIGHT_MEDIUM + FC_WEIGHT_DEMIBOLD // 2) ifTrue:[ |
|
7221 | 662 |
face := #medium. |
663 |
^ self. |
|
6391 | 664 |
]. |
665 |
aNumber <= (FC_WEIGHT_DEMIBOLD + FC_WEIGHT_BOLD // 2) ifTrue:[ |
|
7221 | 666 |
face := #demibold. |
667 |
^ self. |
|
6391 | 668 |
]. |
669 |
aNumber <= (FC_WEIGHT_BOLD + FC_WEIGHT_BLACK // 2) ifTrue:[ |
|
7221 | 670 |
face := #bold. |
671 |
^ self. |
|
6391 | 672 |
]. |
7121 | 673 |
face := #extrabold. |
6391 | 674 |
^ self |
675 |
||
676 |
"/ FC_WEIGHT_THIN := 0. |
|
677 |
"/ FC_WEIGHT_EXTRALIGHT := 40. |
|
678 |
"/ FC_WEIGHT_ULTRALIGHT := FC_WEIGHT_EXTRALIGHT. |
|
679 |
"/ FC_WEIGHT_LIGHT := 50. |
|
680 |
"/ FC_WEIGHT_BOOK := 75. |
|
681 |
"/ FC_WEIGHT_REGULAR := 80. |
|
682 |
"/ FC_WEIGHT_NORMAL := FC_WEIGHT_REGULAR. |
|
683 |
"/ FC_WEIGHT_MEDIUM := 100. |
|
684 |
"/ FC_WEIGHT_DEMIBOLD := 180. |
|
685 |
"/ FC_WEIGHT_SEMIBOLD := FC_WEIGHT_DEMIBOLD. |
|
686 |
"/ FC_WEIGHT_BOLD := 200. |
|
687 |
"/ FC_WEIGHT_EXTRABOLD := 205. |
|
688 |
"/ FC_WEIGHT_ULTRABOLD := FC_WEIGHT_EXTRABOLD. |
|
689 |
"/ FC_WEIGHT_BLACK := 210. |
|
690 |
"/ FC_WEIGHT_HEAVY := FC_WEIGHT_BLACK. |
|
691 |
"/ FC_WEIGHT_EXTRABLACK := 215. |
|
692 |
"/ FC_WEIGHT_ULTRABLACK := FC_WEIGHT_EXTRABLACK. |
|
6317 | 693 |
! ! |
694 |
||
695 |
!XftFontDescription methodsFor:'accessing-private'! |
|
6190
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
696 |
|
7443 | 697 |
getXftFontId |
6190
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
698 |
^ fontId |
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
699 |
|
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
700 |
"Created: / 02-01-2014 / 23:29:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
7114 | 701 |
! |
702 |
||
703 |
setFontId:fontIdArg |
|
704 |
fontId := fontIdArg. |
|
6190
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
705 |
! ! |
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
706 |
|
6587
c1790bb9af59
In case of not configured but installed Xft Fonts convert XftFonts
ab
parents:
6544
diff
changeset
|
707 |
!XftFontDescription methodsFor:'converting'! |
c1790bb9af59
In case of not configured but installed Xft Fonts convert XftFonts
ab
parents:
6544
diff
changeset
|
708 |
|
c1790bb9af59
In case of not configured but installed Xft Fonts convert XftFonts
ab
parents:
6544
diff
changeset
|
709 |
asNonXftFont |
8643 | 710 |
"in some situations, we do not want an Xft font. |
711 |
Return an abstract fontDescription corresponding to the receiver" |
|
8018 | 712 |
|
6587
c1790bb9af59
In case of not configured but installed Xft Fonts convert XftFonts
ab
parents:
6544
diff
changeset
|
713 |
|newFont| |
c1790bb9af59
In case of not configured but installed Xft Fonts convert XftFonts
ab
parents:
6544
diff
changeset
|
714 |
|
7707 | 715 |
newFont := Font |
8643 | 716 |
family:family |
717 |
face:face |
|
718 |
style:style |
|
719 |
size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) |
|
720 |
sizeUnit:sizeUnit |
|
721 |
encoding:encoding. |
|
7877 | 722 |
newFont isForceNonXFTFont:true. |
6656 | 723 |
^ newFont |
7870 | 724 |
|
7877 | 725 |
" |
726 |
|view1 view2| |
|
727 |
||
728 |
view1 := TextView new openAndWait. |
|
729 |
view2 := TextView new openAndWait. |
|
730 |
view1 font:(Button defaultFont). |
|
731 |
view1 contents:'Hello world'. |
|
732 |
view2 font:(Button defaultFont asNonXftFont onDevice:Display). |
|
733 |
view2 contents:'Hello world'. |
|
734 |
" |
|
735 |
||
736 |
"Modified (comment): / 12-02-2017 / 22:14:47 / cg" |
|
8643 | 737 |
"Modified (comment): / 28-02-2019 / 18:13:18 / Claus Gittinger" |
6587
c1790bb9af59
In case of not configured but installed Xft Fonts convert XftFonts
ab
parents:
6544
diff
changeset
|
738 |
! ! |
c1790bb9af59
In case of not configured but installed Xft Fonts convert XftFonts
ab
parents:
6544
diff
changeset
|
739 |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
740 |
!XftFontDescription methodsFor:'error reporting'! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
741 |
|
6198 | 742 |
primitiveFailed |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
743 |
<resource: #skipInDebuggersWalkBack> |
6876
b1aa2b47d252
avoid ifdefs around smalltalk statements
Claus Gittinger <cg@exept.de>
parents:
6833
diff
changeset
|
744 |
|
6936 | 745 |
self class xftAvailable ifFalse:[ |
7114 | 746 |
super primitiveFailed:'Xft support is not configured'. |
6876
b1aa2b47d252
avoid ifdefs around smalltalk statements
Claus Gittinger <cg@exept.de>
parents:
6833
diff
changeset
|
747 |
]. |
6198 | 748 |
super primitiveFailed |
749 |
! |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
750 |
|
6198 | 751 |
primitiveFailed:errorString |
752 |
<resource: #skipInDebuggersWalkBack> |
|
6876
b1aa2b47d252
avoid ifdefs around smalltalk statements
Claus Gittinger <cg@exept.de>
parents:
6833
diff
changeset
|
753 |
|
6936 | 754 |
self class xftAvailable ifFalse:[ |
7114 | 755 |
super primitiveFailed:'Xft support is not configured'. |
6876
b1aa2b47d252
avoid ifdefs around smalltalk statements
Claus Gittinger <cg@exept.de>
parents:
6833
diff
changeset
|
756 |
]. |
6198 | 757 |
super primitiveFailed:errorString |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
758 |
! ! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
759 |
|
6946 | 760 |
!XftFontDescription methodsFor:'finalization'! |
761 |
||
762 |
finalize |
|
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
763 |
self releaseFromDevice |
6946 | 764 |
! ! |
765 |
||
6176 | 766 |
!XftFontDescription methodsFor:'getting a device font'! |
767 |
||
7443 | 768 |
installInDeviceForGCId:aGCId |
769 |
"install the font for aGCId" |
|
770 |
||
771 |
(device isNil or:[fontId isNil]) ifTrue:[ |
|
8018 | 772 |
Logger error:'no device font for: %1' with:self. |
773 |
^ nil. |
|
7443 | 774 |
]. |
775 |
"nothing to install" |
|
776 |
! |
|
777 |
||
6176 | 778 |
onDevice:aGraphicsDevice |
779 |
"Create a new XftFont representing the closes font as |
|
780 |
myself on aDevice; if one already exists, return the one." |
|
781 |
||
7219 | 782 |
^ self onDevice:aGraphicsDevice ifAbsent:self |
7114 | 783 |
! |
784 |
||
785 |
onDevice:aGraphicsDevice ifAbsent:aBlock |
|
7559 | 786 |
"Create a new XftFont representing the closest font as |
7114 | 787 |
myself on aDevice; if one already exists, return the one." |
6176 | 788 |
|
7559 | 789 |
|displayId myPatternHandle closestPatternHandle newFontId computedWeight deviceFont| |
6176 | 790 |
|
7114 | 791 |
(device == aGraphicsDevice) ifTrue:[ |
8370 | 792 |
"I am already assigned to that device ..." |
793 |
^ self |
|
7114 | 794 |
]. |
795 |
aGraphicsDevice isNil ifTrue:[ |
|
8370 | 796 |
^ self |
6544 | 797 |
]. |
7121 | 798 |
aGraphicsDevice supportsXftFonts ifFalse:[ |
8370 | 799 |
^ self asNonXftFont onDevice:aGraphicsDevice. |
6190
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
800 |
]. |
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
801 |
|
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
802 |
deviceFont := aGraphicsDevice deviceFonts detect:[:eachFont | self sameDeviceFontAs:eachFont] ifNone:[]. |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
803 |
deviceFont notNil ifTrue:[ |
8370 | 804 |
^ deviceFont. |
6389 | 805 |
]. |
806 |
||
7121 | 807 |
computedWeight := weight. |
808 |
computedWeight isNil ifTrue:[ |
|
8370 | 809 |
computedWeight := StXFace2FCWeightMap at:(face ? '') asLowercase ifAbsent:[FC_WEIGHT_REGULAR]. |
7121 | 810 |
]. |
811 |
||
8391 | 812 |
(OperatingSystem isOSXlike and:[FirstTimeCalled ~~ false]) ifTrue:[ |
8370 | 813 |
"Slow font matching is a MAC-only feature" |
814 |
Logger info:'XFT: matching font (this may take a long time, if the system''s font cache needs to be filled first. Be patient...'. |
|
815 |
FirstTimeCalled := false. |
|
7559 | 816 |
]. |
817 |
||
8615 | 818 |
OperatingSystem setEnvironment:'LC_CTYPE' to:(self class fixedLC_CTYPE). |
819 |
||
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
820 |
[ |
8370 | 821 |
myPatternHandle := FCPatternHandle create. |
822 |
myPatternHandle |
|
823 |
add:FC_FOUNDRY value:manufacturer; |
|
824 |
add:FC_FAMILY value:family; |
|
825 |
add:FC_WEIGHT value:computedWeight; |
|
8615 | 826 |
add:FC_SLANT value:(StXStyle2FCSlantMap at:(style ? '') asLowercase |
827 |
ifAbsent:[FC_SLANT_ROMAN]). |
|
8370 | 828 |
sizeUnit = #px ifTrue:[ |
829 |
myPatternHandle add:FC_PIXEL_SIZE value:(pixelSize isNil ifTrue:[nil] ifFalse:[pixelSize rounded]). |
|
830 |
] ifFalse:[ |
|
831 |
myPatternHandle add:FC_SIZE value:(size isNil ifTrue:[nil] ifFalse:[size rounded]). |
|
832 |
]. |
|
7114 | 833 |
|
8370 | 834 |
displayId := aGraphicsDevice displayId. |
8615 | 835 |
displayId isNil ifTrue:[ |
836 |
self error:'nil displayId'. |
|
837 |
]. |
|
8370 | 838 |
closestPatternHandle := myPatternHandle matchFontOnDisplayId:displayId screen:aGraphicsDevice screen. |
839 |
closestPatternHandle notNil ifTrue:[ |
|
840 |
newFontId := closestPatternHandle getFontOnDisplayId:displayId. |
|
841 |
newFontId notNil ifTrue:[ |
|
842 |
"/ Good, this font exists!! |
|
843 |
device isNil ifTrue:[ |
|
8615 | 844 |
"not assigned to a device..." |
8370 | 845 |
deviceFont := self. |
846 |
] ifFalse:[ |
|
847 |
deviceFont := self copy. |
|
848 |
]. |
|
849 |
closestPatternHandle := nil. |
|
850 |
deviceFont setDevice:aGraphicsDevice patternId:nil fontId:newFontId. |
|
851 |
aGraphicsDevice registerFont:deviceFont. |
|
852 |
^ deviceFont. |
|
853 |
]. |
|
854 |
]. |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
855 |
] ensure:[ |
8370 | 856 |
myPatternHandle notNil ifTrue:[myPatternHandle destroy]. |
857 |
closestPatternHandle notNil ifTrue:[closestPatternHandle destroy]. |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
858 |
]. |
7114 | 859 |
^ aBlock value |
6176 | 860 |
|
861 |
" |
|
8615 | 862 |
(XftFontDescription family:'monospace' size:16) onDevice:Screen current ifAbsent:[self halt]. |
6176 | 863 |
" |
864 |
||
865 |
"Modified: / 14-04-1997 / 18:22:31 / cg" |
|
6190
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
866 |
"Modified: / 02-01-2014 / 23:43:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
8391 | 867 |
"Modified: / 18-06-2018 / 15:54:36 / Claus Gittinger" |
8615 | 868 |
"Modified (format): / 22-01-2019 / 11:49:50 / Stefan Vogel" |
6176 | 869 |
! ! |
870 |
||
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
871 |
!XftFontDescription methodsFor:'initialization'! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
872 |
|
6963 | 873 |
initialize |
874 |
"Invoked when a new instance is created." |
|
875 |
||
876 |
super initialize. |
|
877 |
size := 0. |
|
878 |
encoding := #'iso10646-1'. |
|
879 |
! |
|
880 |
||
6993 | 881 |
isScaledFont |
882 |
^ true |
|
883 |
! |
|
884 |
||
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
885 |
setDevice: deviceArg patternId: patternIdArg fontId: fontIdArg |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
886 |
device := deviceArg. |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
887 |
fontId := fontIdArg. |
6325 | 888 |
patternIdArg notNil ifTrue:[ |
7114 | 889 |
family := patternIdArg get: FC_FAMILY index: 0. |
890 |
size := patternIdArg get: FC_SIZE index: 0. |
|
8018 | 891 |
weight := patternIdArg get: FC_WEIGHT index: 0. |
892 |
face := StXFace2FCWeightMap keyAtValue: weight. |
|
893 |
slant := patternIdArg get: FC_SLANT index: 0. |
|
894 |
style := StXStyle2FCSlantMap keyAtValue: slant. |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
895 |
|
8018 | 896 |
"/ name := patternIdArg get: 'fullname' index: 0. |
897 |
"/ encoding:= patternIdArg get: 'encoding' index: 0. |
|
6957 | 898 |
]. |
899 |
size isNil ifTrue:[ |
|
7114 | 900 |
size := 0. |
6325 | 901 |
]. |
6963 | 902 |
encoding isNil ifTrue:[ |
7114 | 903 |
encoding := #'iso10646-1'. |
6963 | 904 |
]. |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
905 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
906 |
"Created: / 21-12-2013 / 00:46:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6184
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
907 |
"Modified: / 30-12-2013 / 12:49:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
908 |
! ! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
909 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
910 |
!XftFontDescription methodsFor:'primitives'! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
911 |
|
7563 | 912 |
xftTextExtents:displayIdArg string:aString from:start to:stop into:extentsArrayOrNil |
913 |
"get the extents of aString. |
|
914 |
Answer thr width of aString (in reality the xOff). |
|
915 |
If extentArrayOrNil is an Array, fill is with the extent info: |
|
8018 | 916 |
#(width height x y xOff yOff ascent descent)." |
7563 | 917 |
|
918 |
|error bytesPerCharacter| |
|
919 |
||
920 |
bytesPerCharacter := aString bytesPerCharacter. |
|
7114 | 921 |
|
922 |
%{ /* STACK: 64000 */ |
|
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
923 |
#ifdef XFT |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
924 |
XGlyphInfo info; |
6195
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
925 |
char *string; |
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
926 |
int len; |
7563 | 927 |
int __bytesPerCharacter = __intVal(bytesPerCharacter); |
8018 | 928 |
OBJ fontIdArg = __INST(fontId); |
6195
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
929 |
|
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
930 |
if ( ! __isExternalAddressLike(displayIdArg) ) { |
8018 | 931 |
error = @symbol(BadArg1); |
932 |
goto err; |
|
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
933 |
} |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
934 |
if ( ! __isSmallInteger(start) ) { |
8018 | 935 |
error = @symbol(BadArg3); |
936 |
goto err; |
|
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
937 |
} |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
938 |
if ( ! __isSmallInteger(stop) ) { |
8018 | 939 |
error = @symbol(BadArg4); |
940 |
goto err; |
|
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
941 |
} |
8018 | 942 |
if ( ! __isExternalAddressLike(fontIdArg) ) { |
943 |
error = @symbol(BadFontId); |
|
944 |
goto err; |
|
7563 | 945 |
} |
946 |
||
947 |
string = __stringVal(aString) + ((__intVal(start) - 1) * __bytesPerCharacter); |
|
6195
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
948 |
len = __intVal(stop) - __intVal(start) + 1; |
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
949 |
|
7563 | 950 |
switch (__bytesPerCharacter) { |
8018 | 951 |
case 1: |
952 |
XftTextExtents8(DISPLAY(displayIdArg), XFT_FONT(fontIdArg), (FcChar8*)string, len, &info); |
|
953 |
break; |
|
954 |
case 2: |
|
955 |
XftTextExtents16(DISPLAY(displayIdArg), XFT_FONT(fontIdArg), (FcChar16*)string, len, &info); |
|
956 |
break; |
|
957 |
case 4: |
|
958 |
XftTextExtents32(DISPLAY(displayIdArg), XFT_FONT(fontIdArg), (FcChar32*)string, len, &info); |
|
959 |
break; |
|
960 |
default: |
|
961 |
error = @symbol(BadArg2); |
|
962 |
goto err; |
|
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
963 |
} |
7563 | 964 |
|
965 |
if (extentsArrayOrNil != nil && __isArray(extentsArrayOrNil)) { |
|
8018 | 966 |
switch (__arraySize(extentsArrayOrNil)) { |
967 |
case 8: |
|
968 |
__arrayVal(extentsArrayOrNil)[7] = __MKSMALLINT(XFT_FONT(fontIdArg)->descent); |
|
969 |
// fall into |
|
970 |
case 7: |
|
971 |
__arrayVal(extentsArrayOrNil)[6] = __MKSMALLINT(XFT_FONT(fontIdArg)->ascent); |
|
972 |
// fall into |
|
973 |
case 6: |
|
974 |
__arrayVal(extentsArrayOrNil)[5] = __MKSMALLINT(info.yOff); |
|
975 |
// fall into |
|
976 |
case 5: |
|
977 |
__arrayVal(extentsArrayOrNil)[4] = __MKSMALLINT(info.xOff); |
|
978 |
// fall into |
|
979 |
case 4: |
|
980 |
__arrayVal(extentsArrayOrNil)[3] = __MKSMALLINT(info.y); |
|
981 |
// fall into |
|
982 |
case 3: |
|
983 |
__arrayVal(extentsArrayOrNil)[2] = __MKSMALLINT(info.x); |
|
984 |
// fall into |
|
985 |
case 2: |
|
986 |
{ |
|
987 |
int height; |
|
988 |
||
989 |
height = info.height; |
|
990 |
#if 0 |
|
991 |
height = XFT_FONT(fontIdArg)->descent + XFT_FONT(fontIdArg)->ascent; |
|
992 |
#endif |
|
993 |
__arrayVal(extentsArrayOrNil)[1] = __MKSMALLINT(height); |
|
994 |
} |
|
995 |
// fall into |
|
996 |
case 1: |
|
997 |
__arrayVal(extentsArrayOrNil)[0] = __MKSMALLINT(info.width); |
|
998 |
// fall into |
|
999 |
case 0: |
|
1000 |
break; |
|
1001 |
} |
|
7563 | 1002 |
} |
1003 |
||
1004 |
RETURN(__MKSMALLINT(info.xOff)); |
|
1005 |
||
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1006 |
err:; |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1007 |
#endif |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1008 |
%}. |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1009 |
error notNil ifTrue:[ |
8018 | 1010 |
self primitiveFailed: error. |
1011 |
^ nil. |
|
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1012 |
]. |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1013 |
|
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1014 |
"Created: / 21-12-2013 / 10:42:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6186
c8f36970419f
Added missing & required methods. Since now, while St/X IDE could be switched to use XFT fonts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6185
diff
changeset
|
1015 |
"Modified: / 30-12-2013 / 20:00:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1016 |
! ! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1017 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1018 |
!XftFontDescription methodsFor:'queries-dimensions'! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1019 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1020 |
ascent |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1021 |
"return the ascent - the number of pixels above the baseLine." |
6656 | 1022 |
ascent isNil ifTrue:[ |
8018 | 1023 |
ascent := self class xftFontGetAscent: fontId |
6656 | 1024 |
]. |
1025 |
^ ascent |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1026 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1027 |
"Created: / 21-12-2013 / 01:19:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1028 |
! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1029 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1030 |
descent |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1031 |
"return the descent - the number of pixels below the baseLine." |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1032 |
|
6656 | 1033 |
descent isNil ifTrue:[ |
8018 | 1034 |
descent := self class xftFontGetDescent: fontId |
6656 | 1035 |
]. |
1036 |
^ descent |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1037 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1038 |
"Created: / 21-12-2013 / 01:20:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1039 |
! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1040 |
|
6314 | 1041 |
getFontMetrics |
1042 |
|info| |
|
1043 |
||
1044 |
info := DeviceWorkstation::DeviceFontMetrics new. |
|
1045 |
info |
|
1046 |
ascent:self ascent |
|
1047 |
descent:self descent |
|
1048 |
maxAscent:self maxAscent |
|
1049 |
maxDescent:self maxDescent |
|
1050 |
minWidth:self maxWidth |
|
1051 |
maxWidth:self maxWidth |
|
1052 |
avgWidth:self maxWidth |
|
1053 |
minCode:self minCode |
|
1054 |
maxCode:self maxCode |
|
1055 |
direction:#LeftToRight. |
|
1056 |
^ info |
|
1057 |
! |
|
1058 |
||
6543 | 1059 |
getFontResolution |
1060 |
device isNil ifTrue:[ ^ 72 @ 72 ]. |
|
1061 |
^ device resolution |
|
1062 |
! |
|
1063 |
||
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1064 |
height |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1065 |
"return the height - the number of pixels above plus below the baseLine." |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1066 |
|
6656 | 1067 |
height isNil ifTrue:[ |
8018 | 1068 |
false ifTrue:[ |
1069 |
height := self ascent + self descent. |
|
1070 |
] ifFalse:[ |
|
1071 |
height := self class xftFontGetHeight: fontId |
|
1072 |
]. |
|
6656 | 1073 |
]. |
1074 |
^ height |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1075 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1076 |
"Created: / 21-12-2013 / 01:20:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1077 |
! |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1078 |
|
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1079 |
isFixedWidth |
7610 | 1080 |
"return true, if this is a fixed pitch font |
1081 |
(i.e. all characters are of the same width). |
|
1082 |
Also called monospaced fonts" |
|
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1083 |
|
7342 | 1084 |
fixedWidth isNil ifTrue:[ |
8652 | 1085 |
fontId isNil ifTrue:[ |
1086 |
^ false "we don't know yet" |
|
1087 |
]. |
|
1088 |
fixedWidth := false. "false until proven otherwise. Set to avoid recursion" |
|
1089 |
"/ take some obviously different chars |
|
1090 |
width := self widthOf:' '. |
|
1091 |
fixedWidth := (self widthOf:'i') == width |
|
1092 |
and:[(self widthOf:'W') == width |
|
1093 |
and:[(self widthOf:'.') == width]] |
|
7342 | 1094 |
]. |
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
1095 |
^ fixedWidth. |
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1096 |
|
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1097 |
"Created: / 21-12-2013 / 10:38:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
8652 | 1098 |
"Modified: / 01-03-2019 / 18:26:24 / Stefan Vogel" |
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1099 |
! |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1100 |
|
6186
c8f36970419f
Added missing & required methods. Since now, while St/X IDE could be switched to use XFT fonts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6185
diff
changeset
|
1101 |
maxAscent |
7342 | 1102 |
"return the font's maximum-ascent (i.e. the maximum of all characters); |
6186
c8f36970419f
Added missing & required methods. Since now, while St/X IDE could be switched to use XFT fonts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6185
diff
changeset
|
1103 |
That is the number of units (usually pixels) above the baseline." |
c8f36970419f
Added missing & required methods. Since now, while St/X IDE could be switched to use XFT fonts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6185
diff
changeset
|
1104 |
|
c8f36970419f
Added missing & required methods. Since now, while St/X IDE could be switched to use XFT fonts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6185
diff
changeset
|
1105 |
^ self ascent |
c8f36970419f
Added missing & required methods. Since now, while St/X IDE could be switched to use XFT fonts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6185
diff
changeset
|
1106 |
|
c8f36970419f
Added missing & required methods. Since now, while St/X IDE could be switched to use XFT fonts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6185
diff
changeset
|
1107 |
"Created: / 30-12-2013 / 20:01:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
c8f36970419f
Added missing & required methods. Since now, while St/X IDE could be switched to use XFT fonts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6185
diff
changeset
|
1108 |
! |
c8f36970419f
Added missing & required methods. Since now, while St/X IDE could be switched to use XFT fonts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6185
diff
changeset
|
1109 |
|
c8f36970419f
Added missing & required methods. Since now, while St/X IDE could be switched to use XFT fonts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6185
diff
changeset
|
1110 |
maxDescent |
7342 | 1111 |
"return the font's maximum-descent (i.e. the maximum of all characters); |
6186
c8f36970419f
Added missing & required methods. Since now, while St/X IDE could be switched to use XFT fonts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6185
diff
changeset
|
1112 |
That is the number of units (usually pixels) below the baseline." |
c8f36970419f
Added missing & required methods. Since now, while St/X IDE could be switched to use XFT fonts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6185
diff
changeset
|
1113 |
|
c8f36970419f
Added missing & required methods. Since now, while St/X IDE could be switched to use XFT fonts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6185
diff
changeset
|
1114 |
^ self descent |
c8f36970419f
Added missing & required methods. Since now, while St/X IDE could be switched to use XFT fonts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6185
diff
changeset
|
1115 |
|
c8f36970419f
Added missing & required methods. Since now, while St/X IDE could be switched to use XFT fonts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6185
diff
changeset
|
1116 |
"Created: / 30-12-2013 / 20:01:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
c8f36970419f
Added missing & required methods. Since now, while St/X IDE could be switched to use XFT fonts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6185
diff
changeset
|
1117 |
! |
c8f36970419f
Added missing & required methods. Since now, while St/X IDE could be switched to use XFT fonts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6185
diff
changeset
|
1118 |
|
c8f36970419f
Added missing & required methods. Since now, while St/X IDE could be switched to use XFT fonts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6185
diff
changeset
|
1119 |
maxWidth |
7342 | 1120 |
"return the font's maximum-width character (i.e. the maximum of all characters); |
6186
c8f36970419f
Added missing & required methods. Since now, while St/X IDE could be switched to use XFT fonts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6185
diff
changeset
|
1121 |
That is a number of units (usually pixels)." |
c8f36970419f
Added missing & required methods. Since now, while St/X IDE could be switched to use XFT fonts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6185
diff
changeset
|
1122 |
|
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
1123 |
self isFixedWidth ifTrue:[ |
8018 | 1124 |
^ width |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
1125 |
]. |
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
1126 |
^ self class xftFontGetMaxAdvanceWidth: fontId |
6186
c8f36970419f
Added missing & required methods. Since now, while St/X IDE could be switched to use XFT fonts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6185
diff
changeset
|
1127 |
|
c8f36970419f
Added missing & required methods. Since now, while St/X IDE could be switched to use XFT fonts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6185
diff
changeset
|
1128 |
"Created: / 30-12-2013 / 20:02:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
c8f36970419f
Added missing & required methods. Since now, while St/X IDE could be switched to use XFT fonts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6185
diff
changeset
|
1129 |
! |
c8f36970419f
Added missing & required methods. Since now, while St/X IDE could be switched to use XFT fonts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6185
diff
changeset
|
1130 |
|
7114 | 1131 |
patternStringForId:patternIdArg |
1132 |
|name family size pixelSize face style encoding foundry width| |
|
1133 |
||
1134 |
patternIdArg notNil ifTrue:[ |
|
1135 |
foundry := patternIdArg get: FC_FOUNDRY index: 0. |
|
1136 |
family := patternIdArg get: FC_FAMILY index: 0. |
|
1137 |
size := patternIdArg get: FC_SIZE index: 0. |
|
1138 |
pixelSize := patternIdArg get: FC_PIXEL_SIZE index: 0. |
|
1139 |
face := patternIdArg get: FC_WEIGHT index: 0. |
|
1140 |
face := StXFace2FCWeightMap keyAtValue: face. |
|
1141 |
style := patternIdArg get: FC_SLANT index: 0. |
|
1142 |
style := StXStyle2FCSlantMap keyAtValue: style. |
|
1143 |
width := patternIdArg get: FC_WIDTH index: 0. |
|
1144 |
||
1145 |
name:= patternIdArg get: 'fullname' index: 0. |
|
1146 |
||
1147 |
encoding:= patternIdArg get: 'encoding' index: 0. |
|
1148 |
]. |
|
1149 |
||
1150 |
^ '%8-%1-%2-%3-%4pt/%5px-%6-%9 (%7)' bindWith:family with:face with:style with:size with:pixelSize with:encoding with:name |
|
1151 |
with:foundry with:width. |
|
1152 |
! |
|
1153 |
||
7342 | 1154 |
width |
1155 |
"return the font's characters width; |
|
1156 |
That is a number of units (usually pixels). |
|
1157 |
For variable pitch fonts, the width of the space character is returned. |
|
1158 |
For fixed fonts, this is the same as minWidth or maxWidth (or any character). |
|
1159 |
The receiver must be associated to a device, for this query to be legal." |
|
1160 |
||
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
1161 |
width isNil ifTrue:[ |
8018 | 1162 |
width := self widthOf:' '. |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
1163 |
]. |
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
1164 |
^ width |
7342 | 1165 |
! |
1166 |
||
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1167 |
widthOf:aString from:start to:stop |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1168 |
"return the width of a sub string" |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1169 |
|
8652 | 1170 |
(stop < start) ifTrue:[ |
1171 |
^ 0 |
|
1172 |
]. |
|
1173 |
fixedWidth isNil ifTrue:[ |
|
1174 |
self isFixedWidth. "/ initialize fixedWidth and width |
|
1175 |
]. |
|
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
1176 |
fixedWidth == true ifTrue:[ |
8652 | 1177 |
^ width * (stop - start + 1). |
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
1178 |
]. |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
1179 |
device isNil ifTrue:[ |
8431 | 1180 |
self errorNoDevice. |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
1181 |
]. |
8431 | 1182 |
device isOpen not ifTrue:[ |
1183 |
^ 0. "closed device, width does not matter" |
|
1184 |
]. |
|
1185 |
||
7563 | 1186 |
^ self xftTextExtents:device displayId string:aString from:start to:stop into:nil. |
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1187 |
|
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1188 |
"Created: / 21-12-2013 / 10:42:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6183
a21827076de1
Fix for bad layout and segfault when selecting whole line.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6182
diff
changeset
|
1189 |
"Modified: / 29-12-2013 / 21:16:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
8474 | 1190 |
"Modified: / 18-09-2018 / 11:45:46 / Claus Gittinger" |
8652 | 1191 |
"Modified: / 01-03-2019 / 18:27:52 / Stefan Vogel" |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1192 |
! ! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1193 |
|
6200
8f0d25eec888
class: XftFontDescription
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6199
diff
changeset
|
1194 |
!XftFontDescription methodsFor:'release'! |
8f0d25eec888
class: XftFontDescription
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6199
diff
changeset
|
1195 |
|
6344 | 1196 |
releaseFromDevice |
1197 |
"I am no longer available on the device" |
|
1198 |
||
8177 | 1199 |
|deviceID| |
1200 |
||
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
1201 |
(device notNil and:[fontId notNil]) ifTrue:[ |
8177 | 1202 |
(deviceID := device displayId) notNil ifTrue:[ |
1203 |
self class xftFontClose:fontId displayId:deviceID. |
|
1204 |
]. |
|
1205 |
device := nil. |
|
1206 |
fontId := nil. |
|
1207 |
width := nil. |
|
8652 | 1208 |
fixedWidth := nil. |
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
1209 |
]. |
8177 | 1210 |
|
1211 |
"Modified: / 15-09-2017 / 12:42:25 / cg" |
|
8652 | 1212 |
"Modified: / 01-03-2019 / 18:18:55 / Stefan Vogel" |
8178 | 1213 |
! |
1214 |
||
1215 |
restored |
|
1216 |
"flush device handles when restored" |
|
1217 |
||
1218 |
device := nil. |
|
1219 |
fontId := nil. |
|
1220 |
||
1221 |
"Created: / 15-09-2017 / 13:03:55 / cg" |
|
6200
8f0d25eec888
class: XftFontDescription
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6199
diff
changeset
|
1222 |
! ! |
8f0d25eec888
class: XftFontDescription
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6199
diff
changeset
|
1223 |
|
6319 | 1224 |
!XftFontDescription methodsFor:'testing'! |
1225 |
||
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
1226 |
isAlienFont |
7874 | 1227 |
"my GraphicsContext knows how to disply strings in my font. |
1228 |
Alien fonts are eg. Hershey or Bitmap fonts, which are drawn by st/x itself." |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
1229 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
1230 |
^ false |
7874 | 1231 |
|
1232 |
"Modified (comment): / 12-02-2017 / 22:03:39 / cg" |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
1233 |
! |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
1234 |
|
6319 | 1235 |
isXftFont |
7874 | 1236 |
"anwer true, if this is an Xft font. |
1237 |
Sure, I am" |
|
8018 | 1238 |
|
6319 | 1239 |
^ true |
7874 | 1240 |
|
1241 |
"Modified (comment): / 12-02-2017 / 22:04:23 / cg" |
|
6319 | 1242 |
! ! |
1243 |
||
7116 | 1244 |
!XftFontDescription::FCFontListParser class methodsFor:'api'! |
1245 |
||
1246 |
listOfAvailableFonts |
|
1247 |
^ self new listOfAvailableFonts |
|
1248 |
||
1249 |
" |
|
1250 |
self listOfAvailableFonts |
|
1251 |
" |
|
1252 |
! ! |
|
1253 |
||
6264 | 1254 |
!XftFontDescription::FCFontListParser class methodsFor:'documentation'! |
1255 |
||
1256 |
documentation |
|
1257 |
" |
|
1258 |
parses fc-list output to get a list of XftFontDescriptions |
|
1259 |
||
1260 |
[author:] |
|
6319 | 1261 |
cg |
6264 | 1262 |
|
1263 |
[instance variables:] |
|
1264 |
||
1265 |
[class variables:] |
|
1266 |
||
1267 |
[see also:] |
|
1268 |
||
1269 |
" |
|
1270 |
! ! |
|
1271 |
||
6263 | 1272 |
!XftFontDescription::FCFontListParser methodsFor:'api'! |
1273 |
||
1274 |
listOfAvailableFonts |
|
8369 | 1275 |
"opens a pipe to '/usr/bin/fc-list' or '/usr/X11/bin/fc-list' |
1276 |
and reads all known fonts from it" |
|
1277 |
||
1278 |
"self new listOfAvailableFonts" |
|
1279 |
||
8356 | 1280 |
|readEntry list fcListProg shellEnvironment| |
6263 | 1281 |
|
1282 |
list := OrderedCollection new. |
|
1283 |
||
7116 | 1284 |
readEntry := [ |
8356 | 1285 |
|key line| |
6263 | 1286 |
|
8356 | 1287 |
[ |
1288 |
line := pipeStream nextLine. |
|
1289 |
] doUntil:[(line startsWith:'Pattern has') or:[Transcript showCR:line. false]]. |
|
6263 | 1290 |
|
8356 | 1291 |
currentDescription := XftFontDescription new. |
1292 |
[line := pipeStream nextLine. line notEmptyOrNil] whileTrue:[ |
|
1293 |
"/ Transcript showCR:l. |
|
1294 |
lineStream := line readStream. lineStream skipSeparators. |
|
1295 |
key := ('fc_', (lineStream upTo:$:)) asSymbolIfInterned. |
|
1296 |
( |
|
1297 |
#(fc_family fc_style fc_slant fc_weight fc_width |
|
1298 |
fc_pixelsize fc_spacing fc_foundry fc_antialias |
|
1299 |
fc_file fc_outline fc_scalable fc_charset fc_lang |
|
1300 |
fc_fontversion fc_fontformat fc_decorative fc_index |
|
1301 |
fc_outline fc_familylang fc_stylelang fc_fullname |
|
1302 |
fc_fullnamelang fc_capability fc_hash fc_postscriptname |
|
1303 |
fc_symbol fc_color |
|
1304 |
) includesIdentical:key |
|
1305 |
) ifTrue:[ |
|
1306 |
self perform:key. |
|
1307 |
] ifFalse:[ |
|
1308 |
Transcript show:'Xft ignored line: '; showCR:line. |
|
1309 |
]. |
|
1310 |
]. |
|
1311 |
list add:currentDescription |
|
1312 |
]. |
|
6319 | 1313 |
|
6337 | 1314 |
fcListProg := #('/usr/bin/fc-list' '/usr/X11/bin/fc-list') detect:[:eachProg| |
8356 | 1315 |
eachProg asFilename isExecutableProgram |
1316 |
] ifNone:[ |
|
1317 |
'XftFontDescription [warning]: fc-list program not found - no XFT fonts' errorPrintCR. |
|
1318 |
^ list. |
|
1319 |
]. |
|
6337 | 1320 |
|
8356 | 1321 |
"/ to suppress the disturbing warning message |
1322 |
"/ if LC_CTYPE is wrong (osx problem) |
|
8370 | 1323 |
shellEnvironment := Dictionary new. |
1324 |
shellEnvironment at:'LC_CTYPE' put:XftFontDescription fixedLC_CTYPE. |
|
8356 | 1325 |
|
1326 |
pipeStream := PipeStream |
|
1327 |
readingFrom:fcListProg, ' -v' |
|
1328 |
environment:shellEnvironment. |
|
6263 | 1329 |
[ |
8356 | 1330 |
[pipeStream atEnd] whileFalse:[ |
1331 |
readEntry value. |
|
1332 |
] |
|
6263 | 1333 |
] ensure:[ |
8356 | 1334 |
pipeStream close |
6263 | 1335 |
]. |
1336 |
^ list |
|
1337 |
||
1338 |
" |
|
6337 | 1339 |
FCFontListParser new listOfAvailableFonts |
6263 | 1340 |
" |
1341 |
! ! |
|
1342 |
||
1343 |
!XftFontDescription::FCFontListParser methodsFor:'font list keywords'! |
|
1344 |
||
1345 |
fc_antialias |
|
1346 |
"helper for font listing" |
|
1347 |
||
6319 | 1348 |
currentDescription isAntialiasedFont:(self getBoolean). |
6263 | 1349 |
! |
1350 |
||
1351 |
fc_charset |
|
1352 |
"helper for font listing" |
|
1353 |
||
6319 | 1354 |
|page bits l min max minCode maxCode| |
6263 | 1355 |
|
1356 |
[ l := pipeStream nextLine. l notEmpty ] whileTrue:[ |
|
7221 | 1357 |
"/ Transcript show:'->'; showCR:l. |
1358 |
(l startsWith:Character tab) ifFalse:[ |
|
1359 |
(l startsWith:'(') ifFalse:[self halt]. |
|
1360 |
currentDescription minCode:minCode; maxCode:maxCode. |
|
1361 |
^ self. |
|
1362 |
]. |
|
6264 | 1363 |
|
7221 | 1364 |
lineStream := l readStream. |
1365 |
lineStream skipSeparators. |
|
1366 |
page := Integer readFrom:(lineStream upTo:$:) radix:16. |
|
1367 |
lineStream next. |
|
1368 |
bits := 0 to:7 collect:[:i| |
|
1369 |
lineStream skipSeparators. |
|
1370 |
Integer readFrom:(lineStream upToSeparator) radix:16. |
|
1371 |
]. |
|
1372 |
min := (page * 256 + 0). |
|
1373 |
max := (page * 256 + 255). |
|
1374 |
minCode isNil ifTrue:[ |
|
1375 |
minCode := min. |
|
1376 |
maxCode := max. |
|
1377 |
] ifFalse:[ |
|
1378 |
minCode := minCode min:min. |
|
1379 |
maxCode := maxCode max:max. |
|
1380 |
]. |
|
6263 | 1381 |
]. |
6365
cf89c4bedea4
Instvar drawId renamed to sharedDrawId.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6356
diff
changeset
|
1382 |
"/ currentDescription characterSet:(self getString). |
7116 | 1383 |
currentDescription minCode:minCode; maxCode:maxCode. |
6263 | 1384 |
! |
1385 |
||
6319 | 1386 |
fc_decorative |
6263 | 1387 |
"helper for font listing" |
1388 |
||
6319 | 1389 |
currentDescription isDecorativeFont:(self getBoolean). |
6263 | 1390 |
! |
1391 |
||
1392 |
fc_family |
|
1393 |
"helper for font listing" |
|
1394 |
||
6319 | 1395 |
currentDescription family:(self getString). |
6263 | 1396 |
! |
1397 |
||
6319 | 1398 |
fc_file |
6263 | 1399 |
"helper for font listing" |
1400 |
||
6319 | 1401 |
currentDescription file:(self getString). |
6263 | 1402 |
! |
1403 |
||
1404 |
fc_fontformat |
|
1405 |
"helper for font listing" |
|
1406 |
||
6319 | 1407 |
currentDescription fontFormat:(self getString). |
6263 | 1408 |
! |
1409 |
||
1410 |
fc_fontversion |
|
1411 |
"helper for font listing" |
|
1412 |
||
6319 | 1413 |
currentDescription fontVersion:(self getInteger). |
6263 | 1414 |
! |
1415 |
||
1416 |
fc_foundry |
|
1417 |
"helper for font listing" |
|
1418 |
||
7121 | 1419 |
|foundry| |
1420 |
||
1421 |
foundry := self getString. |
|
7221 | 1422 |
foundry ~= 'unknown' ifTrue:[ |
1423 |
currentDescription foundry:foundry. |
|
7121 | 1424 |
]. |
6263 | 1425 |
! |
1426 |
||
6264 | 1427 |
fc_fullname |
1428 |
"helper for font listing" |
|
1429 |
||
7121 | 1430 |
currentDescription name:self getString. |
6264 | 1431 |
! |
1432 |
||
6263 | 1433 |
fc_outline |
1434 |
"helper for font listing" |
|
1435 |
||
6319 | 1436 |
currentDescription isOutlineFont:(self getBoolean). |
6263 | 1437 |
! |
1438 |
||
1439 |
fc_pixelsize |
|
1440 |
"helper for font listing" |
|
1441 |
||
6325 | 1442 |
currentDescription setPixelSize:(self getInteger). |
1443 |
currentDescription setSizeUnit:#px. |
|
1444 |
"/ currentDescription setSize:(self getInteger). |
|
1445 |
"/ currentDescription setSizeUnit:#pt. |
|
6263 | 1446 |
! |
1447 |
||
1448 |
fc_scalable |
|
1449 |
"helper for font listing" |
|
1450 |
||
6957 | 1451 |
currentDescription isScalableFont:self getBoolean. |
6263 | 1452 |
! |
1453 |
||
1454 |
fc_slant |
|
1455 |
"helper for font listing" |
|
1456 |
||
6319 | 1457 |
currentDescription slant:(self getInteger). |
6263 | 1458 |
! |
1459 |
||
1460 |
fc_spacing |
|
1461 |
"helper for font listing" |
|
1462 |
||
6319 | 1463 |
currentDescription spacing:(self getInteger). |
6263 | 1464 |
! |
1465 |
||
1466 |
fc_style |
|
1467 |
"helper for font listing" |
|
1468 |
||
6319 | 1469 |
|xftStyle| |
1470 |
||
7121 | 1471 |
xftStyle := self getString asLowercase. |
1472 |
(xftStyle includesString:'italic') ifTrue:[ |
|
7221 | 1473 |
currentDescription style:#italic. |
1474 |
^ self. |
|
6319 | 1475 |
]. |
7121 | 1476 |
(xftStyle includesString:'oblique') ifTrue:[ |
7221 | 1477 |
currentDescription style:#oblique. |
1478 |
^ self. |
|
7121 | 1479 |
]. |
1480 |
currentDescription style:#roman. |
|
6263 | 1481 |
! |
1482 |
||
1483 |
fc_weight |
|
1484 |
"helper for font listing" |
|
1485 |
||
6319 | 1486 |
currentDescription weight:(self getInteger). |
6263 | 1487 |
! |
1488 |
||
1489 |
fc_width |
|
1490 |
"helper for font listing" |
|
1491 |
||
6319 | 1492 |
currentDescription width:(self getInteger). |
6263 | 1493 |
! ! |
1494 |
||
7488 | 1495 |
!XftFontDescription::FCFontListParser methodsFor:'font list keywords - ignored'! |
1496 |
||
1497 |
fc_capability |
|
1498 |
"helper for font listing" |
|
1499 |
||
1500 |
"currentDescription capability:" (self getString). |
|
1501 |
! |
|
1502 |
||
1503 |
fc_color |
|
1504 |
"helper for font listing - ignored for now" |
|
1505 |
||
1506 |
"currentDescription isColorFont:"(self getBoolean). |
|
1507 |
! |
|
1508 |
||
1509 |
fc_familylang |
|
1510 |
"helper for font listing" |
|
1511 |
||
1512 |
"currentDescription familylang:" (self getString). |
|
1513 |
! |
|
1514 |
||
1515 |
fc_fullnamelang |
|
1516 |
"helper for font listing" |
|
1517 |
||
1518 |
"currentDescription fullnamelang:" (self getString). |
|
1519 |
! |
|
1520 |
||
1521 |
fc_hash |
|
1522 |
"helper for font listing" |
|
1523 |
||
1524 |
"currentDescription hash:" self getString. |
|
1525 |
! |
|
1526 |
||
1527 |
fc_index |
|
1528 |
"helper for font listing" |
|
1529 |
||
1530 |
"currentDescription index:" (self getInteger). |
|
1531 |
! |
|
1532 |
||
1533 |
fc_lang |
|
1534 |
"helper for font listing" |
|
1535 |
||
1536 |
"/ currentDescription characterSet:(self getString). |
|
1537 |
! |
|
1538 |
||
1539 |
fc_postscriptname |
|
1540 |
"helper for font listing" |
|
1541 |
||
1542 |
"currentDescription postscriptname:" self getString. |
|
1543 |
! |
|
1544 |
||
1545 |
fc_stylelang |
|
1546 |
"helper for font listing" |
|
1547 |
||
1548 |
"currentDescription stylelang:" (self getString). |
|
1549 |
! |
|
1550 |
||
1551 |
fc_symbol |
|
1552 |
"helper for font listing - ignored for now" |
|
1553 |
||
1554 |
"currentDescription isSymbolFont:"(self getBoolean). |
|
1555 |
! ! |
|
1556 |
||
6263 | 1557 |
!XftFontDescription::FCFontListParser methodsFor:'helpers'! |
1558 |
||
6319 | 1559 |
getBoolean |
6263 | 1560 |
"helper for font listing" |
1561 |
||
1562 |
|s| |
|
1563 |
||
1564 |
lineStream skipSeparators. |
|
6319 | 1565 |
s := lineStream nextAlphaNumericWord. |
6957 | 1566 |
^ (s indexOfSubCollection:'True') ~~ 0. "/ match at least 'True' and 'FCTrue' |
6963 | 1567 |
|
1568 |
" |
|
7114 | 1569 |
'xxFalse' indexOfSubCollection:'True' |
1570 |
'FcTrue' indexOfSubCollection:'True' |
|
6963 | 1571 |
" |
6263 | 1572 |
! |
1573 |
||
6264 | 1574 |
getInteger |
1575 |
"helper for font listing" |
|
1576 |
||
1577 |
lineStream skipSeparators. |
|
6319 | 1578 |
^ Integer readFrom:lineStream. |
6264 | 1579 |
! |
1580 |
||
6319 | 1581 |
getString |
6263 | 1582 |
"helper for font listing" |
1583 |
||
7116 | 1584 |
lineStream skipThrough:$". |
1585 |
^ lineStream upTo:$". |
|
6263 | 1586 |
! ! |
1587 |
||
7114 | 1588 |
!XftFontDescription::FCPatternHandle class methodsFor:'instance creation'! |
1589 |
||
1590 |
create |
|
1591 |
^ self new create |
|
1592 |
||
1593 |
" |
|
1594 |
self new create destroy |
|
1595 |
" |
|
1596 |
! ! |
|
1597 |
||
1598 |
!XftFontDescription::FCPatternHandle methodsFor:'primitives'! |
|
1599 |
||
1600 |
add:attribute value: value |
|
1601 |
"Add a value to the specified pattern element after existing values" |
|
1602 |
||
1603 |
^ self add: attribute value: value append: true. |
|
1604 |
! |
|
1605 |
||
1606 |
add:attribute value: value append: append |
|
1607 |
"Add a value to the specified pattern element. If 'append' is true, the value |
|
1608 |
is added after existing values, otherwise it is added before them." |
|
1609 |
||
1610 |
| error | |
|
1611 |
||
7221 | 1612 |
%{ /* STACK: 64000 */ |
7114 | 1613 |
#ifdef XFT |
1614 |
XftValue v; |
|
1615 |
Bool b; |
|
1616 |
||
1617 |
if (__INST(address_) == 0) { |
|
1618 |
error = @symbol(NullReceiver); |
|
1619 |
goto err; |
|
1620 |
} |
|
1621 |
if ( ! __isStringLike ( attribute ) ) { |
|
1622 |
error = @symbol(BadArg1); |
|
1623 |
goto err; |
|
1624 |
} |
|
1625 |
if ( append != true && append != false ) { |
|
1626 |
error = @symbol(BadArg3); |
|
1627 |
goto err; |
|
1628 |
} |
|
1629 |
if ( __isStringLike ( value ) ) { |
|
1630 |
v.type = FcTypeString; |
|
1631 |
/* Passing pointer inside Smalltalk should be safe, |
|
1632 |
* Xft/FontConfig libraries seem to allocate and store |
|
1633 |
* a __copy__ of the string (if I understood the code correctly) |
|
1634 |
*/ |
|
1635 |
v.u.s = __stringVal( value); |
|
1636 |
} else if ( __isSmallInteger( value ) ) { |
|
1637 |
v.type = XftTypeInteger; |
|
1638 |
v.u.i = (int)__intVal( value ); |
|
1639 |
} else if ( value == true || value == false ) { |
|
1640 |
v.type = XftTypeBool; |
|
1641 |
v.u.b = value == true ? True : False; |
|
1642 |
} else if ( __isFloat ( value ) ) { |
|
1643 |
v.type = XftTypeDouble; |
|
1644 |
v.u.d = __floatVal( value ); |
|
1645 |
} else if ( value == nil ) { |
|
1646 |
v.type = XftTypeVoid; |
|
1647 |
v.u.f = NULL; |
|
1648 |
} else { |
|
1649 |
error = @symbol(BadArg2); |
|
1650 |
goto err; |
|
1651 |
} |
|
1652 |
b = XftPatternAdd((XftPattern*)__INST(address_), __stringVal(attribute), v, append == true ? True : False ); |
|
1653 |
RETURN ( b == True ? true : false ); |
|
1654 |
||
1655 |
err:; |
|
1656 |
#endif |
|
1657 |
%}. |
|
1658 |
self primitiveFailed: error |
|
1659 |
||
1660 |
"Created: / 20-12-2013 / 21:50:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1661 |
! |
|
1662 |
||
1663 |
create |
|
1664 |
%{ |
|
1665 |
#ifdef XFT |
|
1666 |
__INST(address_) = (void *)XftPatternCreate(); |
|
1667 |
#endif |
|
1668 |
%}. |
|
1669 |
! |
|
1670 |
||
1671 |
delete: pattern attribute: attribute |
|
1672 |
| error | |
|
7221 | 1673 |
%{ /* STACK: 64000 */ |
7114 | 1674 |
#ifdef XFT |
1675 |
if (__INST(address_) == 0) { |
|
7221 | 1676 |
error = @symbol(BadHandle); |
1677 |
goto err; |
|
7114 | 1678 |
} |
1679 |
if ( ! __isStringLike ( attribute ) ) { |
|
7221 | 1680 |
error = @symbol(BadArg1); |
1681 |
goto err; |
|
7114 | 1682 |
} |
1683 |
XftPatternDel( (XftPattern*)__INST(address_), __stringVal ( attribute ) ); |
|
1684 |
RETURN ( self ); |
|
1685 |
||
1686 |
err:; |
|
1687 |
#endif |
|
1688 |
%}. |
|
1689 |
self primitiveFailed: error |
|
1690 |
! |
|
1691 |
||
1692 |
destroy |
|
7221 | 1693 |
%{ /* STACK: 64000 */ |
7114 | 1694 |
#ifdef XFT |
1695 |
if (__INST(address_) != 0) { |
|
1696 |
XftPatternDestroy((XftPattern*)__INST(address_)); |
|
1697 |
__INST(address_) = 0; |
|
1698 |
RETURN ( self ); |
|
1699 |
} |
|
1700 |
#endif |
|
1701 |
%}. |
|
1702 |
self primitiveFailed. |
|
1703 |
! |
|
1704 |
||
1705 |
duplicate |
|
1706 |
| error | |
|
1707 |
%{ |
|
1708 |
#ifdef XFT |
|
1709 |
if (__INST(address_) != 0) { |
|
1710 |
RETURN (FC_PATTERN_HANDLE_NEW((XftPattern*)__INST(address_))); |
|
1711 |
RETURN ( self ); |
|
1712 |
} |
|
1713 |
#endif |
|
1714 |
%}. |
|
1715 |
self primitiveFailed |
|
1716 |
! |
|
1717 |
||
1718 |
get:attribute index: index |
|
1719 |
"Return a value from the specified element -- multiple values can be indexed |
|
1720 |
with 'index' starting at zero." |
|
1721 |
||
1722 |
| error | |
|
1723 |
||
7221 | 1724 |
%{ /* STACK: 64000 */ |
7114 | 1725 |
#ifdef XFT |
1726 |
XftValue v; |
|
1727 |
XftResult r; |
|
1728 |
||
1729 |
if (__INST(address_) == 0) { |
|
1730 |
error = @symbol(NullReceiver); |
|
1731 |
goto err; |
|
1732 |
} |
|
1733 |
if ( ! __isStringLike ( attribute ) ) { |
|
1734 |
error = @symbol(BadArg1); |
|
1735 |
goto err; |
|
1736 |
} |
|
1737 |
if ( ! __isSmallInteger( index ) ) { |
|
1738 |
error = @symbol(BadArg2); |
|
1739 |
goto err; |
|
1740 |
} |
|
1741 |
r = XftPatternGet((XftPattern*)__INST(address_), __stringVal( attribute ), __intVal( index ), &v); |
|
1742 |
if ( r != XftResultMatch) { |
|
1743 |
RETURN ( nil ); |
|
1744 |
} |
|
1745 |
if ( v.type == XftTypeString) { |
|
1746 |
RETURN ( __MKSTRING(v.u.s) ); |
|
1747 |
} else if ( v.type == XftTypeInteger ) { |
|
1748 |
RETURN ( __MKINT (v.u.i) ); |
|
1749 |
} else if ( v.type == XftTypeBool ) { |
|
1750 |
RETURN ( v.u.b == True ? true : false ); |
|
1751 |
} else if ( v.type == XftTypeDouble ) { |
|
1752 |
RETURN ( __MKFLOAT (v.u.d) ); |
|
1753 |
} else if ( v.type == XftTypeVoid ) { |
|
1754 |
RETURN ( nil ); |
|
1755 |
} else { |
|
1756 |
error = @symbol(UnssuportedTypeValue); |
|
1757 |
goto err; |
|
1758 |
} |
|
1759 |
err:; |
|
1760 |
#endif |
|
1761 |
%}. |
|
1762 |
self primitiveFailed: error |
|
1763 |
! |
|
1764 |
||
1765 |
getFontOnDisplayId:displayId |
|
1766 |
"Note: the pattern is destroyed when the font is closed" |
|
1767 |
||
1768 |
| error | |
|
1769 |
||
1770 |
%{ /* STACK: 64000 */ |
|
1771 |
#ifdef XFT |
|
1772 |
XftFont* f; |
|
1773 |
if (!__isExternalAddressLike(displayId) ) { |
|
7221 | 1774 |
error = @symbol(BadArg1); |
1775 |
goto err; |
|
7114 | 1776 |
} |
1777 |
if (__INST(address_) == 0) { |
|
7221 | 1778 |
error = @symbol(BadHandle); |
1779 |
goto err; |
|
7114 | 1780 |
} |
1781 |
||
1782 |
f = XftFontOpenPattern(DISPLAY(displayId), (XftPattern*)__INST(address_)); |
|
1783 |
if (f == NULL) { |
|
7221 | 1784 |
RETURN (nil); |
7114 | 1785 |
} else { |
7221 | 1786 |
RETURN (XFT_FONT_HANDLE_NEW(f)); |
7114 | 1787 |
} |
1788 |
err:; |
|
1789 |
#endif |
|
1790 |
%}. |
|
1791 |
self primitiveFailed: error |
|
1792 |
||
1793 |
"Created: / 20-12-2013 / 23:53:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1794 |
! |
|
1795 |
||
1796 |
matchFontOnDisplayId:displayId screen:screen |
|
1797 |
| error | |
|
1798 |
||
1799 |
%{ /* STACK: 64000 */ |
|
1800 |
#ifdef XFT |
|
1801 |
XftPattern *p; |
|
1802 |
XftResult r; |
|
1803 |
||
1804 |
if (!__isExternalAddressLike(displayId)) { |
|
7221 | 1805 |
error = @symbol(BadArg1); |
1806 |
goto err; |
|
7114 | 1807 |
} |
1808 |
if (!__isSmallInteger( screen) ) { |
|
7221 | 1809 |
error = @symbol(BadArg2); |
1810 |
goto err; |
|
7114 | 1811 |
} |
1812 |
if (__INST(address_) == 0) { |
|
7221 | 1813 |
error = @symbol(BadHandle); |
1814 |
goto err; |
|
7114 | 1815 |
} |
1816 |
||
1817 |
// Already done in match: |
|
1818 |
// XftConfigSubstitute(FC_PATTERN( patternId )); |
|
1819 |
// XftDefaultSubstitute(DISPLAY(displayId), SCREEN( screen ), FC_PATTERN( patternId )); |
|
1820 |
p = XftFontMatch(DISPLAY(displayId), SCREEN(screen), (XftPattern*)__INST(address_), &r); |
|
1821 |
if (p) { |
|
7221 | 1822 |
RETURN (FC_PATTERN_HANDLE_NEW(p) ); |
7114 | 1823 |
} else { |
7221 | 1824 |
error = @symbol(XftFontMatchReturnedNull); |
7114 | 1825 |
} |
1826 |
err:; |
|
1827 |
#endif |
|
1828 |
%}. |
|
1829 |
self primitiveFailed: error |
|
1830 |
||
1831 |
"Created: / 21-12-2013 / 00:08:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1832 |
! ! |
|
1833 |
||
1834 |
!XftFontDescription::XftDrawHandle class methodsFor:'instance creation'! |
|
1835 |
||
1836 |
createForDisplayId:displayId screen:screen drawable:drawableId |
|
1837 |
^ self new createForDisplayId:displayId screen:screen drawable:drawableId |
|
1838 |
! ! |
|
1839 |
||
1840 |
!XftFontDescription::XftDrawHandle methodsFor:'primitives'! |
|
1841 |
||
1842 |
createForDisplayId:displayId screen:screen drawable:drawableId |
|
1843 |
| error | |
|
1844 |
||
1845 |
%{ /* STACK: 64000 */ |
|
1846 |
#ifdef XFT |
|
1847 |
if ( ! __isExternalAddressLike(displayId) ) { |
|
7221 | 1848 |
error = @symbol(BadArg1); |
1849 |
goto err; |
|
7114 | 1850 |
} |
1851 |
if ( ! __isSmallInteger(screen) ) { |
|
7221 | 1852 |
error = @symbol(BadArg2); |
1853 |
goto err; |
|
7114 | 1854 |
} |
1855 |
if ( ! __isExternalAddressLike(drawableId) ) { |
|
7221 | 1856 |
error = @symbol(BadArg3); |
1857 |
goto err; |
|
7114 | 1858 |
} |
1859 |
__INST(address_) = (void *) XftDrawCreate ( DISPLAY(displayId) , |
|
7221 | 1860 |
DRAWABLE(drawableId) , |
1861 |
DefaultVisual(DISPLAY(displayId), SCREEN (screen)) , |
|
1862 |
DefaultColormap(DISPLAY(displayId), SCREEN (screen))); |
|
7114 | 1863 |
err:; |
1864 |
#endif |
|
1865 |
%}. |
|
1866 |
self primitiveFailed: error |
|
1867 |
||
1868 |
"Created: / 21-12-2013 / 21:12:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1869 |
! |
|
1870 |
||
1871 |
destroy |
|
1872 |
%{ /* STACK: 64000 */ |
|
1873 |
#ifdef XFT |
|
1874 |
if (__INST(address_) != 0) { |
|
7221 | 1875 |
XftDrawDestroy((XftDraw*)__INST(address_)); |
1876 |
__INST(address_) = 0; |
|
1877 |
RETURN ( self ); |
|
7114 | 1878 |
} |
1879 |
#endif |
|
1880 |
%}. |
|
1881 |
self primitiveFailed. |
|
1882 |
! |
|
1883 |
||
1884 |
disassociateFrom:drawableId |
|
1885 |
"Disassociate the XftDrawable from drawableId. |
|
1886 |
This mist be done before the drawable is destroyed, |
|
1887 |
otherwise the XftDrawable is destroyed together with the drawable, |
|
1888 |
and X11 errors will be signaled." |
|
1889 |
||
1890 |
| error | |
|
1891 |
||
1892 |
%{ /* STACK: 64000 */ |
|
1893 |
#ifdef XFT |
|
1894 |
if (__INST(address_) == 0) { |
|
7221 | 1895 |
// nothing to disasassociate from... |
1896 |
RETURN(self); |
|
7114 | 1897 |
} |
1898 |
if (!__isExternalAddressLike(drawableId)) { |
|
7221 | 1899 |
error = @symbol(BadArg); |
1900 |
goto err; |
|
7114 | 1901 |
} |
1902 |
if (XftDrawDrawable((XftDraw*)__INST(address_)) == DRAWABLE(drawableId)) { |
|
7221 | 1903 |
XftDrawChange((XftDraw*)__INST(address_), None); |
7114 | 1904 |
} |
1905 |
RETURN(self); |
|
1906 |
err:; |
|
1907 |
#endif |
|
1908 |
%}. |
|
1909 |
self primitiveFailed: error |
|
1910 |
||
1911 |
"Created: / 26-12-2013 / 12:17:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1912 |
! |
|
1913 |
||
1914 |
drawChange:drawableId |
|
1915 |
| error | |
|
1916 |
||
1917 |
%{ /* STACK: 64000 */ |
|
1918 |
#ifdef XFT |
|
1919 |
if (drawableId == nil) { |
|
7221 | 1920 |
XftDrawChange((XftDraw*)__INST(address_), None); |
1921 |
RETURN (self); |
|
7114 | 1922 |
} |
1923 |
if (!__isExternalAddressLike(drawableId)) { |
|
7221 | 1924 |
error = @symbol(BadArg1); |
1925 |
goto err; |
|
7114 | 1926 |
} |
1927 |
if (XftDrawDrawable((XftDraw*)__INST(address_)) != DRAWABLE( drawableId)) { |
|
7221 | 1928 |
XftDrawChange((XftDraw*)__INST(address_), DRAWABLE( drawableId)); |
7114 | 1929 |
} |
1930 |
RETURN (self); |
|
1931 |
err:; |
|
1932 |
#endif |
|
1933 |
%}. |
|
1934 |
self primitiveFailed: error |
|
1935 |
||
1936 |
"Created: / 26-12-2013 / 12:17:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1937 |
! |
|
1938 |
||
1939 |
drawRectWithColor:aColor x:x y:y width:w height:h |
|
1940 |
| error r g b a pix | |
|
1941 |
||
1942 |
aColor isColor ifFalse:[^self primitiveFailed: #BadArg1]. |
|
1943 |
||
1944 |
r := aColor scaledRed. |
|
1945 |
g := aColor scaledGreen. |
|
1946 |
b := aColor scaledBlue. |
|
1947 |
a := aColor alpha * 65535. |
|
1948 |
r isNil ifTrue:[ |
|
7221 | 1949 |
"/ when drawing into a pixmap... |
1950 |
aColor colorId == 0 ifTrue:[ |
|
1951 |
r := g := b := 0. |
|
1952 |
] ifFalse:[ |
|
1953 |
r := g := b := 16rFFFF. |
|
1954 |
] |
|
7114 | 1955 |
]. |
1956 |
pix := aColor colorId. |
|
1957 |
%{ /* STACK: 64000 */ |
|
1958 |
#ifdef XFT |
|
1959 |
XftColor clr; |
|
1960 |
||
1961 |
if (__INST(address_) == 0) { |
|
7221 | 1962 |
error = @symbol(BadHandle); |
1963 |
goto err; |
|
7114 | 1964 |
} |
1965 |
if (!__isSmallInteger(pix)) { |
|
7221 | 1966 |
error = @symbol(BadColorId); |
1967 |
goto err; |
|
7114 | 1968 |
} |
1969 |
if (!__isSmallInteger(x)) { |
|
7221 | 1970 |
error = @symbol(BadArg2); |
1971 |
goto err; |
|
7114 | 1972 |
} |
1973 |
if (! __isSmallInteger(y)) { |
|
7221 | 1974 |
error = @symbol(BadArg3); |
1975 |
goto err; |
|
7114 | 1976 |
} |
1977 |
if (!__isSmallInteger(w)) { |
|
7221 | 1978 |
error = @symbol(BadArg4); |
1979 |
goto err; |
|
7114 | 1980 |
} |
1981 |
if (!__isSmallInteger(h)) { |
|
7221 | 1982 |
error = @symbol(BadArg5); |
1983 |
goto err; |
|
7114 | 1984 |
} |
1985 |
clr.pixel = (unsigned long)__intVal(pix); |
|
1986 |
clr.color.red = __intVal(r); |
|
1987 |
clr.color.green = __intVal(g); |
|
1988 |
clr.color.blue = __intVal(b); |
|
1989 |
clr.color.alpha = __intVal(a); |
|
1990 |
||
1991 |
XftDrawRect((XftDraw*)__INST(address_), &clr, |
|
7221 | 1992 |
__intVal(x), __intVal(y), __intVal(w) ,__intVal(h)); |
7114 | 1993 |
|
1994 |
RETURN (self); |
|
1995 |
err:; |
|
1996 |
#endif |
|
1997 |
%}. |
|
1998 |
self primitiveFailed: error. |
|
1999 |
||
2000 |
"Created: / 28-12-2013 / 23:35:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2001 |
"Modified: / 31-12-2013 / 00:37:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2002 |
! |
|
2003 |
||
2004 |
drawString:aString color:aColor font:fontIdArg x:x y:y from:start to:stop |
|
2005 |
| error r g b a pix | |
|
2006 |
||
2007 |
aColor isColor ifFalse:[^self primitiveFailed: #BadArg2]. |
|
2008 |
||
2009 |
pix := aColor colorId. |
|
2010 |
r := aColor scaledRed. |
|
2011 |
r isNil ifTrue:[ |
|
7221 | 2012 |
"/ when drawing into a pixmap... |
2013 |
pix == 0 ifTrue:[ |
|
2014 |
r := g := b := a := 0. |
|
2015 |
] ifFalse:[ |
|
2016 |
r := g := b := a := 16rFFFF. |
|
2017 |
] |
|
7114 | 2018 |
] ifFalse:[ |
7221 | 2019 |
g := aColor scaledGreen. |
2020 |
b := aColor scaledBlue. |
|
2021 |
a := aColor alpha * 65535. |
|
7114 | 2022 |
]. |
2023 |
%{ /* STACK: 64000 */ |
|
2024 |
#ifdef XFT |
|
2025 |
int _start, _stop; |
|
2026 |
int __x, __y; |
|
2027 |
XftColor clr; |
|
2028 |
||
2029 |
if (__INST(address_) == 0) { |
|
7221 | 2030 |
error = @symbol(BadHandle); |
2031 |
goto err; |
|
7114 | 2032 |
} |
2033 |
if ( ! __isSmallInteger(pix) ) { |
|
7221 | 2034 |
error = @symbol(BadColorId); |
2035 |
goto err; |
|
7114 | 2036 |
} |
2037 |
if ( ! __isSmallInteger(x) ) { |
|
7221 | 2038 |
error = @symbol(BadArg4); |
2039 |
goto err; |
|
7114 | 2040 |
} |
2041 |
__x = __intVal(x); |
|
2042 |
if ( ! __isSmallInteger(y) ) { |
|
7221 | 2043 |
error = @symbol(BadArg5); |
2044 |
goto err; |
|
7114 | 2045 |
} |
2046 |
__y = __intVal(y); |
|
2047 |
||
2048 |
||
2049 |
if ( ! __isSmallInteger(start) ) { |
|
7221 | 2050 |
error = @symbol(BadArg6); |
2051 |
goto err; |
|
7114 | 2052 |
} |
2053 |
_start = __intVal(start); |
|
2054 |
if ( ! __isSmallInteger(stop) ) { |
|
7221 | 2055 |
error = @symbol(BadArg7); |
2056 |
goto err; |
|
7114 | 2057 |
} |
2058 |
_stop = __intVal(stop); |
|
2059 |
||
2060 |
clr.pixel = (unsigned long)__intVal(pix); |
|
2061 |
clr.color.red = __intVal(r); |
|
2062 |
clr.color.green = __intVal(g); |
|
2063 |
clr.color.blue = __intVal(b); |
|
2064 |
clr.color.alpha = __intVal(a); |
|
2065 |
||
2066 |
if ( __isStringLike(aString) ) { |
|
7221 | 2067 |
XftDrawString8((XftDraw*)__INST(address_), &clr, XFT_FONT(fontIdArg), |
2068 |
__x, __y, |
|
2069 |
__stringVal(aString) + (_start - 1), _stop - _start + 1); |
|
2070 |
RETURN ( self ); |
|
7114 | 2071 |
} else { |
7221 | 2072 |
error = @symbol(BadArg1); |
2073 |
goto err; |
|
7114 | 2074 |
} |
2075 |
err:; |
|
2076 |
#endif |
|
2077 |
%}. |
|
2078 |
self primitiveFailed: error. |
|
2079 |
||
2080 |
"Created: / 28-12-2013 / 12:32:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2081 |
"Modified: / 30-12-2013 / 20:00:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2082 |
! |
|
2083 |
||
2084 |
setClipRect:rect |
|
2085 |
| error xObj yObj wObj hObj | |
|
2086 |
||
2087 |
rect notNil ifTrue:[ |
|
7221 | 2088 |
xObj := rect left. |
2089 |
yObj := rect top. |
|
2090 |
wObj := rect width. |
|
2091 |
hObj := rect height. |
|
7114 | 2092 |
]. |
2093 |
%{ /* STACK: 64000 */ |
|
2094 |
#ifdef XFT |
|
2095 |
if (__INST(address_) == 0) { |
|
7221 | 2096 |
error = @symbol(BadHandle); |
2097 |
goto err; |
|
7114 | 2098 |
} |
2099 |
if (rect != nil) { |
|
7221 | 2100 |
XRectangle r; |
7114 | 2101 |
|
7221 | 2102 |
r.x = __intVal(xObj); |
2103 |
r.y = __intVal(yObj); |
|
2104 |
r.width = __intVal(wObj); |
|
2105 |
r.height = __intVal(hObj); |
|
2106 |
XftDrawSetClipRectangles((XftDraw*)__INST(address_), 0, 0, &r, 1); |
|
7114 | 2107 |
} else { |
7221 | 2108 |
XftDrawSetClipRectangles((XftDraw*)__INST(address_), 0, 0, (XRectangle*)NULL, 0); |
7114 | 2109 |
} |
2110 |
RETURN ( self ); |
|
2111 |
err:; |
|
2112 |
#endif |
|
2113 |
%}. |
|
2114 |
self primitiveFailed: error. |
|
2115 |
||
2116 |
"Created: / 31-12-2013 / 01:24:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2117 |
! ! |
|
2118 |
||
6176 | 2119 |
!XftFontDescription class methodsFor:'documentation'! |
2120 |
||
2121 |
version |
|
6936 | 2122 |
^ '$Header$' |
6176 | 2123 |
! |
2124 |
||
2125 |
version_CVS |
|
6936 | 2126 |
^ '$Header$' |
6176 | 2127 |
! ! |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
2128 |
|
6184
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
2129 |
|
997414d312b5
Fixed font lookup to take face (aka weight) and style (aka slant) into an account).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6183
diff
changeset
|
2130 |
XftFontDescription initialize! |