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