Page MenuHome

Fix for T101481: Improved VFont Loading
ClosedPublic

Authored by Harley Acheson (harley) on Oct 6 2022, 8:38 PM.

Details

Summary

Remove redundancy in the testing and loading of VFont fonts. Includes
improved setting of character map for using Wingding and Symbol fonts.


This is an alterative to D16123: Fix for T101481: 3D Text Objects Wingdings Font. Instead of duplicating the setting of the character map, this removes the redundancy that necessitates that duplication.

In a nutshell, current code has a public function (BKE_vfontdata_from_freetypefont) that loads the FreeType library, checks to see if a font is suitable, loads the font if so, then closes the library.

But the "check" (check_freetypefont) and the "load" (objfnt_to_ftvfontdata) does some of the same things. For example the face is created and closed in both. The complaint in T101481: Regression: Wingding type font doesn't load is because the "check" does not do all the same things as the "load".

This patch removes that redundancy and the chance of these functions getting out of sync. Aa new function is added that returns a face if the font is suitable, so does the testing. This way BKE_vfontdata_from_freetypefont can do both the checking and loading. This then removes some code, makes it easier to follow, does more tests, and improves comments.

Diff Detail

Repository
rB Blender

Event Timeline

Harley Acheson (harley) requested review of this revision.Oct 6 2022, 8:38 PM
Harley Acheson (harley) created this revision.
Campbell Barton (campbellbarton) accepted this revision.EditedOct 7 2022, 1:59 AM

LGTM, minor changes suggested.

Reminder that the patch subject should be usable as the commit subject.

source/blender/blenkernel/intern/vfontdata_freetype.c
269

Prefer a more descriptive name vfont_face_load_from_packed_file.

271

The NULL check doesn't seem necessary (it's not in the previous code, and if it _is_ null, FT_Init_FreeType/FT_Done_FreeType is unnecessary overhead).

Think it's fine to simply not check for NULL.

This revision is now accepted and ready to land.Oct 7 2022, 1:59 AM
Harley Acheson (harley) marked 2 inline comments as done.

Updated to incorporate changes require from review.

Harley Acheson (harley) edited the summary of this revision. (Show Details)Oct 7 2022, 2:59 AM
Harley Acheson (harley) retitled this revision from Fix for T101481 (Alternate): VFont Loading to Fix for T101481: Improved VFont Loading.
This revision was automatically updated to reflect the committed changes.