TGuiFont to TImageFont?

Started by chalky, October 16, 2018, 00:29:52

Previous topic - Next topic

chalky

I am trying to create a custom gadget which would ideally use the same font as standard window controls so that it blends into the GUI. Although I can find the required fonts via:
Local FONT_R:TGuiFont=LookupGuiFont(GUIFONT_SYSTEM,0,FONT_NORMAL)
Local FONT_B:TGuiFont=LookupGuiFont(GUIFONT_SYSTEM,0,FONT_BOLD)


I cannot use these to draw text on a canvas, as SetImageFont wants a TImageFont object and fails with an "Unable to convert" error. Is there a way to create a TImageFont from a TGuiFont so it can be used with the the SetImageFont and DrawText commands?

Henri

Hi,

TGuiFont has a handle to font (along with some attributes). TImageFont has raw pixmap data to be shown in graphic content. Both are originally from the same source (true type font , .ttf) , image font is just converted to images. I don't believe you can get TImageFont from TGuiFont font handle (someone can prove me wrong though), but you can copy the source font from system to your program folder and load that directly with LoadImageFont.

There are also some nice 3rd party fonts to choose from. See https://www.dafont.com

-Henri
- Got 01100011 problems, but the bit ain't 00000001