[squeak-dev] The Trunk: TrueType-mt.89.mcz
commits at source.squeak.org
commits at source.squeak.org
Tue Mar 15 13:19:40 UTC 2022
Marcel Taeumel uploaded a new version of TrueType to project The Trunk:
http://source.squeak.org/trunk/TrueType-mt.89.mcz
==================== Summary ====================
Name: TrueType-mt.89
Author: mt
Time: 15 March 2022, 2:19:39.426851 pm
UUID: 463bce88-f370-4ebd-9281-4ce1814f54cc
Ancestors: TrueType-mt.88
Fixes robustness when facing fonts with 'CFF ' table or fully unknown subfamily names.
=============== Diff against TrueType-mt.88 ===============
Item was changed:
----- Method: TTFontFileHandle>>fontOfPointSize: (in category 'building') -----
fontOfPointSize: pointSize
"Answers a font that represents the receiver. For top-level descriptions, that font can have derivative for different emphases. NOTE THAT the resulting font is not necessarily installed in the system!!"
| handles head tail font |
self isInstalled ifTrue: [
^ ((TextStyle named: self textStyleName) defaultFont
emphasized: self emphasisCode)
asPointSize: pointSize].
+ self hasChildren ifFalse: [
+ "I represent only a single subfamily, which must be supported.
+ See #isSubfamilySupported."
+ ^ self fontDescription
+ ifNil: [
+ TextStyle defaultTTFont
+ asPointSize: pointSize]
+ ifNotNil: [:tt |
+ TTCFont new
+ ttcDescription: tt;
+ setPointSize: pointSize familyName: self familyNameAsIs
+ extraGlyphScale: ttExtraScale extraLineGap: ttExtraGap;
+ yourself]].
- self hasChildren ifFalse: ["I represent only a single subfamily"
- ^ TTCFont new
- ttcDescription: self fontDescription;
- setPointSize: pointSize familyName: self familyNameAsIs extraGlyphScale: ttExtraScale extraLineGap: ttExtraGap;
- yourself].
handles := self children select: [:ea | ea isSubfamilySupported].
+ handles ifEmpty: [^ self children anyOne fontOfPointSize: pointSize].
+ head := handles detect: [:ea | ea isRegular] ifNone: [handles anyOne].
- head := handles detect: [:ea | ea isRegular].
tail := handles copyWithout: head.
head := head fontOfPointSize: pointSize.
tail := tail collect: [:ea | ea fontOfPointSize: pointSize].
font := head.
tail do: [:ea | font derivativeFont: ea].
^ font!
Item was changed:
----- Method: TTFontReader>>checkIntegrity (in category 'reading - support') -----
checkIntegrity
+ (self hasTable: 'CFF ') ifTrue: [
- (self hasTable: 'CFF') ifTrue: [
"Some TTC fonts may actually be collection of PostScript-Based OpenType fonts"
^ self error: 'Type 1 fonts are not supported'].
#(
'cmap' #noCharacterMappingTableFound
'head' #noHeaderTableFound
'hhea' #noHorizontalHeaderTableFound
'hmtx' #noHorizontalMetricsTableFound
'maxp' #noMaximumProfileTableFound
'name' #noNamingTableFound
"OS/2 -- optional in Squeak"
"kern -- optional in Squeak"
'loca' #noRelocationTableFound
'glyf' #noGlyphDataTableFound
) pairsDo: [:tag :errorMessage |
(self hasTable: tag) ifFalse: [
^ self error: errorMessage]].
^ true "Everything is okay."!
Item was changed:
----- Method: TTFontReader>>readNextName (in category 'reading - family name (fast)') -----
readNextName
"Answer the next quad of #(familyName subfamilyName fileName fileOffset). Optimized for speed. Does crazy stuff if there is no 'name' table. Also does crazy stuff if there is not at least a single English entry in the naming table"
+ | data fontOffset tableName nameOffset storageOffset numRecords i record |
- | data fontOffset nameOffset storageOffset numRecords i record |
fontOffset := self offset.
+
+ "1) Find offset of 'name' table. See #checkIntegrity and #readTableDictionary for more details."
-
- "1) Find offset of 'name' table. See #readTableDictionary for more details."
self skip: 12. "count??"
+ [(tableName := self next: 4) = #[67 70 70 32] "CFF " ifTrue: [^ nil].
+ tableName = #[110 97 109 101] "name"] whileFalse: [self skip: 12].
- [(self next: 4) = #[110 97 109 101] "name"] whileFalse: [self skip: 12].
self skipLong.
nameOffset := self nextUnsignedLong.
"2) Find the English version of familyName and subfamilyName. See #readNamingTable for more details."
self offset: nameOffset.
self nextUnsignedShort = 0 "Support only format 1 naming tables"
ifFalse: [self offset: fontOffset+1. ^ nil].
numRecords := self nextUnsignedShort.
storageOffset := self nextUnsignedShort + nameOffset.
i := 0.
data := Array new: 4.
[data first notNil and: [data second notNil]] whileFalse: [
(i := i + 1) > numRecords ifTrue: [self offset: fontOffset+1. ^ nil "Nothing found :("].
record := self
readNamingTableRecordWith: storageOffset
select: [:platformID :languageID :nameID |
(nameID = 1 "familyName" or: [nameID = 2 "subfamilyName" ]) and: [
platformID = 0 "Unicode -- Always English by default?"
or: [platformID = 3 "Windows" and: [(languageID bitAnd: 16r00FF) = 9]]
or: [platformID = 1 "Macintosh" and: [languageID = 1]] ]].
record ifNotNil: [data at: record nameID put: record contents]].
data at: 3 put: self fileName.
data at: 4 put: fontOffset.
self offset: fontOffset+1. "Ready for next call to #nextName"
^ data!
More information about the Squeak-dev
mailing list
|