author | Stefan Vogel <sv@exept.de> |
Fri, 22 Jun 2018 12:01:21 +0200 | |
changeset 8417 | 040acbfae716 |
parent 8391 | 13a58484d01c |
child 8431 | cbea7788e214 |
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 |
||
580 |
|lc_CTYPE| |
|
581 |
||
582 |
lc_CTYPE := OperatingSystem getEnvironment:'LC_CTYPE'. |
|
583 |
lc_CTYPE = 'UTF-8' ifTrue:[ |
|
584 |
^ (Smalltalk language |
|
585 |
,'_',Smalltalk languageTerritory asUppercase |
|
586 |
,'.UTF-8'). |
|
587 |
]. |
|
588 |
^ lc_CTYPE |
|
589 |
! ! |
|
590 |
||
6317 | 591 |
!XftFontDescription methodsFor:'accessing'! |
6190
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
592 |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
593 |
encoding |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
594 |
^ encoding ? #'iso10646-1' |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
595 |
! |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
596 |
|
6319 | 597 |
face |
598 |
^ face ? '' |
|
599 |
! |
|
600 |
||
601 |
fullName |
|
602 |
^ name ? (self userFriendlyName) |
|
603 |
! |
|
604 |
||
6317 | 605 |
graphicsDevice |
6190
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
606 |
^ device |
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
607 |
|
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
608 |
"Created: / 02-01-2014 / 23:22:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6319 | 609 |
! |
610 |
||
611 |
maxCode |
|
6323 | 612 |
^ maxCode ? 16rFFFF |
6319 | 613 |
! |
614 |
||
615 |
maxCode:something |
|
616 |
maxCode := something. |
|
617 |
! |
|
618 |
||
619 |
minCode |
|
6323 | 620 |
^ minCode ? 0 |
6319 | 621 |
! |
622 |
||
623 |
minCode:something |
|
624 |
minCode := something. |
|
625 |
! |
|
626 |
||
627 |
style |
|
628 |
^ style ? '' |
|
6391 | 629 |
! |
630 |
||
631 |
weight:aNumber |
|
7121 | 632 |
"set the weight. The face is the string representation of weight." |
6391 | 633 |
|
634 |
self assert:(self fontId isNil). "/ cannot change an instantiated font |
|
635 |
||
7121 | 636 |
weight := aNumber. |
637 |
||
638 |
aNumber == FC_WEIGHT_THIN ifTrue:[ face := #thin. ^ self]. |
|
639 |
aNumber == FC_WEIGHT_EXTRALIGHT ifTrue:[ face := #extralight. ^ self]. |
|
640 |
aNumber == FC_WEIGHT_LIGHT ifTrue:[ face := #light. ^ self]. |
|
641 |
aNumber == FC_WEIGHT_BOOK ifTrue:[ face := #book. ^ self]. |
|
642 |
aNumber == FC_WEIGHT_REGULAR ifTrue:[ face := #regular. ^ self]. |
|
643 |
aNumber == FC_WEIGHT_MEDIUM ifTrue:[ face := #medium. ^ self]. |
|
644 |
aNumber == FC_WEIGHT_DEMIBOLD ifTrue:[ face := #demibold. ^ self]. |
|
645 |
aNumber == FC_WEIGHT_BOLD ifTrue:[ face := #bold. ^ self]. |
|
646 |
aNumber == FC_WEIGHT_EXTRABOLD ifTrue:[ face := #extrabold. ^ self]. |
|
647 |
aNumber == FC_WEIGHT_BLACK ifTrue:[ face := #black. ^ self]. |
|
648 |
aNumber == FC_WEIGHT_EXTRABLACK ifTrue:[ face := #extrablack. ^ self]. |
|
6391 | 649 |
|
650 |
aNumber <= (FC_WEIGHT_EXTRALIGHT + FC_WEIGHT_LIGHT // 2) ifTrue:[ |
|
7221 | 651 |
face := #extralight. |
652 |
^ self. |
|
6391 | 653 |
]. |
654 |
aNumber <= (FC_WEIGHT_LIGHT + FC_WEIGHT_BOOK // 2) ifTrue:[ |
|
7221 | 655 |
face := #light. |
656 |
^ self. |
|
6391 | 657 |
]. |
658 |
aNumber <= (FC_WEIGHT_MEDIUM + FC_WEIGHT_DEMIBOLD // 2) ifTrue:[ |
|
7221 | 659 |
face := #medium. |
660 |
^ self. |
|
6391 | 661 |
]. |
662 |
aNumber <= (FC_WEIGHT_DEMIBOLD + FC_WEIGHT_BOLD // 2) ifTrue:[ |
|
7221 | 663 |
face := #demibold. |
664 |
^ self. |
|
6391 | 665 |
]. |
666 |
aNumber <= (FC_WEIGHT_BOLD + FC_WEIGHT_BLACK // 2) ifTrue:[ |
|
7221 | 667 |
face := #bold. |
668 |
^ self. |
|
6391 | 669 |
]. |
7121 | 670 |
face := #extrabold. |
6391 | 671 |
^ self |
672 |
||
673 |
"/ FC_WEIGHT_THIN := 0. |
|
674 |
"/ FC_WEIGHT_EXTRALIGHT := 40. |
|
675 |
"/ FC_WEIGHT_ULTRALIGHT := FC_WEIGHT_EXTRALIGHT. |
|
676 |
"/ FC_WEIGHT_LIGHT := 50. |
|
677 |
"/ FC_WEIGHT_BOOK := 75. |
|
678 |
"/ FC_WEIGHT_REGULAR := 80. |
|
679 |
"/ FC_WEIGHT_NORMAL := FC_WEIGHT_REGULAR. |
|
680 |
"/ FC_WEIGHT_MEDIUM := 100. |
|
681 |
"/ FC_WEIGHT_DEMIBOLD := 180. |
|
682 |
"/ FC_WEIGHT_SEMIBOLD := FC_WEIGHT_DEMIBOLD. |
|
683 |
"/ FC_WEIGHT_BOLD := 200. |
|
684 |
"/ FC_WEIGHT_EXTRABOLD := 205. |
|
685 |
"/ FC_WEIGHT_ULTRABOLD := FC_WEIGHT_EXTRABOLD. |
|
686 |
"/ FC_WEIGHT_BLACK := 210. |
|
687 |
"/ FC_WEIGHT_HEAVY := FC_WEIGHT_BLACK. |
|
688 |
"/ FC_WEIGHT_EXTRABLACK := 215. |
|
689 |
"/ FC_WEIGHT_ULTRABLACK := FC_WEIGHT_EXTRABLACK. |
|
6317 | 690 |
! ! |
691 |
||
692 |
!XftFontDescription methodsFor:'accessing-private'! |
|
6190
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
693 |
|
7443 | 694 |
getXftFontId |
6190
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
695 |
^ fontId |
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
696 |
|
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
697 |
"Created: / 02-01-2014 / 23:29:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
7114 | 698 |
! |
699 |
||
700 |
setFontId:fontIdArg |
|
701 |
fontId := fontIdArg. |
|
6190
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
702 |
! ! |
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
703 |
|
6587
c1790bb9af59
In case of not configured but installed Xft Fonts convert XftFonts
ab
parents:
6544
diff
changeset
|
704 |
!XftFontDescription methodsFor:'converting'! |
c1790bb9af59
In case of not configured but installed Xft Fonts convert XftFonts
ab
parents:
6544
diff
changeset
|
705 |
|
c1790bb9af59
In case of not configured but installed Xft Fonts convert XftFonts
ab
parents:
6544
diff
changeset
|
706 |
asNonXftFont |
7870 | 707 |
"in some situations, we do not want an Xft font..." |
8018 | 708 |
|
6587
c1790bb9af59
In case of not configured but installed Xft Fonts convert XftFonts
ab
parents:
6544
diff
changeset
|
709 |
|newFont| |
c1790bb9af59
In case of not configured but installed Xft Fonts convert XftFonts
ab
parents:
6544
diff
changeset
|
710 |
|
7707 | 711 |
newFont := Font |
8018 | 712 |
family:family |
713 |
face:face |
|
714 |
style:style |
|
715 |
size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) |
|
716 |
sizeUnit:sizeUnit |
|
717 |
encoding:encoding. |
|
7877 | 718 |
newFont isForceNonXFTFont:true. |
6656 | 719 |
^ newFont |
7870 | 720 |
|
7877 | 721 |
" |
722 |
|view1 view2| |
|
723 |
||
724 |
view1 := TextView new openAndWait. |
|
725 |
view2 := TextView new openAndWait. |
|
726 |
view1 font:(Button defaultFont). |
|
727 |
view1 contents:'Hello world'. |
|
728 |
view2 font:(Button defaultFont asNonXftFont onDevice:Display). |
|
729 |
view2 contents:'Hello world'. |
|
730 |
" |
|
731 |
||
732 |
"Modified (comment): / 12-02-2017 / 22:14:47 / cg" |
|
6587
c1790bb9af59
In case of not configured but installed Xft Fonts convert XftFonts
ab
parents:
6544
diff
changeset
|
733 |
! ! |
c1790bb9af59
In case of not configured but installed Xft Fonts convert XftFonts
ab
parents:
6544
diff
changeset
|
734 |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
735 |
!XftFontDescription methodsFor:'error reporting'! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
736 |
|
6198 | 737 |
primitiveFailed |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
738 |
<resource: #skipInDebuggersWalkBack> |
6876
b1aa2b47d252
avoid ifdefs around smalltalk statements
Claus Gittinger <cg@exept.de>
parents:
6833
diff
changeset
|
739 |
|
6936 | 740 |
self class xftAvailable ifFalse:[ |
7114 | 741 |
super primitiveFailed:'Xft support is not configured'. |
6876
b1aa2b47d252
avoid ifdefs around smalltalk statements
Claus Gittinger <cg@exept.de>
parents:
6833
diff
changeset
|
742 |
]. |
6198 | 743 |
super primitiveFailed |
744 |
! |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
745 |
|
6198 | 746 |
primitiveFailed:errorString |
747 |
<resource: #skipInDebuggersWalkBack> |
|
6876
b1aa2b47d252
avoid ifdefs around smalltalk statements
Claus Gittinger <cg@exept.de>
parents:
6833
diff
changeset
|
748 |
|
6936 | 749 |
self class xftAvailable ifFalse:[ |
7114 | 750 |
super primitiveFailed:'Xft support is not configured'. |
6876
b1aa2b47d252
avoid ifdefs around smalltalk statements
Claus Gittinger <cg@exept.de>
parents:
6833
diff
changeset
|
751 |
]. |
6198 | 752 |
super primitiveFailed:errorString |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
753 |
! ! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
754 |
|
6946 | 755 |
!XftFontDescription methodsFor:'finalization'! |
756 |
||
757 |
finalize |
|
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
758 |
self releaseFromDevice |
6946 | 759 |
! ! |
760 |
||
6176 | 761 |
!XftFontDescription methodsFor:'getting a device font'! |
762 |
||
7443 | 763 |
installInDeviceForGCId:aGCId |
764 |
"install the font for aGCId" |
|
765 |
||
766 |
(device isNil or:[fontId isNil]) ifTrue:[ |
|
8018 | 767 |
Logger error:'no device font for: %1' with:self. |
768 |
^ nil. |
|
7443 | 769 |
]. |
770 |
"nothing to install" |
|
771 |
! |
|
772 |
||
6176 | 773 |
onDevice:aGraphicsDevice |
774 |
"Create a new XftFont representing the closes font as |
|
775 |
myself on aDevice; if one already exists, return the one." |
|
776 |
||
7219 | 777 |
^ self onDevice:aGraphicsDevice ifAbsent:self |
7114 | 778 |
! |
779 |
||
780 |
onDevice:aGraphicsDevice ifAbsent:aBlock |
|
7559 | 781 |
"Create a new XftFont representing the closest font as |
7114 | 782 |
myself on aDevice; if one already exists, return the one." |
6176 | 783 |
|
7559 | 784 |
|displayId myPatternHandle closestPatternHandle newFontId computedWeight deviceFont| |
6176 | 785 |
|
7114 | 786 |
(device == aGraphicsDevice) ifTrue:[ |
8370 | 787 |
"I am already assigned to that device ..." |
788 |
^ self |
|
7114 | 789 |
]. |
790 |
aGraphicsDevice isNil ifTrue:[ |
|
8370 | 791 |
^ self |
6544 | 792 |
]. |
7121 | 793 |
aGraphicsDevice supportsXftFonts ifFalse:[ |
8370 | 794 |
^ self asNonXftFont onDevice:aGraphicsDevice. |
6190
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
795 |
]. |
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
796 |
|
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
797 |
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
|
798 |
deviceFont notNil ifTrue:[ |
8370 | 799 |
^ deviceFont. |
6389 | 800 |
]. |
801 |
||
7121 | 802 |
computedWeight := weight. |
803 |
computedWeight isNil ifTrue:[ |
|
8370 | 804 |
computedWeight := StXFace2FCWeightMap at:(face ? '') asLowercase ifAbsent:[FC_WEIGHT_REGULAR]. |
7121 | 805 |
]. |
806 |
||
8391 | 807 |
(OperatingSystem isOSXlike and:[FirstTimeCalled ~~ false]) ifTrue:[ |
8370 | 808 |
"Slow font matching is a MAC-only feature" |
809 |
Logger info:'XFT: matching font (this may take a long time, if the system''s font cache needs to be filled first. Be patient...'. |
|
810 |
FirstTimeCalled := false. |
|
7559 | 811 |
]. |
812 |
||
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
813 |
[ |
8370 | 814 |
myPatternHandle := FCPatternHandle create. |
815 |
myPatternHandle |
|
816 |
add:FC_FOUNDRY value:manufacturer; |
|
817 |
add:FC_FAMILY value:family; |
|
818 |
add:FC_WEIGHT value:computedWeight; |
|
819 |
add:FC_SLANT value:(StXStyle2FCSlantMap at:(style ? '') asLowercase ifAbsent:[FC_SLANT_ROMAN]). |
|
820 |
sizeUnit = #px ifTrue:[ |
|
821 |
myPatternHandle add:FC_PIXEL_SIZE value:(pixelSize isNil ifTrue:[nil] ifFalse:[pixelSize rounded]). |
|
822 |
] ifFalse:[ |
|
823 |
myPatternHandle add:FC_SIZE value:(size isNil ifTrue:[nil] ifFalse:[size rounded]). |
|
824 |
]. |
|
7114 | 825 |
|
8370 | 826 |
displayId := aGraphicsDevice displayId. |
827 |
||
828 |
OperatingSystem setEnvironment:'LC_CTYPE' to:(self class fixedLC_CTYPE). |
|
829 |
closestPatternHandle := myPatternHandle matchFontOnDisplayId:displayId screen:aGraphicsDevice screen. |
|
830 |
closestPatternHandle notNil ifTrue:[ |
|
831 |
newFontId := closestPatternHandle getFontOnDisplayId:displayId. |
|
832 |
newFontId notNil ifTrue:[ |
|
833 |
"/ Good, this font exists!! |
|
834 |
device isNil ifTrue:[ |
|
835 |
deviceFont := self. |
|
836 |
] ifFalse:[ |
|
837 |
deviceFont := self copy. |
|
838 |
]. |
|
839 |
closestPatternHandle := nil. |
|
840 |
deviceFont setDevice:aGraphicsDevice patternId:nil fontId:newFontId. |
|
841 |
aGraphicsDevice registerFont:deviceFont. |
|
842 |
^ deviceFont. |
|
843 |
]. |
|
844 |
]. |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
845 |
] ensure:[ |
8370 | 846 |
myPatternHandle notNil ifTrue:[myPatternHandle destroy]. |
847 |
closestPatternHandle notNil ifTrue:[closestPatternHandle destroy]. |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
848 |
]. |
7114 | 849 |
^ aBlock value |
6176 | 850 |
|
851 |
" |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
852 |
(XftFontDescription family:'monospace' size:16) onDevice:Screen current |
6176 | 853 |
" |
854 |
||
855 |
"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
|
856 |
"Modified: / 02-01-2014 / 23:43:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
8391 | 857 |
"Modified: / 18-06-2018 / 15:54:36 / Claus Gittinger" |
6176 | 858 |
! ! |
859 |
||
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
860 |
!XftFontDescription methodsFor:'initialization'! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
861 |
|
6963 | 862 |
initialize |
863 |
"Invoked when a new instance is created." |
|
864 |
||
865 |
super initialize. |
|
866 |
size := 0. |
|
867 |
encoding := #'iso10646-1'. |
|
868 |
! |
|
869 |
||
6993 | 870 |
isScaledFont |
871 |
^ true |
|
872 |
! |
|
873 |
||
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
874 |
setDevice: deviceArg patternId: patternIdArg fontId: fontIdArg |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
875 |
device := deviceArg. |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
876 |
fontId := fontIdArg. |
6325 | 877 |
patternIdArg notNil ifTrue:[ |
7114 | 878 |
family := patternIdArg get: FC_FAMILY index: 0. |
879 |
size := patternIdArg get: FC_SIZE index: 0. |
|
8018 | 880 |
weight := patternIdArg get: FC_WEIGHT index: 0. |
881 |
face := StXFace2FCWeightMap keyAtValue: weight. |
|
882 |
slant := patternIdArg get: FC_SLANT index: 0. |
|
883 |
style := StXStyle2FCSlantMap keyAtValue: slant. |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
884 |
|
8018 | 885 |
"/ name := patternIdArg get: 'fullname' index: 0. |
886 |
"/ encoding:= patternIdArg get: 'encoding' index: 0. |
|
6957 | 887 |
]. |
888 |
size isNil ifTrue:[ |
|
7114 | 889 |
size := 0. |
6325 | 890 |
]. |
6963 | 891 |
encoding isNil ifTrue:[ |
7114 | 892 |
encoding := #'iso10646-1'. |
6963 | 893 |
]. |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
894 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
895 |
"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
|
896 |
"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
|
897 |
! ! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
898 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
899 |
!XftFontDescription methodsFor:'primitives'! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
900 |
|
7563 | 901 |
xftTextExtents:displayIdArg string:aString from:start to:stop into:extentsArrayOrNil |
902 |
"get the extents of aString. |
|
903 |
Answer thr width of aString (in reality the xOff). |
|
904 |
If extentArrayOrNil is an Array, fill is with the extent info: |
|
8018 | 905 |
#(width height x y xOff yOff ascent descent)." |
7563 | 906 |
|
907 |
|error bytesPerCharacter| |
|
908 |
||
909 |
bytesPerCharacter := aString bytesPerCharacter. |
|
7114 | 910 |
|
911 |
%{ /* 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
|
912 |
#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
|
913 |
XGlyphInfo info; |
6195
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
914 |
char *string; |
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
915 |
int len; |
7563 | 916 |
int __bytesPerCharacter = __intVal(bytesPerCharacter); |
8018 | 917 |
OBJ fontIdArg = __INST(fontId); |
6195
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
918 |
|
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
919 |
if ( ! __isExternalAddressLike(displayIdArg) ) { |
8018 | 920 |
error = @symbol(BadArg1); |
921 |
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
|
922 |
} |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
923 |
if ( ! __isSmallInteger(start) ) { |
8018 | 924 |
error = @symbol(BadArg3); |
925 |
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
|
926 |
} |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
927 |
if ( ! __isSmallInteger(stop) ) { |
8018 | 928 |
error = @symbol(BadArg4); |
929 |
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
|
930 |
} |
8018 | 931 |
if ( ! __isExternalAddressLike(fontIdArg) ) { |
932 |
error = @symbol(BadFontId); |
|
933 |
goto err; |
|
7563 | 934 |
} |
935 |
||
936 |
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
|
937 |
len = __intVal(stop) - __intVal(start) + 1; |
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
938 |
|
7563 | 939 |
switch (__bytesPerCharacter) { |
8018 | 940 |
case 1: |
941 |
XftTextExtents8(DISPLAY(displayIdArg), XFT_FONT(fontIdArg), (FcChar8*)string, len, &info); |
|
942 |
break; |
|
943 |
case 2: |
|
944 |
XftTextExtents16(DISPLAY(displayIdArg), XFT_FONT(fontIdArg), (FcChar16*)string, len, &info); |
|
945 |
break; |
|
946 |
case 4: |
|
947 |
XftTextExtents32(DISPLAY(displayIdArg), XFT_FONT(fontIdArg), (FcChar32*)string, len, &info); |
|
948 |
break; |
|
949 |
default: |
|
950 |
error = @symbol(BadArg2); |
|
951 |
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
|
952 |
} |
7563 | 953 |
|
954 |
if (extentsArrayOrNil != nil && __isArray(extentsArrayOrNil)) { |
|
8018 | 955 |
switch (__arraySize(extentsArrayOrNil)) { |
956 |
case 8: |
|
957 |
__arrayVal(extentsArrayOrNil)[7] = __MKSMALLINT(XFT_FONT(fontIdArg)->descent); |
|
958 |
// fall into |
|
959 |
case 7: |
|
960 |
__arrayVal(extentsArrayOrNil)[6] = __MKSMALLINT(XFT_FONT(fontIdArg)->ascent); |
|
961 |
// fall into |
|
962 |
case 6: |
|
963 |
__arrayVal(extentsArrayOrNil)[5] = __MKSMALLINT(info.yOff); |
|
964 |
// fall into |
|
965 |
case 5: |
|
966 |
__arrayVal(extentsArrayOrNil)[4] = __MKSMALLINT(info.xOff); |
|
967 |
// fall into |
|
968 |
case 4: |
|
969 |
__arrayVal(extentsArrayOrNil)[3] = __MKSMALLINT(info.y); |
|
970 |
// fall into |
|
971 |
case 3: |
|
972 |
__arrayVal(extentsArrayOrNil)[2] = __MKSMALLINT(info.x); |
|
973 |
// fall into |
|
974 |
case 2: |
|
975 |
{ |
|
976 |
int height; |
|
977 |
||
978 |
height = info.height; |
|
979 |
#if 0 |
|
980 |
height = XFT_FONT(fontIdArg)->descent + XFT_FONT(fontIdArg)->ascent; |
|
981 |
#endif |
|
982 |
__arrayVal(extentsArrayOrNil)[1] = __MKSMALLINT(height); |
|
983 |
} |
|
984 |
// fall into |
|
985 |
case 1: |
|
986 |
__arrayVal(extentsArrayOrNil)[0] = __MKSMALLINT(info.width); |
|
987 |
// fall into |
|
988 |
case 0: |
|
989 |
break; |
|
990 |
} |
|
7563 | 991 |
} |
992 |
||
993 |
RETURN(__MKSMALLINT(info.xOff)); |
|
994 |
||
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
995 |
err:; |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
996 |
#endif |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
997 |
%}. |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
998 |
error notNil ifTrue:[ |
8018 | 999 |
self primitiveFailed: error. |
1000 |
^ 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
|
1001 |
]. |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1002 |
|
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1003 |
"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
|
1004 |
"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
|
1005 |
! ! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1006 |
|
6198 | 1007 |
!XftFontDescription methodsFor:'printing & storing'! |
1008 |
||
1009 |
storeOn:aStream |
|
1010 |
"append a character sequence to the argument, aStream from which the |
|
1011 |
receiver can be reconstructed using readFrom:." |
|
1012 |
||
1013 |
aStream nextPutAll:'(XftFontDescription family:'. family storeOn:aStream. |
|
1014 |
aStream nextPutAll:' face:'. face storeOn:aStream. |
|
1015 |
aStream nextPutAll:' style:'. style storeOn:aStream. |
|
1016 |
aStream nextPutAll:' size:'. size storeOn:aStream. |
|
1017 |
aStream nextPutAll:' encoding:'. encoding storeOn:aStream. |
|
1018 |
aStream nextPut:$) |
|
1019 |
||
1020 |
" |
|
1021 |
(XftFontDescription family: 'DejaVu Sans' size: 8) storeString |
|
1022 |
" |
|
1023 |
! ! |
|
1024 |
||
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1025 |
!XftFontDescription methodsFor:'queries-dimensions'! |
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 |
ascent |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1028 |
"return the ascent - the number of pixels above the baseLine." |
6656 | 1029 |
ascent isNil ifTrue:[ |
8018 | 1030 |
ascent := self class xftFontGetAscent: fontId |
6656 | 1031 |
]. |
1032 |
^ ascent |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1033 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1034 |
"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
|
1035 |
! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1036 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1037 |
descent |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1038 |
"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
|
1039 |
|
6656 | 1040 |
descent isNil ifTrue:[ |
8018 | 1041 |
descent := self class xftFontGetDescent: fontId |
6656 | 1042 |
]. |
1043 |
^ descent |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1044 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1045 |
"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
|
1046 |
! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1047 |
|
6314 | 1048 |
getFontMetrics |
1049 |
|info| |
|
1050 |
||
1051 |
info := DeviceWorkstation::DeviceFontMetrics new. |
|
1052 |
info |
|
1053 |
ascent:self ascent |
|
1054 |
descent:self descent |
|
1055 |
maxAscent:self maxAscent |
|
1056 |
maxDescent:self maxDescent |
|
1057 |
minWidth:self maxWidth |
|
1058 |
maxWidth:self maxWidth |
|
1059 |
avgWidth:self maxWidth |
|
1060 |
minCode:self minCode |
|
1061 |
maxCode:self maxCode |
|
1062 |
direction:#LeftToRight. |
|
1063 |
^ info |
|
1064 |
! |
|
1065 |
||
6543 | 1066 |
getFontResolution |
1067 |
device isNil ifTrue:[ ^ 72 @ 72 ]. |
|
1068 |
^ device resolution |
|
1069 |
! |
|
1070 |
||
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1071 |
height |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1072 |
"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
|
1073 |
|
6656 | 1074 |
height isNil ifTrue:[ |
8018 | 1075 |
false ifTrue:[ |
1076 |
height := self ascent + self descent. |
|
1077 |
] ifFalse:[ |
|
1078 |
height := self class xftFontGetHeight: fontId |
|
1079 |
]. |
|
6656 | 1080 |
]. |
1081 |
^ height |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1082 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1083 |
"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
|
1084 |
! |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1085 |
|
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1086 |
isFixedWidth |
7610 | 1087 |
"return true, if this is a fixed pitch font |
1088 |
(i.e. all characters are of the same width). |
|
1089 |
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
|
1090 |
|
7342 | 1091 |
fixedWidth isNil ifTrue:[ |
8018 | 1092 |
fontId isNil ifTrue:[ |
1093 |
^ false "we don't know yet" |
|
1094 |
]. |
|
1095 |
"/ take some obviously different chars |
|
1096 |
width := self widthOf:' '. |
|
1097 |
fixedWidth := (self widthOf:'i') == width |
|
1098 |
and:[(self widthOf:'W') == width |
|
1099 |
and:[(self widthOf:'.') == width]] |
|
7342 | 1100 |
]. |
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
1101 |
^ 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
|
1102 |
|
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1103 |
"Created: / 21-12-2013 / 10:38:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1104 |
! |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1105 |
|
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
|
1106 |
maxAscent |
7342 | 1107 |
"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
|
1108 |
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
|
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 |
^ 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
|
1111 |
|
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 |
"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
|
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 |
|
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 |
maxDescent |
7342 | 1116 |
"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
|
1117 |
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
|
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 |
^ 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
|
1120 |
|
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 |
"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
|
1122 |
! |
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
|
1123 |
|
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
|
1124 |
maxWidth |
7342 | 1125 |
"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
|
1126 |
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
|
1127 |
|
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
1128 |
self isFixedWidth ifTrue:[ |
8018 | 1129 |
^ width |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
1130 |
]. |
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
1131 |
^ 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
|
1132 |
|
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
|
1133 |
"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
|
1134 |
! |
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
|
1135 |
|
7114 | 1136 |
patternStringForId:patternIdArg |
1137 |
|name family size pixelSize face style encoding foundry width| |
|
1138 |
||
1139 |
patternIdArg notNil ifTrue:[ |
|
1140 |
foundry := patternIdArg get: FC_FOUNDRY index: 0. |
|
1141 |
family := patternIdArg get: FC_FAMILY index: 0. |
|
1142 |
size := patternIdArg get: FC_SIZE index: 0. |
|
1143 |
pixelSize := patternIdArg get: FC_PIXEL_SIZE index: 0. |
|
1144 |
face := patternIdArg get: FC_WEIGHT index: 0. |
|
1145 |
face := StXFace2FCWeightMap keyAtValue: face. |
|
1146 |
style := patternIdArg get: FC_SLANT index: 0. |
|
1147 |
style := StXStyle2FCSlantMap keyAtValue: style. |
|
1148 |
width := patternIdArg get: FC_WIDTH index: 0. |
|
1149 |
||
1150 |
name:= patternIdArg get: 'fullname' index: 0. |
|
1151 |
||
1152 |
encoding:= patternIdArg get: 'encoding' index: 0. |
|
1153 |
]. |
|
1154 |
||
1155 |
^ '%8-%1-%2-%3-%4pt/%5px-%6-%9 (%7)' bindWith:family with:face with:style with:size with:pixelSize with:encoding with:name |
|
1156 |
with:foundry with:width. |
|
1157 |
! |
|
1158 |
||
7342 | 1159 |
width |
1160 |
"return the font's characters width; |
|
1161 |
That is a number of units (usually pixels). |
|
1162 |
For variable pitch fonts, the width of the space character is returned. |
|
1163 |
For fixed fonts, this is the same as minWidth or maxWidth (or any character). |
|
1164 |
The receiver must be associated to a device, for this query to be legal." |
|
1165 |
||
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
1166 |
width isNil ifTrue:[ |
8018 | 1167 |
width := self widthOf:' '. |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
1168 |
]. |
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
1169 |
^ width |
7342 | 1170 |
! |
1171 |
||
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1172 |
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
|
1173 |
"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
|
1174 |
|
6187
cfe33a9940ee
Memory/performance optimization - use stack-allocated XftColor.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6186
diff
changeset
|
1175 |
(stop < start) ifTrue:[^ 0]. |
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
1176 |
fixedWidth == true ifTrue:[ |
8018 | 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:[ |
8018 | 1180 |
self errorNoDevice. |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
1181 |
]. |
7563 | 1182 |
^ 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
|
1183 |
|
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1184 |
"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
|
1185 |
"Modified: / 29-12-2013 / 21:16:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1186 |
! ! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1187 |
|
6200
8f0d25eec888
class: XftFontDescription
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6199
diff
changeset
|
1188 |
!XftFontDescription methodsFor:'release'! |
8f0d25eec888
class: XftFontDescription
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6199
diff
changeset
|
1189 |
|
6344 | 1190 |
releaseFromDevice |
1191 |
"I am no longer available on the device" |
|
1192 |
||
8177 | 1193 |
|deviceID| |
1194 |
||
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
1195 |
(device notNil and:[fontId notNil]) ifTrue:[ |
8177 | 1196 |
(deviceID := device displayId) notNil ifTrue:[ |
1197 |
self class xftFontClose:fontId displayId:deviceID. |
|
1198 |
]. |
|
1199 |
device := nil. |
|
1200 |
fontId := nil. |
|
1201 |
width := nil. |
|
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
1202 |
]. |
8177 | 1203 |
|
1204 |
"Modified: / 15-09-2017 / 12:42:25 / cg" |
|
8178 | 1205 |
! |
1206 |
||
1207 |
restored |
|
1208 |
"flush device handles when restored" |
|
1209 |
||
1210 |
device := nil. |
|
1211 |
fontId := nil. |
|
1212 |
||
1213 |
"Created: / 15-09-2017 / 13:03:55 / cg" |
|
6200
8f0d25eec888
class: XftFontDescription
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6199
diff
changeset
|
1214 |
! ! |
8f0d25eec888
class: XftFontDescription
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6199
diff
changeset
|
1215 |
|
6319 | 1216 |
!XftFontDescription methodsFor:'testing'! |
1217 |
||
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
1218 |
isAlienFont |
7874 | 1219 |
"my GraphicsContext knows how to disply strings in my font. |
1220 |
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
|
1221 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
1222 |
^ false |
7874 | 1223 |
|
1224 |
"Modified (comment): / 12-02-2017 / 22:03:39 / cg" |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
1225 |
! |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
1226 |
|
6319 | 1227 |
isXftFont |
7874 | 1228 |
"anwer true, if this is an Xft font. |
1229 |
Sure, I am" |
|
8018 | 1230 |
|
6319 | 1231 |
^ true |
7874 | 1232 |
|
1233 |
"Modified (comment): / 12-02-2017 / 22:04:23 / cg" |
|
6319 | 1234 |
! ! |
1235 |
||
7116 | 1236 |
!XftFontDescription::FCFontListParser class methodsFor:'api'! |
1237 |
||
1238 |
listOfAvailableFonts |
|
1239 |
^ self new listOfAvailableFonts |
|
1240 |
||
1241 |
" |
|
1242 |
self listOfAvailableFonts |
|
1243 |
" |
|
1244 |
! ! |
|
1245 |
||
6264 | 1246 |
!XftFontDescription::FCFontListParser class methodsFor:'documentation'! |
1247 |
||
1248 |
documentation |
|
1249 |
" |
|
1250 |
parses fc-list output to get a list of XftFontDescriptions |
|
1251 |
||
1252 |
[author:] |
|
6319 | 1253 |
cg |
6264 | 1254 |
|
1255 |
[instance variables:] |
|
1256 |
||
1257 |
[class variables:] |
|
1258 |
||
1259 |
[see also:] |
|
1260 |
||
1261 |
" |
|
1262 |
! ! |
|
1263 |
||
6263 | 1264 |
!XftFontDescription::FCFontListParser methodsFor:'api'! |
1265 |
||
1266 |
listOfAvailableFonts |
|
8369 | 1267 |
"opens a pipe to '/usr/bin/fc-list' or '/usr/X11/bin/fc-list' |
1268 |
and reads all known fonts from it" |
|
1269 |
||
1270 |
"self new listOfAvailableFonts" |
|
1271 |
||
8356 | 1272 |
|readEntry list fcListProg shellEnvironment| |
6263 | 1273 |
|
1274 |
list := OrderedCollection new. |
|
1275 |
||
7116 | 1276 |
readEntry := [ |
8356 | 1277 |
|key line| |
6263 | 1278 |
|
8356 | 1279 |
[ |
1280 |
line := pipeStream nextLine. |
|
1281 |
] doUntil:[(line startsWith:'Pattern has') or:[Transcript showCR:line. false]]. |
|
6263 | 1282 |
|
8356 | 1283 |
currentDescription := XftFontDescription new. |
1284 |
[line := pipeStream nextLine. line notEmptyOrNil] whileTrue:[ |
|
1285 |
"/ Transcript showCR:l. |
|
1286 |
lineStream := line readStream. lineStream skipSeparators. |
|
1287 |
key := ('fc_', (lineStream upTo:$:)) asSymbolIfInterned. |
|
1288 |
( |
|
1289 |
#(fc_family fc_style fc_slant fc_weight fc_width |
|
1290 |
fc_pixelsize fc_spacing fc_foundry fc_antialias |
|
1291 |
fc_file fc_outline fc_scalable fc_charset fc_lang |
|
1292 |
fc_fontversion fc_fontformat fc_decorative fc_index |
|
1293 |
fc_outline fc_familylang fc_stylelang fc_fullname |
|
1294 |
fc_fullnamelang fc_capability fc_hash fc_postscriptname |
|
1295 |
fc_symbol fc_color |
|
1296 |
) includesIdentical:key |
|
1297 |
) ifTrue:[ |
|
1298 |
self perform:key. |
|
1299 |
] ifFalse:[ |
|
1300 |
Transcript show:'Xft ignored line: '; showCR:line. |
|
1301 |
]. |
|
1302 |
]. |
|
1303 |
list add:currentDescription |
|
1304 |
]. |
|
6319 | 1305 |
|
6337 | 1306 |
fcListProg := #('/usr/bin/fc-list' '/usr/X11/bin/fc-list') detect:[:eachProg| |
8356 | 1307 |
eachProg asFilename isExecutableProgram |
1308 |
] ifNone:[ |
|
1309 |
'XftFontDescription [warning]: fc-list program not found - no XFT fonts' errorPrintCR. |
|
1310 |
^ list. |
|
1311 |
]. |
|
6337 | 1312 |
|
8356 | 1313 |
"/ to suppress the disturbing warning message |
1314 |
"/ if LC_CTYPE is wrong (osx problem) |
|
8370 | 1315 |
shellEnvironment := Dictionary new. |
1316 |
shellEnvironment at:'LC_CTYPE' put:XftFontDescription fixedLC_CTYPE. |
|
8356 | 1317 |
|
1318 |
pipeStream := PipeStream |
|
1319 |
readingFrom:fcListProg, ' -v' |
|
1320 |
environment:shellEnvironment. |
|
6263 | 1321 |
[ |
8356 | 1322 |
[pipeStream atEnd] whileFalse:[ |
1323 |
readEntry value. |
|
1324 |
] |
|
6263 | 1325 |
] ensure:[ |
8356 | 1326 |
pipeStream close |
6263 | 1327 |
]. |
1328 |
^ list |
|
1329 |
||
1330 |
" |
|
6337 | 1331 |
FCFontListParser new listOfAvailableFonts |
6263 | 1332 |
" |
1333 |
! ! |
|
1334 |
||
1335 |
!XftFontDescription::FCFontListParser methodsFor:'font list keywords'! |
|
1336 |
||
1337 |
fc_antialias |
|
1338 |
"helper for font listing" |
|
1339 |
||
6319 | 1340 |
currentDescription isAntialiasedFont:(self getBoolean). |
6263 | 1341 |
! |
1342 |
||
1343 |
fc_charset |
|
1344 |
"helper for font listing" |
|
1345 |
||
6319 | 1346 |
|page bits l min max minCode maxCode| |
6263 | 1347 |
|
1348 |
[ l := pipeStream nextLine. l notEmpty ] whileTrue:[ |
|
7221 | 1349 |
"/ Transcript show:'->'; showCR:l. |
1350 |
(l startsWith:Character tab) ifFalse:[ |
|
1351 |
(l startsWith:'(') ifFalse:[self halt]. |
|
1352 |
currentDescription minCode:minCode; maxCode:maxCode. |
|
1353 |
^ self. |
|
1354 |
]. |
|
6264 | 1355 |
|
7221 | 1356 |
lineStream := l readStream. |
1357 |
lineStream skipSeparators. |
|
1358 |
page := Integer readFrom:(lineStream upTo:$:) radix:16. |
|
1359 |
lineStream next. |
|
1360 |
bits := 0 to:7 collect:[:i| |
|
1361 |
lineStream skipSeparators. |
|
1362 |
Integer readFrom:(lineStream upToSeparator) radix:16. |
|
1363 |
]. |
|
1364 |
min := (page * 256 + 0). |
|
1365 |
max := (page * 256 + 255). |
|
1366 |
minCode isNil ifTrue:[ |
|
1367 |
minCode := min. |
|
1368 |
maxCode := max. |
|
1369 |
] ifFalse:[ |
|
1370 |
minCode := minCode min:min. |
|
1371 |
maxCode := maxCode max:max. |
|
1372 |
]. |
|
6263 | 1373 |
]. |
6365
cf89c4bedea4
Instvar drawId renamed to sharedDrawId.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6356
diff
changeset
|
1374 |
"/ currentDescription characterSet:(self getString). |
7116 | 1375 |
currentDescription minCode:minCode; maxCode:maxCode. |
6263 | 1376 |
! |
1377 |
||
6319 | 1378 |
fc_decorative |
6263 | 1379 |
"helper for font listing" |
1380 |
||
6319 | 1381 |
currentDescription isDecorativeFont:(self getBoolean). |
6263 | 1382 |
! |
1383 |
||
1384 |
fc_family |
|
1385 |
"helper for font listing" |
|
1386 |
||
6319 | 1387 |
currentDescription family:(self getString). |
6263 | 1388 |
! |
1389 |
||
6319 | 1390 |
fc_file |
6263 | 1391 |
"helper for font listing" |
1392 |
||
6319 | 1393 |
currentDescription file:(self getString). |
6263 | 1394 |
! |
1395 |
||
1396 |
fc_fontformat |
|
1397 |
"helper for font listing" |
|
1398 |
||
6319 | 1399 |
currentDescription fontFormat:(self getString). |
6263 | 1400 |
! |
1401 |
||
1402 |
fc_fontversion |
|
1403 |
"helper for font listing" |
|
1404 |
||
6319 | 1405 |
currentDescription fontVersion:(self getInteger). |
6263 | 1406 |
! |
1407 |
||
1408 |
fc_foundry |
|
1409 |
"helper for font listing" |
|
1410 |
||
7121 | 1411 |
|foundry| |
1412 |
||
1413 |
foundry := self getString. |
|
7221 | 1414 |
foundry ~= 'unknown' ifTrue:[ |
1415 |
currentDescription foundry:foundry. |
|
7121 | 1416 |
]. |
6263 | 1417 |
! |
1418 |
||
6264 | 1419 |
fc_fullname |
1420 |
"helper for font listing" |
|
1421 |
||
7121 | 1422 |
currentDescription name:self getString. |
6264 | 1423 |
! |
1424 |
||
6263 | 1425 |
fc_outline |
1426 |
"helper for font listing" |
|
1427 |
||
6319 | 1428 |
currentDescription isOutlineFont:(self getBoolean). |
6263 | 1429 |
! |
1430 |
||
1431 |
fc_pixelsize |
|
1432 |
"helper for font listing" |
|
1433 |
||
6325 | 1434 |
currentDescription setPixelSize:(self getInteger). |
1435 |
currentDescription setSizeUnit:#px. |
|
1436 |
"/ currentDescription setSize:(self getInteger). |
|
1437 |
"/ currentDescription setSizeUnit:#pt. |
|
6263 | 1438 |
! |
1439 |
||
1440 |
fc_scalable |
|
1441 |
"helper for font listing" |
|
1442 |
||
6957 | 1443 |
currentDescription isScalableFont:self getBoolean. |
6263 | 1444 |
! |
1445 |
||
1446 |
fc_slant |
|
1447 |
"helper for font listing" |
|
1448 |
||
6319 | 1449 |
currentDescription slant:(self getInteger). |
6263 | 1450 |
! |
1451 |
||
1452 |
fc_spacing |
|
1453 |
"helper for font listing" |
|
1454 |
||
6319 | 1455 |
currentDescription spacing:(self getInteger). |
6263 | 1456 |
! |
1457 |
||
1458 |
fc_style |
|
1459 |
"helper for font listing" |
|
1460 |
||
6319 | 1461 |
|xftStyle| |
1462 |
||
7121 | 1463 |
xftStyle := self getString asLowercase. |
1464 |
(xftStyle includesString:'italic') ifTrue:[ |
|
7221 | 1465 |
currentDescription style:#italic. |
1466 |
^ self. |
|
6319 | 1467 |
]. |
7121 | 1468 |
(xftStyle includesString:'oblique') ifTrue:[ |
7221 | 1469 |
currentDescription style:#oblique. |
1470 |
^ self. |
|
7121 | 1471 |
]. |
1472 |
currentDescription style:#roman. |
|
6263 | 1473 |
! |
1474 |
||
1475 |
fc_weight |
|
1476 |
"helper for font listing" |
|
1477 |
||
6319 | 1478 |
currentDescription weight:(self getInteger). |
6263 | 1479 |
! |
1480 |
||
1481 |
fc_width |
|
1482 |
"helper for font listing" |
|
1483 |
||
6319 | 1484 |
currentDescription width:(self getInteger). |
6263 | 1485 |
! ! |
1486 |
||
7488 | 1487 |
!XftFontDescription::FCFontListParser methodsFor:'font list keywords - ignored'! |
1488 |
||
1489 |
fc_capability |
|
1490 |
"helper for font listing" |
|
1491 |
||
1492 |
"currentDescription capability:" (self getString). |
|
1493 |
! |
|
1494 |
||
1495 |
fc_color |
|
1496 |
"helper for font listing - ignored for now" |
|
1497 |
||
1498 |
"currentDescription isColorFont:"(self getBoolean). |
|
1499 |
! |
|
1500 |
||
1501 |
fc_familylang |
|
1502 |
"helper for font listing" |
|
1503 |
||
1504 |
"currentDescription familylang:" (self getString). |
|
1505 |
! |
|
1506 |
||
1507 |
fc_fullnamelang |
|
1508 |
"helper for font listing" |
|
1509 |
||
1510 |
"currentDescription fullnamelang:" (self getString). |
|
1511 |
! |
|
1512 |
||
1513 |
fc_hash |
|
1514 |
"helper for font listing" |
|
1515 |
||
1516 |
"currentDescription hash:" self getString. |
|
1517 |
! |
|
1518 |
||
1519 |
fc_index |
|
1520 |
"helper for font listing" |
|
1521 |
||
1522 |
"currentDescription index:" (self getInteger). |
|
1523 |
! |
|
1524 |
||
1525 |
fc_lang |
|
1526 |
"helper for font listing" |
|
1527 |
||
1528 |
"/ currentDescription characterSet:(self getString). |
|
1529 |
! |
|
1530 |
||
1531 |
fc_postscriptname |
|
1532 |
"helper for font listing" |
|
1533 |
||
1534 |
"currentDescription postscriptname:" self getString. |
|
1535 |
! |
|
1536 |
||
1537 |
fc_stylelang |
|
1538 |
"helper for font listing" |
|
1539 |
||
1540 |
"currentDescription stylelang:" (self getString). |
|
1541 |
! |
|
1542 |
||
1543 |
fc_symbol |
|
1544 |
"helper for font listing - ignored for now" |
|
1545 |
||
1546 |
"currentDescription isSymbolFont:"(self getBoolean). |
|
1547 |
! ! |
|
1548 |
||
6263 | 1549 |
!XftFontDescription::FCFontListParser methodsFor:'helpers'! |
1550 |
||
6319 | 1551 |
getBoolean |
6263 | 1552 |
"helper for font listing" |
1553 |
||
1554 |
|s| |
|
1555 |
||
1556 |
lineStream skipSeparators. |
|
6319 | 1557 |
s := lineStream nextAlphaNumericWord. |
6957 | 1558 |
^ (s indexOfSubCollection:'True') ~~ 0. "/ match at least 'True' and 'FCTrue' |
6963 | 1559 |
|
1560 |
" |
|
7114 | 1561 |
'xxFalse' indexOfSubCollection:'True' |
1562 |
'FcTrue' indexOfSubCollection:'True' |
|
6963 | 1563 |
" |
6263 | 1564 |
! |
1565 |
||
6264 | 1566 |
getInteger |
1567 |
"helper for font listing" |
|
1568 |
||
1569 |
lineStream skipSeparators. |
|
6319 | 1570 |
^ Integer readFrom:lineStream. |
6264 | 1571 |
! |
1572 |
||
6319 | 1573 |
getString |
6263 | 1574 |
"helper for font listing" |
1575 |
||
7116 | 1576 |
lineStream skipThrough:$". |
1577 |
^ lineStream upTo:$". |
|
6263 | 1578 |
! ! |
1579 |
||
7114 | 1580 |
!XftFontDescription::FCPatternHandle class methodsFor:'instance creation'! |
1581 |
||
1582 |
create |
|
1583 |
^ self new create |
|
1584 |
||
1585 |
" |
|
1586 |
self new create destroy |
|
1587 |
" |
|
1588 |
! ! |
|
1589 |
||
1590 |
!XftFontDescription::FCPatternHandle methodsFor:'primitives'! |
|
1591 |
||
1592 |
add:attribute value: value |
|
1593 |
"Add a value to the specified pattern element after existing values" |
|
1594 |
||
1595 |
^ self add: attribute value: value append: true. |
|
1596 |
! |
|
1597 |
||
1598 |
add:attribute value: value append: append |
|
1599 |
"Add a value to the specified pattern element. If 'append' is true, the value |
|
1600 |
is added after existing values, otherwise it is added before them." |
|
1601 |
||
1602 |
| error | |
|
1603 |
||
7221 | 1604 |
%{ /* STACK: 64000 */ |
7114 | 1605 |
#ifdef XFT |
1606 |
XftValue v; |
|
1607 |
Bool b; |
|
1608 |
||
1609 |
if (__INST(address_) == 0) { |
|
1610 |
error = @symbol(NullReceiver); |
|
1611 |
goto err; |
|
1612 |
} |
|
1613 |
if ( ! __isStringLike ( attribute ) ) { |
|
1614 |
error = @symbol(BadArg1); |
|
1615 |
goto err; |
|
1616 |
} |
|
1617 |
if ( append != true && append != false ) { |
|
1618 |
error = @symbol(BadArg3); |
|
1619 |
goto err; |
|
1620 |
} |
|
1621 |
if ( __isStringLike ( value ) ) { |
|
1622 |
v.type = FcTypeString; |
|
1623 |
/* Passing pointer inside Smalltalk should be safe, |
|
1624 |
* Xft/FontConfig libraries seem to allocate and store |
|
1625 |
* a __copy__ of the string (if I understood the code correctly) |
|
1626 |
*/ |
|
1627 |
v.u.s = __stringVal( value); |
|
1628 |
} else if ( __isSmallInteger( value ) ) { |
|
1629 |
v.type = XftTypeInteger; |
|
1630 |
v.u.i = (int)__intVal( value ); |
|
1631 |
} else if ( value == true || value == false ) { |
|
1632 |
v.type = XftTypeBool; |
|
1633 |
v.u.b = value == true ? True : False; |
|
1634 |
} else if ( __isFloat ( value ) ) { |
|
1635 |
v.type = XftTypeDouble; |
|
1636 |
v.u.d = __floatVal( value ); |
|
1637 |
} else if ( value == nil ) { |
|
1638 |
v.type = XftTypeVoid; |
|
1639 |
v.u.f = NULL; |
|
1640 |
} else { |
|
1641 |
error = @symbol(BadArg2); |
|
1642 |
goto err; |
|
1643 |
} |
|
1644 |
b = XftPatternAdd((XftPattern*)__INST(address_), __stringVal(attribute), v, append == true ? True : False ); |
|
1645 |
RETURN ( b == True ? true : false ); |
|
1646 |
||
1647 |
err:; |
|
1648 |
#endif |
|
1649 |
%}. |
|
1650 |
self primitiveFailed: error |
|
1651 |
||
1652 |
"Created: / 20-12-2013 / 21:50:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1653 |
! |
|
1654 |
||
1655 |
create |
|
1656 |
%{ |
|
1657 |
#ifdef XFT |
|
1658 |
__INST(address_) = (void *)XftPatternCreate(); |
|
1659 |
#endif |
|
1660 |
%}. |
|
1661 |
! |
|
1662 |
||
1663 |
delete: pattern attribute: attribute |
|
1664 |
| error | |
|
7221 | 1665 |
%{ /* STACK: 64000 */ |
7114 | 1666 |
#ifdef XFT |
1667 |
if (__INST(address_) == 0) { |
|
7221 | 1668 |
error = @symbol(BadHandle); |
1669 |
goto err; |
|
7114 | 1670 |
} |
1671 |
if ( ! __isStringLike ( attribute ) ) { |
|
7221 | 1672 |
error = @symbol(BadArg1); |
1673 |
goto err; |
|
7114 | 1674 |
} |
1675 |
XftPatternDel( (XftPattern*)__INST(address_), __stringVal ( attribute ) ); |
|
1676 |
RETURN ( self ); |
|
1677 |
||
1678 |
err:; |
|
1679 |
#endif |
|
1680 |
%}. |
|
1681 |
self primitiveFailed: error |
|
1682 |
! |
|
1683 |
||
1684 |
destroy |
|
7221 | 1685 |
%{ /* STACK: 64000 */ |
7114 | 1686 |
#ifdef XFT |
1687 |
if (__INST(address_) != 0) { |
|
1688 |
XftPatternDestroy((XftPattern*)__INST(address_)); |
|
1689 |
__INST(address_) = 0; |
|
1690 |
RETURN ( self ); |
|
1691 |
} |
|
1692 |
#endif |
|
1693 |
%}. |
|
1694 |
self primitiveFailed. |
|
1695 |
! |
|
1696 |
||
1697 |
duplicate |
|
1698 |
| error | |
|
1699 |
%{ |
|
1700 |
#ifdef XFT |
|
1701 |
if (__INST(address_) != 0) { |
|
1702 |
RETURN (FC_PATTERN_HANDLE_NEW((XftPattern*)__INST(address_))); |
|
1703 |
RETURN ( self ); |
|
1704 |
} |
|
1705 |
#endif |
|
1706 |
%}. |
|
1707 |
self primitiveFailed |
|
1708 |
! |
|
1709 |
||
1710 |
get:attribute index: index |
|
1711 |
"Return a value from the specified element -- multiple values can be indexed |
|
1712 |
with 'index' starting at zero." |
|
1713 |
||
1714 |
| error | |
|
1715 |
||
7221 | 1716 |
%{ /* STACK: 64000 */ |
7114 | 1717 |
#ifdef XFT |
1718 |
XftValue v; |
|
1719 |
XftResult r; |
|
1720 |
||
1721 |
if (__INST(address_) == 0) { |
|
1722 |
error = @symbol(NullReceiver); |
|
1723 |
goto err; |
|
1724 |
} |
|
1725 |
if ( ! __isStringLike ( attribute ) ) { |
|
1726 |
error = @symbol(BadArg1); |
|
1727 |
goto err; |
|
1728 |
} |
|
1729 |
if ( ! __isSmallInteger( index ) ) { |
|
1730 |
error = @symbol(BadArg2); |
|
1731 |
goto err; |
|
1732 |
} |
|
1733 |
r = XftPatternGet((XftPattern*)__INST(address_), __stringVal( attribute ), __intVal( index ), &v); |
|
1734 |
if ( r != XftResultMatch) { |
|
1735 |
RETURN ( nil ); |
|
1736 |
} |
|
1737 |
if ( v.type == XftTypeString) { |
|
1738 |
RETURN ( __MKSTRING(v.u.s) ); |
|
1739 |
} else if ( v.type == XftTypeInteger ) { |
|
1740 |
RETURN ( __MKINT (v.u.i) ); |
|
1741 |
} else if ( v.type == XftTypeBool ) { |
|
1742 |
RETURN ( v.u.b == True ? true : false ); |
|
1743 |
} else if ( v.type == XftTypeDouble ) { |
|
1744 |
RETURN ( __MKFLOAT (v.u.d) ); |
|
1745 |
} else if ( v.type == XftTypeVoid ) { |
|
1746 |
RETURN ( nil ); |
|
1747 |
} else { |
|
1748 |
error = @symbol(UnssuportedTypeValue); |
|
1749 |
goto err; |
|
1750 |
} |
|
1751 |
err:; |
|
1752 |
#endif |
|
1753 |
%}. |
|
1754 |
self primitiveFailed: error |
|
1755 |
! |
|
1756 |
||
1757 |
getFontOnDisplayId:displayId |
|
1758 |
"Note: the pattern is destroyed when the font is closed" |
|
1759 |
||
1760 |
| error | |
|
1761 |
||
1762 |
%{ /* STACK: 64000 */ |
|
1763 |
#ifdef XFT |
|
1764 |
XftFont* f; |
|
1765 |
if (!__isExternalAddressLike(displayId) ) { |
|
7221 | 1766 |
error = @symbol(BadArg1); |
1767 |
goto err; |
|
7114 | 1768 |
} |
1769 |
if (__INST(address_) == 0) { |
|
7221 | 1770 |
error = @symbol(BadHandle); |
1771 |
goto err; |
|
7114 | 1772 |
} |
1773 |
||
1774 |
f = XftFontOpenPattern(DISPLAY(displayId), (XftPattern*)__INST(address_)); |
|
1775 |
if (f == NULL) { |
|
7221 | 1776 |
RETURN (nil); |
7114 | 1777 |
} else { |
7221 | 1778 |
RETURN (XFT_FONT_HANDLE_NEW(f)); |
7114 | 1779 |
} |
1780 |
err:; |
|
1781 |
#endif |
|
1782 |
%}. |
|
1783 |
self primitiveFailed: error |
|
1784 |
||
1785 |
"Created: / 20-12-2013 / 23:53:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1786 |
! |
|
1787 |
||
1788 |
matchFontOnDisplayId:displayId screen:screen |
|
1789 |
| error | |
|
1790 |
||
1791 |
%{ /* STACK: 64000 */ |
|
1792 |
#ifdef XFT |
|
1793 |
XftPattern *p; |
|
1794 |
XftResult r; |
|
1795 |
||
1796 |
if (!__isExternalAddressLike(displayId)) { |
|
7221 | 1797 |
error = @symbol(BadArg1); |
1798 |
goto err; |
|
7114 | 1799 |
} |
1800 |
if (!__isSmallInteger( screen) ) { |
|
7221 | 1801 |
error = @symbol(BadArg2); |
1802 |
goto err; |
|
7114 | 1803 |
} |
1804 |
if (__INST(address_) == 0) { |
|
7221 | 1805 |
error = @symbol(BadHandle); |
1806 |
goto err; |
|
7114 | 1807 |
} |
1808 |
||
1809 |
// Already done in match: |
|
1810 |
// XftConfigSubstitute(FC_PATTERN( patternId )); |
|
1811 |
// XftDefaultSubstitute(DISPLAY(displayId), SCREEN( screen ), FC_PATTERN( patternId )); |
|
1812 |
p = XftFontMatch(DISPLAY(displayId), SCREEN(screen), (XftPattern*)__INST(address_), &r); |
|
1813 |
if (p) { |
|
7221 | 1814 |
RETURN (FC_PATTERN_HANDLE_NEW(p) ); |
7114 | 1815 |
} else { |
7221 | 1816 |
error = @symbol(XftFontMatchReturnedNull); |
7114 | 1817 |
} |
1818 |
err:; |
|
1819 |
#endif |
|
1820 |
%}. |
|
1821 |
self primitiveFailed: error |
|
1822 |
||
1823 |
"Created: / 21-12-2013 / 00:08:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1824 |
! ! |
|
1825 |
||
1826 |
!XftFontDescription::XftDrawHandle class methodsFor:'instance creation'! |
|
1827 |
||
1828 |
createForDisplayId:displayId screen:screen drawable:drawableId |
|
1829 |
^ self new createForDisplayId:displayId screen:screen drawable:drawableId |
|
1830 |
! ! |
|
1831 |
||
1832 |
!XftFontDescription::XftDrawHandle methodsFor:'primitives'! |
|
1833 |
||
1834 |
createForDisplayId:displayId screen:screen drawable:drawableId |
|
1835 |
| error | |
|
1836 |
||
1837 |
%{ /* STACK: 64000 */ |
|
1838 |
#ifdef XFT |
|
1839 |
if ( ! __isExternalAddressLike(displayId) ) { |
|
7221 | 1840 |
error = @symbol(BadArg1); |
1841 |
goto err; |
|
7114 | 1842 |
} |
1843 |
if ( ! __isSmallInteger(screen) ) { |
|
7221 | 1844 |
error = @symbol(BadArg2); |
1845 |
goto err; |
|
7114 | 1846 |
} |
1847 |
if ( ! __isExternalAddressLike(drawableId) ) { |
|
7221 | 1848 |
error = @symbol(BadArg3); |
1849 |
goto err; |
|
7114 | 1850 |
} |
1851 |
__INST(address_) = (void *) XftDrawCreate ( DISPLAY(displayId) , |
|
7221 | 1852 |
DRAWABLE(drawableId) , |
1853 |
DefaultVisual(DISPLAY(displayId), SCREEN (screen)) , |
|
1854 |
DefaultColormap(DISPLAY(displayId), SCREEN (screen))); |
|
7114 | 1855 |
err:; |
1856 |
#endif |
|
1857 |
%}. |
|
1858 |
self primitiveFailed: error |
|
1859 |
||
1860 |
"Created: / 21-12-2013 / 21:12:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1861 |
! |
|
1862 |
||
1863 |
destroy |
|
1864 |
%{ /* STACK: 64000 */ |
|
1865 |
#ifdef XFT |
|
1866 |
if (__INST(address_) != 0) { |
|
7221 | 1867 |
XftDrawDestroy((XftDraw*)__INST(address_)); |
1868 |
__INST(address_) = 0; |
|
1869 |
RETURN ( self ); |
|
7114 | 1870 |
} |
1871 |
#endif |
|
1872 |
%}. |
|
1873 |
self primitiveFailed. |
|
1874 |
! |
|
1875 |
||
1876 |
disassociateFrom:drawableId |
|
1877 |
"Disassociate the XftDrawable from drawableId. |
|
1878 |
This mist be done before the drawable is destroyed, |
|
1879 |
otherwise the XftDrawable is destroyed together with the drawable, |
|
1880 |
and X11 errors will be signaled." |
|
1881 |
||
1882 |
| error | |
|
1883 |
||
1884 |
%{ /* STACK: 64000 */ |
|
1885 |
#ifdef XFT |
|
1886 |
if (__INST(address_) == 0) { |
|
7221 | 1887 |
// nothing to disasassociate from... |
1888 |
RETURN(self); |
|
7114 | 1889 |
} |
1890 |
if (!__isExternalAddressLike(drawableId)) { |
|
7221 | 1891 |
error = @symbol(BadArg); |
1892 |
goto err; |
|
7114 | 1893 |
} |
1894 |
if (XftDrawDrawable((XftDraw*)__INST(address_)) == DRAWABLE(drawableId)) { |
|
7221 | 1895 |
XftDrawChange((XftDraw*)__INST(address_), None); |
7114 | 1896 |
} |
1897 |
RETURN(self); |
|
1898 |
err:; |
|
1899 |
#endif |
|
1900 |
%}. |
|
1901 |
self primitiveFailed: error |
|
1902 |
||
1903 |
"Created: / 26-12-2013 / 12:17:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1904 |
! |
|
1905 |
||
1906 |
drawChange:drawableId |
|
1907 |
| error | |
|
1908 |
||
1909 |
%{ /* STACK: 64000 */ |
|
1910 |
#ifdef XFT |
|
1911 |
if (drawableId == nil) { |
|
7221 | 1912 |
XftDrawChange((XftDraw*)__INST(address_), None); |
1913 |
RETURN (self); |
|
7114 | 1914 |
} |
1915 |
if (!__isExternalAddressLike(drawableId)) { |
|
7221 | 1916 |
error = @symbol(BadArg1); |
1917 |
goto err; |
|
7114 | 1918 |
} |
1919 |
if (XftDrawDrawable((XftDraw*)__INST(address_)) != DRAWABLE( drawableId)) { |
|
7221 | 1920 |
XftDrawChange((XftDraw*)__INST(address_), DRAWABLE( drawableId)); |
7114 | 1921 |
} |
1922 |
RETURN (self); |
|
1923 |
err:; |
|
1924 |
#endif |
|
1925 |
%}. |
|
1926 |
self primitiveFailed: error |
|
1927 |
||
1928 |
"Created: / 26-12-2013 / 12:17:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1929 |
! |
|
1930 |
||
1931 |
drawRectWithColor:aColor x:x y:y width:w height:h |
|
1932 |
| error r g b a pix | |
|
1933 |
||
1934 |
aColor isColor ifFalse:[^self primitiveFailed: #BadArg1]. |
|
1935 |
||
1936 |
r := aColor scaledRed. |
|
1937 |
g := aColor scaledGreen. |
|
1938 |
b := aColor scaledBlue. |
|
1939 |
a := aColor alpha * 65535. |
|
1940 |
r isNil ifTrue:[ |
|
7221 | 1941 |
"/ when drawing into a pixmap... |
1942 |
aColor colorId == 0 ifTrue:[ |
|
1943 |
r := g := b := 0. |
|
1944 |
] ifFalse:[ |
|
1945 |
r := g := b := 16rFFFF. |
|
1946 |
] |
|
7114 | 1947 |
]. |
1948 |
pix := aColor colorId. |
|
1949 |
%{ /* STACK: 64000 */ |
|
1950 |
#ifdef XFT |
|
1951 |
XftColor clr; |
|
1952 |
||
1953 |
if (__INST(address_) == 0) { |
|
7221 | 1954 |
error = @symbol(BadHandle); |
1955 |
goto err; |
|
7114 | 1956 |
} |
1957 |
if (!__isSmallInteger(pix)) { |
|
7221 | 1958 |
error = @symbol(BadColorId); |
1959 |
goto err; |
|
7114 | 1960 |
} |
1961 |
if (!__isSmallInteger(x)) { |
|
7221 | 1962 |
error = @symbol(BadArg2); |
1963 |
goto err; |
|
7114 | 1964 |
} |
1965 |
if (! __isSmallInteger(y)) { |
|
7221 | 1966 |
error = @symbol(BadArg3); |
1967 |
goto err; |
|
7114 | 1968 |
} |
1969 |
if (!__isSmallInteger(w)) { |
|
7221 | 1970 |
error = @symbol(BadArg4); |
1971 |
goto err; |
|
7114 | 1972 |
} |
1973 |
if (!__isSmallInteger(h)) { |
|
7221 | 1974 |
error = @symbol(BadArg5); |
1975 |
goto err; |
|
7114 | 1976 |
} |
1977 |
clr.pixel = (unsigned long)__intVal(pix); |
|
1978 |
clr.color.red = __intVal(r); |
|
1979 |
clr.color.green = __intVal(g); |
|
1980 |
clr.color.blue = __intVal(b); |
|
1981 |
clr.color.alpha = __intVal(a); |
|
1982 |
||
1983 |
XftDrawRect((XftDraw*)__INST(address_), &clr, |
|
7221 | 1984 |
__intVal(x), __intVal(y), __intVal(w) ,__intVal(h)); |
7114 | 1985 |
|
1986 |
RETURN (self); |
|
1987 |
err:; |
|
1988 |
#endif |
|
1989 |
%}. |
|
1990 |
self primitiveFailed: error. |
|
1991 |
||
1992 |
"Created: / 28-12-2013 / 23:35:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1993 |
"Modified: / 31-12-2013 / 00:37:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1994 |
! |
|
1995 |
||
1996 |
drawString:aString color:aColor font:fontIdArg x:x y:y from:start to:stop |
|
1997 |
| error r g b a pix | |
|
1998 |
||
1999 |
aColor isColor ifFalse:[^self primitiveFailed: #BadArg2]. |
|
2000 |
||
2001 |
pix := aColor colorId. |
|
2002 |
r := aColor scaledRed. |
|
2003 |
r isNil ifTrue:[ |
|
7221 | 2004 |
"/ when drawing into a pixmap... |
2005 |
pix == 0 ifTrue:[ |
|
2006 |
r := g := b := a := 0. |
|
2007 |
] ifFalse:[ |
|
2008 |
r := g := b := a := 16rFFFF. |
|
2009 |
] |
|
7114 | 2010 |
] ifFalse:[ |
7221 | 2011 |
g := aColor scaledGreen. |
2012 |
b := aColor scaledBlue. |
|
2013 |
a := aColor alpha * 65535. |
|
7114 | 2014 |
]. |
2015 |
%{ /* STACK: 64000 */ |
|
2016 |
#ifdef XFT |
|
2017 |
int _start, _stop; |
|
2018 |
int __x, __y; |
|
2019 |
XftColor clr; |
|
2020 |
||
2021 |
if (__INST(address_) == 0) { |
|
7221 | 2022 |
error = @symbol(BadHandle); |
2023 |
goto err; |
|
7114 | 2024 |
} |
2025 |
if ( ! __isSmallInteger(pix) ) { |
|
7221 | 2026 |
error = @symbol(BadColorId); |
2027 |
goto err; |
|
7114 | 2028 |
} |
2029 |
if ( ! __isSmallInteger(x) ) { |
|
7221 | 2030 |
error = @symbol(BadArg4); |
2031 |
goto err; |
|
7114 | 2032 |
} |
2033 |
__x = __intVal(x); |
|
2034 |
if ( ! __isSmallInteger(y) ) { |
|
7221 | 2035 |
error = @symbol(BadArg5); |
2036 |
goto err; |
|
7114 | 2037 |
} |
2038 |
__y = __intVal(y); |
|
2039 |
||
2040 |
||
2041 |
if ( ! __isSmallInteger(start) ) { |
|
7221 | 2042 |
error = @symbol(BadArg6); |
2043 |
goto err; |
|
7114 | 2044 |
} |
2045 |
_start = __intVal(start); |
|
2046 |
if ( ! __isSmallInteger(stop) ) { |
|
7221 | 2047 |
error = @symbol(BadArg7); |
2048 |
goto err; |
|
7114 | 2049 |
} |
2050 |
_stop = __intVal(stop); |
|
2051 |
||
2052 |
clr.pixel = (unsigned long)__intVal(pix); |
|
2053 |
clr.color.red = __intVal(r); |
|
2054 |
clr.color.green = __intVal(g); |
|
2055 |
clr.color.blue = __intVal(b); |
|
2056 |
clr.color.alpha = __intVal(a); |
|
2057 |
||
2058 |
if ( __isStringLike(aString) ) { |
|
7221 | 2059 |
XftDrawString8((XftDraw*)__INST(address_), &clr, XFT_FONT(fontIdArg), |
2060 |
__x, __y, |
|
2061 |
__stringVal(aString) + (_start - 1), _stop - _start + 1); |
|
2062 |
RETURN ( self ); |
|
7114 | 2063 |
} else { |
7221 | 2064 |
error = @symbol(BadArg1); |
2065 |
goto err; |
|
7114 | 2066 |
} |
2067 |
err:; |
|
2068 |
#endif |
|
2069 |
%}. |
|
2070 |
self primitiveFailed: error. |
|
2071 |
||
2072 |
"Created: / 28-12-2013 / 12:32:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2073 |
"Modified: / 30-12-2013 / 20:00:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2074 |
! |
|
2075 |
||
2076 |
setClipRect:rect |
|
2077 |
| error xObj yObj wObj hObj | |
|
2078 |
||
2079 |
rect notNil ifTrue:[ |
|
7221 | 2080 |
xObj := rect left. |
2081 |
yObj := rect top. |
|
2082 |
wObj := rect width. |
|
2083 |
hObj := rect height. |
|
7114 | 2084 |
]. |
2085 |
%{ /* STACK: 64000 */ |
|
2086 |
#ifdef XFT |
|
2087 |
if (__INST(address_) == 0) { |
|
7221 | 2088 |
error = @symbol(BadHandle); |
2089 |
goto err; |
|
7114 | 2090 |
} |
2091 |
if (rect != nil) { |
|
7221 | 2092 |
XRectangle r; |
7114 | 2093 |
|
7221 | 2094 |
r.x = __intVal(xObj); |
2095 |
r.y = __intVal(yObj); |
|
2096 |
r.width = __intVal(wObj); |
|
2097 |
r.height = __intVal(hObj); |
|
2098 |
XftDrawSetClipRectangles((XftDraw*)__INST(address_), 0, 0, &r, 1); |
|
7114 | 2099 |
} else { |
7221 | 2100 |
XftDrawSetClipRectangles((XftDraw*)__INST(address_), 0, 0, (XRectangle*)NULL, 0); |
7114 | 2101 |
} |
2102 |
RETURN ( self ); |
|
2103 |
err:; |
|
2104 |
#endif |
|
2105 |
%}. |
|
2106 |
self primitiveFailed: error. |
|
2107 |
||
2108 |
"Created: / 31-12-2013 / 01:24:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2109 |
! ! |
|
2110 |
||
6176 | 2111 |
!XftFontDescription class methodsFor:'documentation'! |
2112 |
||
2113 |
version |
|
6936 | 2114 |
^ '$Header$' |
6176 | 2115 |
! |
2116 |
||
2117 |
version_CVS |
|
6936 | 2118 |
^ '$Header$' |
6176 | 2119 |
! ! |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
2120 |
|
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
|
2121 |
|
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
|
2122 |
XftFontDescription initialize! |