Temporarily installed Fonts don't work in Xojo's GDI Text Rendering implem. (but work with Direct2D

since case feedback://showreport?report_id=46596 is not fixed in Xojo 2018v3, I opened a new case feedback://showreport?report_id=54392.
In fact listbox and canvas objects still show text in System font.
After verification I’ll add, if requested, a file showing the issue.

I suspect that it’s broken again. 2018r3 introduced the possibility to use GDI Text Rendering again (default in e.g. ListBox).
I’ve added an example project that shows this issue.
But please add your example, too… That allows Xojo to check a fix against the issue you’re seeing.
I don’t know if the example I provided has the same underlying issue as yours (since my example project just closes, and doesn’t even fall back to the System Font when trying to .DrawString in a Canvas).

You have to add the file FOR verification.

Added example file.

@Jürg Otter I’ll see your workaround and apply it. Thanks.

In a canvas I put the following code, but no text is shown.
Replacing self.BitmapForCaching with new Picture too shows no text, but the app does not crash.

Dim p As Picture = self.BitmapForCaching(g.Width, g.Height)
g.drawpicture p,0,0
p.Graphics.TextSize = 18
p.Graphics.TextFont = mFont//a temporally installed font
p.Graphics.ForeColor = &c000000
p.Graphics.bold = true
p.Graphics.DrawString “???” + EndOfLine + “???” + EndOfLine + “???”,0,0

In the code above, you’re drawing an Empty Picture to g.DrawPicture.
Put that line of code at the very end (once you have drawn something to the Picture - only then draw the Picture to the Canvas).
What happens then?

Either using self.BitmapForCaching or New Picture (with no crash), instead of the temporally installed font, System is used.

Then it seems that there are at least two issues with custom Fonts in the current Xojo releases.
Either they are “closing” the app, or the fonts just don’t display any longer. And there is a workaround that only seems to work for certain fonts/types (maybe).
So it’s good that Xojo has both examples to look at, investigate and fix.

Provided the Feedback case gets enough votes to move higher.

…or raise the Engineer’s interest, knowing the possible cause - and fix it :slight_smile: Thanks @William Yu !
Now let’s just hope this is a regression enough for getting the fix in 2018, and not having to wait until 2019 :wink:

Well, well, well. Case fixed. Thanks @William Yu !

last December fix actually did not work, so a few months ago I opened a new case feedback://showreport?report_id=55423.

Issue: temporarily installed fonts (Windows platform) work OK for all objects, except listboxes and canvases, where the system font takes over.

A few days ago I found that the issue happens only with .ttc fonts, that is fonts-family/collection.
Instead, using .ttf fonts, listbox and canvas both behave properly.
Of course, using .ttf one loses the ability to code something like listbox1.bold = true, since .ttf fonts do not behave as a family/collection. Unless someone teaches me the trick to make four .ttf fonts behave as if they were a .ttc font. It would be great.

If anybody intends to apply this temporary workaround, then one should keep in mind that the .ttf files for bold, italic and bolditalic must all be created as plain/regular with their own particular name (myTTFreg.ttf, myTTFbld.ttf etc) and applied to a listbox or canvas by its name. For instance g.textfont = myTTFbld. And so on and so forth.

Therefore I updated the case above, hoping the new piece of info may help fix the issue.

Actually, Windows treats same family font files with different style attributes automatically as a family. If I create four fonts, say MyFont style Plain, myFont Style Bold, MyFont style Italic and MyFont style BoldItalic in Fontographer or FontLab Studio, and install them all, The will show as one font with attributes in Wordpad, Word and other apps. That should solve your issue temporarily.

Great! And besides, it works for Mac too, so no need to have a different set of fonts for the two platforms.
Thank you, Michel.