[Cuis-dev] TrueType font import problems

Bernhard Pieber bernhard at pieber.com
Sat Aug 26 11:59:04 PDT 2023


Hi everyone,

I tried importing a TrueType font I had on my system (Optima.ttc). I copied the file to a new folder named Fonts and used the following:
TrueTypeFontFamily readAllTrueTypeFontsIn: DirectoryEntry currentDirectory / 'Fonts'

This resulted in the error "This TTF Collection has an unsupported header version“ in TTFontReader>>#readTTCFontFrom:.

The reason is that the font uses a TTC Header Version 2.0, see:
https://docs.fileformat.com/font/ttc/

I changed the code to allow both header versions. If I understand the difference between version 1 and 2 of the header formats correctly, this should be a safe change. Installing the font worked with this change. 

However, instead of Optima Regular it used Optima ExtraBlack when I selected Optima as the font. I found no way to select Optimal Regular as the font style.

Optima.ttc contains five styles:
Optima Regular
Optima Italic
Optima Bold
Optima Bold Italic
Optima ExtraBlack

The code for importing the TTC file imports all 5 styles:
TTFontReader readTTCFrom: (DirectoryEntry currentDirectory / 'Fonts' // 'Optima.ttc') binaryContents.

However, only 4 of those 5 are saved in the font family:
TrueTypeFontFamily availableFamilies at: 'Optima'

There seems to be a restriction TrueTypeFontFamily that there can only be one font variant per TextEmphasis combination.

As a workaround I changed TTFontDescription>>#emphasis to identify Black as Bold. Now Optima Regular is used as default. However, I cannot use Optima Bold now.

I attach the ChangeSet with the fix and the workaround.

Given that we use only TrueType fonts now, I think the best solution would be to remove bold an italic from TextEmphasis and use the all variants of the TrueType font families instead.

By the way, is there a package with a nice font viewer?

Cheers,
Bernhard
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 5984-CuisCore-BernhardPieber-2023Aug26-15h22m-bp.001.cs.st
Type: application/octet-stream
Size: 1999 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20230826/a3400404/attachment.obj>


More information about the Cuis-dev mailing list