[Pkg] The Trunk: TrueType-topa.32.mcz
commits at source.squeak.org
commits at source.squeak.org
Sat Mar 7 01:19:58 UTC 2015
Tobias Pape uploaded a new version of TrueType to project The Trunk:
http://source.squeak.org/trunk/TrueType-topa.32.mcz
==================== Summary ====================
Name: TrueType-topa.32
Author: topa
Time: 7 March 2015, 2:19:21.165 am
UUID: b69e6550-31b2-40db-8ff2-e5e990b214e7
Ancestors: TrueType-topa.31
Fix TrueType-topa.31 for Microsoft-encoded names and language tags
=============== Diff against TrueType-topa.31 ===============
Item was changed:
----- Method: TTFileDescription>>processNamingTable: (in category 'ttf tables') -----
processNamingTable: fontFile
"copyright CHARPTR The font's copyright notice.
familyName CHARPTR The font's family name.
subfamilyName CHARPTR The font's subfamily name.
uniqueName CHARPTR A unique identifier for this font.
fullName CHARPTR The font's full name (a combination of
familyName and subfamilyName).
versionName CHARPTR The font's version string.
"
+ | nRecords initialOffset storageOffset format |
- | nRecords initialOffset storageOffset |
initialOffset := fontFile position.
+ format := fontFile nextNumber: 2.
+ format = 0 ifFalse: [self error: 'Cannot handle format 1 naming tables'].
- fontFile skip: 2. "Skip format selector"
"Get the number of name records"
nRecords := fontFile nextNumber: 2.
"Offset from the beginning of this table"
storageOffset := (fontFile nextNumber: 2) + initialOffset.
1 to: nRecords do:[:i| | pID sID lID nID length offset string |
fontFile position: initialOffset + 6 + ((i-1) * 12).
pID := fontFile nextNumber: 2.
sID := fontFile nextNumber: 2.
lID := fontFile nextNumber: 2.
nID := fontFile nextNumber: 2.
length := fontFile nextNumber: 2.
offset := fontFile nextNumber: 2.
"Read only Macintosh or Microsoft strings"
(pID = 1 or:[pID = 3 and:[sID = 1]]) ifTrue:[
"MS uses Unicode all others single byte"
"multiBytes := pID = 3."
fontFile position: storageOffset+offset.
string := (fontFile next: length) asString.
pID = 3 ifTrue:[ | keep |
keep := true.
string := string select:[:ch| keep := keep not].
].
+ "Select only English names, prefer Macintosh"
+ ((pID = 1 and: [lID = 0]) or: [pID = 3 and: [lID = 16r0409]]) ifTrue: [
+ nID caseOf: {
+ "[0] -> [copyright := string]."
+ [1] -> [(pID = 1 or:[familyName == nil]) ifTrue:[familyName := string]].
+ [2] -> [(pID = 1 or:[subfamilyName == nil]) ifTrue:[subfamilyName := string]].
+ "[3] -> [(pID = 1 or:[uniqueName == nil]) ifTrue:[uniqueName := string]]."
+ "[4] -> [(pID = 1 or:[fullName == nil]) ifTrue:[fullName := string]]."
+ "[5] -> [(pID = 1 or:[versionName == nil]) ifTrue:[versionName := string]]."
+ "[6] -> [(pID = 1 or:[postscriptName == ni]) ifTrue:[postscriptName := string]]."
+ "[7] -> [(pID = 1 or:[trademark == nil]) ifTrue:[trademark := string]]."
+ } otherwise:["ignore"].
+ ]
- nID caseOf: {
- "Select only English names, prefer Macintosh"
- "[0] -> [copyright := string]."
- [1] -> [(lID = 0 and: [pID = 1 or:[familyName == nil]]) ifTrue:[familyName := string]].
- [2] -> [(lID = 0 and: [pID = 1 or:[subfamilyName == nil]]) ifTrue:[subfamilyName := string]].
- "[3] -> [(lID = 0 and: [pID = 1 or:[uniqueName == nil]]) ifTrue:[uniqueName := string]]."
- "[4] -> [(lID = 0 and: [pID = 1 or:[fullName == nil]]) ifTrue:[fullName := string]]."
- "[5] -> [(lID = 0 and: [pID = 1 or:[versionName == nil]]) ifTrue:[versionName := string]]."
- "[6] -> [(lID = 0 and: [pID = 1 or:[postscriptName == ni]l]) ifTrue:[postscriptName := string]]."
- "[7] -> [lpID = 0 and: [pID = 1 or:[trademark == nil]]) ifTrue:[trademark := string]]."
- } otherwise:["ignore"].
].
].
!
Item was changed:
----- Method: TTFontReader>>processNamingTable: (in category 'processing') -----
processNamingTable: entry
"copyright CHARPTR The font's copyright notice.
familyName CHARPTR The font's family name.
subfamilyName CHARPTR The font's subfamily name.
uniqueName CHARPTR A unique identifier for this font.
fullName CHARPTR The font's full name (a combination of
familyName and subfamilyName).
versionName CHARPTR The font's version string.
+ " | nRecords initialOffset format storageOffset strings |
- " | nRecords initialOffset storageOffset strings |
strings := Array new: 8.
strings atAllPut:''.
initialOffset := entry offset.
+ format := entry nextUShort.
+ format = 0 ifFalse: [self error: 'Cannot handle format 1 naming tables'].
- entry skip: 2. "Skip format selector"
"Get the number of name records"
nRecords := entry nextUShort.
"Offset from the beginning of this table"
storageOffset := entry nextUShort + initialOffset.
1 to: nRecords do:[:i| | pID sID lID nID length offset multiBytes string |
pID := entry nextUShort.
sID := entry nextUShort.
lID := entry nextUShort.
nID := entry nextUShort.
length := entry nextUShort.
offset := entry nextUShort.
"Read only Macintosh or Microsoft strings"
(pID = 1 or:[pID = 3 and:[sID = 1]]) ifTrue:[
"MS uses Unicode all others single byte"
multiBytes := pID = 3.
string := entry stringAt: storageOffset + offset length: length multiByte: multiBytes.
+
+ "Select only English names.
+ Note: We prefer Macintosh strings about everything."
+ ((pID = 1 and: [lID = 0]) or: [pID = 3 and: [lID = 16r0409]]) ifTrue: [
+ "Put the name at the right location."
+ nID < strings size ifTrue:[
+ (pID = 1 or:[(strings at: nID+1) = ''])
+ ifTrue:[strings at: nID+1 put: string].
+ ].
- "Put the name at the right location.
- Note: We prefer Macintosh strings about everything else and use only English names."
- nID < strings size ifTrue:[
- (lID = 0 and: [pID = 1 or:[(strings at: nID+1) = '']])
- ifTrue:[strings at: nID+1 put: string].
].
].
].
fontDescription setStrings: strings.!
More information about the Packages
mailing list