[MaxGUI] setgadgetfont working example? On canvas?
BlitzMax Forums/BlitzMax Beginners Area/[MaxGUI] setgadgetfont working example? On canvas?
| ||
Hello all. I cant seem to get one, ONE ever-lovin example of the setgadgetfont to work. Would someone give me a simple demo of a canvas, and some font being set as the canvas font? Hell, I'll even settle for a settextareafont! Also, would the following work for incbin:IncBin "../Media/Fonts/bitdust1.ttf" Global bitdust1:TGuiFont=LoadGuiFont("incbin::../Media/Fonts/bitdust1.ttf",18,False,False,False) SetGadgetFont cavMyCanvas,bitdust1 Also, would I have to use the directory specific load for the font? I mean thats the way I've done it for the plain old regular font loading in the past. |
| ||
Here's my understanding: SetGadgetFont requires a GuiFont, except for the canvas (which is really a graphical item) which uses ImageFont. The ways to load these two are different: LoadImageFont wants the filename (where the file needs to be renamed to the Windows name of the font if it isn't already) while LoadGuiFont just wants the Windows font name without the ".ttf". LoadGuiFont only works if the font is loaded in Windows (i.e. shows up in Windows' font list), while LoadImageFont can load the .ttf whether it's loaded in Windows or not. Copy Arial.ttf to the same folder as this example for LoadImageFont to work: Strict Local win:TGadget = CreateWindow( "", 0,0, 400,200 ) Local can:TGadget = CreateCanvas( 0,0, 400,80, win ) SetGraphics CanvasGraphics( can ) SetBlend ALPHABLEND DrawText "This is default font", 10,10 Local iFont:TImageFont = LoadImageFont( "Arial.ttf", 24 ) SetImageFont iFont DrawText "This should be Arial (and bigger)", 10,40 Flip Local but1:TGadget = CreateButton( "default font", 10,90, 80,30, win ) Local but2:TGadget = CreateButton( "Arial", 110,90, 80,30, win ) Local gFont:TGuiFont = LoadGuiFont( "Arial", 24 ) SetGadgetFont but2, gFont Repeat WaitEvent Until EventID() = EVENT_WINDOWCLOSE ![]() (Sorry, I haven't messed with Incbin.) |
| ||
Hey thanks! I appreciate it! But also, I found out that I had a "Sofa King" moment. I forgot to: Import brl.freetypefont Thanks Wendell!!! Sofa King |