eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'XftFontDescription':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: XftFontDescription


Inheritance:

   Object
   |
   +--FontDescription
      |
      +--XftFontDescription

Package:
stx:libview
Category:
Graphics-Support
Version:
rev: 1.147 date: 2024/04/22 17:47:40
user: stefan
file: XftFontDescription.st directory: libview
module: stx stc-classLibrary: libview

Description:


WARNING: Unfinished.

Experimental implementation of custom font rendered using
Xft library (UNIX / X Window only), To actually use it,
add following definitions to the end of stx/configurations/myConf
(works on Ubuntu 12.10)

--- snip ---
XDEFS+=-DXFT
XINCLUDE+=$(shell pkg-config --cflags xft)
LIB_XFT=-l:libXft.so.2 -l:libfontconfig.so.1
--- snip --

NOTE: This class should be named XftFont, however then
there would be a name clash with XftFont structure
defined in Xft.h - therefore the class is named
XftFontDescription to avoid that name clash.



[instance variables:]

[class variables:]

copyright

COPYRIGHT (c) 2013 by Jan Vrany COPYRIGHT (c) 2013 by Claus Gittinger / eXept Software AG All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

change & update
o  aboutToDestroyViewWithDevice: aDevice id: aWindowId
a view is going to be destroyed.
Have to disassociate the XftDrawId from the drawableId aWindowId

class initialization
o  initialize
Invoked at system start or when the class is dynamically loaded.

examples
o  example1
XftFontDescription example1

o  example2
XftFontDescription example2

o  example3
XftFontDescription example2

initialization
o  flushListOfAvailableFonts
XftFontDescription flushListOfAvailableFonts

instance creation
o  for: aFontOrFontDescription

o  new
(comment from inherited method)
return an instance of myself without indexed variables

primitives
o  xftAvailable

o  xftFontClose: fontIdArg displayId: displayId

o  xftFontGetAscent: fontIdArg

o  xftFontGetDescent: fontIdArg

o  xftFontGetHeight: fontIdArg

o  xftFontGetMaxAdvanceWidth: fontIdArg

o  xftFontGetPattern: fontIdArg

queries
o  listOfAvailableFonts
uses fc-list to get a list of available fontDescriptions

Usage example(s):

     XftFontDescription flushListOfAvailableFonts.
     XftFontDescription listOfAvailableFonts

utilities
o  fixedLC_CTYPE
to suppress the disturbing warning messages from fontconfig,
if LC_CTYPE is wrong (osx problem only?)


Instance protocol:

accessing
o  encoding
(comment from inherited method)
return the font's encoding, as a symbol
such as #'iso8859', #'jis0208.1983' or #ascii.
If the encoding is not known, return nil;
You should assume ascii/iso8859-encoding then.

o  face
(comment from inherited method)
return the face, a string

o  fullName

o  graphicsDevice
(comment from inherited method)
return the device I am on

o  maxCode
16rFFFF

o  maxCode: something

o  minCode
(comment from inherited method)
return the smallest UCS code in font.
Dummy for now

o  minCode: something

o  style
(comment from inherited method)
return the style, a string

o  weight: aNumber
set the weight. The face is the string representation of weight.

accessing-private
o  getXftFontId

o  setFontId: fontIdArg

converting
o  asNonXftFont
in some situations, we do not want an Xft font.
Return an abstract fontDescription corresponding to the receiver

Usage example(s):

    |view1 view2|

    view1 := TextView new openAndWaitUntilVisible.
    view2 := TextView new openAndWaitUntilVisible.
    view1 font:(Button defaultFont).
    view1 contents:'Hello world'.
    view2 font:(Button defaultFont asNonXftFont onDevice:Display).
    view2 contents:'Hello world'.

displaying
o  displayString: aString from: index1 to: index2 x: x y: y in: aGC opaque: opaque
this is only called for fonts which have a nil fontId,
and therefore use the replacementFont. Should never be called
for non-replacement fonts.

error reporting
o  primitiveFailed
(comment from inherited method)
report an error that some primitive code failed.
The error is reported by raising the PrimitiveFailure exception.

o  primitiveFailed: errorString
(comment from inherited method)
report an error that some primitive code failed.
The error is reported by raising the PrimitiveFailureSignal exception.

finalization
o  finalize
(comment from inherited method)
this is invoked for executor objects which have been registered
in a Registry, when the original object dies.
Subclasses may redefine this method
This interface is also VW-compatible

getting a device font
o  installInDeviceForGCId: aGCId
install the font for aGCId

o  onDevice: aGraphicsDevice
Create a new XftFont representing the font closest to
myself on aDevice; if one already exists, return that one.

o  onDevice: aGraphicsDevice ifAbsent: aBlock
Create a new XftFont representing the font closest to
myself on aDevice; if one already exists, return that one.

Usage example(s):

     (XftFontDescription family:'monospace' size:16) onDevice:Screen current ifAbsent:[self halt].

initialization
o  initialize
Invoked when a new instance is created.

o  isScaledFont

o  reinitialize
fontId is no longer valid after snapIn

o  setDevice: deviceArg patternId: patternIdArg fontId: fontIdArg
name := patternIdArg get: 'fullname' index: 0.

primitives
o  xftTextExtents: displayIdArg string: aString from: start to: stop into: extentsArrayOrNil
get the extents of aString.
Answer thr width of aString (in reality the xOff).
If extentArrayOrNil is an Array, fill is with the extent info:
#(width height x y xOff yOff ascent descent).

queries-dimensions
o  ascent
return the ascent - the number of pixels above the baseLine.

o  descent
return the descent - the number of pixels below the baseLine.

o  getFontMetrics

o  getFontResolution

o  height
return the height - the number of pixels above plus below the baseLine.

o  isFixedWidth
return true, if this is a fixed pitch font
(i.e. all characters are of the same width).
Also called monospaced fonts

o  maxAscent
return the font's maximum-ascent (i.e. the maximum of all characters);
That is the number of units (usually pixels) above the baseline.

o  maxDescent
return the font's maximum-descent (i.e. the maximum of all characters);
That is the number of units (usually pixels) below the baseline.

o  maxWidth
return the font's maximum-width character (i.e. the maximum of all characters);
That is a number of units (usually pixels).

o  patternStringForId: patternIdArg

o  width
return the font's characters width;
That is a number of units (usually pixels).
For variable pitch fonts, the width of the space character is returned.
For fixed fonts, this is the same as minWidth or maxWidth (or any character).
The receiver must be associated to a device, for this query to be legal.

o  widthOf: aString from: start to: stop
return the width of a sub string

release
o  releaseFromDevice
I am no longer available on the device

o  restored
private: instance has been restored (either from snapin or binary store);
flush device handles

testing
o  isAlienFont
my GraphicsContext knows how to disply strings in my font.
Alien fonts are eg. Hershey or Bitmap fonts, which are drawn by st/x itself.

o  isXftFont
anwer true, if this is an Xft font.
Sure, I am


Private classes:

    FCFontListParser
    FCPatternHandle
    XftDrawHandle
    XftFontHandle


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Thu, 21 Nov 2024 19:03:29 GMT