[Solved] Installing font if not exists lazarus / 21-General ---------------------------------------------------------------------- madref · 2024-11-11 10:58 With this function I check if a font is installed on a system. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function FontIsAvailable(const FontName: string): Boolean;begin  Result := Screen.Fonts.IndexOf(FontName) >= 0;end; How can I install a font if it is not on the system through code? ---------------------------------------------------------------------- Thaddy · 2024-11-11 11:46 By using a font resource and compiling that into your program. ---------------------------------------------------------------------- madref · 2024-11-11 12:04 Again....how? ---------------------------------------------------------------------- rvk · 2024-11-11 12:16 Quote from: madref on November 11, 2024, 11:58:11 amHow can I install a font if it is not on the system through code? Do you really want to install the font for the whole system? You can even use any font without even installing it (and even loading it from resource instead of external file). https://forum.lazarus.freepascal.org/index.php/topic,63107.msg477587.h tml#msg477587 O, and you didn't mention what platform. You have multiple platforms in your signature. ---------------------------------------------------------------------- madref · 2024-11-12 15:51 My main platform is Mac OSx. And I want to integrate it in this : https://forum.lazarus.freepascal.org/index.php/topic,67070.75.html ---------------------------------------------------------------------- rvk · 2024-11-12 22:45 Quote from: madref on November 12, 2024, 04:51:40 pmMy main platform is Mac OSx. Can't help you with Mac OS other than pointing you too this website for a solution. https://www.tweaking4all.com/software-development/lazarus- development/macos-application-custom-font/ ---------------------------------------------------------------------- madref · 2024-11-12 23:35 I don't want to use it for the whole app, but just for my graphics routines (Poppetjes). ---------------------------------------------------------------------- rvk · 2024-11-12 23:49 Quote from: madref on November 13, 2024, 12:35:13 amI don't want to use it for the whole app, but just for my graphics routines (Poppetjes). So? The method is still the same. My understanding is that after doing what is described on that page, you have access to that font like you do normally x.font.name := 'xxx'. But I could be mistaken (like I said, I don't do Mac). Extra info https://stackoverflow.com/questions/27680893/how-to-use-custom-fonts- in-a-mac-application ---------------------------------------------------------------------- madref · 2024-11-13 09:13 Thanks RVK. This solution works great. But now I have a strange behavior. In run-time (the red one) I get the font to work, but in design-time (the green one) I don't het the same result. Is there an explanation for? ---------------------------------------------------------------------- rvk · 2024-11-13 10:38 Quote from: madref on November 13, 2024, 10:13:48 amBut now I have a strange behavior. In run-time (the red one) I get the font to work, but in design-time (the green one) I don't het the same result. As explained in the link, during design-time you need to install the font like normal. Otherwise the IDE doesn't have access to it. The mentioned solution is only for running the app outside the ide and on computers where the font isn't present. QuoteTip: During development of your application – install the font! When you’re still developing your application, I’d recommend installing the TTF font on your computer like any other regular font. This way you can access the font and see the result in the development phase of your application. Keep in mind that you need to restart Lazarus after installing or removing a font, for Lazarus to “see” the font. Font installation is quite simple: double click the TTF file and follow the steps to install. Removing the font (to test if your application actually picks up the custom font, even when the font is not installed) is pretty straight forward as well: open FontBook (“Applications”  “FontBook”), find your font, right click the font-name, and select “Remove XYZ family”.https://www.tweaking4all.com/software-development/lazarus- development/macos-application-custom-font/ ---------------------------------------------------------------------- madref · 2024-11-13 21:44 oeps...hadn't read that part correctly