author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Fri, 08 Dec 2017 09:10:33 +0000 | |
branch | jv |
changeset 8232 | ddbaa22b9352 |
parent 7855 | 46203abe7d57 |
child 8420 | 76e39223f5ab |
permissions | -rw-r--r-- |
7796 | 1 |
" |
2 |
COPYRIGHT (c) 2013 by Jan Vrany |
|
3 |
COPYRIGHT (c) 2013 by eXept Software AG |
|
4 |
All Rights Reserved |
|
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 |
7720
8efc17a5de76
XFT: Correctly answer `true` to `isAntialiasedFont`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7719
diff
changeset
|
18 |
instanceVariableNames:'device fontId closestFont minCode maxCode ascent descent height |
7342 | 19 |
fixedWidth' |
7151
51e71e95c952
X11/FontConfig: Removed all FontConfig related code from XftFontDescription
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7128
diff
changeset
|
20 |
classVariableNames:'CachedFontList RecentlyUsedFonts Lobby' |
51e71e95c952
X11/FontConfig: Removed all FontConfig related code from XftFontDescription
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7128
diff
changeset
|
21 |
poolDictionaries:'FcConstants' |
6185
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
22 |
category:'Graphics-Support' |
6176 | 23 |
! |
24 |
||
6263 | 25 |
Object subclass:#FCFontListParser |
26 |
instanceVariableNames:'pipeStream lineStream currentDescription' |
|
27 |
classVariableNames:'' |
|
28 |
poolDictionaries:'' |
|
29 |
privateIn:XftFontDescription |
|
30 |
! |
|
31 |
||
6188
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
32 |
ExternalAddress subclass:#XftDrawHandle |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
33 |
instanceVariableNames:'' |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
34 |
classVariableNames:'' |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
35 |
poolDictionaries:'' |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
36 |
privateIn:XftFontDescription |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
37 |
! |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
38 |
|
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
39 |
ExternalAddress subclass:#XftFontHandle |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
40 |
instanceVariableNames:'' |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
41 |
classVariableNames:'' |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
42 |
poolDictionaries:'' |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
43 |
privateIn:XftFontDescription |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
44 |
! |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
45 |
|
6176 | 46 |
!XftFontDescription primitiveDefinitions! |
47 |
%{ |
|
48 |
/* |
|
49 |
* includes, defines, structure definitions |
|
50 |
* and typedefs come here. |
|
51 |
*/ |
|
52 |
||
53 |
#undef True |
|
54 |
#undef False |
|
6179 | 55 |
#undef Time |
6176 | 56 |
#define Time XTime |
57 |
||
6188
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
58 |
#ifdef XFT |
7154
f2d585b5f20e
X11/FontConfig: Conditionally compile FontConfig support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7151
diff
changeset
|
59 |
# ifndef HAVE_FONTCONFIG |
f2d585b5f20e
X11/FontConfig: Conditionally compile FontConfig support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7151
diff
changeset
|
60 |
# error "XFT defined but not HAVE_FONTCONFIG. Xft fonts cannot be used without FontConfig support" |
f2d585b5f20e
X11/FontConfig: Conditionally compile FontConfig support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7151
diff
changeset
|
61 |
# endif |
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
62 |
|
6936 | 63 |
extern OBJ __GLOBAL_GET_BY_NAME(char *); |
6188
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
64 |
|
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
65 |
# define __HANDLE_VAL(type, externalAddress) \ |
6936 | 66 |
((type)__externalAddressVal(externalAddress)) |
6489 | 67 |
|
6936 | 68 |
# define __HANDLE_NEW(ptr, __cls) \ |
69 |
({ \ |
|
70 |
OBJ handle = __MKEXTERNALADDRESS(ptr); \ |
|
71 |
OBJ clsObj = __GLOBAL_GET_BY_NAME(__cls);\ |
|
72 |
__InstPtr(handle)->o_class = clsObj; \ |
|
73 |
__STORE(handle, clsObj); \ |
|
74 |
handle; \ |
|
75 |
}) |
|
6188
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
76 |
|
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
77 |
|
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
78 |
|
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
79 |
# 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
|
80 |
# define SCREEN(x) ((int)(__intVal(x))) |
6188
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
81 |
# define DRAWABLE(x) __HANDLE_VAL(Drawable, x) |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
82 |
# define GC(x) __HANDLE_VAL(GC, x) |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
83 |
# define VISUAL(x) __HANDLE_VAL(Visual*, x) |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
84 |
# define COLORMAP(x) __HANDLE_VAL(Colormap, x) |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
85 |
|
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
86 |
/* FontConfig objects */ |
6193 | 87 |
# define FC_PATTERN(x) __HANDLE_VAL(XftPattern*, x) |
7151
51e71e95c952
X11/FontConfig: Removed all FontConfig related code from XftFontDescription
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7128
diff
changeset
|
88 |
# define FC_PATTERN_HANDLE_NEW(x) __HANDLE_NEW(x, "FcPattern") |
6188
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
89 |
|
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
90 |
/* Xft Objects */ |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
91 |
|
6193 | 92 |
# 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
|
93 |
# 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
|
94 |
|
6193 | 95 |
# 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
|
96 |
# 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
|
97 |
|
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
98 |
|
6176 | 99 |
# include <X11/Xft/Xft.h> |
100 |
# include <X11/Xft/XftCompat.h> |
|
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
101 |
|
6176 | 102 |
#endif |
103 |
||
104 |
%} |
|
105 |
! ! |
|
106 |
||
107 |
!XftFontDescription class methodsFor:'documentation'! |
|
108 |
||
7796 | 109 |
copyright |
110 |
" |
|
111 |
COPYRIGHT (c) 2013 by Jan Vrany |
|
112 |
COPYRIGHT (c) 2013 by eXept Software AG |
|
113 |
All Rights Reserved |
|
114 |
||
115 |
This software is furnished under a license and may be used |
|
116 |
only in accordance with the terms of that license and with the |
|
117 |
inclusion of the above copyright notice. This software may not |
|
118 |
be provided or otherwise made available to, or used by, any |
|
119 |
other person. No title to or ownership of the software is |
|
120 |
hereby transferred. |
|
121 |
||
122 |
" |
|
123 |
! |
|
124 |
||
6176 | 125 |
documentation |
126 |
" |
|
127 |
WARNING: Unfinished. |
|
128 |
||
129 |
Experimental implementation of custom font rendered using |
|
130 |
Xft library (UNIX / X Window only), To actually use it, |
|
131 |
add following definitions to the end of stx/configurations/myConf |
|
132 |
(works on Ubuntu 12.10) |
|
133 |
||
134 |
--- snip --- |
|
135 |
XDEFS+=-DXFT |
|
136 |
XINCLUDE+=$(shell pkg-config --cflags xft) |
|
137 |
LIB_XFT=-l:libXft.so.2 -l:libfontconfig.so.1 |
|
138 |
--- snip -- |
|
139 |
||
140 |
NOTE: This class should be named XftFont, however then |
|
141 |
there would be a name clash with XftFont structure |
|
142 |
defined in Xft.h - therefore the class is named |
|
143 |
XftFontDescription to avoid that name clash. |
|
144 |
||
145 |
||
146 |
[author:] |
|
6179 | 147 |
Jan Vrany <jan.vrany@fit.cvut.cz> |
6176 | 148 |
|
149 |
[instance variables:] |
|
150 |
||
151 |
[class variables:] |
|
152 |
||
153 |
[see also:] |
|
154 |
||
155 |
" |
|
156 |
! ! |
|
157 |
||
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
|
158 |
!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
|
159 |
|
6327 | 160 |
flushListOfAvailableFonts |
161 |
CachedFontList := nil. |
|
162 |
||
163 |
" |
|
164 |
XftFontDescription flushListOfAvailableFonts |
|
165 |
" |
|
166 |
! |
|
167 |
||
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
|
168 |
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
|
169 |
"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
|
170 |
|
6947 | 171 |
Lobby isNil ifTrue:[ |
7121 | 172 |
Lobby := Registry new. |
6946 | 173 |
]. |
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
|
174 |
|
6185
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
175 |
"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
|
176 |
! ! |
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
|
177 |
|
6325 | 178 |
!XftFontDescription class methodsFor:'instance creation'! |
179 |
||
7571 | 180 |
family:familyString face:faceString style:styleString size:size sizeUnit:sizeUnit encoding:encoding |
181 |
"returns a font for given family, face, style, size and the specified encoding. |
|
182 |
The returned font is not associated to a specific device" |
|
183 |
||
184 |
|proto| |
|
185 |
||
186 |
RecentlyUsedFonts notNil ifTrue:[ |
|
187 |
proto := RecentlyUsedFonts |
|
188 |
detect:[:fn | |
|
7171
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
189 |
fn sameFamily: familyString |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
190 |
face: faceString |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
191 |
style: styleString |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
192 |
size: size |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
193 |
unit: sizeUnit |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
194 |
pixelSize: nil |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
195 |
encoding: encoding] |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
196 |
ifNone:[ nil ]. |
7571 | 197 |
proto notNil ifTrue:[ |
198 |
^ proto |
|
199 |
]. |
|
200 |
]. |
|
201 |
||
202 |
CachedFontList notNil ifTrue:[ |
|
203 |
proto := CachedFontList |
|
204 |
detect:[:fn | |
|
7171
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
205 |
fn sameFamily: familyString |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
206 |
face: faceString |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
207 |
style: styleString |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
208 |
size: size |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
209 |
unit: sizeUnit |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
210 |
pixelSize: nil |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
211 |
encoding: encoding] |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
212 |
ifNone:[ nil ]. |
7571 | 213 |
proto notNil ifTrue:[ |
214 |
^ (proto shallowCopy) |
|
215 |
setDevice: nil patternId: nil fontId: nil; |
|
216 |
family:familyString face:faceString style:styleString size:size sizeUnit:sizeUnit encoding:encoding |
|
217 |
]. |
|
218 |
]. |
|
219 |
^ super |
|
220 |
family:familyString face:faceString style:styleString size:size sizeUnit:sizeUnit encoding:encoding |
|
7171
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
221 |
|
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
222 |
"Modified: / 29-02-2016 / 08:34:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
7571 | 223 |
! |
224 |
||
6993 | 225 |
for:aFontOrFontDescription |
226 |
^ self |
|
227 |
family:aFontOrFontDescription family |
|
228 |
face:aFontOrFontDescription face |
|
229 |
style:aFontOrFontDescription style |
|
230 |
size:aFontOrFontDescription size |
|
231 |
sizeUnit:#pt |
|
232 |
encoding:aFontOrFontDescription encoding |
|
233 |
! |
|
234 |
||
6821
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
235 |
named: aString |
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
236 |
^ self new setName: aString |
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
237 |
|
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
238 |
"Created: / 05-03-2015 / 05:20:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6993 | 239 |
! |
240 |
||
6325 | 241 |
new |
7720
8efc17a5de76
XFT: Correctly answer `true` to `isAntialiasedFont`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7719
diff
changeset
|
242 |
"return an initialized instance" |
8efc17a5de76
XFT: Correctly answer `true` to `isAntialiasedFont`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7719
diff
changeset
|
243 |
|
6963 | 244 |
^ self basicNew initialize. |
6325 | 245 |
! ! |
246 |
||
7036 | 247 |
!XftFontDescription class methodsFor:'* uncategorized *'! |
6957 | 248 |
|
7036 | 249 |
aboutToDestroyViewWithDevice:aGLXWorkstation id:anExternalAddress |
250 |
||
251 |
"Created: / 11-10-2015 / 11:32:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
6957 | 252 |
! ! |
253 |
||
6176 | 254 |
!XftFontDescription class methodsFor:'examples'! |
255 |
||
256 |
example1 |
|
257 |
" |
|
258 |
XftFontDescription example1 |
|
259 |
" |
|
260 |
|top textView| |
|
261 |
||
262 |
top := StandardSystemView new. |
|
263 |
top extent:300@200. |
|
264 |
||
265 |
textView := EditTextView new. |
|
266 |
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
|
267 |
textView basicFont: (XftFontDescription family: 'DejaVu Sans' size: 16). |
6176 | 268 |
|
269 |
top addSubView:textView. |
|
270 |
||
6188
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
271 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile asText). |
6176 | 272 |
|
273 |
top open. |
|
274 |
||
275 |
"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
|
276 |
"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
|
277 |
! |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
278 |
|
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
279 |
example2 |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
280 |
" |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
281 |
XftFontDescription example2 |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
282 |
" |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
283 |
|top textView| |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
284 |
|
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
285 |
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
|
286 |
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
|
287 |
|
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
288 |
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
|
289 |
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
|
290 |
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
|
291 |
|
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
292 |
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
|
293 |
|
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
294 |
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
|
295 |
|
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
296 |
top open. |
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
297 |
|
a09b2e2303cb
Oops. make it compilable again (bug in stc - FCConstants private
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6184
diff
changeset
|
298 |
"Created: / 30-12-2013 / 19:49:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6389 | 299 |
! |
300 |
||
301 |
example3 |
|
302 |
" |
|
303 |
XftFontDescription example2 |
|
304 |
" |
|
305 |
|top textView| |
|
306 |
||
307 |
top := StandardSystemView new. |
|
308 |
top extent:300@200. |
|
309 |
||
310 |
textView := EditTextView new. |
|
311 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
312 |
textView basicFont: (XftFontDescription family: 'Indie Flower' size: 30). |
|
313 |
||
314 |
top addSubView:textView. |
|
315 |
||
316 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
317 |
||
318 |
top open. |
|
319 |
||
320 |
"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
|
321 |
! ! |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
322 |
|
6936 | 323 |
!XftFontDescription class methodsFor:'primitives'! |
324 |
||
325 |
xftAvailable |
|
7154
f2d585b5f20e
X11/FontConfig: Conditionally compile FontConfig support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7151
diff
changeset
|
326 |
<resource: #obsolete> |
f2d585b5f20e
X11/FontConfig: Conditionally compile FontConfig support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7151
diff
changeset
|
327 |
|
f2d585b5f20e
X11/FontConfig: Conditionally compile FontConfig support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7151
diff
changeset
|
328 |
^ ConfigurableFeatures hasXFT |
6936 | 329 |
|
330 |
"Created: / 20-12-2013 / 21:10:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
7154
f2d585b5f20e
X11/FontConfig: Conditionally compile FontConfig support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7151
diff
changeset
|
331 |
"Modified (format): / 22-02-2016 / 08:15:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
7718
6e51fc8b207f
XFT: Drop support for shared drawables.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7717
diff
changeset
|
332 |
|
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
333 |
! |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
334 |
|
7718
6e51fc8b207f
XFT: Drop support for shared drawables.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7717
diff
changeset
|
335 |
xftDrawDestroy: xftDrawId |
6e51fc8b207f
XFT: Drop support for shared drawables.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7717
diff
changeset
|
336 |
%{ |
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
337 |
#ifdef XFT |
7772
a59648e60593
XFT: Make destroying of an `XftDraw*` more robust
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7766
diff
changeset
|
338 |
XftDraw *xftDraw; |
a59648e60593
XFT: Make destroying of an `XftDraw*` more robust
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7766
diff
changeset
|
339 |
if (__isExternalAddressLike(xftDrawId) && (xftDraw = XFT_DRAW(xftDrawId)) != NULL) { |
a59648e60593
XFT: Make destroying of an `XftDraw*` more robust
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7766
diff
changeset
|
340 |
__externalAddressVal(xftDrawId) = NULL; |
7718
6e51fc8b207f
XFT: Drop support for shared drawables.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7717
diff
changeset
|
341 |
XftDrawDestroy(xftDraw); |
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
342 |
} |
7718
6e51fc8b207f
XFT: Drop support for shared drawables.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7717
diff
changeset
|
343 |
RETURN (self); |
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
344 |
#endif |
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
345 |
%}. |
7718
6e51fc8b207f
XFT: Drop support for shared drawables.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7717
diff
changeset
|
346 |
self primitiveFailed. |
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
347 |
|
6936 | 348 |
! ! |
349 |
||
6263 | 350 |
!XftFontDescription class methodsFor:'queries'! |
351 |
||
352 |
listOfAvailableFonts |
|
6264 | 353 |
"uses fc-list to get a list of available fontDescriptions" |
354 |
||
6263 | 355 |
CachedFontList isNil ifTrue:[ |
6393 | 356 |
CachedFontList := FCFontListParser new listOfAvailableFonts |
6263 | 357 |
]. |
358 |
^ CachedFontList |
|
359 |
||
360 |
" |
|
6337 | 361 |
XftFontDescription flushListOfAvailableFonts. |
6319 | 362 |
XftFontDescription listOfAvailableFonts |
6263 | 363 |
" |
364 |
! ! |
|
365 |
||
6317 | 366 |
!XftFontDescription methodsFor:'accessing'! |
6190
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
367 |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
368 |
encoding |
7036 | 369 |
^ encoding ? 'iso10646-1' |
6319 | 370 |
! |
371 |
||
372 |
fullName |
|
373 |
^ name ? (self userFriendlyName) |
|
374 |
! |
|
375 |
||
6317 | 376 |
graphicsDevice |
6190
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
377 |
^ device |
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
378 |
|
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
379 |
"Created: / 02-01-2014 / 23:22:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6319 | 380 |
! |
381 |
||
382 |
maxCode |
|
6323 | 383 |
^ maxCode ? 16rFFFF |
6319 | 384 |
! |
385 |
||
386 |
maxCode:something |
|
387 |
maxCode := something. |
|
388 |
! |
|
389 |
||
390 |
minCode |
|
6323 | 391 |
^ minCode ? 0 |
6319 | 392 |
! |
393 |
||
394 |
minCode:something |
|
395 |
minCode := something. |
|
396 |
! |
|
397 |
||
398 |
size |
|
6325 | 399 |
^ size ? 0 |
6391 | 400 |
! |
401 |
||
402 |
weight:aNumber |
|
403 |
"set the weight" |
|
404 |
||
405 |
self assert:(self fontId isNil). "/ cannot change an instantiated font |
|
406 |
||
7121 | 407 |
weight := aNumber. |
408 |
||
409 |
aNumber == FC_WEIGHT_THIN ifTrue:[ face := #thin. ^ self]. |
|
410 |
aNumber == FC_WEIGHT_EXTRALIGHT ifTrue:[ face := #extralight. ^ self]. |
|
411 |
aNumber == FC_WEIGHT_LIGHT ifTrue:[ face := #light. ^ self]. |
|
412 |
aNumber == FC_WEIGHT_BOOK ifTrue:[ face := #book. ^ self]. |
|
413 |
aNumber == FC_WEIGHT_REGULAR ifTrue:[ face := #regular. ^ self]. |
|
414 |
aNumber == FC_WEIGHT_MEDIUM ifTrue:[ face := #medium. ^ self]. |
|
415 |
aNumber == FC_WEIGHT_DEMIBOLD ifTrue:[ face := #demibold. ^ self]. |
|
416 |
aNumber == FC_WEIGHT_BOLD ifTrue:[ face := #bold. ^ self]. |
|
417 |
aNumber == FC_WEIGHT_EXTRABOLD ifTrue:[ face := #extrabold. ^ self]. |
|
418 |
aNumber == FC_WEIGHT_BLACK ifTrue:[ face := #black. ^ self]. |
|
419 |
aNumber == FC_WEIGHT_EXTRABLACK ifTrue:[ face := #extrablack. ^ self]. |
|
6391 | 420 |
|
421 |
aNumber <= (FC_WEIGHT_EXTRALIGHT + FC_WEIGHT_LIGHT // 2) ifTrue:[ |
|
7221 | 422 |
face := #extralight. |
423 |
^ self. |
|
6391 | 424 |
]. |
425 |
aNumber <= (FC_WEIGHT_LIGHT + FC_WEIGHT_BOOK // 2) ifTrue:[ |
|
7221 | 426 |
face := #light. |
427 |
^ self. |
|
6391 | 428 |
]. |
429 |
aNumber <= (FC_WEIGHT_MEDIUM + FC_WEIGHT_DEMIBOLD // 2) ifTrue:[ |
|
7221 | 430 |
face := #medium. |
431 |
^ self. |
|
6391 | 432 |
]. |
433 |
aNumber <= (FC_WEIGHT_DEMIBOLD + FC_WEIGHT_BOLD // 2) ifTrue:[ |
|
7221 | 434 |
face := #demibold. |
435 |
^ self. |
|
6391 | 436 |
]. |
437 |
aNumber <= (FC_WEIGHT_BOLD + FC_WEIGHT_BLACK // 2) ifTrue:[ |
|
7221 | 438 |
face := #bold. |
439 |
^ self. |
|
6391 | 440 |
]. |
7121 | 441 |
face := #extrabold. |
6391 | 442 |
^ self |
443 |
||
444 |
"/ FC_WEIGHT_THIN := 0. |
|
445 |
"/ FC_WEIGHT_EXTRALIGHT := 40. |
|
446 |
"/ FC_WEIGHT_ULTRALIGHT := FC_WEIGHT_EXTRALIGHT. |
|
447 |
"/ FC_WEIGHT_LIGHT := 50. |
|
448 |
"/ FC_WEIGHT_BOOK := 75. |
|
449 |
"/ FC_WEIGHT_REGULAR := 80. |
|
450 |
"/ FC_WEIGHT_NORMAL := FC_WEIGHT_REGULAR. |
|
451 |
"/ FC_WEIGHT_MEDIUM := 100. |
|
452 |
"/ FC_WEIGHT_DEMIBOLD := 180. |
|
453 |
"/ FC_WEIGHT_SEMIBOLD := FC_WEIGHT_DEMIBOLD. |
|
454 |
"/ FC_WEIGHT_BOLD := 200. |
|
455 |
"/ FC_WEIGHT_EXTRABOLD := 205. |
|
456 |
"/ FC_WEIGHT_ULTRABOLD := FC_WEIGHT_EXTRABOLD. |
|
457 |
"/ FC_WEIGHT_BLACK := 210. |
|
458 |
"/ FC_WEIGHT_HEAVY := FC_WEIGHT_BLACK. |
|
459 |
"/ FC_WEIGHT_EXTRABLACK := 215. |
|
460 |
"/ FC_WEIGHT_ULTRABLACK := FC_WEIGHT_EXTRABLACK. |
|
6317 | 461 |
! ! |
462 |
||
463 |
!XftFontDescription methodsFor:'accessing-private'! |
|
6190
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
464 |
|
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
465 |
getFontId |
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
466 |
^ fontId |
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
467 |
|
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
468 |
"Created: / 02-01-2014 / 23:29:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
469 |
! ! |
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
470 |
|
6587
c1790bb9af59
In case of not configured but installed Xft Fonts convert XftFonts
ab
parents:
6544
diff
changeset
|
471 |
!XftFontDescription methodsFor:'converting'! |
c1790bb9af59
In case of not configured but installed Xft Fonts convert XftFonts
ab
parents:
6544
diff
changeset
|
472 |
|
c1790bb9af59
In case of not configured but installed Xft Fonts convert XftFonts
ab
parents:
6544
diff
changeset
|
473 |
asNonXftFont |
c1790bb9af59
In case of not configured but installed Xft Fonts convert XftFonts
ab
parents:
6544
diff
changeset
|
474 |
|newFont| |
c1790bb9af59
In case of not configured but installed Xft Fonts convert XftFonts
ab
parents:
6544
diff
changeset
|
475 |
|
7707 | 476 |
newFont := Font |
477 |
family:family |
|
478 |
face:face |
|
479 |
style:style |
|
480 |
size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) |
|
481 |
sizeUnit:sizeUnit |
|
482 |
encoding:encoding. |
|
6587
c1790bb9af59
In case of not configured but installed Xft Fonts convert XftFonts
ab
parents:
6544
diff
changeset
|
483 |
|
6656 | 484 |
^ newFont |
6587
c1790bb9af59
In case of not configured but installed Xft Fonts convert XftFonts
ab
parents:
6544
diff
changeset
|
485 |
! ! |
c1790bb9af59
In case of not configured but installed Xft Fonts convert XftFonts
ab
parents:
6544
diff
changeset
|
486 |
|
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
487 |
!XftFontDescription methodsFor:'displaying'! |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
488 |
|
6351 | 489 |
displayString:aString from:index1 to:index2Arg x:xArg y:yArg in:aGC opaque:opaque |
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
490 |
"display a partial string at some position in aGC." |
7035 | 491 |
|
6707 | 492 |
|index2 bytesPerCharacter transformation |
7061 | 493 |
clipOrg clipCorn clipRect clipX clipY clipW clipH clipPnt |
6707 | 494 |
fg fgR fgG fgB fgA fgPixel bg bgR bgG bgB bgA bgPixel |
7035 | 495 |
drawX drawY drawPnt displayId screen drawableId error stringLen drawId drawIdIsShared |
7766
ba07a358cb4a
XFT: Fixed SIGSEGV-crash in D'n'D when using XFT fonts
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7723
diff
changeset
|
496 |
newXftDrawId newDrawableAssociation | |
7719
c2f802dd340a
XFT: Forbid XFT rendering on bitmaps (depth-1 pixmaps)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7718
diff
changeset
|
497 |
|
7766
ba07a358cb4a
XFT: Fixed SIGSEGV-crash in D'n'D when using XFT fonts
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7723
diff
changeset
|
498 |
aGC isPixmap ifTrue:[ |
ba07a358cb4a
XFT: Fixed SIGSEGV-crash in D'n'D when using XFT fonts
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7723
diff
changeset
|
499 |
aGC depth ifTrue:[ |
7719
c2f802dd340a
XFT: Forbid XFT rendering on bitmaps (depth-1 pixmaps)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7718
diff
changeset
|
500 |
"/ Using XFT font to draw in bitmap is not allowed. In theory it could |
c2f802dd340a
XFT: Forbid XFT rendering on bitmaps (depth-1 pixmaps)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7718
diff
changeset
|
501 |
"/ work if XFT would just turn gray into either black or white. But XFT |
c2f802dd340a
XFT: Forbid XFT rendering on bitmaps (depth-1 pixmaps)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7718
diff
changeset
|
502 |
"/ doesn't do it and simply draw nothing without failing in any way. |
c2f802dd340a
XFT: Forbid XFT rendering on bitmaps (depth-1 pixmaps)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7718
diff
changeset
|
503 |
"/ |
c2f802dd340a
XFT: Forbid XFT rendering on bitmaps (depth-1 pixmaps)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7718
diff
changeset
|
504 |
"/ To prevent this silent failures, forbid drawing XFT onto bitmaps |
c2f802dd340a
XFT: Forbid XFT rendering on bitmaps (depth-1 pixmaps)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7718
diff
changeset
|
505 |
"/ (depth-1 pixmaps). After all, the while point of XFT is to use |
c2f802dd340a
XFT: Forbid XFT rendering on bitmaps (depth-1 pixmaps)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7718
diff
changeset
|
506 |
"/ anti-aliased fonts. |
c2f802dd340a
XFT: Forbid XFT rendering on bitmaps (depth-1 pixmaps)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7718
diff
changeset
|
507 |
self error: 'XFT font cannot be used with bitmaps'. |
c2f802dd340a
XFT: Forbid XFT rendering on bitmaps (depth-1 pixmaps)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7718
diff
changeset
|
508 |
^self |
c2f802dd340a
XFT: Forbid XFT rendering on bitmaps (depth-1 pixmaps)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7718
diff
changeset
|
509 |
]. |
c2f802dd340a
XFT: Forbid XFT rendering on bitmaps (depth-1 pixmaps)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7718
diff
changeset
|
510 |
]. |
c2f802dd340a
XFT: Forbid XFT rendering on bitmaps (depth-1 pixmaps)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7718
diff
changeset
|
511 |
|
7035 | 512 |
|
6351 | 513 |
"limit the string len, otherwise bad output is generated" |
6477 | 514 |
stringLen := index2Arg - index1 + 1. |
7342 | 515 |
stringLen > 1000 "8000" ifTrue:[ |
516 |
index2 := index1 + 1000 "8000" - 1. |
|
6351 | 517 |
] ifFalse:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
518 |
stringLen <= 0 ifTrue:[^ self]. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
519 |
index2 := index2Arg. |
6351 | 520 |
]. |
6209 | 521 |
bytesPerCharacter := aString bitsPerCharacter // 8. |
6199
2a683b1824c6
Bugfix in XftFontDescription>>#displayString:from:to:x:y:in:opaque: takes transformation into an account.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6198
diff
changeset
|
522 |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
523 |
clipRect := aGC deviceClippingBoundsOrNil. |
7050 | 524 |
clipRect notNil ifTrue:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
525 |
clipX := clipRect left. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
526 |
clipY := clipRect top. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
527 |
clipW := clipRect width. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
528 |
clipH := clipRect height. |
6489 | 529 |
]. |
6199
2a683b1824c6
Bugfix in XftFontDescription>>#displayString:from:to:x:y:in:opaque: takes transformation into an account.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6198
diff
changeset
|
530 |
|
7061 | 531 |
transformation := aGC transformation. |
6356 | 532 |
transformation isNil ifTrue:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
533 |
drawX := xArg. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
534 |
drawY := yArg. |
6356 | 535 |
] ifFalse:[ |
7115 | 536 |
drawPnt := transformation transformPoint:(xArg @ yArg). |
537 |
drawX := drawPnt x ceiling. |
|
538 |
drawY := drawPnt y ceiling. |
|
6356 | 539 |
]. |
540 |
||
7068 | 541 |
fg := aGC paint. |
542 |
fgR := fg scaledRed. |
|
543 |
fgG := fg scaledGreen. |
|
544 |
fgB := fg scaledBlue. |
|
545 |
fgA := fg scaledAlpha. |
|
546 |
||
6263 | 547 |
fgR isNil ifTrue:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
548 |
"/ when drawing into a pixmap... |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
549 |
fgPixel := fg colorId. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
550 |
fgPixel == 0 ifTrue:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
551 |
fgR := fgG := fgB := 0. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
552 |
] ifFalse:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
553 |
fgR := fgG := fgB := 16rFFFF. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
554 |
] |
6263 | 555 |
]. |
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
556 |
|
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
557 |
opaque ifTrue:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
558 |
bg := aGC backgroundPaint. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
559 |
bg isColor ifTrue:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
560 |
bgR := bg scaledRed. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
561 |
bgG := bg scaledGreen. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
562 |
bgB := bg scaledBlue. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
563 |
bgA := bg scaledAlpha. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
564 |
] ifFalse:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
565 |
"images are not yet implemented" |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
566 |
"/ #todo: fill background rectangle |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
567 |
bgR := bgG := bgB := bgA := 16rFFFF. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
568 |
]. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
569 |
bgR isNil ifTrue:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
570 |
"/ when drawing into a pixmap... |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
571 |
bgPixel := bg colorId. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
572 |
bgPixel == 0 ifTrue:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
573 |
bgR := bgG := bgB := 0. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
574 |
] ifFalse:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
575 |
bgR := bgG := bgB := 16rFFFF. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
576 |
] |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
577 |
]. |
6193 | 578 |
]. |
6333 | 579 |
displayId := device displayIdOrErrorIfBroken. |
6365
cf89c4bedea4
Instvar drawId renamed to sharedDrawId.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6356
diff
changeset
|
580 |
displayId isNil ifTrue:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
581 |
^ self. |
6333 | 582 |
]. |
6193 | 583 |
screen := device screen. |
6351 | 584 |
drawableId := aGC drawableId. |
7718
6e51fc8b207f
XFT: Drop support for shared drawables.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7717
diff
changeset
|
585 |
|
6e51fc8b207f
XFT: Drop support for shared drawables.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7717
diff
changeset
|
586 |
((aGC class == XGraphicsContext) or:[aGC isKindOf: XGraphicsContext]) ifTrue:[ |
7032 | 587 |
"/ TODO: Following should be done atomically together with drawing... |
588 |
drawId := aGC xftDrawId. |
|
589 |
drawIdIsShared := false. |
|
590 |
drawId isNil ifTrue:[ |
|
7541 | 591 |
%{ /* STACK: 64000 */ |
7719
c2f802dd340a
XFT: Forbid XFT rendering on bitmaps (depth-1 pixmaps)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7718
diff
changeset
|
592 |
drawId = XFT_DRAW_HANDLE_NEW ( XftDrawCreate ( DISPLAY( displayId ) , |
c2f802dd340a
XFT: Forbid XFT rendering on bitmaps (depth-1 pixmaps)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7718
diff
changeset
|
593 |
DRAWABLE( drawableId ) , |
c2f802dd340a
XFT: Forbid XFT rendering on bitmaps (depth-1 pixmaps)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7718
diff
changeset
|
594 |
DefaultVisual( DISPLAY( displayId), SCREEN (screen) ) , |
c2f802dd340a
XFT: Forbid XFT rendering on bitmaps (depth-1 pixmaps)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7718
diff
changeset
|
595 |
DefaultColormap( DISPLAY( displayId), SCREEN (screen) ) ) ); |
6530
b4c269c96b08
Changes XftFontDescription to use per-view XftDrawId...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6529
diff
changeset
|
596 |
%}. |
7032 | 597 |
aGC xftDrawId: drawId. |
598 |
]. |
|
6819
f91377f97414
Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
599 |
] ifFalse:[ |
7718
6e51fc8b207f
XFT: Drop support for shared drawables.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7717
diff
changeset
|
600 |
self error: 'GC passed to XftGraphicsContext is not an XGraphicsContext!!'. |
6e51fc8b207f
XFT: Drop support for shared drawables.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7717
diff
changeset
|
601 |
^self |
7075 | 602 |
]. |
6209 | 603 |
|
7541 | 604 |
%{ /* STACK: 64000 */ |
6193 | 605 |
#ifdef XFT |
606 |
XftColor color; |
|
607 |
XGlyphInfo extents; |
|
608 |
XRectangle clipRX; |
|
6936 | 609 |
char *string; |
6195
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
610 |
int len; |
6209 | 611 |
int __bytesPerCharacter; |
6936 | 612 |
XftDraw *__sharedDrawId; |
613 |
XftFont *__xftFont = XFT_FONT(__INST(fontId)); |
|
6193 | 614 |
|
6209 | 615 |
if (!(__bothSmallInteger(drawX, drawY) |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
616 |
&& __bothSmallInteger(index1, index2) |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
617 |
&& __isSmallInteger(bytesPerCharacter) |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
618 |
&& (__isSmallInteger(fgPixel) || (__bothSmallInteger(fgR, fgG) && __bothSmallInteger(fgB, fgA))) |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
619 |
&& (opaque == false || __isSmallInteger(bgPixel) || (__bothSmallInteger(bgR, bgG) && __bothSmallInteger(bgB, bgA))) |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
620 |
&& __isNonNilObject(aString) |
6209 | 621 |
)) { |
6936 | 622 |
goto err; |
6209 | 623 |
} |
624 |
||
625 |
__bytesPerCharacter = __intVal(bytesPerCharacter); |
|
7718
6e51fc8b207f
XFT: Drop support for shared drawables.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7717
diff
changeset
|
626 |
__sharedDrawId = XFT_DRAW ( drawId ); |
6e51fc8b207f
XFT: Drop support for shared drawables.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7717
diff
changeset
|
627 |
|
6936 | 628 |
string = __stringVal(aString) + ((__intVal(index1) - 1 ) * __bytesPerCharacter); |
6195
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
629 |
len = __intVal(index2) - __intVal(index1) + 1; |
6193 | 630 |
|
7050 | 631 |
if (clipRect != nil) { |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
632 |
clipRX.x = __intVal(clipX); |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
633 |
clipRX.y = __intVal(clipY); |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
634 |
clipRX.width = __intVal(clipW); |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
635 |
clipRX.height = __intVal(clipH); |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
636 |
XftDrawSetClipRectangles(__sharedDrawId, 0, 0, &clipRX, 1); |
6193 | 637 |
} else { |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
638 |
XftDrawSetClip(__sharedDrawId, 0); |
6193 | 639 |
} |
640 |
||
6223 | 641 |
if (opaque == true) { |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
642 |
if (bgPixel != nil) { |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
643 |
color.pixel = (unsigned long)__intVal(bgPixel); |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
644 |
} |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
645 |
color.color.red = __intVal(bgR); |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
646 |
color.color.green = __intVal(bgG); |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
647 |
color.color.blue = __intVal(bgB); |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
648 |
color.color.alpha = __intVal(bgA); |
7068 | 649 |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
650 |
switch (__bytesPerCharacter) { |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
651 |
case 1: |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
652 |
XftTextExtents8(DISPLAY(displayId), __xftFont, (FcChar8*)string, len, &extents); |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
653 |
break; |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
654 |
case 2: |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
655 |
XftTextExtents16(DISPLAY(displayId), __xftFont, (FcChar16*)string, len, &extents); |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
656 |
break; |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
657 |
case 4: |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
658 |
XftTextExtents32(DISPLAY(displayId), __xftFont, (FcChar32*)string, len, &extents); |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
659 |
break; |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
660 |
} |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
661 |
XftDrawRect(__sharedDrawId, &color, __intVal(drawX) - extents.x, __intVal(drawY) - __xftFont->ascent, extents.width, __xftFont->height); |
6193 | 662 |
} |
6223 | 663 |
if (fgPixel != nil) { |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
664 |
color.pixel = (unsigned long)__intVal(fgPixel); |
6223 | 665 |
} |
7068 | 666 |
color.color.red = __intVal(fgR); |
667 |
color.color.green = __intVal(fgG); |
|
668 |
color.color.blue = __intVal(fgB); |
|
669 |
color.color.alpha = __intVal(fgA); |
|
670 |
||
6209 | 671 |
switch (__bytesPerCharacter) { |
6195
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
672 |
case 1: |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
673 |
XftDrawString8(__sharedDrawId, &color,__xftFont, |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
674 |
__intVal(drawX), |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
675 |
__intVal(drawY), |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
676 |
(FcChar8*)string, |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
677 |
len); |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
678 |
break; |
6936 | 679 |
|
6195
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
680 |
case 2: |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
681 |
XftDrawString16(__sharedDrawId, &color, __xftFont, |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
682 |
__intVal(drawX), |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
683 |
__intVal(drawY), |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
684 |
(FcChar16*)string, |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
685 |
len); |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
686 |
break; |
6936 | 687 |
|
6195
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
688 |
case 4: |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
689 |
XftDrawString32(__sharedDrawId, &color, __xftFont, |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
690 |
__intVal(drawX), |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
691 |
__intVal(drawY), |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
692 |
(FcChar32*)string, |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
693 |
len); |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
694 |
break; |
6936 | 695 |
|
696 |
default: |
|
697 |
goto err; |
|
6193 | 698 |
} |
6936 | 699 |
|
700 |
RETURN(self); |
|
701 |
||
6193 | 702 |
#endif |
703 |
err:; |
|
704 |
%}. |
|
705 |
self primitiveFailed: error. |
|
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
706 |
|
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
707 |
"Created: / 21-12-2013 / 21:11:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6530
b4c269c96b08
Changes XftFontDescription to use per-view XftDrawId...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6529
diff
changeset
|
708 |
"Modified: / 23-06-2014 / 22:06:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6176 | 709 |
! ! |
710 |
||
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
711 |
!XftFontDescription methodsFor:'error reporting'! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
712 |
|
6198 | 713 |
primitiveFailed |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
714 |
<resource: #skipInDebuggersWalkBack> |
6876
b1aa2b47d252
avoid ifdefs around smalltalk statements
Claus Gittinger <cg@exept.de>
parents:
6833
diff
changeset
|
715 |
|
7154
f2d585b5f20e
X11/FontConfig: Conditionally compile FontConfig support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7151
diff
changeset
|
716 |
ConfigurableFeatures hasXFT ifFalse:[ |
6936 | 717 |
super primitiveFailed:'Xft support is not configured'. |
6876
b1aa2b47d252
avoid ifdefs around smalltalk statements
Claus Gittinger <cg@exept.de>
parents:
6833
diff
changeset
|
718 |
]. |
6198 | 719 |
super primitiveFailed |
720 |
! |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
721 |
|
6198 | 722 |
primitiveFailed:errorString |
723 |
<resource: #skipInDebuggersWalkBack> |
|
6876
b1aa2b47d252
avoid ifdefs around smalltalk statements
Claus Gittinger <cg@exept.de>
parents:
6833
diff
changeset
|
724 |
|
7154
f2d585b5f20e
X11/FontConfig: Conditionally compile FontConfig support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7151
diff
changeset
|
725 |
ConfigurableFeatures hasXFT ifFalse:[ |
6936 | 726 |
super primitiveFailed:'Xft support is not configured'. |
6876
b1aa2b47d252
avoid ifdefs around smalltalk statements
Claus Gittinger <cg@exept.de>
parents:
6833
diff
changeset
|
727 |
]. |
6198 | 728 |
super primitiveFailed:errorString |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
729 |
! ! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
730 |
|
6946 | 731 |
!XftFontDescription methodsFor:'finalization'! |
732 |
||
733 |
finalizationLobby |
|
734 |
^ Lobby |
|
735 |
! |
|
736 |
||
737 |
finalize |
|
738 |
self xftDrawDestroy |
|
739 |
! ! |
|
740 |
||
6176 | 741 |
!XftFontDescription methodsFor:'getting a device font'! |
742 |
||
743 |
onDevice:aGraphicsDevice |
|
744 |
"Create a new XftFont representing the closes font as |
|
745 |
myself on aDevice; if one already exists, return the one." |
|
746 |
||
7171
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
747 |
^ self onDevice: aGraphicsDevice ifAbsent: nil |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
748 |
|
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
749 |
"Modified: / 14-04-1997 / 18:22:31 / cg" |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
750 |
"Modified: / 29-02-2016 / 07:08:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
7114 | 751 |
! |
752 |
||
7171
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
753 |
onDevice:aGraphicsDevice ifAbsent: aBlock |
7114 | 754 |
"Create a new XftFont representing the closes font as |
755 |
myself on aDevice; if one already exists, return the one." |
|
6176 | 756 |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
757 |
| myPatternId closestPatternId1 closestPatternId2 newFontId | |
6176 | 758 |
|
7114 | 759 |
(device == aGraphicsDevice) ifTrue:[ |
7525 | 760 |
"I am already assigned to that device ..." |
761 |
^ self |
|
7114 | 762 |
]. |
763 |
aGraphicsDevice isNil ifTrue:[ |
|
7525 | 764 |
^ self |
6544 | 765 |
]. |
7121 | 766 |
aGraphicsDevice supportsXftFonts ifFalse:[ |
7171
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
767 |
^ super onDevice:aGraphicsDevice ifAbsent:aBlock. |
6190
d651313d4044
Fixes to share XftFontDescription instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6189
diff
changeset
|
768 |
]. |
7589
91aab751f507
Again: remove RecentlyUseFont (rely on larger CachedRegistry)
Stefan Vogel <sv@exept.de>
parents:
7571
diff
changeset
|
769 |
|
7571 | 770 |
RecentlyUsedFonts isNil ifTrue:[ |
771 |
RecentlyUsedFonts := OrderedCollection new:20. |
|
6389 | 772 |
]. |
773 |
||
7571 | 774 |
RecentlyUsedFonts keysAndValuesDo:[:index :aFont | |
7171
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
775 |
((aFont class == self class) and:[(self sameDeviceFontAs:aFont)]) ifTrue:[ |
7571 | 776 |
"/ Transcript showCR:'hit'. |
777 |
RecentlyUsedFonts |
|
778 |
removeIndex:index; |
|
779 |
addFirst:aFont. |
|
780 |
^ aFont |
|
781 |
] |
|
7121 | 782 |
]. |
783 |
||
7571 | 784 |
RecentlyUsedFonts size >= 20 ifTrue:[ |
785 |
RecentlyUsedFonts removeLast. |
|
7559 | 786 |
]. |
787 |
||
7571 | 788 |
aGraphicsDevice deviceFonts do:[:aFont | |
7525 | 789 |
((aFont class == self class) and:[self sameDeviceFontAs:aFont]) ifTrue:[ |
7571 | 790 |
RecentlyUsedFonts addFirst:aFont. |
791 |
^ aFont |
|
7525 | 792 |
]. |
7171
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
793 |
]. |
7114 | 794 |
|
7171
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
795 |
"/ Transcript show: 'XFT font not found in cache:'; showCR: self printString. |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
796 |
[ |
7171
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
797 |
myPatternId := FcPattern fromFontDescription: self. |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
798 |
newFontId := self xftFontOpenPattern: aGraphicsDevice displayId pattern: myPatternId. |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
799 |
newFontId notNil ifTrue:[ |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
800 |
"/ Good, this font exists!! |
7103 | 801 |
myPatternId := nil. |
7525 | 802 |
] ifFalse:[ |
7171
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
803 |
closestPatternId1 := self xftFontMatch: aGraphicsDevice displayId screen: aGraphicsDevice screen pattern: myPatternId. |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
804 |
closestPatternId1 isNil ifTrue:[ |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
805 |
self error: 'No font matches'. |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
806 |
]. |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
807 |
closestPatternId2 := closestPatternId1 copy. |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
808 |
newFontId := self xftFontOpenPattern: aGraphicsDevice displayId pattern: closestPatternId1. |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
809 |
"/ !!!!!!!! closestPatternId is no longer valid !!!!!!!! |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
810 |
closestPatternId1 := nil. |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
811 |
newFontId isNil ifTrue:[ |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
812 |
^ aBlock value |
7525 | 813 |
]. |
814 |
]. |
|
7171
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
815 |
fontId := newFontId. |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
816 |
device := aGraphicsDevice. |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
817 |
aGraphicsDevice registerFont:self. |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
818 |
RecentlyUsedFonts addFirst:self. |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
819 |
myPatternId notNil ifTrue:[myPatternId release]. |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
820 |
closestPatternId1 notNil ifTrue:[closestPatternId1 release]. |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
821 |
closestPatternId2 notNil ifTrue:[closestPatternId2 release]. |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
822 |
^ self. |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
823 |
] ensure:[ |
7171
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
824 |
myPatternId notNil ifTrue:[myPatternId release]. |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
825 |
closestPatternId1 notNil ifTrue:[closestPatternId1 release]. |
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
826 |
closestPatternId2 notNil ifTrue:[closestPatternId2 release]. |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
827 |
]. |
6176 | 828 |
|
829 |
" |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
830 |
(XftFontDescription family:'monospace' size:16) onDevice:Screen current |
6176 | 831 |
" |
832 |
||
7171
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
833 |
"Modified: / 29-02-2016 / 08:36:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6176 | 834 |
! ! |
835 |
||
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
836 |
!XftFontDescription methodsFor:'initialization'! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
837 |
|
6963 | 838 |
initialize |
7720
8efc17a5de76
XFT: Correctly answer `true` to `isAntialiasedFont`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7719
diff
changeset
|
839 |
super initialize. |
8efc17a5de76
XFT: Correctly answer `true` to `isAntialiasedFont`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7719
diff
changeset
|
840 |
flags := AntialiasedFlag |
6963 | 841 |
|
7720
8efc17a5de76
XFT: Correctly answer `true` to `isAntialiasedFont`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7719
diff
changeset
|
842 |
"Modified: / 26-11-2016 / 21:25:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6993 | 843 |
! |
844 |
||
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
845 |
setDevice: deviceArg patternId: patternIdArg fontId: fontIdArg |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
846 |
device := deviceArg. |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
847 |
fontId := fontIdArg. |
6325 | 848 |
patternIdArg notNil ifTrue:[ |
7169
ae5df93e3b78
X11/XFT: Make sure `style` and `face` are never empty strings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7154
diff
changeset
|
849 |
family := patternIdArg at: FC_FAMILY index: 1. |
ae5df93e3b78
X11/XFT: Make sure `style` and `face` are never empty strings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7154
diff
changeset
|
850 |
size := patternIdArg at: FC_SIZE index: 1. |
ae5df93e3b78
X11/XFT: Make sure `style` and `face` are never empty strings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7154
diff
changeset
|
851 |
face := patternIdArg at: FC_WEIGHT index: 1. |
ae5df93e3b78
X11/XFT: Make sure `style` and `face` are never empty strings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7154
diff
changeset
|
852 |
face := StXFace2FCWeightMap keyAtValue: face. |
ae5df93e3b78
X11/XFT: Make sure `style` and `face` are never empty strings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7154
diff
changeset
|
853 |
face isEmptyOrNil ifTrue:[ face := nil ]. |
ae5df93e3b78
X11/XFT: Make sure `style` and `face` are never empty strings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7154
diff
changeset
|
854 |
style := patternIdArg at: FC_SLANT index: 1. |
ae5df93e3b78
X11/XFT: Make sure `style` and `face` are never empty strings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7154
diff
changeset
|
855 |
style := StXStyle2FCSlantMap keyAtValue: style. |
ae5df93e3b78
X11/XFT: Make sure `style` and `face` are never empty strings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7154
diff
changeset
|
856 |
style isEmptyOrNil ifTrue:[ style := nil ]. |
ae5df93e3b78
X11/XFT: Make sure `style` and `face` are never empty strings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7154
diff
changeset
|
857 |
name := patternIdArg at: FC_FULLNAME index: 1. |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
858 |
|
7169
ae5df93e3b78
X11/XFT: Make sure `style` and `face` are never empty strings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7154
diff
changeset
|
859 |
encoding:= patternIdArg at: 'encoding' index: 1. |
6963 | 860 |
]. |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
861 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
862 |
"Created: / 21-12-2013 / 00:46:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
7171
71c34a23762b
X11/XFT: Fixed a baaad bug in font caching causing horrible performance regression
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7169
diff
changeset
|
863 |
"Modified: / 29-02-2016 / 07:43:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6821
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
864 |
! |
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
865 |
|
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
866 |
setName: aString |
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
867 |
"Initializes font description from a string like 'times-12' or 'times,charter-12:bold'" |
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
868 |
|
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
869 |
| pattern | |
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
870 |
|
7151
51e71e95c952
X11/FontConfig: Removed all FontConfig related code from XftFontDescription
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7128
diff
changeset
|
871 |
pattern := FcPattern fromString: aString. |
6821
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
872 |
pattern notNil ifTrue:[ |
7151
51e71e95c952
X11/FontConfig: Removed all FontConfig related code from XftFontDescription
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7128
diff
changeset
|
873 |
family := pattern at: FC_FAMILY index: 1. |
51e71e95c952
X11/FontConfig: Removed all FontConfig related code from XftFontDescription
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7128
diff
changeset
|
874 |
size := pattern at: FC_SIZE index: 1. |
51e71e95c952
X11/FontConfig: Removed all FontConfig related code from XftFontDescription
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7128
diff
changeset
|
875 |
face := pattern at: FC_WEIGHT index: 1. |
6821
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
876 |
face := StXFace2FCWeightMap keyAtValue: face. |
7151
51e71e95c952
X11/FontConfig: Removed all FontConfig related code from XftFontDescription
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7128
diff
changeset
|
877 |
style := pattern at: FC_SLANT index: 1. |
6821
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
878 |
style := StXStyle2FCSlantMap keyAtValue: style. |
7151
51e71e95c952
X11/FontConfig: Removed all FontConfig related code from XftFontDescription
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7128
diff
changeset
|
879 |
name := pattern at: FC_FULLNAME index: 1. |
51e71e95c952
X11/FontConfig: Removed all FontConfig related code from XftFontDescription
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7128
diff
changeset
|
880 |
encoding:= pattern at: 'encoding' index: 1. |
6821
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
881 |
encoding notNil ifTrue:[encoding := encoding asSymbol]. |
7151
51e71e95c952
X11/FontConfig: Removed all FontConfig related code from XftFontDescription
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7128
diff
changeset
|
882 |
pattern release. |
6821
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
883 |
]. |
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
884 |
|
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
885 |
" |
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
886 |
XftFontDescription named: 'times-12' |
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
887 |
XftFontDescription named: 'times,charter-12:bold' |
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
888 |
XftFontDescription named: 'Sans-10' |
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
889 |
" |
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
890 |
|
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
891 |
"Created: / 05-03-2015 / 05:19:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
892 |
! ! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
893 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
894 |
!XftFontDescription methodsFor:'primitives'! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
895 |
|
6936 | 896 |
xftDrawChange:xftDrawId drawable:drawableId |
7114 | 897 |
| error | |
7563 | 898 |
|
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
899 |
%{ |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
900 |
#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
|
901 |
if ( ! __isExternalAddressLike(xftDrawId) ) { |
7563 | 902 |
error = @symbol(BadArg1); |
903 |
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
|
904 |
} |
6936 | 905 |
if (drawableId == nil) { |
906 |
XftDrawChange(XFT_DRAW(xftDrawId), None); |
|
907 |
RETURN (self); |
|
7563 | 908 |
} |
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
909 |
if ( ! __isExternalAddressLike(drawableId) ) { |
7563 | 910 |
error = @symbol(BadArg2); |
911 |
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
|
912 |
} |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
913 |
if (XftDrawDrawable( XFT_DRAW(xftDrawId) ) != DRAWABLE( drawableId ) ) { |
6936 | 914 |
XftDrawChange( XFT_DRAW(xftDrawId) , DRAWABLE( drawableId ) ); |
7563 | 915 |
} |
6936 | 916 |
RETURN (self); |
917 |
err:; |
|
7114 | 918 |
#endif |
919 |
%}. |
|
920 |
self primitiveFailed: error |
|
921 |
||
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 |
"Created: / 26-12-2013 / 12:17:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
7114 | 923 |
! |
924 |
||
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
925 |
xftDrawCreate: displayId screen: screen drawable: drawableId |
7114 | 926 |
| error | |
927 |
||
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
928 |
%{ |
7114 | 929 |
#ifdef XFT |
930 |
if ( ! __isExternalAddressLike(displayId) ) { |
|
7221 | 931 |
error = @symbol(BadArg1); |
932 |
goto err; |
|
7114 | 933 |
} |
934 |
if ( ! __isSmallInteger(screen) ) { |
|
7221 | 935 |
error = @symbol(BadArg2); |
936 |
goto err; |
|
7114 | 937 |
} |
938 |
if ( ! __isExternalAddressLike(drawableId) ) { |
|
7221 | 939 |
error = @symbol(BadArg3); |
940 |
goto err; |
|
7114 | 941 |
} |
6188
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
942 |
RETURN ( XFT_DRAW_HANDLE_NEW ( XftDrawCreate ( DISPLAY( displayId ) , |
6198 | 943 |
DRAWABLE( drawableId ) , |
944 |
DefaultVisual( DISPLAY( displayId), SCREEN (screen) ) , |
|
945 |
DefaultColormap( DISPLAY( displayId), SCREEN (screen) ) ) ) ); |
|
7114 | 946 |
err:; |
947 |
#endif |
|
948 |
%}. |
|
949 |
self primitiveFailed: error |
|
950 |
||
951 |
"Created: / 21-12-2013 / 21:12:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
952 |
! |
|
953 |
||
6189
9194261bf002
fixed - a structure field conflicted with a local variable name
Claus Gittinger <cg@exept.de>
parents:
6188
diff
changeset
|
954 |
xftDrawRect: drawIdArg color: aColor x: x y: y width: w height: h |
7114 | 955 |
| error r g b a pix | |
956 |
||
6189
9194261bf002
fixed - a structure field conflicted with a local variable name
Claus Gittinger <cg@exept.de>
parents:
6188
diff
changeset
|
957 |
aColor isColor ifFalse:[^self primitiveFailed: #BadArg2]. |
7114 | 958 |
|
959 |
r := aColor scaledRed. |
|
960 |
g := aColor scaledGreen. |
|
961 |
b := aColor scaledBlue. |
|
962 |
a := aColor alpha * 65535. |
|
963 |
r isNil ifTrue:[ |
|
7221 | 964 |
"/ when drawing into a pixmap... |
965 |
aColor colorId == 0 ifTrue:[ |
|
966 |
r := g := b := 0. |
|
967 |
] ifFalse:[ |
|
968 |
r := g := b := 16rFFFF. |
|
969 |
] |
|
7114 | 970 |
]. |
971 |
pix := aColor colorId. |
|
7541 | 972 |
%{ /* STACK: 64000 */ |
7114 | 973 |
#ifdef XFT |
974 |
XftColor clr; |
|
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
975 |
if ( ! __isExternalAddressLike(drawIdArg) ) { |
6198 | 976 |
error = @symbol(BadArg1); |
7221 | 977 |
goto err; |
7114 | 978 |
} |
6187
cfe33a9940ee
Memory/performance optimization - use stack-allocated XftColor.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6186
diff
changeset
|
979 |
if ( ! __isSmallInteger(pix) ) { |
7221 | 980 |
error = @symbol(BadColorId); |
981 |
goto err; |
|
7114 | 982 |
} |
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
983 |
if ( ! __isSmallInteger(x) ) { |
7221 | 984 |
error = @symbol(BadArg3); |
985 |
goto err; |
|
7114 | 986 |
} |
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
987 |
if ( ! __isSmallInteger(y) ) { |
7221 | 988 |
error = @symbol(BadArg4); |
989 |
goto err; |
|
7114 | 990 |
} |
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
991 |
if ( ! __isSmallInteger(w) ) { |
7221 | 992 |
error = @symbol(BadArg5); |
993 |
goto err; |
|
7114 | 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 |
if ( ! __isSmallInteger(h) ) { |
6198 | 996 |
error = @symbol(BadArg6); |
997 |
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
|
998 |
} |
7114 | 999 |
clr.pixel = (unsigned long)__intVal(pix); |
1000 |
clr.color.red = __intVal(r); |
|
1001 |
clr.color.green = __intVal(g); |
|
1002 |
clr.color.blue = __intVal(b); |
|
1003 |
clr.color.alpha = __intVal(a); |
|
1004 |
||
6187
cfe33a9940ee
Memory/performance optimization - use stack-allocated XftColor.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6186
diff
changeset
|
1005 |
XftDrawRect(XFT_DRAW(drawIdArg), &clr, |
7221 | 1006 |
__intVal(x), __intVal(y), __intVal(w) ,__intVal(h)); |
7114 | 1007 |
|
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1008 |
RETURN ( self ); |
7114 | 1009 |
err:; |
1010 |
#endif |
|
1011 |
%}. |
|
1012 |
self primitiveFailed: error. |
|
1013 |
||
1014 |
"Created: / 28-12-2013 / 23:35:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1015 |
"Modified: / 31-12-2013 / 00:37:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1016 |
! |
|
1017 |
||
6188
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
1018 |
xftDrawSetClip: drawIdArg rectangle: rect |
6198 | 1019 |
| error xObj yObj wObj hObj | |
6188
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
1020 |
|
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
1021 |
rect notNil ifTrue:[ |
6198 | 1022 |
xObj := rect left. |
1023 |
yObj := rect top. |
|
1024 |
wObj := rect width. |
|
1025 |
hObj := rect height. |
|
6188
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
1026 |
]. |
7541 | 1027 |
%{ /* STACK: 64000 */ |
6188
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
1028 |
#ifdef XFT |
6191
86ef1e69ffc1
Call XftConfigSubstitute() & XftDefaultSubstitute() before matching fonts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6190
diff
changeset
|
1029 |
XRectangle r; |
6188
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
1030 |
if ( ! __isExternalAddressLike(drawIdArg) ) { |
6198 | 1031 |
error = @symbol(BadArg1); |
1032 |
goto err; |
|
6188
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
1033 |
} |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
1034 |
if (rect != nil) { |
6198 | 1035 |
r.x = __intVal(xObj); |
1036 |
r.y = __intVal(yObj); |
|
1037 |
r.width = __intVal(wObj); |
|
1038 |
r.height = __intVal(hObj); |
|
1039 |
XftDrawSetClipRectangles( XFT_DRAW(drawIdArg) , 0, 0, &r, 1); |
|
6188
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
1040 |
} else { |
6198 | 1041 |
XftDrawSetClipRectangles( XFT_DRAW(drawIdArg) , 0, 0, (XRectangle*)NULL, 0); |
6188
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
1042 |
} |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
1043 |
RETURN ( self ); |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
1044 |
err:; |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
1045 |
#endif |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
1046 |
%}. |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
1047 |
self primitiveFailed: error. |
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
1048 |
|
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
1049 |
"Created: / 31-12-2013 / 01:24:39 / 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
|
1050 |
! |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1051 |
|
6189
9194261bf002
fixed - a structure field conflicted with a local variable name
Claus Gittinger <cg@exept.de>
parents:
6188
diff
changeset
|
1052 |
xftDrawString: drawIdArg color: aColor font: fontIdArg x: x y: y string: text from: start to: stop |
7114 | 1053 |
| error r g b a pix | |
1054 |
||
1055 |
aColor isColor ifFalse:[^self primitiveFailed: #BadArg2]. |
|
1056 |
||
1057 |
r := aColor scaledRed. |
|
6189
9194261bf002
fixed - a structure field conflicted with a local variable name
Claus Gittinger <cg@exept.de>
parents:
6188
diff
changeset
|
1058 |
g := aColor scaledGreen. |
9194261bf002
fixed - a structure field conflicted with a local variable name
Claus Gittinger <cg@exept.de>
parents:
6188
diff
changeset
|
1059 |
b := aColor scaledBlue. |
9194261bf002
fixed - a structure field conflicted with a local variable name
Claus Gittinger <cg@exept.de>
parents:
6188
diff
changeset
|
1060 |
a := aColor alpha * 65535. |
7114 | 1061 |
r isNil ifTrue:[ |
7221 | 1062 |
"/ when drawing into a pixmap... |
6263 | 1063 |
aColor colorId == 0 ifTrue:[ |
1064 |
r := g := b := 0. |
|
7221 | 1065 |
] ifFalse:[ |
6263 | 1066 |
r := g := b := 16rFFFF. |
7221 | 1067 |
] |
7114 | 1068 |
]. |
6189
9194261bf002
fixed - a structure field conflicted with a local variable name
Claus Gittinger <cg@exept.de>
parents:
6188
diff
changeset
|
1069 |
pix := aColor colorId. |
7541 | 1070 |
%{ /* STACK: 64000 */ |
7114 | 1071 |
#ifdef XFT |
1072 |
int _start, _stop; |
|
1073 |
int __x, __y; |
|
1074 |
XftColor clr; |
|
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1075 |
if ( ! __isExternalAddressLike(drawIdArg) ) { |
6198 | 1076 |
error = @symbol(BadArg1); |
7221 | 1077 |
goto err; |
7114 | 1078 |
} |
1079 |
if ( ! __isSmallInteger(pix) ) { |
|
7221 | 1080 |
error = @symbol(BadColorId); |
1081 |
goto err; |
|
7114 | 1082 |
} |
1083 |
if ( ! __isSmallInteger(x) ) { |
|
7221 | 1084 |
error = @symbol(BadArg4); |
1085 |
goto err; |
|
7114 | 1086 |
} |
1087 |
__x = __intVal(x); |
|
1088 |
if ( ! __isSmallInteger(y) ) { |
|
7221 | 1089 |
error = @symbol(BadArg5); |
1090 |
goto err; |
|
7114 | 1091 |
} |
1092 |
__y = __intVal(y); |
|
1093 |
||
1094 |
||
1095 |
if ( ! __isSmallInteger(start) ) { |
|
7221 | 1096 |
error = @symbol(BadArg6); |
1097 |
goto err; |
|
7114 | 1098 |
} |
1099 |
_start = __intVal(start); |
|
1100 |
if ( ! __isSmallInteger(stop) ) { |
|
7221 | 1101 |
error = @symbol(BadArg7); |
1102 |
goto err; |
|
7114 | 1103 |
} |
1104 |
_stop = __intVal(stop); |
|
1105 |
||
1106 |
clr.pixel = (unsigned long)__intVal(pix); |
|
1107 |
clr.color.red = __intVal(r); |
|
1108 |
clr.color.green = __intVal(g); |
|
1109 |
clr.color.blue = __intVal(b); |
|
1110 |
clr.color.alpha = __intVal(a); |
|
1111 |
||
6186
c8f36970419f
Added missing & required methods. Since now, while St/X IDE could be switched to use XFT fonts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6185
diff
changeset
|
1112 |
if ( __isStringLike(text) ) { |
6198 | 1113 |
XftDrawString8(XFT_DRAW(drawIdArg), &clr, XFT_FONT(fontIdArg), |
7221 | 1114 |
__x, __y, |
6198 | 1115 |
__stringVal(text) + (_start - 1), _stop - _start + 1); |
7221 | 1116 |
RETURN ( self ); |
7114 | 1117 |
} else { |
6198 | 1118 |
error = @symbol(BadArg5); |
7221 | 1119 |
goto err; |
7114 | 1120 |
} |
1121 |
err:; |
|
1122 |
#endif |
|
1123 |
%}. |
|
1124 |
self primitiveFailed: error. |
|
1125 |
||
1126 |
"Created: / 28-12-2013 / 12:32:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1127 |
"Modified: / 30-12-2013 / 20:00:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1128 |
! |
|
1129 |
||
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1130 |
xftFontGetAscent: fontIdArg |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1131 |
| error | |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1132 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1133 |
%{ |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1134 |
#ifdef XFT |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1135 |
int v; |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1136 |
if ( ! __isExternalAddressLike(fontIdArg) ) { |
7221 | 1137 |
error = @symbol(BadArg1); |
1138 |
goto err; |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1139 |
} |
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1140 |
v = XFT_FONT(fontIdArg)->ascent; |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1141 |
RETURN ( __MKINT( v ) ); |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1142 |
err:; |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1143 |
#endif |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1144 |
%}. |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1145 |
self primitiveFailed: error |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1146 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1147 |
"Created: / 21-12-2013 / 00:56:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1148 |
! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1149 |
|
6198 | 1150 |
xftFontGetDescent:fontIdArg |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1151 |
| error | |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1152 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1153 |
%{ |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1154 |
#ifdef XFT |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1155 |
int v; |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1156 |
if ( ! __isExternalAddressLike(fontIdArg) ) { |
7221 | 1157 |
error = @symbol(BadArg1); |
1158 |
goto err; |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1159 |
} |
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1160 |
v = XFT_FONT(fontIdArg)->descent; |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1161 |
RETURN ( __MKINT( v ) ); |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1162 |
err:; |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1163 |
#endif |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1164 |
%}. |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1165 |
self primitiveFailed: error |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1166 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1167 |
"Created: / 21-12-2013 / 00:56:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1168 |
! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1169 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1170 |
xftFontGetHeight: fontIdArg |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1171 |
| error | |
7114 | 1172 |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1173 |
%{ |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1174 |
#ifdef XFT |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1175 |
int v; |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1176 |
if ( ! __isExternalAddressLike(fontIdArg) ) { |
7221 | 1177 |
error = @symbol(BadArg1); |
1178 |
goto err; |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1179 |
} |
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1180 |
v = XFT_FONT(fontIdArg)->height; |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1181 |
RETURN ( __MKINT( v ) ); |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1182 |
err:; |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1183 |
#endif |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1184 |
%}. |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1185 |
self primitiveFailed: error |
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 |
"Created: / 21-12-2013 / 00:56:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1188 |
! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1189 |
|
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
|
1190 |
xftFontGetMaxAdvanceWidth: fontIdArg |
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
|
1191 |
| error | |
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
|
1192 |
|
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
|
1193 |
%{ |
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
|
1194 |
#ifdef XFT |
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
|
1195 |
int v; |
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
|
1196 |
if ( ! __isExternalAddressLike(fontIdArg) ) { |
7221 | 1197 |
error = @symbol(BadArg1); |
1198 |
goto err; |
|
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
|
1199 |
} |
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
|
1200 |
v = XFT_FONT(fontIdArg)->max_advance_width; |
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
|
1201 |
RETURN ( __MKINT( v ) ); |
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
|
1202 |
err:; |
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
|
1203 |
#endif |
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
|
1204 |
%}. |
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
|
1205 |
self primitiveFailed: error |
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
|
1206 |
|
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
|
1207 |
"Created: / 30-12-2013 / 20:02:20 / 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
|
1208 |
! |
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
|
1209 |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1210 |
xftFontGetPattern: fontIdArg |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1211 |
| error | |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1212 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1213 |
%{ |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1214 |
#ifdef XFT |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1215 |
XftPattern* p; |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1216 |
if ( ! __isExternalAddressLike(fontIdArg) ) { |
7221 | 1217 |
error = @symbol(BadArg1); |
1218 |
goto err; |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1219 |
} |
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1220 |
p = XFT_FONT(fontIdArg)->pattern; |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1221 |
if (p == NULL) { |
7221 | 1222 |
RETURN ( nil ); |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1223 |
} else { |
7221 | 1224 |
RETURN ( FC_PATTERN_HANDLE_NEW ( p ) ); |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1225 |
} |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1226 |
err:; |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1227 |
#endif |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1228 |
%}. |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1229 |
self primitiveFailed: error |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1230 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1231 |
"Created: / 21-12-2013 / 00:55:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1232 |
! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1233 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1234 |
xftFontMatch: displayId screen: screen pattern: patternId |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1235 |
| error | |
7114 | 1236 |
|
1237 |
%{ /* STACK: 64000 */ |
|
1238 |
#ifdef XFT |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1239 |
XftPattern* p; |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1240 |
XftResult r; |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1241 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1242 |
if ( ! __isExternalAddressLike(displayId) ) { |
6198 | 1243 |
error = @symbol(BadArg1); |
1244 |
goto err; |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1245 |
} |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1246 |
if ( ! __isSmallInteger( screen ) ) { |
6198 | 1247 |
error = @symbol(BadArg2); |
1248 |
goto err; |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1249 |
} |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1250 |
if ( ! __isExternalAddressLike(patternId) ) { |
6198 | 1251 |
error = @symbol(BadArg3); |
7221 | 1252 |
goto err; |
7114 | 1253 |
} |
6195
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
1254 |
|
6191
86ef1e69ffc1
Call XftConfigSubstitute() & XftDefaultSubstitute() before matching fonts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6190
diff
changeset
|
1255 |
XftConfigSubstitute(FC_PATTERN( patternId )); |
86ef1e69ffc1
Call XftConfigSubstitute() & XftDefaultSubstitute() before matching fonts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6190
diff
changeset
|
1256 |
XftDefaultSubstitute(DISPLAY(displayId) , SCREEN( screen ), FC_PATTERN( patternId )); |
6188
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
1257 |
p = XftFontMatch( DISPLAY(displayId) , SCREEN( screen ), FC_PATTERN( patternId ), &r ); |
6192
d79a5e546361
Fixes in call to XftFontMatch() - ignore result value (last arg).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6191
diff
changeset
|
1258 |
if (p) { |
6198 | 1259 |
RETURN ( FC_PATTERN_HANDLE_NEW ( p ) ); |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1260 |
} else { |
6198 | 1261 |
error = @symbol(XftFontMatchReturnedNull); |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1262 |
} |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1263 |
err:; |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1264 |
#endif |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1265 |
%}. |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1266 |
self primitiveFailed: error |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1267 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1268 |
"Created: / 21-12-2013 / 00:08:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1269 |
! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1270 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1271 |
xftFontOpenPattern: displayId pattern: patternId |
7103 | 1272 |
"Note: the pattern is destroyed when the font is closed" |
1273 |
||
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1274 |
| error | |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1275 |
|
7541 | 1276 |
%{ /* STACK: 64000 */ |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1277 |
#ifdef XFT |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1278 |
XftFont* f; |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1279 |
if ( ! __isExternalAddressLike(displayId) ) { |
7563 | 1280 |
error = @symbol(BadArg1); |
1281 |
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
|
1282 |
} |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1283 |
if ( ! __isExternalAddressLike(patternId) ) { |
7563 | 1284 |
error = @symbol(BadArg2); |
1285 |
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
|
1286 |
} |
7563 | 1287 |
|
6188
9d09f76582b7
Fixed problem with clipping.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6187
diff
changeset
|
1288 |
f = XftFontOpenPattern( DISPLAY(displayId) , FC_PATTERN( patternId ) ); |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1289 |
if (f == NULL) { |
7103 | 1290 |
RETURN ( nil ); |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1291 |
} else { |
7103 | 1292 |
RETURN ( XFT_FONT_HANDLE_NEW ( f ) ); |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1293 |
} |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1294 |
err:; |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1295 |
#endif |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1296 |
%}. |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1297 |
self primitiveFailed: error |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1298 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1299 |
"Created: / 20-12-2013 / 23:53:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1300 |
! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1301 |
|
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1302 |
xftTextExtents: displayIdArg font: fontIdArg string: text from: start to: stop |
6195
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
1303 |
| error extents bitsPerCharacter | |
7114 | 1304 |
|
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1305 |
extents := Array new: 6. |
6195
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
1306 |
bitsPerCharacter := text bitsPerCharacter. |
7541 | 1307 |
%{ /* 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
|
1308 |
#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
|
1309 |
XGlyphInfo info; |
6195
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
1310 |
int bytesPerCharacter; |
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
1311 |
char *string; |
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
1312 |
int len; |
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
1313 |
|
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
1314 |
bytesPerCharacter = __intVal(bitsPerCharacter) / 8; |
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
1315 |
|
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1316 |
if ( ! __isExternalAddressLike(displayIdArg) ) { |
7221 | 1317 |
error = @symbol(BadArg1); |
1318 |
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
|
1319 |
} |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1320 |
if ( ! __isExternalAddressLike(fontIdArg) ) { |
7221 | 1321 |
error = @symbol(BadArg2); |
1322 |
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
|
1323 |
} |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1324 |
if ( ! __isSmallInteger(start) ) { |
7221 | 1325 |
error = @symbol(BadArg4); |
1326 |
goto err; |
|
7114 | 1327 |
} |
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1328 |
if ( ! __isSmallInteger(stop) ) { |
7221 | 1329 |
error = @symbol(BadArg5); |
1330 |
goto err; |
|
7563 | 1331 |
} |
1332 |
||
6195
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
1333 |
string = __stringVal( text ) + (( __intVal(start) - 1 ) * bytesPerCharacter); |
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
1334 |
len = __intVal(stop) - __intVal(start) + 1; |
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
1335 |
|
7563 | 1336 |
|
6195
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
1337 |
switch (bytesPerCharacter) { |
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
1338 |
case 1: |
7221 | 1339 |
XftTextExtents8(DISPLAY(displayIdArg), XFT_FONT(fontIdArg), (FcChar8*)string, len, &info); |
1340 |
break; |
|
6195
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
1341 |
case 2: |
7221 | 1342 |
XftTextExtents16(DISPLAY(displayIdArg), XFT_FONT(fontIdArg), (FcChar16*)string, len, &info); |
1343 |
break; |
|
6195
9a14f8e6c10c
Added support for wide strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6194
diff
changeset
|
1344 |
case 4: |
7221 | 1345 |
XftTextExtents32(DISPLAY(displayIdArg), XFT_FONT(fontIdArg), (FcChar32*)string, len, &info); |
1346 |
break; |
|
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1347 |
} |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1348 |
__ArrayInstPtr(extents)->a_element[0] = __MKSMALLINT(info.width); |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1349 |
__ArrayInstPtr(extents)->a_element[1] = __MKSMALLINT(info.height); |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1350 |
__ArrayInstPtr(extents)->a_element[2] = __MKSMALLINT(info.x); |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1351 |
__ArrayInstPtr(extents)->a_element[3] = __MKSMALLINT(info.y); |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1352 |
__ArrayInstPtr(extents)->a_element[4] = __MKSMALLINT(info.xOff); |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1353 |
__ArrayInstPtr(extents)->a_element[5] = __MKSMALLINT(info.yOff); |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1354 |
error = nil; |
7114 | 1355 |
err:; |
1356 |
#endif |
|
1357 |
%}. |
|
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1358 |
error notNil ifTrue:[ |
7221 | 1359 |
self primitiveFailed: error. |
1360 |
^ 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
|
1361 |
]. |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1362 |
^ extents |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1363 |
|
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1364 |
"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
|
1365 |
"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
|
1366 |
! ! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1367 |
|
6198 | 1368 |
!XftFontDescription methodsFor:'printing & storing'! |
1369 |
||
1370 |
storeOn:aStream |
|
1371 |
"append a character sequence to the argument, aStream from which the |
|
1372 |
receiver can be reconstructed using readFrom:." |
|
1373 |
||
1374 |
aStream nextPutAll:'(XftFontDescription family:'. family storeOn:aStream. |
|
1375 |
aStream nextPutAll:' face:'. face storeOn:aStream. |
|
1376 |
aStream nextPutAll:' style:'. style storeOn:aStream. |
|
1377 |
aStream nextPutAll:' size:'. size storeOn:aStream. |
|
1378 |
aStream nextPutAll:' encoding:'. encoding storeOn:aStream. |
|
1379 |
aStream nextPut:$) |
|
1380 |
||
1381 |
" |
|
1382 |
(XftFontDescription family: 'DejaVu Sans' size: 8) storeString |
|
1383 |
" |
|
1384 |
! ! |
|
1385 |
||
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1386 |
!XftFontDescription methodsFor:'queries-dimensions'! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1387 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1388 |
ascent |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1389 |
"return the ascent - the number of pixels above the baseLine." |
6656 | 1390 |
ascent isNil ifTrue:[ |
6707 | 1391 |
ascent := self xftFontGetAscent: fontId |
6656 | 1392 |
]. |
1393 |
^ ascent |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1394 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1395 |
"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
|
1396 |
! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1397 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1398 |
descent |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1399 |
"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
|
1400 |
|
6656 | 1401 |
descent isNil ifTrue:[ |
6707 | 1402 |
descent := self xftFontGetDescent: fontId |
6656 | 1403 |
]. |
1404 |
^ descent |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1405 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1406 |
"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
|
1407 |
! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1408 |
|
6314 | 1409 |
getFontMetrics |
1410 |
|info| |
|
1411 |
||
1412 |
info := DeviceWorkstation::DeviceFontMetrics new. |
|
1413 |
info |
|
1414 |
ascent:self ascent |
|
1415 |
descent:self descent |
|
1416 |
maxAscent:self maxAscent |
|
1417 |
maxDescent:self maxDescent |
|
1418 |
minWidth:self maxWidth |
|
1419 |
maxWidth:self maxWidth |
|
1420 |
avgWidth:self maxWidth |
|
1421 |
minCode:self minCode |
|
1422 |
maxCode:self maxCode |
|
1423 |
direction:#LeftToRight. |
|
1424 |
^ info |
|
1425 |
! |
|
1426 |
||
6543 | 1427 |
getFontResolution |
1428 |
device isNil ifTrue:[ ^ 72 @ 72 ]. |
|
1429 |
^ device resolution |
|
1430 |
! |
|
1431 |
||
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1432 |
height |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1433 |
"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
|
1434 |
|
6656 | 1435 |
height isNil ifTrue:[ |
6707 | 1436 |
height := self xftFontGetHeight: fontId |
6656 | 1437 |
]. |
1438 |
^ height |
|
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1439 |
|
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1440 |
"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
|
1441 |
! |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1442 |
|
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1443 |
isFixedWidth |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1444 |
"return true, if this is a fixed pitch font (i.e. all characters |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1445 |
are of the same width)" |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1446 |
|
7342 | 1447 |
fixedWidth isNil ifTrue:[ |
1448 |
(device notNil and:[fontId notNil]) ifTrue:[ |
|
1449 |
|w| |
|
1450 |
||
1451 |
"/ take some obvously different chars |
|
1452 |
w := self widthOf:'.'. |
|
1453 |
((self widthOf:'i') == w |
|
1454 |
and:[ (self widthOf:'W') == w |
|
1455 |
and:[ (self widthOf:' ') == w ]] |
|
1456 |
) ifTrue:[ |
|
1457 |
fixedWidth := w. |
|
1458 |
] ifFalse:[ |
|
1459 |
fixedWidth := false |
|
1460 |
] |
|
1461 |
] |
|
1462 |
]. |
|
1463 |
^ fixedWidth notNil and:[fixedWidth isInteger] |
|
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1464 |
|
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1465 |
"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
|
1466 |
! |
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1467 |
|
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
|
1468 |
maxAscent |
7342 | 1469 |
"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
|
1470 |
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
|
1471 |
|
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
|
1472 |
^ 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
|
1473 |
|
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
|
1474 |
"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
|
1475 |
! |
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
|
1476 |
|
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
|
1477 |
maxDescent |
7342 | 1478 |
"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
|
1479 |
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
|
1480 |
|
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
|
1481 |
^ 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
|
1482 |
|
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
|
1483 |
"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
|
1484 |
! |
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
|
1485 |
|
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
|
1486 |
maxWidth |
7342 | 1487 |
"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
|
1488 |
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
|
1489 |
|
7342 | 1490 |
(fixedWidth class == SmallInteger) ifTrue:[ |
1491 |
^ fixedWidth |
|
1492 |
]. |
|
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
|
1493 |
^ self xftFontGetMaxAdvanceWidth: fontId |
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
|
1494 |
|
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
|
1495 |
"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
|
1496 |
! |
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
|
1497 |
|
7342 | 1498 |
width |
1499 |
"return the font's characters width; |
|
1500 |
That is a number of units (usually pixels). |
|
1501 |
For variable pitch fonts, the width of the space character is returned. |
|
1502 |
For fixed fonts, this is the same as minWidth or maxWidth (or any character). |
|
1503 |
The receiver must be associated to a device, for this query to be legal." |
|
1504 |
||
1505 |
fixedWidth class == SmallInteger ifTrue:[ |
|
1506 |
^ fixedWidth |
|
1507 |
]. |
|
1508 |
^ self widthOf:' ' |
|
1509 |
||
1510 |
"Modified: 30.4.1996 / 16:43:45 / cg" |
|
1511 |
! |
|
1512 |
||
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1513 |
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
|
1514 |
"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
|
1515 |
|
6472 | 1516 |
|extents maxWidthOfSingleGlyph| |
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1517 |
|
6187
cfe33a9940ee
Memory/performance optimization - use stack-allocated XftColor.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6186
diff
changeset
|
1518 |
(stop < start) ifTrue:[^ 0]. |
6472 | 1519 |
maxWidthOfSingleGlyph := self maxWidth. |
1520 |
"xOff from XFTTextExtents is a signed short. |
|
1521 |
Work arond for long strings" |
|
1522 |
(stop - start + 1) * maxWidthOfSingleGlyph > 32767 ifTrue:[ |
|
6819
f91377f97414
Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
1523 |
|total chunkSize| |
6472 | 1524 |
|
6819
f91377f97414
Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
1525 |
chunkSize := (32767 // maxWidthOfSingleGlyph) - 1. |
f91377f97414
Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
1526 |
total := 0. |
f91377f97414
Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
1527 |
start to:stop by:chunkSize do:[:eachChunkStart| |
f91377f97414
Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
1528 |
extents := self xftTextExtents:device displayId font:fontId string:aString |
f91377f97414
Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
1529 |
from:eachChunkStart to:((eachChunkStart+chunkSize-1) min:stop). |
f91377f97414
Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
1530 |
"/ extents --> #(width height x y xOff yOff) |
f91377f97414
Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
1531 |
total := total + extents fifth. |
f91377f97414
Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
1532 |
]. |
f91377f97414
Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
1533 |
^ total. |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
1534 |
]. |
6472 | 1535 |
extents := self xftTextExtents: device displayId font:fontId string:aString from:start to:stop. |
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1536 |
"/ extents --> #(width height x y xOff yOff) |
7342 | 1537 |
"/ cg: shouln't this be first ?!! |
6183
a21827076de1
Fix for bad layout and segfault when selecting whole line.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6182
diff
changeset
|
1538 |
^ extents fifth. |
6182
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1539 |
|
8bf2372670d9
Fixes to make XftFontDescription>>example1 to render something. Sometimes it segfaults
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6180
diff
changeset
|
1540 |
"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
|
1541 |
"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
|
1542 |
! ! |
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1543 |
|
6200
8f0d25eec888
class: XftFontDescription
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6199
diff
changeset
|
1544 |
!XftFontDescription methodsFor:'release'! |
8f0d25eec888
class: XftFontDescription
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6199
diff
changeset
|
1545 |
|
6344 | 1546 |
releaseFromDevice |
1547 |
"I am no longer available on the device" |
|
1548 |
||
6946 | 1549 |
Lobby unregister:self. |
7055 | 1550 |
"/ cg: no, xftDrawDestroy should not be done. |
1551 |
"/ (releaseFromDevice is called when either the display connection |
|
1552 |
"/ is lost, or a snapshot image is restarted) |
|
1553 |
"/ self xftDrawDestroy. |
|
6946 | 1554 |
|
7298
6cc9d56cb05d
Issue #76: XFT: Flush `RecentlyUsedFonts` cache when restarting from snapahot
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7223
diff
changeset
|
1555 |
RecentlyUsedFonts := nil. |
6344 | 1556 |
device := nil. |
1557 |
fontId := nil. |
|
6946 | 1558 |
closestFont := nil. |
7718
6e51fc8b207f
XFT: Drop support for shared drawables.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7717
diff
changeset
|
1559 |
|
6e51fc8b207f
XFT: Drop support for shared drawables.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7717
diff
changeset
|
1560 |
"Modified: / 25-11-2016 / 00:12:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6200
8f0d25eec888
class: XftFontDescription
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6199
diff
changeset
|
1561 |
! ! |
8f0d25eec888
class: XftFontDescription
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6199
diff
changeset
|
1562 |
|
6319 | 1563 |
!XftFontDescription methodsFor:'testing'! |
1564 |
||
6936 | 1565 |
isScaledFont |
1566 |
"Xft fonts are always scaled" |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
1567 |
|
6936 | 1568 |
^ true |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
1569 |
! |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7342
diff
changeset
|
1570 |
|
6319 | 1571 |
isXftFont |
1572 |
^ true |
|
1573 |
! ! |
|
1574 |
||
6264 | 1575 |
!XftFontDescription::FCFontListParser class methodsFor:'documentation'! |
1576 |
||
1577 |
documentation |
|
1578 |
" |
|
1579 |
parses fc-list output to get a list of XftFontDescriptions |
|
1580 |
||
1581 |
[author:] |
|
6319 | 1582 |
cg |
6264 | 1583 |
|
1584 |
[instance variables:] |
|
1585 |
||
1586 |
[class variables:] |
|
1587 |
||
1588 |
[see also:] |
|
1589 |
||
1590 |
" |
|
1591 |
! ! |
|
1592 |
||
6263 | 1593 |
!XftFontDescription::FCFontListParser methodsFor:'api'! |
1594 |
||
1595 |
listOfAvailableFonts |
|
6337 | 1596 |
|readEntry list l fcListProg| |
6263 | 1597 |
|
1598 |
list := OrderedCollection new. |
|
1599 |
||
6319 | 1600 |
readEntry := |
6656 | 1601 |
[ |
1602 |
|key| |
|
6263 | 1603 |
|
6656 | 1604 |
[l startsWith:'Pattern has'] whileFalse:[ |
1605 |
l := pipeStream nextLine. Transcript showCR:l. |
|
1606 |
]. |
|
7114 | 1607 |
|
7221 | 1608 |
currentDescription := XftFontDescription new. |
6656 | 1609 |
[ l := pipeStream nextLine. l notEmptyOrNil ] whileTrue:[ |
7221 | 1610 |
"/ Transcript showCR:l. |
6656 | 1611 |
lineStream := l readStream. lineStream skipSeparators. |
1612 |
key := lineStream upToSeparator. |
|
7221 | 1613 |
( |
6656 | 1614 |
#('family:' 'style:' 'slant:' 'weight:' 'width:' |
1615 |
'pixelsize:' 'spacing:' 'foundry:' 'antialias:' |
|
1616 |
'file:' 'outline' 'scalable:' 'charset:' 'lang:' |
|
1617 |
'fontversion:' 'fontformat:' 'decorative:' 'index:' |
|
1618 |
'outline:' 'familylang:' 'stylelang:' 'fullname:' |
|
1619 |
'fullnamelang:' 'capability:' 'hash:' 'postscriptname:' |
|
1620 |
) includes:key |
|
7221 | 1621 |
) ifTrue:[ |
6656 | 1622 |
self perform:('fc_',(key allButLast)) asSymbol |
7221 | 1623 |
] ifFalse:[ |
6656 | 1624 |
Transcript show:'Xft ignored line: '; showCR:l. |
1625 |
self breakPoint:#cg. |
|
7221 | 1626 |
]. |
1627 |
]. |
|
1628 |
list add:currentDescription |
|
1629 |
]. |
|
6319 | 1630 |
|
6337 | 1631 |
fcListProg := #('/usr/bin/fc-list' '/usr/X11/bin/fc-list') detect:[:eachProg| |
7221 | 1632 |
eachProg asFilename isExecutableProgram |
1633 |
] ifNone:[ |
|
1634 |
'XftFontDescription [warning]: fc-list program not found - no XFT fonts' errorPrintCR. |
|
1635 |
^ list. |
|
1636 |
]. |
|
6337 | 1637 |
|
1638 |
pipeStream := PipeStream readingFrom:fcListProg, ' -v'. |
|
6263 | 1639 |
[ |
7221 | 1640 |
[pipeStream atEnd] whileFalse:[ |
6656 | 1641 |
l := pipeStream nextLine. |
7221 | 1642 |
readEntry value. |
1643 |
] |
|
6263 | 1644 |
] ensure:[ |
7221 | 1645 |
pipeStream close |
6263 | 1646 |
]. |
1647 |
^ list |
|
1648 |
||
1649 |
" |
|
6337 | 1650 |
FCFontListParser new listOfAvailableFonts |
6263 | 1651 |
" |
1652 |
! ! |
|
1653 |
||
1654 |
!XftFontDescription::FCFontListParser methodsFor:'font list keywords'! |
|
1655 |
||
1656 |
fc_antialias |
|
1657 |
"helper for font listing" |
|
1658 |
||
6319 | 1659 |
currentDescription isAntialiasedFont:(self getBoolean). |
6263 | 1660 |
! |
1661 |
||
6264 | 1662 |
fc_capability |
1663 |
"helper for font listing" |
|
1664 |
||
6319 | 1665 |
"currentDescription capability:" (self getString). |
6264 | 1666 |
! |
1667 |
||
6263 | 1668 |
fc_charset |
1669 |
"helper for font listing" |
|
1670 |
||
6319 | 1671 |
|page bits l min max minCode maxCode| |
6263 | 1672 |
|
1673 |
[ l := pipeStream nextLine. l notEmpty ] whileTrue:[ |
|
7221 | 1674 |
"/ Transcript show:'->'; showCR:l. |
1675 |
(l startsWith:Character tab) ifFalse:[ |
|
1676 |
(l startsWith:'(') ifFalse:[self halt]. |
|
6393 | 1677 |
currentDescription minCode:minCode. |
1678 |
currentDescription maxCode:maxCode. |
|
7221 | 1679 |
^ self. |
1680 |
]. |
|
6264 | 1681 |
|
7221 | 1682 |
lineStream := l readStream. |
1683 |
lineStream skipSeparators. |
|
1684 |
page := Integer readFrom:(lineStream upTo:$:) radix:16. |
|
1685 |
lineStream next. |
|
1686 |
bits := 0 to:7 collect:[:i| |
|
1687 |
lineStream skipSeparators. |
|
1688 |
Integer readFrom:(lineStream upToSeparator) radix:16. |
|
1689 |
]. |
|
1690 |
min := (page * 256 + 0). |
|
1691 |
max := (page * 256 + 255). |
|
1692 |
minCode isNil ifTrue:[ |
|
1693 |
minCode := min. |
|
1694 |
maxCode := max. |
|
1695 |
] ifFalse:[ |
|
1696 |
minCode := minCode min:min. |
|
1697 |
maxCode := maxCode max:max. |
|
1698 |
]. |
|
6263 | 1699 |
]. |
6365
cf89c4bedea4
Instvar drawId renamed to sharedDrawId.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6356
diff
changeset
|
1700 |
"/ currentDescription characterSet:(self getString). |
6319 | 1701 |
currentDescription minCode:minCode. |
1702 |
currentDescription maxCode:maxCode. |
|
6263 | 1703 |
! |
1704 |
||
6319 | 1705 |
fc_decorative |
6263 | 1706 |
"helper for font listing" |
1707 |
||
6319 | 1708 |
currentDescription isDecorativeFont:(self getBoolean). |
6263 | 1709 |
! |
1710 |
||
1711 |
fc_family |
|
1712 |
"helper for font listing" |
|
1713 |
||
6319 | 1714 |
currentDescription family:(self getString). |
6263 | 1715 |
! |
1716 |
||
1717 |
fc_familylang |
|
1718 |
"helper for font listing" |
|
1719 |
||
6319 | 1720 |
"currentDescription familylang:" (self getString). |
6263 | 1721 |
! |
1722 |
||
6319 | 1723 |
fc_file |
6263 | 1724 |
"helper for font listing" |
1725 |
||
6319 | 1726 |
currentDescription file:(self getString). |
6263 | 1727 |
! |
1728 |
||
1729 |
fc_fontformat |
|
1730 |
"helper for font listing" |
|
1731 |
||
6319 | 1732 |
currentDescription fontFormat:(self getString). |
6263 | 1733 |
! |
1734 |
||
1735 |
fc_fontversion |
|
1736 |
"helper for font listing" |
|
1737 |
||
6319 | 1738 |
currentDescription fontVersion:(self getInteger). |
6263 | 1739 |
! |
1740 |
||
1741 |
fc_foundry |
|
1742 |
"helper for font listing" |
|
1743 |
||
6319 | 1744 |
currentDescription foundry:(self getString). |
6263 | 1745 |
! |
1746 |
||
6264 | 1747 |
fc_fullname |
1748 |
"helper for font listing" |
|
1749 |
||
6319 | 1750 |
"currentDescription fullname:" (self getString). |
7488 | 1751 |
! |
1752 |
||
1753 |
fc_fullnamelang |
|
1754 |
"helper for font listing" |
|
1755 |
||
1756 |
"currentDescription fullnamelang:" (self getString). |
|
1757 |
! |
|
1758 |
||
1759 |
fc_hash |
|
1760 |
"helper for font listing" |
|
1761 |
||
1762 |
"currentDescription hash:" self getString. |
|
1763 |
! |
|
1764 |
||
1765 |
fc_index |
|
1766 |
"helper for font listing" |
|
1767 |
||
1768 |
"currentDescription index:" (self getInteger). |
|
1769 |
! |
|
1770 |
||
1771 |
fc_lang |
|
1772 |
"helper for font listing" |
|
1773 |
||
1774 |
"/ currentDescription characterSet:(self getString). |
|
1775 |
! |
|
1776 |
||
6263 | 1777 |
fc_outline |
1778 |
"helper for font listing" |
|
1779 |
||
6319 | 1780 |
currentDescription isOutlineFont:(self getBoolean). |
6263 | 1781 |
! |
1782 |
||
1783 |
fc_pixelsize |
|
1784 |
"helper for font listing" |
|
1785 |
||
6325 | 1786 |
currentDescription setPixelSize:(self getInteger). |
1787 |
currentDescription setSizeUnit:#px. |
|
1788 |
"/ currentDescription setSize:(self getInteger). |
|
1789 |
"/ currentDescription setSizeUnit:#pt. |
|
6263 | 1790 |
! |
1791 |
||
7488 | 1792 |
fc_postscriptname |
1793 |
"helper for font listing" |
|
1794 |
||
1795 |
"currentDescription postscriptname:" self getString. |
|
1796 |
! |
|
1797 |
||
6263 | 1798 |
fc_scalable |
1799 |
"helper for font listing" |
|
1800 |
||
6319 | 1801 |
currentDescription isScalableFont:(self getBoolean). |
6263 | 1802 |
! |
1803 |
||
1804 |
fc_slant |
|
1805 |
"helper for font listing" |
|
1806 |
||
6319 | 1807 |
currentDescription slant:(self getInteger). |
6263 | 1808 |
! |
1809 |
||
1810 |
fc_spacing |
|
1811 |
"helper for font listing" |
|
1812 |
||
6319 | 1813 |
currentDescription spacing:(self getInteger). |
6263 | 1814 |
! |
1815 |
||
1816 |
fc_style |
|
1817 |
"helper for font listing" |
|
1818 |
||
6319 | 1819 |
|xftStyle| |
1820 |
||
1821 |
xftStyle := self getString. |
|
6391 | 1822 |
"/ ((xftStyle includesString:'Bold') or:[xftStyle includesString:'Fett']) ifTrue:[ |
1823 |
"/ currentDescription face:'bold'. |
|
1824 |
"/ currentDescription style:'roman'. |
|
1825 |
"/ ^ self. |
|
1826 |
"/ ]. |
|
1827 |
((xftStyle includesString:'Italic') or:[xftStyle includesString:'Oblique']) ifTrue:[ |
|
1828 |
"/ currentDescription face:'medium'. |
|
6393 | 1829 |
currentDescription style:'italic'. |
7221 | 1830 |
^ self. |
6319 | 1831 |
]. |
6391 | 1832 |
"/ (xftStyle includesString:'Regular') ifTrue:[ |
1833 |
"/ currentDescription face:'regular'. |
|
1834 |
"/ currentDescription style:'roman'. |
|
1835 |
"/ ^ self. |
|
1836 |
"/ ]. |
|
6319 | 1837 |
"/ self halt. |
6391 | 1838 |
"/ currentDescription face:'medium'. |
6319 | 1839 |
currentDescription style:'roman'. |
6263 | 1840 |
! |
1841 |
||
7488 | 1842 |
fc_stylelang |
1843 |
"helper for font listing" |
|
1844 |
||
1845 |
"currentDescription stylelang:" (self getString). |
|
1846 |
! |
|
1847 |
||
6263 | 1848 |
fc_weight |
1849 |
"helper for font listing" |
|
7488 | 1850 |
|
6319 | 1851 |
currentDescription weight:(self getInteger). |
6263 | 1852 |
! |
1853 |
||
1854 |
fc_width |
|
1855 |
"helper for font listing" |
|
1856 |
||
6319 | 1857 |
currentDescription width:(self getInteger). |
7488 | 1858 |
! ! |
1859 |
||
6263 | 1860 |
!XftFontDescription::FCFontListParser methodsFor:'helpers'! |
1861 |
||
6319 | 1862 |
getBoolean |
6263 | 1863 |
"helper for font listing" |
1864 |
||
1865 |
|s| |
|
1866 |
||
1867 |
lineStream skipSeparators. |
|
6319 | 1868 |
s := lineStream nextAlphaNumericWord. |
1869 |
^ s = 'FcTrue'. |
|
6263 | 1870 |
! |
1871 |
||
6264 | 1872 |
getInteger |
1873 |
"helper for font listing" |
|
1874 |
||
1875 |
lineStream skipSeparators. |
|
6319 | 1876 |
^ Integer readFrom:lineStream. |
6264 | 1877 |
! |
1878 |
||
6319 | 1879 |
getString |
6263 | 1880 |
"helper for font listing" |
1881 |
||
1882 |
lineStream skipSeparators. |
|
6319 | 1883 |
lineStream peekFor:$". |
1884 |
^ (lineStream upTo:$"). |
|
7114 | 1885 |
! ! |
1886 |
||
6176 | 1887 |
!XftFontDescription class methodsFor:'documentation'! |
1888 |
||
1889 |
version |
|
6936 | 1890 |
^ '$Header$' |
6176 | 1891 |
! |
1892 |
||
1893 |
version_CVS |
|
6936 | 1894 |
^ '$Header$' |
6821
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
1895 |
! |
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
1896 |
|
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
1897 |
version_HG |
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
1898 |
|
0e2fb9a04314
Added XftFontDescription class>>named: and corresponding primitived (XftNameParse())
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6819
diff
changeset
|
1899 |
^ '$Changeset: <not expanded> $' |
6176 | 1900 |
! ! |
6180
6034bf4c5022
More work on XftFontDescription.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6179
diff
changeset
|
1901 |
|
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
|
1902 |
|
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
|
1903 |
XftFontDescription initialize! |