[squeak-dev] The Trunk: TrueType-ar.8.mcz

commits at source.squeak.org commits at source.squeak.org
Sun Aug 30 02:39:11 UTC 2009


Andreas Raab uploaded a new version of TrueType to project The Trunk:
http://source.squeak.org/trunk/TrueType-ar.8.mcz

==================== Summary ====================

Name: TrueType-ar.8
Author: ar
Time: 29 August 2009, 7:38:39 am
UUID: 0d01ea7c-59a5-fc4e-912b-4a2cbf5ccdb5
Ancestors: TrueType-ar.7

Process typographic metrics from the OS/2 table in truetype fonts.

=============== Diff against TrueType-ar.7 ===============

Item was added:
+ ----- Method: TTFontDescription>>fontHeight (in category 'accessing') -----
+ fontHeight
+ 	^ascender - descender!

Item was added:
+ ----- Method: TTFontDescription>>typographicDescender (in category 'accessing') -----
+ typographicDescender
+ 	"Microsoft defines this as the 'true typographic metrics' of the font."
+ 	^sTypoDescender ifNil:[descender]!

Item was changed:
  Object subclass: #TTFileDescription
+ 	instanceVariableNames: 'fileName fileOffset familyName subfamilyName ascender descender lineGap unitsPerEm numGlyphs indexToLocOffset indexToLocFormat glyphTableOffset cmapType cmapOffset numHMetrics hmtxTableOffset sTypoAscender sTypoDescender sTypoLineGap'
+ 	classVariableNames: 'AllFontsAndFiles FontPaths OfferNonPortableFonts'
- 	instanceVariableNames: 'fileName fileOffset familyName subfamilyName ascender descender lineGap unitsPerEm numGlyphs indexToLocOffset indexToLocFormat glyphTableOffset cmapType cmapOffset numHMetrics hmtxTableOffset'
- 	classVariableNames: 'FontPaths OfferNonPortableFonts AllFontsAndFiles'
  	poolDictionaries: ''
  	category: 'TrueType-Fonts'!
  
  !TTFileDescription commentStamp: 'ar 7/29/2009 22:18' prior: 0!
  Contrary to TTFontDescritption, this class leaves true type files on disk and only reads the required portions when constructing glyphs. This avoids the need of reading the entire font into memory at the cost of having to hit disk whenever a glyph is requested.!

Item was added:
+ ----- Method: TTFontDescription>>setTypographicAscender:descender:lineGap: (in category 'private-initialization') -----
+ setTypographicAscender: asc descender: desc lineGap: lGap
+ 	sTypoAscender := asc.
+ 	sTypoDescender := desc.
+ 	sTypoLineGap := lGap.
+ !

Item was changed:
  ----- Method: TTFileDescription>>lineGap (in category 'accessing') -----
  lineGap
+ 	"Leading of the font. Relative to unitsPerEm.
+ 	Easily confused with the typographic linegap."
- 	"Ascender of the font. Relative to unitsPerEm."
  	^lineGap!

Item was added:
+ ----- Method: TTFileDescription>>typographicLineGap (in category 'accessing') -----
+ typographicLineGap
+ 	"Microsoft defines this as the 'true typographic metrics' of the font."
+ 	^sTypoLineGap ifNil:[lineGap]!

Item was changed:
  ----- Method: TTFileDescription>>ascender (in category 'accessing') -----
  ascender
+ 	"Ascender of the font. Relative to unitsPerEm.
+ 	Easily confused with the typographic ascender."
- 	"Ascender of the font. Relative to unitsPerEm."
  	^ascender!

Item was changed:
  ----- Method: TTFileDescription>>on:offset: (in category 'initialize') -----
  on: aFileName offset: fontOffset
  	"Initialize the receiver from a file name"
  	fileName := aFileName.
  	fileOffset := fontOffset.
  	self withFileDo:[:fontFile|
  		"Some bitmap fonts are called .ttf; skip anything that doesn't have a header"
  		(self findTable: 'head' in: fontFile) ifFalse:[^nil].
  		self processFontHeaderTable: fontFile.
  		(self findTable: 'maxp' in: fontFile) 
  			ifFalse:[^self error: 'File does not have a profile table'].
  		self processMaximumProfileTable: fontFile.
  		(self findTable: 'name' in: fontFile) 
  			ifFalse:[^self error: 'File does not have a naming table'].
  		self processNamingTable: fontFile.
  		(self findTable: 'hhea' in: fontFile) 
  			ifFalse:[^self error: 'File does not have a horizontal header table'].
  		self processHorizontalHeaderTable: fontFile.
+ 		(self findTable: 'OS/2' in: fontFile)
+ 			ifTrue:[self processOS2Table: fontFile].
  		(self findTable: 'hmtx' in: fontFile) 
  			ifFalse:[^self error: 'File does not have a horizontal header table'].
  		hmtxTableOffset := fontFile position.
  		(self findTable: 'loca' in: fontFile) 
  			ifFalse:[^self error: 'File does not have a naming table'].
  		indexToLocOffset := fontFile position.
  		(self findTable: 'glyf' in: fontFile) 
  			ifFalse:[^self error: 'File does not have a naming table'].
  		glyphTableOffset := fontFile position.
  		(self findTable: 'cmap' in: fontFile) 
  			ifFalse:[^self error: 'File does not have a header table'].
  		self processCharacterMappingTable: fontFile.
  	].!

Item was added:
+ ----- Method: TTFileDescription>>renderGlyph:height:fgColor:bgColor:depth: (in category 'rendering') -----
+ renderGlyph: code height: height fgColor: fgColor bgColor: bgColor depth: depth
+ 	"Render the glyph with the given code point at the specified pixel height."
+ 	^(self at: code) 
+ 		asFormWithScale: height asFloat / (ascender - descender) 
+ 			ascender: ascender 
+ 			descender: descender 
+ 			fgColor: fgColor bgColor: bgColor depth: depth!

Item was changed:
  ----- Method: TTFontDescription>>lineGap (in category 'properties') -----
  lineGap
+ 	"Leading of the font. Relative to unitsPerEm.
+ 	Easily confused with the typographic linegap."
  	^lineGap!

Item was added:
+ ----- Method: TTFontDescription>>typographicLineGap (in category 'accessing') -----
+ typographicLineGap
+ 	"Microsoft defines this as the 'true typographic metrics' of the font."
+ 	^sTypoLineGap ifNil:[lineGap]!

Item was added:
+ ----- Method: TTFileDescription>>typographicAscender (in category 'accessing') -----
+ typographicAscender
+ 	"Microsoft defines this as the 'true typographic metrics' of the font."
+ 	^sTypoAscender ifNil:[ascender]!

Item was changed:
  ----- Method: TTFileDescription>>descender (in category 'accessing') -----
  descender
+ 	"Descender of the font. Relative to unitsPerEm.
+ 	Easily confused with the typographic descender."
- 	"Descender of the font. Relative to unitsPerEm."
  	^descender!

Item was changed:
  ----- Method: TTFontDescription>>descender (in category 'properties') -----
  descender
+ 	"Descender of the font. Relative to unitsPerEm.
+ 	Easily confused with the typographic descender."
  	^descender!

Item was changed:
  Object subclass: #TTFontDescription
+ 	instanceVariableNames: 'glyphTable glyphs kernPairs copyright familyName fullName subfamilyName uniqueName versionName postscriptName trademark bounds unitsPerEm ascender descender lineGap sTypoAscender sTypoDescender sTypoLineGap'
+ 	classVariableNames: 'Default Descriptions'
- 	instanceVariableNames: 'glyphTable glyphs kernPairs copyright familyName fullName subfamilyName uniqueName versionName postscriptName trademark bounds unitsPerEm ascender descender lineGap'
- 	classVariableNames: 'Descriptions Default'
  	poolDictionaries: ''
  	category: 'TrueType-Fonts'!
  
  !TTFontDescription commentStamp: '<historical>' prior: 0!
  Holds a TrueType font in memory.  Is used by TTSampleStringMorph as its font.  
  
  Class owns a default example.  !

Item was added:
+ ----- Method: TTFileDescription>>typographicDescender (in category 'accessing') -----
+ typographicDescender
+ 	"Microsoft defines this as the 'true typographic metrics' of the font."
+ 	^sTypoDescender ifNil:[descender]!

Item was changed:
  ----- Method: TTFontDescription>>ascender (in category 'properties') -----
  ascender
+ 	"Ascender of the font. Relative to unitsPerEm.
+ 	Easily confused with the typographic ascender."
  	^ascender!

Item was added:
+ ----- Method: TTFontDescription>>renderGlyph:height:fgColor:bgColor:depth: (in category 'rendering') -----
+ renderGlyph: code height: fontHeight fgColor: fgColor bgColor: bgColor depth: depth
+ 	"Render the glyph with the given code point at the specified pixel height."
+ 	^(self at: code) 
+ 		asFormWithScale: fontHeight asFloat / (ascender - descender) 
+ 			ascender: ascender 
+ 			descender: descender 
+ 			fgColor: fgColor bgColor: bgColor depth: depth!

Item was added:
+ ----- Method: TTFontReader>>processOS2Table: (in category 'processing') -----
+ processOS2Table: entry
+ "
+ 	USHORT  	 version   	0x0004
+ 	SHORT 	xAvgCharWidth 	 
+ 	USHORT 	usWeightClass 	 
+ 	USHORT 	usWidthClass 	 
+ 	USHORT 	fsType 	 
+ 	SHORT 	ySubscriptXSize 	 
+ 	SHORT 	ySubscriptYSize 	 
+ 	SHORT 	ySubscriptXOffset 	 
+ 	SHORT 	ySubscriptYOffset 	 
+ 	SHORT 	ySuperscriptXSize 	 
+ 	SHORT 	ySuperscriptYSize 	 
+ 	SHORT 	ySuperscriptXOffset 	 
+ 	SHORT 	ySuperscriptYOffset 	 
+ 	SHORT 	yStrikeoutSize 	 
+ 	SHORT 	yStrikeoutPosition 	 
+ 	SHORT 	sFamilyClass 	 
+ 	BYTE 	panose[10] 	 
+ 	ULONG 	ulUnicodeRange1 	Bits 0-31
+ 	ULONG 	ulUnicodeRange2 	Bits 32-63
+ 	ULONG 	ulUnicodeRange3 	Bits 64-95
+ 	ULONG 	ulUnicodeRange4 	Bits 96-127
+ 	CHAR 	achVendID[4] 	 
+ 	USHORT 	fsSelection 	 
+ 	USHORT 	usFirstCharIndex 	 
+ 	USHORT 	usLastCharIndex 	 
+ 	SHORT 	sTypoAscender 	 
+ 	SHORT 	sTypoDescender 	 
+ 	SHORT 	sTypoLineGap 	 
+ 	USHORT 	usWinAscent 	 
+ 	USHORT 	usWinDescent 	 
+ 	ULONG 	ulCodePageRange1 	Bits 0-31
+ 	ULONG 	ulCodePageRange2 	Bits 32-63
+ 	SHORT 	sxHeight 	 
+ 	SHORT 	sCapHeight 	 
+ 	USHORT 	usDefaultChar 	 
+ 	USHORT 	usBreakChar 	 
+ 	USHORT 	usMaxContext 	 "
+ 	| version fsSelection minAscii maxAscii asc desc lGap |
+ 	version := entry nextShort. "table version"
+ 	version = 0 ifTrue:[^self].
+ 	entry skip: 60.
+ 	fsSelection := entry nextUShort.
+ 	minAscii := entry nextUShort.
+ 	maxAscii := entry nextUShort.
+ 	asc := entry nextShort.
+ 	desc := entry nextShort.
+ 	lGap := entry nextShort.
+ 	fontDescription setTypographicAscender: asc descender: desc lineGap: lGap.!

Item was added:
+ ----- Method: TTFontDescription>>typographicAscender (in category 'accessing') -----
+ typographicAscender
+ 	"Microsoft defines this as the 'true typographic metrics' of the font."
+ 	^sTypoAscender ifNil:[ascender]!

Item was added:
+ ----- Method: TTFileDescription>>processOS2Table: (in category 'ttf tables') -----
+ processOS2Table: fontFile
+ "
+ 	USHORT  	 version   	0x0004
+ 	SHORT 	xAvgCharWidth 	 
+ 	USHORT 	usWeightClass 	 
+ 	USHORT 	usWidthClass 	 
+ 	USHORT 	fsType 	 
+ 	SHORT 	ySubscriptXSize 	 
+ 	SHORT 	ySubscriptYSize 	 
+ 	SHORT 	ySubscriptXOffset 	 
+ 	SHORT 	ySubscriptYOffset 	 
+ 	SHORT 	ySuperscriptXSize 	 
+ 	SHORT 	ySuperscriptYSize 	 
+ 	SHORT 	ySuperscriptXOffset 	 
+ 	SHORT 	ySuperscriptYOffset 	 
+ 	SHORT 	yStrikeoutSize 	 
+ 	SHORT 	yStrikeoutPosition 	 
+ 	SHORT 	sFamilyClass 	 
+ 	BYTE 	panose[10] 	 
+ 	ULONG 	ulUnicodeRange1 	Bits 0-31
+ 	ULONG 	ulUnicodeRange2 	Bits 32-63
+ 	ULONG 	ulUnicodeRange3 	Bits 64-95
+ 	ULONG 	ulUnicodeRange4 	Bits 96-127
+ 	CHAR 	achVendID[4] 	 
+ 	USHORT 	fsSelection 	 
+ 	USHORT 	usFirstCharIndex 	 
+ 	USHORT 	usLastCharIndex 	 
+ 	SHORT 	sTypoAscender 	 
+ 	SHORT 	sTypoDescender 	 
+ 	SHORT 	sTypoLineGap 	 
+ 	USHORT 	usWinAscent 	 
+ 	USHORT 	usWinDescent 	 
+ 	ULONG 	ulCodePageRange1 	Bits 0-31
+ 	ULONG 	ulCodePageRange2 	Bits 32-63
+ 	SHORT 	sxHeight 	 
+ 	SHORT 	sCapHeight 	 
+ 	USHORT 	usDefaultChar 	 
+ 	USHORT 	usBreakChar 	 
+ 	USHORT 	usMaxContext 	 "
+ 	| version fsSelection minAscii maxAscii |
+ 	version := self short: (fontFile nextNumber: 2). "table version"
+ 	version = 0 ifTrue:[^self].
+ 	fontFile skip: 60.
+ 	fsSelection := fontFile nextNumber: 2.
+ 	minAscii := fontFile nextNumber: 2.
+ 	maxAscii := fontFile nextNumber: 2.
+ 	sTypoAscender := self short: (fontFile nextNumber: 2).
+ 	sTypoDescender := self short: (fontFile nextNumber: 2).
+ 	sTypoLineGap := self short: (fontFile nextNumber: 2).
+ !

Item was added:
+ ----- Method: TTFileDescription>>fontHeight (in category 'accessing') -----
+ fontHeight
+ 	^ascender - descender!




More information about the Squeak-dev mailing list