How to make the system use its own font
- Eugene Lutsenko
- Posts: 1649
- Joined: Sat Feb 04, 2012 2:23 am
- Location: Russia, Southern federal district, city of Krasnodar
- Contact:
How to make the system use its own font
How do I make the system use my own font? So that the interface is displayed correctly on any computer with any version of Windows?
Re: How to make the system use its own font
hi,
"what" you want to display "right" ... different DBF
Xbase++ use OEM <-> ANSI Conversation so your App must be ANSI
OEM use Codepage but under Xbase++ you can´t open OEM DBF with Codepage (like in harbour)
but ANSI is only 1/2 Way ... UNICODE is what you need.
i use ARIAL UNICODE TTF from Office for Chinese Sign.
when using UNCICODE you also need enhance Function like AT() or SUBSTR() which will not work correct. so all Window Controls and Function must be able to use UNICODE
this was the Reason why i began to write my own Controls to understand Window.
"what" you want to display "right" ... different DBF

Xbase++ use OEM <-> ANSI Conversation so your App must be ANSI
OEM use Codepage but under Xbase++ you can´t open OEM DBF with Codepage (like in harbour)
but ANSI is only 1/2 Way ... UNICODE is what you need.
i use ARIAL UNICODE TTF from Office for Chinese Sign.
when using UNCICODE you also need enhance Function like AT() or SUBSTR() which will not work correct. so all Window Controls and Function must be able to use UNICODE
this was the Reason why i began to write my own Controls to understand Window.
greetings by OHR
Jimmy
Jimmy
Re: How to make the system use its own font
Hi,
You can load your own font at startup with this.
DllCall("GDI32.DLL", DLL_STDCALL, "AddFontResourceA", cFont )
Where cFont contains the path and name of the font.
Before closing your application, you can use this:
DllCall("GDI32.DLL", DLL_STDCALL, "RemoveFontResourceA", cFont )
You can load your own font at startup with this.
DllCall("GDI32.DLL", DLL_STDCALL, "AddFontResourceA", cFont )
Where cFont contains the path and name of the font.
Before closing your application, you can use this:
DllCall("GDI32.DLL", DLL_STDCALL, "RemoveFontResourceA", cFont )
- Eugene Lutsenko
- Posts: 1649
- Joined: Sat Feb 04, 2012 2:23 am
- Location: Russia, Southern federal district, city of Krasnodar
- Contact:
Re: How to make the system use its own font
And how do I determine the paths to the place where these fonts are located now?
[/size]
Code: Select all
DC_XbpMenuConfig( ;
{ GRA_CLR_WHITE,; // 1 - Sub Menu Background Color
fColor,; // 2 - Sub Menu Vertical Bar Foreground Color
bColor,; // 3 - Sub Menu Vertical Bar Background Color
GRA_CLR_BLACK,; // 4 - Sub Menu Outline Color
'8.MS Sans Serif Bold', ; // 5 - Sub Menu Vertical Bar Font
.F., ;
'8.MS Sans Serif', ; // 6 - Sub Menu Check Character Font
'b', ; // 7 - Sub Menu Check Character
fColor,; // 8 - Menu Bar Foreground Color
bColor, ; // 9 - Menu Bar Background Color
GRA_CLR_BLACK,; // 10 - Sub Menu Foreground Color
'8.MS Sans Serif' } ) // 11 - Menu Bar Font
- Eugene Lutsenko
- Posts: 1649
- Joined: Sat Feb 04, 2012 2:23 am
- Location: Russia, Southern federal district, city of Krasnodar
- Contact:
Re: How to make the system use its own font
I tried it, but it didn't work out
[/size]
Code: Select all
Hi,
You can put all the needed fonts is a subfolder of your application. Then load them when you start.
Code:
************************
FUNCTION InstallFonts() // <<<===################################
************************
Local aList := directory(".\fonts\*.ttf")
Local i , cFont , cPath:=Disk_dir
for i := 1 to len(aList)
cFont := cPath+'\fonts\'+aList[i][F_NAME]
DllCall("GDI32.DLL", DLL_STDCALL, "AddFontResourceA", cFont )
next
RETURN NIL
It is also a good idea to remove them when you close your application.
Code:
************************
FUNCTION RemoveFonts()
************************
Local aList := directory(".\fonts\*.ttf")
Local i , cFont , cPath:=Disk_dir , nGo , nteller := 1
for i := 1 to len(aList)
cFont := cPath+'\fonts\'+aList[i][F_NAME]
nTeller := 1
nGo := 999
do while nGo > 0 .and. nTeller < 20 // try up to 20 times to remove is the result 'ngo' is bigger than nul.
nGo := DllCall("GDI32.DLL", DLL_STDCALL, "RemoveFontResourceA", cFont )
nTeller ++
enddo
next
RETURN NIL
-
- Posts: 42
- Joined: Mon Dec 23, 2013 2:10 pm
- Contact:
Re: How to make the system use its own font
It doesn't work for vector fonts (versions 5 and later) which are based on Unicode.
You need another solution.
Micosoft applications such as Office, Microsoft 365, Sql Server etc. use the Unicode fonts.
But several software and development tools do not always allow these options, especially since these tools are mainly intended for countries that use the Latin characters.
For the countries of Asia and the Middle East, developers always find it difficult to adopt their applications to support the necessary fonts (Xbase ++ as an example).

You need another solution.
Micosoft applications such as Office, Microsoft 365, Sql Server etc. use the Unicode fonts.
But several software and development tools do not always allow these options, especially since these tools are mainly intended for countries that use the Latin characters.
For the countries of Asia and the Middle East, developers always find it difficult to adopt their applications to support the necessary fonts (Xbase ++ as an example).


Re: How to make the system use its own font
hi,
after AddFontResourceA() to "inform" OS about new Font
---
IMHO you are on wrong Way ...
it is not a Problem of Font when Sign are display/print wrong, it is the Codepage of OEM DBF
if you open OEM DBF with right Codepage than it will display/print with almost every installed System Font.
Information about Codepage you will find in DBF Header at Byte 29 (or 30)so the Question is how to open DBF under Xbase++ with Codepage 
you have to sendEugene Lutsenko wrote:I tried it, but it didn't work out
Code: Select all
SendMessage(HWND_BROADCAST,WM_FONTCHANGE,0,0)
---
IMHO you are on wrong Way ...
it is not a Problem of Font when Sign are display/print wrong, it is the Codepage of OEM DBF
if you open OEM DBF with right Codepage than it will display/print with almost every installed System Font.
Information about Codepage you will find in DBF Header at Byte 29 (or 30)
Code: Select all
cTest := SUBSTR( cTxt, 30, 1 ) // 0-29 / 1-30
// look for Codepage
DO CASE
CASE cTest = CHR( 0x01 )
_CodePage := "DOS 437"
CASE cTest = CHR( 0x02 )
_CodePage := "DOS 850"
CASE cTest = CHR( 0x03 )
_CodePage := "WIN 1251"
CASE cTest = CHR( 0xC8 )
_CodePage := "WIN 1250"
CASE cTest = CHR( 0x64 )
_CodePage := "DOS 852"
CASE cTest = CHR( 0x65 )
_CodePage := "DOS 865"
CASE cTest = CHR( 0x66 )
_CodePage := "DOS 866"
OTHERWISE
_CodePage := STR( ASC( cTest ) )
// ??? mehr
ENDCASE

greetings by OHR
Jimmy
Jimmy
- Eugene Lutsenko
- Posts: 1649
- Joined: Sat Feb 04, 2012 2:23 am
- Location: Russia, Southern federal district, city of Krasnodar
- Contact:
Re: How to make the system use its own font
I am more concerned about the correct display of the interface language on computers with fonts without Cyrillic
Re: How to make the system use its own font
hi,
these Setting are which my latest Release can use
http://www.hmgforum.com/viewtopic.php?f ... 5&start=56
next Release will have Export to XLSx (without Excel, 3-PP LIB or DLL)
i guess i can, under Windows 10, when using Codepage "Russian WINDOWS-1" and "RUWIN" as Nation-LanguageEugene Lutsenko wrote:I am more concerned about the correct display of the interface language on computers with fonts without Cyrillic
these Setting are which my latest Release can use
http://www.hmgforum.com/viewtopic.php?f ... 5&start=56
Code: Select all
STATIC FUNCTION WinCodePage()
LOCAL cRet := ""
LOCAL aLangName := { "Basque", ;
"Czech 852", ;
"Czech ISO-8859-2", ;
"Czech KAM", ;
"Catalan", ;
"English", ;
"French", ;
"Galician", ;
"German Ansi", ;
"German OEM", ;
"Hebrew 862", ;
"Hebrew 1255", ;
"Hungarian 852", ;
"Hungarian CWI-2", ;
"Hungarian WINDOWS-1", ;
"Italian", ;
"Polish 852", ;
"Polish ISO-8859-1", ;
"Polish Mozowia", ;
"Portuguese", ;
"Romanian", ;
"Russian WINDOWS-1", ;
"Serbian ISO-8859-2", ;
"Serbian 852", ;
"Spanish" }
LOCAL aLangID := { "EU", ;
"CS852", ;
"CSISO", ;
"CSKAM", ;
"CA", ;
"EN", ;
"FR", ;
"GL", ;
"DEWIN", ;
"DE850", ;
"HE862", ;
"HEWIN", ;
"HU852", ;
"HUCWI", ;
"HUWIN", ;
"IT", ;
"PL852", ;
"PLISO", ;
"PLMAZ", ;
"PT", ;
"RO", ;
"RUWIN", ;
"SRISO", ;
"SR852", ;
"ES" }
greetings by OHR
Jimmy
Jimmy