Skip to content

Dynamically Loaded Fonts in Firemonkey on WIndows

Notifications You must be signed in to change notification settings

HemulGM/FireMonkey-Fonts

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

FireMonkey-Fonts

EN: Dynamically Loaded Fonts in FireMonkey on Windows

RU: Динамическая загрузка шрифтов в FireMonkey в Windows

Instruction/Инструкция

EN: Add a module to the project and throw the necessary fonts into the project resources

RU: Добавить модуль в проект и добавлять нужные шрифты в ресурсы проекта (загружены будут все)

Notes by the author of the original repository / Заметки автора оригинального репозитория

I think I have an answer how to do this, which was only possible because of a LOT of help by Roy Nelson of Embarcadero's support staff who pointed me in the right direction.

I have verified that this works with Berlin 10.1 (without the Anniversary Patch applied) on Windows 10, 64 bit but I don't guarantee that will will work on all compiler versions/Windows versions and any insight other people have to offer would be very interesting to hear.

First off, I think the (currently) insurmountable issue starts with trying to use AddFontMemResourceEx as that produces fonts that are not enumerable and for Firemonkey to convert an installed TrueType Font to a graphically rendered D2D font--which is what it actually uses--it has to first be able to find it.

Replacing AddFontMemResourceEx with AddFontResource with a temp font file you write from the resource solves that problem, but it's not enough. After it's installed you need to force the TextLayout rendering engine to rebuild its font list which you can do with calling two lines from the FMX.Canvas.D2D.pas unit.

UnregisterCanvasClasses; //this tells it to forget everything it knows
RegisterCanvasClasses; //this tells it to learn it again based on the current state of this system, which now includes our dynamically loaded font.

About

Dynamically Loaded Fonts in Firemonkey on WIndows

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Pascal 100.0%