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