Marcel Taeumel uploaded a new version of TrueType to project The Trunk: http://source.squeak.org/trunk/TrueType-mt.97.mcz
==================== Summary ====================
Name: TrueType-mt.97 Author: mt Time: 4 August 2022, 11:24:52.723989 am UUID: 14ab8945-1550-4d43-9954-697bee6f6538 Ancestors: TrueType-mt.96
Fixes regression in backwards compatibility with TrueType fonts that only have a deprecated Unicode mapping table.
Thanks to Stef (spfa) for pointing this out!
I will backport this to Squeak 6.0.
=============== Diff against TrueType-mt.96 ===============
Item was added: + Notification subclass: #TTCharacterMappingDeprecated + instanceVariableNames: 'mappingTable' + classVariableNames: '' + poolDictionaries: '' + category: 'TrueType-Support'!
Item was added: + ----- Method: TTCharacterMappingDeprecated>>defaultAction (in category 'priv handling') ----- + defaultAction + + Transcript showln: '[TTFontReader] Character mapping is deprecated: ', mappingTable. + ^ true!
Item was added: + ----- Method: TTCharacterMappingDeprecated>>mappingTable (in category 'accessing') ----- + mappingTable + + ^ mappingTable!
Item was added: + ----- Method: TTCharacterMappingDeprecated>>mappingTable: (in category 'accessing') ----- + mappingTable: anObject + + mappingTable := anObject.!
Item was changed: ----- Method: TTCharacterMappingTable>>encodingNameForSqueak (in category 'accessing') ----- encodingNameForSqueak "After #prepare 'ing the cmap table from the font file for squeak, we basically have mappings for Unicode code points. Those can be restricted to < 256 (i.e., 'Latin1' or encodingID = 0). Windows' symbol fonts can also have the speciality that its symbols are also available from 16r20 to 16rFF (i.e., 'Symbol' or encoding ID = 1). Other than that, we distinguish the basic multilingual plane (short: BMP) and full Unicode support. Note that those encodings are not relevant for mapping code points to glyphs as missing code points are automatically mapped to the fallback glyph, that is, the glyph index 0. See TTGlyph >> #isFallback." + ^ #('Latin1' 'Symbol' 'Unicode BMP' 'Unicode Full' 'Deprecated') at: encodingID + 1! - ^ #('Latin1' 'Symbol' 'Unicode BMP' 'Unicode Full') at: encodingID + 1!
Item was changed: ----- Method: TTCharacterMappingTable>>prepareFromUnicode (in category 'initialization') ----- prepareFromUnicode "Nothing to do. #characterMap is already organized in Unicode code points. See TTFontReader >> #cmapArrayOfSize:."
+ encodingID < 3 ifTrue: [ + TTCharacterMappingDeprecated new + mappingTable: self; + signal]. - self - assert: [encodingID >= 3] - description: 'Encoding not supported: ', self encodingName. platformID := -1. "Squeak" + encodingID := encodingID < 3 + ifTrue: [4 "Deprecated"] ifFalse: [ + encodingID = 3 ifTrue: [2 "BMP"] ifFalse: [3"Full"]]. - encodingID := encodingID = 3 ifTrue: [2 "BMP"] ifFalse: [3"Full"]. macLanguageID := nil.!
Item was added: + Notification subclass: #TTCharacterMappingUnsupported + instanceVariableNames: 'cmapFmt' + classVariableNames: '' + poolDictionaries: '' + category: 'TrueType-Support'!
Item was added: + ----- Method: TTCharacterMappingUnsupported>>cmapFmt (in category 'accessing') ----- + cmapFmt + + ^ cmapFmt!
Item was added: + ----- Method: TTCharacterMappingUnsupported>>cmapFmt: (in category 'accessing') ----- + cmapFmt: anObject + + cmapFmt := anObject.!
Item was added: + ----- Method: TTCharacterMappingUnsupported>>defaultAction (in category 'priv handling') ----- + defaultAction + + Transcript showln: '[TTFontReader] Unsupported format of cmap: ', cmapFmt. + ^ true!
Item was changed: ----- Method: TTFontReader>>decodeCmapFmtTable (in category 'reading - decode cmap') ----- decodeCmapFmtTable "Decode cmap table. Currently supports formats 0, 4, 6, and 12 https://docs.microsoft.com/en-us/typography/opentype/spec/cmap#format-0-byte..." | cmapFmt | ^ (cmapFmt := self nextUnsignedShort) caseOf: { [0] -> [self decodeCmapFmtTable0]. "[2] -> [ High-byte mapping through table ]" [4] -> [self decodeCmapFmtTable4]. [6] -> [self decodeCmapFmtTable6]. "[8] -> [ Mixed 16-bit and 32-bit coverage ]" "[10] -> [ Trimmed array ]" [12] -> [self decodeCmapFmtTable12]. "[13] -> [ Many-to-one range mappings -- last-resort fonts ]" "[14] -> [ Unicode variation sequences ]" } otherwise: [ + TTCharacterMappingUnsupported new + cmapFmt: cmapFmt; + signal. - Transcript showln: '[TTFontReader] Unsupported format of cmap: ', cmapFmt. {nil.nil}]!
Item was changed: ----- Method: TTFontReader>>readCharacterMappingTable (in category 'reading - tables') ----- readCharacterMappingTable "Read the font's character to glyph index mapping table. If an appropriate mapping can be found then return an association with the format identifier and the contents of the table"
| initialOffset numTables tables ourTable | initialOffset := self offset. self skipShort. "version" numTables := self nextUnsignedShort. tables := Array new: numTables. "1) Get an overview of all included mappings." 1 to: numTables do: [:index | | platformID encodingID offset cmap | platformID := self nextUnsignedShort. encodingID := self nextUnsignedShort. offset := self nextUnsignedLong. tables at: index put: (TTCharacterMappingTable new platformID: platformID; encodingID: encodingID; characterMap: offset; yourself)].
"2*) Read all mappings" "tables do: [:subTable | self offset: initialOffset + subTable characterMap during: [ | cmap | cmap := self decodeCmapFmtTable. subTable characterMap: cmap second; macLanguageID: cmap first]]." "2**) Read the most useful mapping -- skip format 13 and 14 for now." ourTable := tables detect: [:t | t platformID = 0 "Unicode" and: [t encodingID = 4 "Full"]] ifNone: [ tables detect: [:t | t platformID = 3 "Windows" and: [t encodingID = 10 "Full"]] ifNone: [ tables detect: [:t | t platformID = 0 and: [t encodingID = 3 "BMP"]] ifNone: [ tables detect: [:t | t platformID = 3 and: [t encodingID = 1 "BMP"]] ifNone: [ + tables detect: [:t | t platformID = 0 "Unicode" and: [t encodingID < 3 "Deprecated"]] ifNone: [ + tables detect: [:t | t platformID = 3 "Windows Symbol encoding?"] ifNone: [tables last] ]]]]]. - tables detect: [:t | t platformID = 3 "Windows Symbol encoding?"] ifNone: [tables last] ]]]]. self offset: initialOffset + ourTable characterMap during: [ | cmap | cmap := self decodeCmapFmtTable. ourTable characterMap: cmap second; macLanguageID: cmap first]. tables := {ourTable}.
"3) Finished. See #processCharacterMappingTable." cmapTables := tables.!
squeak-dev@lists.squeakfoundation.org