Squeak Class Documentation category index | class index  
 
StrikeFont
  category: Graphics-Text
  superclass: AbstractFont
  subclasses: FormSetFont

I represent a compact encoding of a set of Forms corresponding to characters in the ASCII character set. All the forms are placed side by side in a large form whose height is the font height, and whose width is the sum of all the character widths. The xTable variable gives the left-x coordinates of the subforms corresponding to the glyphs. Characters are mapped to glyphs by using the characterToGyphMap.

Subclasses can have non-trivial mapping rules as well as different representations for glyphs sizes (e.g., not using an xTable). If so, these classes should return nil when queried for xTable and/or the characterToGlyphMap. This will cause the CharacterScanner primitive to fail and query the font for the width of a character (so that a more programatical approach can be implemented).

For display, fonts need to implement two messages:
#installOn: aDisplayContext foregroundColor: foregroundColor backgroundColor: backgroundColor
This method installs the receiver (a font) on the given DisplayContext (which may be an instance of BitBlt or Canvas (or any of it's subclasses). The font should take the appropriate action to initialize the display context so that further display operations can be optimized.
#displayString: aString on: aDisplayContext from: startIndex to: stopIndex at: aPoint kern: kernDelta
This method is called for each subsequent run of characters in aString which is to be displayed with the (previously installed) settings.

instance methods
  Mac reader
  aComment
fixKerning:
readMacFontHex:
strikeFromHex:width:height:
xTableFromHex:

  accessing
  ascent
ascentKern
baseKern
characterToGlyphMap
characterToGlyphMap:
descent
descentKern
familyName
familySizeFace
fontNameWithPointSize
glyphs
height
lineGrid
maxAscii
maxWidth
minAscii
name
name:
pointSize
pointSize:
raster
setGlyphs:
subscript
superscript
textStyle
widthOf:
xTable

  character shapes
  alter:formBlock:
characterForm:pixelValueAt:put:
characterFormAt:
characterFormAt:put:
edit:
ensureCleanBold
extendMaxAsciiTo:
fillZeroWidthSlots
fixOneWideChars
makeCarriageReturnsWhite
widen:by:

  copying
  veryDeepCopyWith:

  displaying
  characters:in:displayAt:clippedBy:rule:fillColor:
composeWord:in:beginningAt:
displayLine:at:
displayString:on:from:to:at:kern:
fontDisplay
installOn:foregroundColor:backgroundColor:
widthOfString:

  emphasis
  bonk:with:
emphasis
emphasis:
emphasized:
makeBoldGlyphs
makeCondensedGlyphs
makeItalicGlyphs
makeStruckOutGlyphs
makeUnderlinedGlyphs
reset

  file in/out
  buildfontNamed:fromForms:startingAtAscii:ascent:descent:maxWid:
displayChar:form:
encodedForRemoteCanvas
newFromStrike:
objectForDataStream:
printOn:
readBDFFromFile:name:
readBFHeaderFrom:
readFromBitFont:
readFromStrike2:
readFromStrike2Stream:
restOfLine:from:
writeAsStrike2On:
writeAsStrike2named:

  object fileIn
 

  private
  createCharacterToGlyphMap

  testing
  checkCharacter:

class methods
  accessing
  familyName:size:
familyNames

  derivative font caching
  shutDown

  examples
  convertFontsNamed:
example
readStrikeFont2Family:

  instance creation
  decodedFromRemoteCanvas:
familyName:size:emphasized:
fromStrike:
newFromBDFFile:name:
passwordFontSize:

instance methods
  Mac reader top  
 

aComment

To read Mac font resources.
1) Use ResEdit in the Fonts folder in the System Folder. Open the file of the Font you want. (A screen font, not a TrueType outline font).
2) Open the FOND resource and scroll down to the list of sizes and resource numbers. Note the resource number of the size you want.
3) Open the NFNT resource. Click on the number you have noted.
4) Choose 'Open Using Hex Editor' from the resource editor.
5) Copy all of the hex numbers and paste into a text editor. Save the file into the Smalltalk folder under the name 'FontName 12 hex' (or other size).
6) Enter the fileName below and execute:

TextStyle default fontAt: 8 put: (StrikeFont new readMacFontHex: 'fileName').

Select text and type Command-7 to change it to your new font.

(There is some problem in the ParagraphEditor with the large size of Cairo 18. Its line heights are not the right.)


 

fixKerning:

Insert one pixel (extraWidth) between each character. And add the bits for the space character


 

readMacFontHex:

Read the hex version of a Mac FONT type resource. See the method aComment for how to prepare the input file. 4/26/96 tk


 

strikeFromHex:width:height:

read in just the raw strike bits from a hex file. No spaces or returns. W is in words (2 bytes), h in pixels.


 

xTableFromHex:


  accessing top  
 

ascent

Answer the receiver's maximum extent of characters above the baseline.


 

ascentKern

Return the kern delta for ascenders.


 

baseKern

Return the base kern value to be used for all characters.


 

characterToGlyphMap

Return the character to glyph mapping table. If the table is not provided the character scanner will query the font directly for the width of each individual character.


 

characterToGlyphMap:


 

descent

Answer the receiver's maximum extent of characters below the baseline.


 

descentKern

Return the kern delta for descenders.


 

familyName


 

familySizeFace

Answer an array with familyName, a String, pointSize, an Integer, and
faceCode, an Integer.


 

fontNameWithPointSize


 

glyphs

Answer a Form containing the bits representing the characters of the
receiver.


 

height

Answer the height of the receiver, total of maximum extents of
characters above and below the baseline.


 

lineGrid


 

maxAscii

Answer the integer that is the last Ascii character value of the receiver.


 

maxWidth

Answer the integer that is the width of the receiver's widest character.


 

minAscii

Answer the integer that is the first Ascii character value of the receiver.


 

name

Answer the receiver's name.


 

name:

Set the receiver's name.


 

pointSize


 

pointSize:


 

raster

Answer an integer that specifies the layout of the glyphs' form.


 

setGlyphs:

Replace the glyphs form. Used to make a synthetic bold or italic font quickly.


 

subscript

Answer an integer that is the further vertical offset relative to the
baseline for positioning characters as subscripts.


 

superscript

Answer an integer that is the further vertical offset relative to the
baseline for positioning characters as superscripts.


 

textStyle


 

widthOf:

Answer the width of the argument as a character in the receiver.


 

xTable

Answer an Array of the left x-coordinate of characters in glyphs.


  character shapes top  
 

alter:formBlock:


 

characterForm:pixelValueAt:put:


 

characterFormAt:

Answer a Form copied out of the glyphs for the argument, character.


 

characterFormAt:put:

Copy characterForm over the glyph for the argument, character.


 

edit:

(TextStyle default fontAt: 1) edit: $_


 

ensureCleanBold

This ensures that all character glyphs have at least one pixel of white space on the right
so as not to cause artifacts in neighboring characters in bold or italic.


 

extendMaxAsciiTo:

Extend the range of this font so that it can display glyphs up to newMax.


 

fillZeroWidthSlots

Note: this is slow because it copies the font once for every replacement.


 

fixOneWideChars

This fixes all 1-wide characters to be 2 wide with blank on the right
so as not to cause artifacts in neighboring characters in bold or italic.


 

makeCarriageReturnsWhite

Some larger fonts have a gray carriage return (from the zero wide fixup) make it white so it doesn't show


 

widen:by:


  copying top  
 

veryDeepCopyWith:

Return self. I am shared. Do not record me.


  displaying top  
 

characters:in:displayAt:clippedBy:rule:fillColor:

Simple, slow, primitive method for displaying a line of characters.
No wrap-around is provided.


 

composeWord:in:beginningAt:

Non-primitive composition of a word--add up widths of characters, add
sum to beginning x and answer the resulting x. Similar to performance
of scanning primitive, but without stop conditions.


 

displayLine:at:

Display the characters in aString, starting at position aPoint.


 

displayString:on:from:to:at:kern:

Draw the given string from startIndex to stopIndex
at aPoint on the (already prepared) BitBlt.


 

fontDisplay

TextStyle default defaultFont fontDisplay.


 

installOn:foregroundColor:backgroundColor:

Install the receiver on the given DisplayContext (either BitBlt or Canvas) for further drawing operations.


 

widthOfString:


  emphasis top  
 

bonk:with:

Bonking means to run through the glyphs clearing out black pixels
between characters to prevent them from straying into an adjacent
character as a result of, eg, bolding or italicizing


 

emphasis

Answer the integer code for synthetic bold, italic, underline, and
strike-out.


 

emphasis:

Set the integer code for synthetic bold, itallic, underline, and strike-out,
where bold=1, italic=2, underlined=4, and struck out=8.


 

emphasized:

Answer a copy of the receiver with emphasis set to include code.


 

makeBoldGlyphs

Make a bold set of glyphs with same widths by ORing 1 bit to the right
(requires at least 1 pixel of intercharacter space)


 

makeCondensedGlyphs

Make a condensed set of glyphs with same widths.
NOTE: this has been superceded by kerning -- should not get called


 

makeItalicGlyphs

Make an italic set of glyphs with same widths by skewing left and right.
In the process, characters would overlap, so we widen them all first.


 

makeStruckOutGlyphs

Make a struck-out set of glyphs with same widths


 

makeUnderlinedGlyphs

Make an underlined set of glyphs with same widths


 

reset

Reset the cache of derivative emphasized fonts


  file in/out top  
 

buildfontNamed:fromForms:startingAtAscii:ascent:descent:maxWid:

This builds a StrikeFont instance from existing forms.


 

displayChar:form:

Convenience utility used during conversion of BitFont files


 

encodedForRemoteCanvas


 

newFromStrike:

Build an instance from the strike font file name. The '.strike' extension
is optional.


 

objectForDataStream:

I am about to be written on an object file. Write a reference to a known Font in the other system instead.


 

printOn:

Append to the argument, aStream, a sequence of characters that
identifies the receiver.


 

readBDFFromFile:name:

This builds a StrikeFont instance by reading the X11 Binary
Distribution Format font source file. See the BDFFontReader class
comment.


 

readBFHeaderFrom:


 

readFromBitFont:

This builds a StrikeFont instance by reading the data file format
produced by BitFont, a widely available font conversion utility
written by Peter DiCamillo at Brown University


 

readFromStrike2:

StrikeFont new readFromStrike2: 'Palatino14.sf2'


 

readFromStrike2Stream:

Build an instance from the supplied binary stream on data in strike2 format


 

restOfLine:from:

Utility method to assist reading of BitFont data files


 

writeAsStrike2On:

Write me onto a file in strike2 format.
fileName should be of the form: <family name><pointSize>.sf2


 

writeAsStrike2named:

Write me onto a file in strike2 format.
fileName should be of the form: <family name><pointSize>.sf2


  object fileIn top  

  private top  
 

createCharacterToGlyphMap

Private. Create the character to glyph mapping for a font that didn't have any before. This is basically equivalent to what the former setStopCondition did, only based on indexes.


  testing top  
 

checkCharacter:

Answer a Character that is within the ascii range of the receiver--either
character or the last character in the receiver.


class methods
  accessing top  
 

familyName:size:

Answer a font (or the default font if the name is unknown) in the specified size.


 

familyNames


  derivative font caching top  
 

shutDown

StrikeFont shutDown


  examples top  
 

convertFontsNamed:

StrikeFont convertFontsNamed: 'NewYork'


 

example

Displays a line of text on the display screen at the location of the cursor.
Example depends on the strike font file, 'TimesRoman10.strike'. existing.


 

readStrikeFont2Family:

StrikeFont readStrikeFont2Family: 'Lucida'


  instance creation top  
 

decodedFromRemoteCanvas:


 

familyName:size:emphasized:

Create the font with this emphasis


 

fromStrike:

Read a font from disk in the old ST-80 'strike' format.
Note: this is an old format; use strike2 format instead


 

newFromBDFFile:name:

StrikeFont newFromBDFFile: 'helvR12.bdf' name: 'Helvetica12'


 

passwordFontSize: