Hi all,
I'm developing a multiplatform app and I need to have the same look on all OS. Is it possible to include a my personal font in the Lazarus compiled binary to have the same graphic/size/etc on all OS?
Thank you,
Kjow

Mailing lists / lazarus / 2010-07
7 messages · 5 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Hi all,
I'm developing a multiplatform app and I need to have the same look on all OS. Is it possible to include a my personal font in the Lazarus compiled binary to have the same graphic/size/etc on all OS?
Thank you,
Kjow
Since nobody else has commented: I've done this with Delphi in Windows, embedding a (bitmap) font as a resource. Quite frankly I didn't find it entirely satisfactory since if for some reason the OS though that the binary was locked it couldn't access the resource and fell back to a "close equivalent".
I'm not sure that the same can be done in a portable fashion because of the X/unix case where the binary and the fonts are potentially stored on different hosts. It /might/ be possible to handle that particular case by making the app look like an X font server, but that would clearly fail if there was already one set up.
I'm developing a multiplatform app and I need to have the same look on all OS. Is it…
Kjow wroteI'm developing a multiplatform app and I need to have the same look on all OS. Is it possible to include a my personal font in the Lazarus compiled binary to have the same graphic/size/etc on all OS?
Putting the font in the executable and reading afterwards should be the easy part. You can either use a .RC file or a .LRS file and there are APIs to retrive this. Not sure where this is documented. Lazarus uses this, so it should work very well.
Now the problem would be that I don't know if we currently support loading a not-installed font from a file in TFont. You would need to check that. If we don't, then we need a new function TFont.LoadTTFFontFromStream / LoadTTFFontFromFile, and it will need a per-widgetset implementation to connect this font stream with the widgetset.
The other solution would be placing your font file in the adequate place where system fonts should be. Your installer should do it. For unix systems you can implement "make install" to do that too, besides the traditional deb / rpm packages.
Since nobody else has commented: I've done this with Delphi in Windows, embedding a…
From: Mark Morgan Lloyd [mailto:]
Sent: 21 July 2010 08:52
Kjow wrote: > Hi all, > > I'm developing a multiplatform app and I need to have the same look
on
> all OS. Is it possible to include a my personal font in the Lazarus > compiled binary to have the same graphic/size/etc on all OS? Since nobody else has commented: I've done this with Delphi in Windows,
embedding a (bitmap)
font as a resource. Quite frankly I didn't find it entirely
satisfactory since if for some
reason the OS though that the binary was locked it couldn't access the
resource and fell back >to a "close equivalent".
I'm not sure that the same can be done in a portable fashion because of
the X/unix case where >the binary and the fonts are potentially stored on different hosts. It /might/ be possible to >handle that particular case by making the app look like an X font server, but that would
colleagues]
The way I've done it in the past with Delphi, is to have a TrueType font in the resources and something along these lines
=-=-=-=-=-=
const
cFont:array[0..0,0..2] of string=
(('tmp\','SciCalc','scicalc2_small.ttf'));
function LoadFont(FontIdx:Integer; Load:boolean):boolean;
var fnt,FontRes : string;
Res : TResourceStream;
begin
result:=false; //assume it all went wrong...
fnt:=SettingsRootDir+cFont[FontIdx,0]+cFont[FontIdx,2];
if Load then
begin
if not(FileExists(fnt)) then
begin
try
Res :=TResourceStream.Create(Hinstance,
cFont[FontIdx,1],
RT_RCDATA);
Res.SaveToFile(fnt);
Res.Free;
except
end;
end;
if FileExists(fnt) then
begin
FontRes:=fnt+#0;
result:=(AddFontResource(@FontRes[1])0);
if result then PostMessage(HWND_BROADCAST,WM_FONTCHANGE,0,0);
end;
end
else
begin
FontRes:=fnt+#0;
result:=RemoveFontResource(@FontRes[1]);
if result then PostMessage(HWND_BROADCAST,WM_FONTCHANGE,0,0);
//Could Delete file is wanted :shrug: depends on how app was
installed
end;
end;=-=-=-=-=-=
Now, this is very Windows centric, but the idea is there. Windows cannot load a font from memory - it /has/ to be a file, hence the persisting part. Something XPlatform along these lines would be super, but alas I'm not the man to do it. However this code posted here is up for grabs as a working windows implementation for whoever wants to use it.
DSP
2010/7/21 Duncan Parsons :
[cut]
Thank you all, I'll try as soon as possible.
Regards,
Kjow
I'm developing a multiplatform app and I need to have the same look on all OS. Is it…
i was going to reply to this and got lost in other stuff... what widget set are you using? i'm thinking of the fpGUI widget set and its specific design to look the same across all platforms...
is the font really that important that folk can't read or understand it between platforms?
2010/7/21 waldo kitty :
Hi,
I use gtk2 for i386-linux and arm-linux, win32/64... for windows :) between gtk2 and windows there are a lot of differences, but at moment I found that setting these params:
charset: DEFAULT_CHARSET
name: charter [bitstream]
the differences are not so bad -> very similar.
But there isn't a big choise in fonts...
In the next future I'll try qt for i386-linux and arm-linux, but not for windows.