Page 1 of 1

How do I make my program take fonts from a given folder?

Posted: Mon Nov 07, 2022 9:33 pm
by Eugene Lutsenko
hi!

Users of the Eidos system not from Russia are faced with the fact that they have questions displayed on screen forms wherever Cyrillic is used. I understand that they simply do not have the necessary fonts in Windows. How do I make my program take fonts from a given folder?
http://aidos.byethost5.com/map5.php

Re: How do I make my program take fonts from a given folder?

Posted: Tue Nov 08, 2022 12:40 am
by skiman
Hi,

Code: Select all

	
	cFont := '.\fonts\thisismyfont.ttf'	// subfolder fonts contains the font
	DllCall("GDI32.DLL", DLL_STDCALL, "AddFontResourceA", cFont )

Re: How do I make my program take fonts from a given folder?

Posted: Tue Nov 08, 2022 9:50 am
by Eugene Lutsenko
Thanks a lot, skiman !

Re: How do I make my program take fonts from a given folder?

Posted: Wed Nov 09, 2022 1:19 am
by k-insis
Mind that this effects system only until next reboot.


https://learn.microsoft.com/en-us/windo ... tresourcea

This function installs the font only for the current session. When the system restarts, the font will not be present. To have the font installed even after restarting the system, the font must be listed in the registry.
Eugene Lutsenko wrote: Tue Nov 08, 2022 9:50 am Thanks a lot, skiman !

Re: How do I make my program take fonts from a given folder?

Posted: Wed Nov 09, 2022 1:31 am
by skiman
Hi,

Yes, you need to load it every time at startup.

When you close your application you can do the following, to release the font.

Code: Select all

DllCall("GDI32.DLL", DLL_STDCALL, "RemoveFontResourceA", cFont )

Re: How do I make my program take fonts from a given folder?

Posted: Wed Nov 09, 2022 2:21 am
by Eugene Lutsenko
Thanks, I'll take it into account

But so far so:
http://lc.kubagro.ru/__AidosALL.txt

Search: "n InstallFonts()"

Re: How do I make my program take fonts from a given folder?

Posted: Wed Nov 09, 2022 11:54 am
by Eugene Lutsenko
I made the release of fonts during the normal logout. How do I find out the correspondence of ttf file names and font names?

Re: How do I make my program take fonts from a given folder?

Posted: Thu Nov 10, 2022 12:10 am
by k-insis
Windows api function GetFontResourceInfo (gdi32.dll) that does that

BOOL GetFontResourceInfo(LPCTSTR lpszFilename, // font file name
LPDWORD cbBuffer, // size of buffer for resouce information
LPVOID lpBuffer, // buffer for returned resouce information
DWORD dwQueryType, // resouce information query type
);

There was post on superuser:

https://superuser.com/questions/1432800 ... mmand-line


Eugene Lutsenko wrote: Wed Nov 09, 2022 11:54 am I made the release of fonts during the normal logout. How do I find out the correspondence of ttf file names and font names?

Re: How do I make my program take fonts from a given folder?

Posted: Thu Nov 10, 2022 8:39 pm
by Eugene Lutsenko
I would like to download only those fonts that are actually used in the Eidos system. There are not so many of them, they take up less space and it happens faster.