eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'FontDescription':

Home

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

Class: FontDescription


Inheritance:

   Object
   |
   +--FontDescription
      |
      +--BitmapFont
      |
      +--CompoundFont
      |
      +--Font
      |
      +--TTFontDescription
      |
      +--XftFontDescription

Package:
stx:libview
Category:
Graphics-Support
Version:
rev: 1.139 date: 2024/03/07 12:22:32
user: stefan
file: FontDescription.st directory: libview
module: stx stc-classLibrary: libview

Description:


FontDescription is just a place-holder for scanned font names.

[Instance variables:]
    family          <String>        the font's family ('courier', 'helvetica' etc)
    face            <String>        the font's face ('bold', 'medium' etc)
    style           <String>        the font's style ('roman', 'italic', 'oblique')
    size            <String>        the font's size (by default, in points, not in pixels; but see sizeUnit)
    encoding        <Symbol>        the font's encoding (usually #iso8859-1)

    manufacturer    <nil|String|Array>
                                    the font's origin - if known
    name            <nil|String|Array>
                                    the platform specific name

    flags           <SmallInteger>  holds serif/italic etc. as flag bits
    masks           <SmallInteger>  currently dummy; to allow ST-80 compatible subclassing
    pixelSize       <SmallInteger>  currently dummy; to allow ST-80 compatible subclassing
    sizeUnit        <Symbol>        #px or #pt; defines what size is measuring
    weight          <SmallInteger>  for real fonts, which support it
    slant           <SmallInteger>  for real fonts, which support it

[class variables:]
    BoldnessMask                    currently dummy; to allow ST-80 compatible subclassing
    FixedFlag                       currently dummy; to allow ST-80 compatible subclassing
    ItalicFlag                      currently dummy; to allow ST-80 compatible subclassing
    OutlineFlag                     currently dummy; to allow ST-80 compatible subclassing
    SerifFlag                       currently dummy; to allow ST-80 compatible subclassing
    ShadowFlag                      currently dummy; to allow ST-80 compatible subclassing
    StrikeoutFlag                   currently dummy; to allow ST-80 compatible subclassing
    UnderlineFlag                   currently dummy; to allow ST-80 compatible subclassing

copyright

COPYRIGHT (c) 1994 by Claus Gittinger 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:

accessing
o  defaultEncoding: encodingSymbol

o  genericFonts

defaults
o  defaultEncoding
^ #'iso8859-1'

o  defaultFace

o  defaultSize

o  defaultStyle

initialization
o  initialize
initialize class variables

o  initializeCharacterEncodingToCharacterSetMapping
character encoding

o  initializeCharacterSetToFontMapping
character sets

o  initializeGenericFonts
generic fonts, that do not exist as a device font and are
replaced by a real font

instance creation
o  family: familyString
returns a font for given family and default (12pt) size
with default encoding.
The new fonts face defaults `medium', its style to `roman'.
The returned font is not associated to a specific device

Usage example(s):

     Font family:'helvetica'
     Font family:'courier'

o  family: familyString face: faceString size: sizeNum
returns a font for given family and size with default encoding.
The new fonts style defaults to `roman'.
The returned font is not associated to a specific device

Usage example(s):

     Font family:'helvetica' face:'medium' size:10
     Font family:'helvetica' face:'bold' size:10
     Font family:'courier'   face:'bold' size:10

o  family: familyString face: faceString style: styleString size: sizeNum
returns a font for given family, face, style and size with default encoding.
The returned font is not associated to a specific device

Usage example(s):

     Font family:'helvetica' face:'medium' style:'roman'  size:10
     Font family:'helvetica' face:'medium' style:'italic' size:10
     Font family:'helvetica' face:'bold'   style:'roman'  size:10
     Font family:'courier'   face:'bold'   style:'italic' size:10

o  family: familyString face: faceString style: styleString size: sizeNum encoding: encoding
returns a font for given family, face, style, size and the specified encoding.
The returned font is not associated to a specific device

o  family: familyString face: faceString style: styleString size: size sizeUnit: sizeUnit encoding: encoding
returns a font for given family, face, style, size and the specified encoding.
The returned font is not associated to a specific device

o  family: familyString pixelSize: sizeNum
returns a font for given family and pixelSize with default encoding.
The new fonts face defaults to `medium', its style to `roman'.
Notice: the returned font will typically only be usable on a screen,
and will not scale as to the devices resolution.
Use #family:size: for resolution-independent sizing.

Usage example(s):

     (Font family:'helvetica' size:10) onDevice:Screen current
     (Font family:'helvetica' pixelSize:10) onDevice:Screen current

o  family: familyString size: sizeNum
returns a font for given family and size with default encoding.
The new fonts face defaults to `medium', its style to `roman'.
The returned font is not associated to a specific device

Usage example(s):

     Font family:'helvetica' size:10
     Font family:'courier' size:10

o  family: familyString size: sizeNum encoding: encoding
returns a font for given family and size with default encoding.
The new fonts face defaults to `medium', its style to `roman'.
The returned font is not associated to a specific device

Usage example(s):

     Font family:'helvetica' size:10 encoding:#'iso8859-1'
     Font family:'courier' size:10 encoding:#'iso8859-1'

o  family: familyString style: aStyle size: sizeNum
returns a font for given family and size with default encoding.
The new fonts face defaults to `medium', its style to `roman'.
The returned font is not associated to a specific device

Usage example(s):

     Font family:'helvetica' style:#roman size:48
     Font family:'courier' style:#roman size:10

o  name: aFontName
returns a font with the given explicit name.
WARNING:
You should not use explicit naming, since font names vary
with operatingSystems, devices and architecture.

This interface is provided for special purposes only.
On X, the name given should be according the X fontname conventions;
i.e. something like: '-*-times-bold-r-normal-*-*-240-*-*-*-*-iso8859-1'.

On other devices, font naming may be completely different.

Usage example(s):

     Font name:'-*-times-bold-r-normal-*-*-240-*-*-*-*-iso8859-1'
     Font name:'6x10'
     Font name:'k14'
     ((Font name:'k14') on:Display) encoding

queries
o  characterSetForCharacterEncoding: encodingName
return the font-encoding for a character encoding

Usage example(s):

     FontDescription characterSetForCharacterEncoding:'utf8'
     FontDescription characterSetForCharacterEncoding:'koi8-r'
     FontDescription characterSetForCharacterEncoding:'unicode'

o  fontNamePatternForCharset: aCharSetName
return the font-encoding for an iso-charset

Usage example(s):

     FontDescription fontNamePatternForCharset:'iso2022-jp'
     FontDescription fontNamePatternForCharset:'euc-jp'

o  preferredFontEncodingFor: fileEncoding
given a file encoding, return a corresponding match pattern for a preferred fontEncoding


Instance protocol:

Compatibility-ST80
o  boldness: aNumber
added for ST-80 compatibility; actually ignored currently

o  color: aColor
added for ST-80 compatibility; actually ignored currently

o  encodings: aCollectionOfEncodings
added for ST-80 compatibility; actually ignored currently

o  fixedWidth: aBoolean
added for ST-80 compatibility; actually ignored currently

o  italic: aBoolean
added for ST-80 compatibility; actually ignored currently

o  outline: aBoolean
added for ST-80 compatibility; actually ignored currently

o  pixelSize

o  pixelSize: aNumber
if specified, the size is ignored, and a pixel-sized font is chosen.

o  serif: aBoolean
added for ST-80 compatibility; actually ignored currently

o  setPixelSize: aNumber

o  setSize: aNumber

o  setSizeUnit: aSymbol

o  shadow: aBoolean
added for ST-80 compatibility; actually ignored currently

o  strikeout: aBoolean
added for ST-80 compatibility; actually ignored currently

o  underline: aBoolean
added for ST-80 compatibility; actually ignored currently

accessing
o  device
return the device I am on

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  encoding
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
return the face, a string

o  face: aString
set the face, a string such as 'bold'

o  family
return the family, a string

o  family: aString
set the family, a string

o  family: familyString face: faceString style: styleString size: sizeNum encoding: encodingString
set the instance values

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  family: familyString face: faceString style: styleString size: sizeArg sizeUnit: sizeUnitArg encoding: encodingString
set the instance values

o  file: aNumber
set the file

o  flags

o  flags: anInteger

o  fontFormat: aString
set the fontFormat

o  fontId
return the device-dependent font-id

o  fontVersion: aNumber
set the fontVersion

o  foundry
return the manufacturer/foundry

o  foundry: aString
set the value of the manufacturer/foundry

o  graphicsDevice
return the device I am on

o  hasOverlappingCharacters: aBoolean
set whether this has overlapping chars (for windows cleartype drawing only)

o  isAntialiasedFont: aBoolean
set whether this is an antialiased font (currently for XftFonts only)

o  isDecorativeFont: aBoolean
set whether this is a decorative font (currently for XftFonts only)

o  isForceNonXFTFont: aBoolean
set this to prevent that the font is resolved as an Xft font.
Special workaround hack: some operations (drawing into a form)
may not work correctly with Xft fonts

o  isGenericFont: aBoolean
set whether this is a pseudo font

o  isOutlineFont: aBoolean
set whether this is an outline font (currently for XftFonts only)

o  isScalableFont: aBoolean
set whether this is a scalable font (currently for XftFonts only)

o  languages: aLanguagesString
a string containing the supported languages separated by vertical bars;
eg. |de|en|..|

o  manufacturer
return the manufacturer/foundry

o  manufacturer: aString
set the value of the manufacturer/foundry

o  masks

o  masks: something

o  name
the name (typically filename) if known

o  name: aString

o  sizeUnit
currently returns one of #pt or #px (internal use only)

o  slant
get the slant

Usage example(s):

slant

o  slant: aNumber
set the slant

o  spacing
get the spacing

Usage example(s):

spacing

o  spacing: aNumber
set the spacing

o  style
return the style, a string

o  style: aString
set the style

o  weight: aNumber
set the weight

o  width: aNumber
set the width

comparing
o  = aFont
two fonts are considered equal, if the font-name components are;
independent of the device, the font is on

o  hash
return a number for hashing - req'd since = is redefined.

o  sameDeviceFontAs: aFont

converting
o  asBold
return the bold font corresponding to the receiver

o  asEncoding: anotherEncoding
CompoundFonts do not have a family

o  asFace: anotherFace
return the bold font corresponding to the receiver

o  asFamily: anotherFamily
return another font corresponding to the receiver face, style and size but
with another family

o  asFontDescription

o  asFontWithPixelSize: anotherSize
return another font corresponding to the receiver's family, face and style but
with another pixel size.
Alias for asPixelSize:

o  asItalic
return the italic font corresponding to the receiver

o  asNonXftFont
return a non XFT font/fontDescription corresponding to the receiver

o  asPixelSize: anotherSize
return another font corresponding to the receiver's family, face and style but
with another pixel size

o  asSize: anotherPointSize
return another font corresponding to the receiver's family,
face and style but with another (point-) size

o  asStyle: anotherStyle
CompoundFonts do not have a family

o  fromLiteralArrayEncoding: literalEncoding
read my contents from a aLiteralEncodedArray.
Must match to what is generated in #literalArrayEncoding

o  literalArrayEncoding
return myself encoded as a literal array.
Must match to what is expected in #fromLiteralArrayEncoding:

o  on: aDevice
given the receiver, return a device Font

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  onDevice: aDevice
given the receiver, return a device Font

o  scaled: factor
return another font corresponding to the receiver's family, face and style but
with another pixel size

o  size: anotherSize
return a font corresponding to the receiver, but with different size.

** This is an obsolete interface - do not use it (it may vanish in future versions) **

displaying
o  displayOpaqueString: aString from: index1 to: index2 x: x y: y in: aGC
display a partial string at some position in aGC.
- display part of a string, drawing both fore- and background pixels

o  displayOpaqueString: aString x: x y: y in: aGC
display a string at some position in aGC.

o  displayString: aString from: index1 to: index2 x: x y: y in: aGC
display a partial string at some position in aGC.

o  displayString: aString from: index1 to: index2 x: x y: y in: aGC opaque: opaque
display a partial string at some position in aGC.

** This method must be redefined in concrete classes (subclassResponsibility) **

o  displayString: aString from: index1 to: index2 x: x0 y: y0 in: aGC opaque: opaque maxWidth: maxWidth
redefined for subclasses that do not implement maxWidth

o  displayString: aString x: x y: y in: aGC
display a string at some position in aGC.

errors
o  errorNoDevice
a query was made for device-specific info

getting a device font
o  onDevice: aDevice ifAbsent: exceptionBlock
create a new Font representing the same font as
myself on aDevice. This does NOT try to look for existing
or replacement fonts (i.e. can be used to get physical fonts).

o  onDevice: aDevice xFontsOnly: xFontsOnly xftFontsOnly: xftFontsOnly ifAbsent: exceptionBlock
create a new Font representing the same font as myself on aDevice.
The xFontsOnly/xftFontsOnly are only relevant for XWindow devices;
xFontsOnly will suppress xft fonts, whereas xftFontsOnly will suppress x fonts
(the first is useful if ST/X has a slow remote X connection for display,
on which xft fonts are very slow. Yes, this is actually a reasonable setup
in use at one of our customers)
This does NOT try to look for existing
or replacement fonts (i.e. can be used to get physical fonts).

inspecting
o  inspector2TabCharacterSet
( an extension from the stx:libtool package )
an extra tab showing the font

o  inspector2TabPreview
( an extension from the stx:libtool package )
an extra tab showing the quick brown fox

printing & storing
o  printOn: aStream
append a user-friendly representation of the receiver to aStream

o  storeOn: aStream
append a user-friendly representation of the receiver to aStream

o  userFriendlyName
return a user-friendly printed representation of the receiver

Usage example(s):

     View defaultFont userFriendlyName
     Button defaultFont userFriendlyName

private
o  installInDeviceForGCId: aGCId
install the font for aGCId.
This is a No-op. Subclasses may redefine this.

queries
o  bold
return true, if the receiver is a bold font -
Added for st-80 compatibility.

o  boldness
return the boldness of the characters in this font 0 .. 1 -
Added for st-80 compatibility

o  color
return the default color in which this font is to be rendered.
Added for st-80 compatibility.
For now always black.

o  existsOn: aDevice
return true, if the receiver is available on aDevice;
false otherwise. This is a kludge method; its better to
ask a device for its available fonts and use this info ...
Notice, that if you simply use a font by name, the system
will automatically take a replacement font.

o  fullName

o  hasOverlappingCharacters
answer true, if this is a windows font where characters overlap

o  isAntialiasedFont
answer true, if this is an antialiased font (currently Xft only)

o  isDecorativeFont
answer true, if this is an decorative font (currently Xft only)

o  isForceNonXFTFont
this flag is set if someone wants to preven an XFT font to be used
when the receiver is resolved.
This is a temporary hack - some functions (drawing into a bitmap) may not work
correctly when Xft fonts are used

o  isGenericFont
answer true, if this is a pseudo font

o  isOutlineFont
answer true, if this is an outline font (currently Xft only)

o  isScaledFont
answer true, if this is a scalable font

o  italic
return true if this is an italic font -
Added for st-80 compatibility

o  serif
return true, if this font has serifs.
Added for st-80 compatibility

o  size
return the size, a number

o  species

o  underline
return true if this is an underlined font -
Added for st-80 compatibility
(always false here)

o  usableForLanguage: aLanguageString
true, if this font is usable for the given language, which is an iso language
string such as 'de', 'en' etc.
If the font has no language info (i.e. non-Xft fonts),
true is returned.

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

** This method must be redefined in concrete classes (subclassResponsibility) **

o  ascentOn: aDevice
return the ascent - the number of pixels above the baseLine.

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

** This method must be redefined in concrete classes (subclassResponsibility) **

o  descentOn: aDevice
return the ascent - the number of pixels above the baseLine.

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

** This method must be redefined in concrete classes (subclassResponsibility) **

o  heightOf: aString
return the height of the given string.
Here, assume the characters are of constant height

o  heightOf: aString on: aDevice
return the height of the given string on the given device.

o  heightOn: aDevice
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

** This method must be redefined in concrete classes (subclassResponsibility) **

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.

** This method must be redefined in concrete classes (subclassResponsibility) **

o  maxCode
return the biggest UCS code in font.
Dummy for now

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.

** This method must be redefined in concrete classes (subclassResponsibility) **

o  maxHeight
return the font's characters maximum height;
That is the number of units (usually pixels).

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

** This method must be redefined in concrete classes (subclassResponsibility) **

o  minCode
return the smallest UCS code in font.
Dummy for now

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
return the width of a string

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

** This method must be redefined in concrete classes (subclassResponsibility) **

o  widthOf: aString from: start to: stop on: aDevice
return the width of a sub string.
Here, assume that this fonts width is device independent.

o  widthOf: aString on: aDevice
return the width of a string

o  widthOn: aDevice
return the width on some device; that is the width of the space character
(which is the width of any character iff the font is a fixed pitch font)

queries-encoding
o  isASCII
return true, if the receiver's encoding is
compatible with ascii (i.e. its ascii or iso8859)

o  isISO8859
return true, if the receiver's encoding is
compatible with iso8859 (i.e. iso8859)

o  isJIS
return true, if the receiver's encoding is
compatible with jis (i.e. jisXXX)

testing
o  isAlienFont
answer true, if this is an alien font which does not have a device representation.
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.
return false here; to be redefined in subclass(es)



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Fri, 22 Nov 2024 00:10:36 GMT