Using TT Fonts?

Aaron reic0024 at d.umn.edu
Mon Aug 26 22:29:16 UTC 2002


On Tue, 27 Aug 2002, [iso-8859-1] Stéphane Rollandin wrote:

> At 22:34 26/08/2002, Aaron wrote:
> >  I had to
> >resort to manually decoding the change set, which I've attached.  Would've
> >been a huge pain in the butt for a larger file, though.
> >
> >Works great!
>
> I suspect you send the wrong file ! it starts with headers and can not be
> filed in (even after removing those headers)... looks like the code
> _before_ you cleaned it up :)

D'oh, that's the case! Here's the *real* one! :)

Aaron
-------------- next part --------------
'From Squeak3.2gamma of 3 February 2002 [latest update: #4653] on 4 February 2002 at 10:07:33 pm'!
AbstractFont subclass: #StrikeFont
instanceVariableNames: 'characterToGlyphMap xTable glyphs name type minAscii maxAscii maxWidth strikeLength ascent descent xOffset raster subscript superscript emphasis derivativeFonts pointSize '
classVariableNames: 'DefaultStringScanner ToSqueakMap '
poolDictionaries: 'TextConstants '
category: 'Graphics-Text'!

!StrikeFont methodsFor: 'host fonts' stamp: 'ar 2/4/2002 21:51'!
fontName: fontName size: ptSize emphasis: emphasisCode
"^StrikeFont fontName: (StrikeFont fontNameFromUser) size: 12 emphasis: 0."
| fontHandle xStart w glyphForm fontHeight fw enc fullWidth |
fontHandle _ self primitiveCreateFont: fontName size: ptSize emphasis: emphasisCode.
fontHandle ifNil:[^nil].
pointSize _ ptSize.
name _ fontName.
emphasis _ emphasisCode.
minAscii _ 0.
maxAscii _ 255.
ascent _ self primitiveFontAscent: fontHandle.
descent _ self primitiveFontDescent: fontHandle.
fontHeight _ ascent + descent.
xTable _ Array new: 258.
fullWidth _ Array new: 256.
xStart _ maxWidth _ 0.
0 to: 255 do:[:i|
xTable at: i+1 put: xStart.
fw _ self primitiveFont: fontHandle fullWidthOfChar: i.
(i = 9 or: [i = 13]) ifTrue:[fw := {0. 0. 0}].
fullWidth at: i+1 put: fw.
w _ fw at: 2.
(fw at: 1) > 0 ifTrue:[w _ w + (fw at: 1)].
(fw at: 3) > 0 ifTrue:[w _ w + (fw at: 3)].
w > maxWidth ifTrue:[maxWidth _ w].
xStart _ xStart + w].
xStart = 0 ifTrue:[^nil].
strikeLength _ xStart.
xTable at: 256 put: xStart.
xTable at: 257 put: xStart.
xTable at: 258 put: xStart.
glyphs _ Form extent: xTable last @ fontHeight depth: 1.
glyphForm _ Form extent: maxWidth @ fontHeight depth: 1.
0 to: 255 do:[:i|
glyphForm fillWhite.
self primitiveFont: fontHandle glyphOfChar: i into: glyphForm.
xStart _ xTable at: i+1.
glyphForm displayOn: glyphs at: xStart at 0.
"glyphForm displayOn: Display at: xStart at 0."
].
enc := self primitiveFontEncoding: fontHandle.
enc = 1 ifTrue:[characterToGlyphMap := self isoToSqueakMap].
self primitiveDestroyFont: fontHandle.
^self! !

!StrikeFont methodsFor: 'host fonts' stamp: 'ar 2/4/2002 21:52'!
isoToSqueakMap
ToSqueakMap ifNotNil:[ToSqueakMap].
ToSqueakMap := Array new: 256.
0 to: 255 do:[:i|
ToSqueakMap at: i+1 put: (Character value: i) squeakToIso asciiValue.
].
^ToSqueakMap! !

!StrikeFont methodsFor: 'host fonts' stamp: 'ar 2/4/2002 21:42'!
primitiveCreateFont: fontName size: fontSize emphasis: fontFlags
<primitive:'primitiveCreateFont' module:'FontPlugin'>
^nil! !

!StrikeFont methodsFor: 'host fonts' stamp: 'ar 2/4/2002 21:42'!
primitiveDestroyFont: fontHandle
<primitive:'primitiveDestroyFont' module:'FontPlugin'>
^self primitiveFailed! !

!StrikeFont methodsFor: 'host fonts' stamp: 'ar 2/4/2002 21:42'!
primitiveFont: fontHandle fullWidthOfChar: charIndex
<primitive:'primitiveFontFullWidthOfChar' module:'FontPlugin'>
^Array 
	with: 0
	with: (self primitiveFont: fontHandle widthOfChar: charIndex)
	with: 0!
!

!StrikeFont methodsFor: 'host fonts' stamp: 'ar 2/4/2002 21:42'!
primitiveFont: fontHandle getData: buffer
<primitive:'primitiveGetFontData' module:'FontPlugin'>
^self primitiveFailed! !

!StrikeFont methodsFor: 'host fonts' stamp: 'ar 2/4/2002 21:43'!
primitiveFont: fontHandle getKernPair: kernIndex
<primitive:'primitiveFontGetKernPair' module:'FontPlugin'>
^0! !

!StrikeFont methodsFor: 'host fonts' stamp: 'ar 2/4/2002 21:43'!
primitiveFont: fontHandle glyphOfChar: charIndex into: glyphForm
<primitive:'primitiveFontGlyphOfChar' module:'FontPlugin'>
^self primitiveFailed! !

!StrikeFont methodsFor: 'host fonts' stamp: 'ar 2/4/2002 21:43'!
primitiveFont: fontHandle widthOfChar: charIndex
<primitive:'primitiveFontWidthOfChar' module:'FontPlugin'>
^self primitiveFailed! !

!StrikeFont methodsFor: 'host fonts' stamp: 'ar 2/4/2002 21:43'!
primitiveFontAscent: fontHandle
<primitive:'primitiveFontAscent' module:'FontPlugin'>
^self primitiveFailed! !

!StrikeFont methodsFor: 'host fonts' stamp: 'ar 2/4/2002 21:43'!
primitiveFontDataSize: fontHandle
<primitive:'primitiveFontDataSize' module:'FontPlugin'>
^self primitiveFailed! !

!StrikeFont methodsFor: 'host fonts' stamp: 'ar 2/4/2002 21:43'!
primitiveFontDescent: fontHandle
<primitive:'primitiveFontDescent' module:'FontPlugin'>
^self primitiveFailed! !

!StrikeFont methodsFor: 'host fonts' stamp: 'ar 2/4/2002 21:43'!
primitiveFontEmbeddingFlags: fontHandle
<primitive:'primitiveFontEmbeddingFlags' module:'FontPlugin'>
^self primitiveFailed! !

!StrikeFont methodsFor: 'host fonts' stamp: 'ar 2/4/2002 21:43'!
primitiveFontEncoding: fontHandle
<primitive:'primitiveFontEncoding' module:'FontPlugin'>
^self primitiveFailed! !

!StrikeFont methodsFor: 'host fonts' stamp: 'ar 2/4/2002 21:43'!
primitiveFontNumKernPairs: fontHandle
<primitive:'primitiveFontNumKernPairs' module:'FontPlugin'>
^0! !


!StrikeFont class methodsFor: 'host fonts' stamp: 'ar 2/4/2002 21:52'!
fontName: fontName size: ptSize emphasis: emphasisCode
"
^StrikeFont fontName: (StrikeFont fontNameFromUser) size: 12 emphasis: 0.
"
^self new fontName: fontName size: ptSize emphasis: emphasisCode! !

!StrikeFont class methodsFor: 'host fonts' stamp: 'ar 2/4/2002 21:53'!
fontNameFromUser
"StrikeFont fontNameFromUser"
| fontNames index labels |
fontNames _ self listFontNames asSortedCollection.
labels _ WriteStream on: (String new: 100).
fontNames do:[:fn| labels nextPutAll: fn] separatedBy:[labels cr].
index _ (PopUpMenu labels: labels contents) startUpWithCaption:'Choose your font'.
index = 0 ifTrue:[^nil].
^fontNames at: index! !

!StrikeFont class methodsFor: 'host fonts' stamp: 'ar 2/4/2002 21:44'!
listFontName: index
<primitive:'primitiveListFont' module:'FontPlugin'>
^nil! !

!StrikeFont class methodsFor: 'host fonts' stamp: 'ar 2/4/2002 21:53'!
listFontNames
"StrikeFont listFontNames"
"List all the OS font names"
| font fontNames index |
fontNames _ WriteStream on: Array new.
index _ 0.
[font _ self listFontName: index.
font == nil] whileFalse:[
fontNames nextPut: font.
index _ index + 1].
^fontNames contents! !

!StrikeFont class methodsFor: 'host fonts' stamp: 'ar 2/4/2002 21:55'!
textStyleFrom: fontName
"StrikeFont textStyleFromUser"
| styleName fonts |
styleName _ fontName asSymbol.
"(TextConstants includesKey: styleName)
ifTrue:[(self confirm: 
styleName , ' is already defined in TextConstants.
Do you want to replace that definition?')
ifFalse: [^ self]]."
fonts _ #(10 11 12 13 14 16 18 20 22 24 26 28 30 36 48 60 72 90).
('Rendering ', styleName) displayProgressAt: Sensor cursorPoint
from: 1 to: fonts size during:[:bar|
fonts _ fonts
collect:[:ptSize| bar value: (fonts indexOf: ptSize).
   self fontName: styleName 
size: ptSize
emphasis: 0]
thenSelect:[:font| font notNil]]. "reject those that failed"
fonts size = 0 ifTrue:[^self error:'Could not create font style', styleName].
^TextConstants
at: styleName
put: (TextStyle fontArray: fonts).! !

!StrikeFont class methodsFor: 'host fonts' stamp: 'ar 2/4/2002 21:55'!
textStyleFrom: fontName sizes: ptSizes
| styleName fonts |
styleName _ fontName asSymbol.
(TextConstants includesKey: styleName)
ifTrue:[(self confirm: 
styleName , ' is already defined in TextConstants.
Do you want to replace that definition?')
ifFalse: [^ self]].
('Rendering ', styleName) displayProgressAt: Sensor cursorPoint
from: 1 to: ptSizes size during:[:bar|
fonts _ ptSizes
collect:[:ptSize| bar value: (ptSizes indexOf: ptSize).
   self fontName: styleName 
size: ptSize
emphasis: 0]
thenSelect:[:font| font notNil]]. "reject those that failed"
fonts size = 0 ifTrue:[^self error:'Could not create font style', styleName].
^TextConstants
at: styleName
put: (TextStyle fontArray: fonts)! !

!StrikeFont class methodsFor: 'host fonts' stamp: 'ar 2/4/2002 21:55'!
textStyleFromUser
"StrikeFont textStyleFromUser"
| styleName fonts |
styleName _ self fontNameFromUser ifNil:[^self].
styleName _ styleName asSymbol.
(TextConstants includesKey: styleName)
ifTrue:[(self confirm: 
styleName , ' is already defined in TextConstants.
Do you want to replace that definition?')
ifFalse: [^ self]].
fonts _ #(10 12 14 16 18 20 22 24 26 28 30 36 48 60 72 90).
('Rendering ', styleName) displayProgressAt: Sensor cursorPoint
from: 1 to: fonts size during:[:bar|
fonts _ fonts
collect:[:ptSize| bar value: (fonts indexOf: ptSize).
   self fontName: styleName 
size: ptSize
emphasis: 0]
thenSelect:[:font| font notNil]]. "reject those that failed"
fonts size = 0 ifTrue:[^self error:'Could not create font style', styleName].
^TextConstants
at: styleName
put: (TextStyle fontArray: fonts)! !



More information about the Squeak-dev mailing list