Author Topic: TGuiFont to TImageFont?  (Read 179 times)

Offline chalky

  • Jr. Member
  • **
  • Posts: 36
TGuiFont to TImageFont?
« on: October 16, 2018, 12:29:52 AM »
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:
Code: [Select]
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?

Offline Henri

  • Full Member
  • ***
  • Posts: 168
Re: TGuiFont to TImageFont?
« Reply #1 on: October 16, 2018, 01:13:38 PM »
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