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