... and saw that in Delphi there is an "AddFontResource" function not planned to be implemented in lazarus...
...
So, the 'simple' way to embed fonts inside resource can not be as simple as I thought lol
AddFontMemResourceEx (and
AddFontResource) are
not Delphi specific. They are Windows specific. You can use them perfectly fine in Lazarus (under Windows). My code shows how to use AddFontMemResourceEx. It worked perfectly in Lazarus for assigning a font loaded from resource and the font only resides in memory. (I tested it before posting this code.) So at least for Windows you can use this method directly from memory. If you want a cross-platform solution you have to look at how to do this in Linux/MacOS.
If you want to save your fonts to disk and register them with the OS, I hope you make sure the user has the correct privileges to do so. It's just the mess of saving the font, registering them and
not forgetting to UNREGISTER them and deleting the file which made me decide that i'd use the AddFontMemResourceEx-method. (I doubt your way would be 'simpler' than my example)
For unregistering and removing the font you could use the same method i used. The finalization-section of your program.
Edit:I don't have a lot of Linux-GUI experience so you have to check the method below yourself. (I only used Linux as server with just the console). I searched a little for adding fonts in Linux "on the fly". I'm going to assume the user/program does not have privileges to install a system-font. You shouldn't either because otherwise your program will run into trouble if it runs unprivileged. Maybe you can add the font as file in $HOME/.fonts/ and run fc-cache --force. You'll have to check if after that you can assign the name of the font to any of your components in runtime. The method is described
here.
If this method works you could write your own cross-platform routines which would use AddFontResource on Windows and $HOME/.fonts/ on Linux.