'From Cuis 1.0 of 2 October 2009 [latest update: #316] on 10 November 2009 at 3:53:57 pm'!

!StrikeFont methodsFor: 'emphasis' stamp: 'jmv 11/4/2009 13:57'!
emphasized: code
	"Answer a copy of the receiver with emphasis set to include code."
	| derivative addedEmphasis derivedFrom safeCode |
	self isBaseFont ifFalse: [ ^self baseFont emphasized: (code bitOr: emphasis) ].
	code = 0 ifTrue: [ ^ self ].
	
	derivativeFonts ifNil: [derivativeFonts := Array new: 32].
	derivative _ derivativeFonts at: (safeCode _ code min: derivativeFonts size).
	derivative ifNotNil: [^ derivative].  "Already have this style"

	"Dont have it -- derive from another with one with less emphasis"
	addedEmphasis _ 1 bitShift: safeCode highBit - 1.
	derivedFrom _ self emphasized: safeCode - addedEmphasis.  "Order is Bold, Ital, Under, Narrow"
	derivative _ derivedFrom copy.
	addedEmphasis = 1 ifTrue: [   "Compute synthetic bold version of the font"
		derivative
			ensureCleanBold;
			name: derivedFrom name , 'B';
			makeBoldGlyphs ].
	addedEmphasis = 2 ifTrue: [   "Compute synthetic italic version of the font"
		derivative
			name: derivedFrom name , 'I';
			makeItalicGlyphs ].
	addedEmphasis = 4 ifTrue: [   "Compute underlined version of the font"
		derivative
			name: derivedFrom name , 'U';
			makeUnderlinedGlyphs ].
	addedEmphasis = 8 ifTrue: [   "Compute narrow version of the font"
		derivative
			name: derivedFrom name , 'N';
			makeCondensedGlyphs ].
	addedEmphasis = 16 ifTrue: [   "Compute struck-out version of the font"
		derivative
			name: derivedFrom name , 'X';
			makeStruckOutGlyphs ].
	derivative baseFont: self.
	derivative emphasis: safeCode.
	derivativeFonts at: safeCode put: derivative.
	^ derivative! !

!StrikeFont methodsFor: 'private' stamp: 'jmv 11/4/2009 13:48'!
fixDerivatives
	self isBaseFont
		ifTrue: [
			baseFont _ nil.
			derivativeFonts ifNotNil: [
				derivativeFonts do: [ :der |
					der ifNotNil: [
						der baseFont: self.
						der fixDerivatives ]]]]
		ifFalse: [
			derivativeFonts _ nil ].! !

!StrikeFont methodsFor: 'building' stamp: 'jmv 10/30/2009 13:05'!
stripHighGlyphs
	"Remove glyphs for characters above 128"
	| i |

	characterToGlyphMap _ nil.
	maxAscii _ 127.
	
	xTable _ xTable copyFrom: 1 to: maxAscii + 3.
	i _ xTable at: maxAscii + 2.
	xTable at: maxAscii + 3 put: i.
	glyphs _ glyphs copy: (0@0 extent: i+1@glyphs height).
	maxWidth _ 0.
	2 to: xTable size do: [ :ii |
		maxWidth _ maxWidth max: (xTable at: ii) - (xTable at: ii-1)-1 ].
	self reset! !

