Ooops
August 04, 2020, 12:14:51 PM

Author Topic: fontface with SDL?  (Read 166 times)

Offline Ashmoor

  • Jr. Member
  • **
  • Posts: 60
fontface with SDL?
« on: July 09, 2020, 04:04:02 PM »
How can I load a font face and draw it using SDL.gl2sdlmax2d? LoadImageFont and DrawText do not seem to work.

Offline Derron

  • Hero Member
  • *****
  • Posts: 3074
Re: fontface with SDL?
« Reply #1 on: July 10, 2020, 06:55:32 AM »
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

Offline Ashmoor

  • Jr. Member
  • **
  • Posts: 60
Re: fontface with SDL?
« Reply #2 on: July 10, 2020, 09:17:40 AM »
Here is the code. I surely am doing something wrong but I don't know what it is.

Code: BlitzMax
  1. SuperStrict
  2.  
  3.  
  4. Framework SDL.gl2sdlmax2d
  5. Import BRL.Retro
  6. Import BRL.Font
  7. Import BRL.Max2D
  8.  
  9.  
  10. Global fontDiavloBlack40:TImageFont
  11. fontDiavloBlack40 = LoadImageFont("fonts/Diavlo_BLACK_II.otf", 60, SMOOTHFONT)
  12.  
  13.  
  14. Graphics 800,600
  15.  
  16.  
  17. Repeat
  18.        
  19.         Cls
  20.                 DrawTestText()                         
  21.         Flip()
  22.  
  23.  
  24.         If KeyHit (KEY_ESCAPE) Or AppTerminate() Then End
  25. Forever
  26.  
  27. Function DrawTestText()
  28.         SetImageFont(fontDiavloBlack40)
  29.         DrawText("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",20,200)
  30.         SetImageFont(Null)
  31. EndFunction
  32.  

Offline Derron

  • Hero Member
  • *****
  • Posts: 3074
Re: fontface with SDL?
« Reply #3 on: July 10, 2020, 01:05:12 PM »
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

Offline Ashmoor

  • Jr. Member
  • **
  • Posts: 60
Re: fontface with SDL?
« Reply #4 on: July 10, 2020, 02:53:18 PM »
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.

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal