Theos PowerBasic Museum 2017

Archive => Discussion - Legacy Software (PBWIN 9.0+/PBCC 5.0+) => Topic started by: Ari Savola on July 19, 2010, 10:23:15 PM

Title: PRB: Added font not showing up in GDIP functions
Post by: Ari Savola on July 19, 2010, 10:23:15 PM
Hi folks,

here's my problem at the moment: I am adding a new, temporary, private TTF font with AddFontResourceEx (or with basic AddFontResource), but the GDIP functions I use don't see the font.

 ....
 LOCAL s AS STRING, x as LONG
 STATIC sTempFolder, szFontFile AS STRING

 GetTempWorkFolder(BYREF sTempFolder)
 s = LoadResourceAsString(0, "PB100", %RT_RCDATA)
 x = FREEFILE
 OPEN sTempfolder & "CoertSchrift_Romaans.ttf" FOR BINARY AS #x
 PUT$ #x, s
 CLOSE #x
 szFontFile = sTempfolder & "CoertSchrift_Romaans.ttf" & $NUL
 x = AddFontResourceEx(BYVAL STRPTR(szFontFile),%FR_PRIVATE,BYVAL 0)
 .....


 .....
 LOCAL sfont AS STRING
 LOCAL pBrush,pFontFamily,pFont,pFormat,rc AS DWORD

 rc = GdipCreateSolidFill(&HFFC0C0C0, pBrush)
 sfont = UCODE$("CoertSchrift Romaans" & $NUL)
 rc = GdipCreateFontFamilyFromName(BYVAL sfont, BYVAL %NULL, pFontFamily)
 rc = GdipCreateFont(pFontFamily, 48, %FontStyleBold, %UnitPixel, pFont)
 ......


If I use the basic AddFontResource (to make it "public"), I can see the font with WordPad, while my program is running.  So I guess the adding part is partly working.  But GdipCreateFontFamilyFromName() gives me error 14 (Font Family Not Found).

"SendMessage(%HWND_BROADCAST, %WM_FONTCHANGE, 0, 0)" didn't help either.

What can I do to make the GDIP to notice the added font too?

cheers.. C[_]
Title: Re: PRB: Added font not showing up in GDIP functions
Post by: José Roca on July 19, 2010, 10:58:23 PM
 
Try using sfont = UCODE$("CoertSchrift Romaans" & $NUL).
Title: Re: PRB: Added font not showing up in GDIP functions
Post by: Ari Savola on July 20, 2010, 08:31:10 AM
Thanks, I had forgot that, but that fix won't help.

I also forgot to mention that if I MANUALLY add the font to the system beforehand, the font is found and my tool is working.  So I suspect I'm missing something important..?  The test system under Vmware is mostly XP SP2 Pro ENG (because it is quite light, and available..), also tried W7 x64 which acted the same.

cheers.. aSa C[_]