<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									Lazarus Pascal - Linux - How to use a custom font in your Lazarus application - Delphi, Lazarus, Free Pascal				            </title>
            <link>https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-linux-how-to-use-a-custom-font-in-your-lazarus-application/</link>
            <description>Tweaking4All.com Discussion Board</description>
            <language>en-US</language>
            <lastBuildDate>Wed, 17 Jun 2026 04:15:17 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>Lazarus Pascal - Linux - How to use a custom font in your Lazarus application</title>
                        <link>https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-linux-how-to-use-a-custom-font-in-your-lazarus-application/#post-5871</link>
                        <pubDate>Sat, 28 Jun 2025 11:15:04 +0000</pubDate>
                        <description><![CDATA[In one of my applications I use my own font (see also Windows, MacOS) and I wanted use that same TTF font in the Linux binary.
Since I&#039;m not totally convinced this is the &quot;best&quot; way to do t...]]></description>
                        <content:encoded><![CDATA[<p>In one of my applications I use my own font (see also <a href="https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-how-to-use-a-custom-fonr-file-in-windows/" target="_blank" rel="noopener">Windows</a>, <a href="https://www.tweaking4all.com/software-development/lazarus-development/macos-application-custom-font/" target="_blank" rel="noopener">MacOS</a>) and I wanted use that same TTF font in the Linux binary.</p>
<p>Since I'm not totally convinced this is the "best" way to do this (not a Linux GUI user myself), her what worked for me.</p>
<p>For one your font needs to be copied to "<strong>~/.fonts</strong>", and I did it this way: <br />When the font cannot be found in the directory, the application will create the directory and copy the font (distributed with the executable and placed in the same directory as the executable!), and show a message that the application needs to restart - you could do an automatic restart with a TProcess but for odd reason with my application this kept failing and locking files.</p>
<p>So this is my code, used in the OnCreate event of the main form;</p>
<pre contenteditable="false">  if not FileExistsUTF8(ExpandFileNameUTF8('~/.fonts')+DirectorySeparator+'yourfont.ttf') then
    begin
      ForceDirectoriesUTF8(ExpandFileNameUTF8('~/.fonts'));

      CopyFile( ExtractFilePath(ParamStr(0))+DirectorySeparator+'yourfont.ttf', 
                ExpandFileNameUTF8('~/.fonts')+DirectorySeparator+'yourfont.ttf' );

      MessageDlg('Installed "yourfont.ttf'' font in "~/.fonts".'+LineEnding+LineEnding+
                 'Closing YourApplicationName now.'+LineEnding+LineEnding+
                 'Please restart this one time so the installed font becomes available.', mtInformation, ,0);

      Application.Terminate;
    end;               </pre>
<p> </p>
<p>The restart is needed so your application sees the newly copied font.<br />After the restart it will see that it was installed in "<strong>~/.fonts</strong>".</p>
<p> </p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/">Delphi, Lazarus, Free Pascal</category>                        <dc:creator>Hans</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-linux-how-to-use-a-custom-font-in-your-lazarus-application/#post-5871</guid>
                    </item>
							        </channel>
        </rss>
		