fontface with SDL?

Started by Ashmoor, July 09, 2020, 16:04:02

Previous topic - Next topic

Ashmoor

How can I load a font face and draw it using SDL.gl2sdlmax2d? LoadImageFont and DrawText do not seem to work.

Derron

Can you give a short non working (but compileable :D) example (setting driver, loading font, drawing font)?

It works here though - hence the asking.


bye
Ron

Ashmoor

Here is the code. I surely am doing something wrong but I don't know what it is.

Code (blitzmax) Select

SuperStrict


Framework SDL.gl2sdlmax2d
Import BRL.Retro
Import BRL.Font
Import BRL.Max2D


Global fontDiavloBlack40:TImageFont
fontDiavloBlack40 = LoadImageFont("fonts/Diavlo_BLACK_II.otf", 60, SMOOTHFONT)


Graphics 800,600


Repeat

Cls
DrawTestText()
Flip()


If KeyHit (KEY_ESCAPE) Or AppTerminate() Then End
Forever

Function DrawTestText()
SetImageFont(fontDiavloBlack40)
DrawText("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",20,200)
SetImageFont(Null)
EndFunction

Derron

I guess you miss to import a font loader...

Import brl.FreeTypeFont


This is why
fontDiavloBlack40 = LoadImageFont("fonts/Diavlo_BLACK_II.otf", 60, SMOOTHFONT)
If Not fontDiavloBlack40 Throw "font loading failed"

would throw the message "font loading failed" - until you import the module above.

bye
Ron

Ashmoor

That worked fine. Thanks!

Is there a way to figure out which modules do what? I've been reading the help and searching through the module sources but can't figure out what they do.