How Can I use embedded font or install new fonts in my firemonkey application?
I tried this solution but WM_FONTCHANGE
is not defined in FMX!
I want
I followed the instructions here, and they were of some help. I have a few extra hints that may help,
Now, I've adding the following code,
procedure TMainForm.FormCreate(Sender: TObject);
begin
AddFontResource('c:\fontpath\myfont.ttf');
SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0) ;
end;
procedure TMainForm.FormDestroy(Sender: TObject);
begin
RemoveFontResource('c:\fontpath\myfont.ttf');
SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0) ;
end;
When I run this in a firemonkey form, i've observed the following.
This tells me that my code works (see bullets 1. and 6.) - but FMX won't recognise the font on my main form if you use the name that appears in notepad. I've quadruple checked the font name.
I created two identical projects. One was VCL and the other was FMX. The VCL project works perfectly - both for static text and dynamic text. The FMX code works for neither. If I had to hazard a guess, i'd say that FMX is building a list of fonts on startup, and checking the list of available fonts against that list (ie. like a cache). I'd hazard a guess this is being done to abstract FMX from the underlying operating system...
If anyone has made this work under firemonkey, I would appreciate any advice. Also, if anyone knows how to achieve the same goal under a Mac, i'd appreciate a pointer too.
Regards,
Mr Ed.