[Cuis-dev] TrueType font import problems

Bernhard Pieber bernhard at pieber.com
Mon Sep 11 13:07:47 PDT 2023


Hi Juan,

Thanks for improving this. I had problems getting it to work, though.

At first I tried this:
TrueTypeFontFamily readTrueTypeFontEntry: '/System/Library/Fonts' asDirectoryEntry // 'Optima.ttc'.

However, this method still has the old behavior: Optima ExtraBlack replaces Optima Regular as the baseTTFontDescription.

After some digging I found I needed to copy Optima.ttc to its own directory and use this method instead:
TrueTypeFontFamily readAllTrueTypeFontsIn: DirectoryEntry smalltalkImageDirectory / 'TrueTypeFonts' / 'Optima'.

This works as you described. Now I two families Optima and Optima-ExtraBlack.

The method TrueTypeFontFamily<<#readTrueTypeFontEntry: is used when installing a font file from a file list, so it should probably be fixed as well.

Cheers,
Bernhard


------- Original Message -------
Juan Vuletich <juan at cuis.st> schrieb am Mittwoch, 30. August 2023 um 01:00:


> 
> 
> Hi Bernhard,
> 
> I pushed your fix to support V2 headers.
> 
> But I also did a few more things. When importing fonts like Optima,
> ExtraBlack and other styles beyond regular / italic / bold / bold italic
> will be turned into different FontFamilies.
> 
> I also changed the handling of fonts and sizes in TextEditors quite a
> bit. I think it is nicer now.
> 
> Please pull, update, and test.
> 
> Thanks,
> 
> 
> On 8/27/2023 5:23 AM, Bernhard Pieber via Cuis-dev wrote:
> 
> > Here is a slightly improved version.
> > 
> > > Am 26.08.2023 um 20:59 schrieb Bernhard Pieber via Cuis-devcuis-dev at lists.cuis.st:
> > > 
> > > 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
> > > --
> > > Cuis-dev mailing list
> > > Cuis-dev at lists.cuis.st
> > > https://lists.cuis.st/mailman/listinfo/cuis-dev
> > > <5984-CuisCore-BernhardPieber-2023Aug26-15h22m-bp.001.cs.st>
> 
> 
> 
> --
> Juan Vuletich
> cuis.st
> github.com/jvuletich
> researchgate.net/profile/Juan-Vuletich
> independent.academia.edu/JuanVuletich
> patents.justia.com/inventor/juan-manuel-vuletich
> linkedin.com/in/juan-vuletich-75611b3
> twitter.com/JuanVuletich


More information about the Cuis-dev mailing list