Page MenuHome

Fix for T53332: BFont 43 Inaccessible Glyphs
ClosedPublic

Authored by Harley Acheson (harley) on Oct 1 2022, 6:35 PM.

Details

Summary

Preloading of BFont (default for 3D Text Objects) glyphs will not load
any with a character code greater than 256, resulting in 43 characters
that are inaccessible. This patch corrects that preloading code.


When fonts are loaded for 3D Text objects, there is an attempt made to preload the first 256 glyphs. There are further assumptions that this will load all the contents of the built-in "bfont.pfb" font in that it will refuse to look up any glyphs that are later not found.

Unfortunately the loop that does the preloading will not do so for any codepoints that are above 256. This font contains 43 codepoints above that number. Most of the unavailable glyphs are fairly obscure and not noticed but we have had at least two bug reports about "per-mille - ‰" (codepoint value of 8240) not working despite it being in the font: T53332: Text Object - Edit Mode - Special Characters - Circle and Promille doesn't get created, T66038: Broken Special Characters

Diff Detail

Repository
rB Blender

Event Timeline

Harley Acheson (harley) requested review of this revision.Oct 1 2022, 6:35 PM
Harley Acheson (harley) created this revision.
Harley Acheson (harley) retitled this revision from Fix for T53332: BFont Missing 43 Glyphs Inaccessible to Fix for T53332: BFont 43 Inaccessible Glyphs.Oct 1 2022, 6:46 PM
Harley Acheson (harley) edited the summary of this revision. (Show Details)
Harley Acheson (harley) added a project: Core.
Harley Acheson (harley) edited the summary of this revision. (Show Details)Oct 1 2022, 6:49 PM

face->num_glyphs not accurate for bfont

Campbell Barton (campbellbarton) requested changes to this revision.Oct 6 2022, 6:00 AM

This patch seems fine but it's vague why the old code didn't work.

You mention face->num_glyphs isn't correct. Is that an error in the font-data or freetype? If it was correct would the old code work?

It would be good to have a short explanation of what was going wrong exactly.

source/blender/blenkernel/intern/vfontdata_freetype.c
337–340

These can be moved into the body of the for loop.

This revision now requires changes to proceed.Oct 6 2022, 6:00 AM

@Campbell Barton (campbellbarton) - This patch seems fine but it's vague why the old code didn't work.

I should have been more clear. It is because it is currently using a loop of while (charcode < charcode_reserve) so charcode can't be above 256 since that is the value of charcode_reserve . Although there are only 239 (or so) glyphs in the font, 43 of them have charcodes above 256. Like that "per-mille" which has a charcode of 8240, even though it is only the 189th glyph in the font.

You mention face->num_glyphs isn't correct. Is that an error in the font-data or freetype? If it was correct would the old code work?

face->num_glyphs isn't used in current code. But I tried using it in the first draft of my patch. I thought I could use that when calculating the amount of glyphs to preload but it reported an incorrect number. If I remember right it said that there were 219 glyphs in the font even though there are actually 239.

This revision is now accepted and ready to land.Oct 6 2022, 8:07 AM
Harley Acheson (harley) edited the summary of this revision. (Show Details)Oct 6 2022, 6:55 PM