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