Jump to content
Leadwerks Community

Recommended Posts

Posted

File Name: TFontManager

File Submitter: AndyGFX

File Submitted: 03 Jul 2010

File Category: BlitzMax Code

 

TFontManager Class:

 

Type TFontManager

Field fonts:TMap
Field CurrentFont:TGLFont

Method New()
	Self.fonts = New TMap
	Local def:TGLFont = LoadFont("incbin::Arial9")
	Self.fonts.Insert("Arial9", def)
End Method

Method AddFont(fname:String)
	Local fnt:TGLFont = LoadFont("abstract::" + fname)
	Self.fonts.Insert(fname, fnt)

	? Debug
		Print("FONT: " + fname + " loaded.")
	?

End Method

Method RemoveFont(fname:String)
	Self.Fonts.Remove(fname)
End Method

Method SetCurrentFont(fname:String)
	Self.CurrentFont = TGLFont(Self.fonts.ValueForKey(fname))
	SetFont(Self.CurrentFont)
End Method

Method GetCurrentFont:TGLFont()
	Return Self.CurrentFont
End Method


end type

 

sample:

...
Global Fonts:TFontManager = New TFontManager
...
Fonts.AddFont("courier_new_8_bold")
Fonts.AddFont("courier_new_8_normal")
Fonts.AddFont("verdana_10_normal")
Fonts.AddFont("verdana_10_bold")
...

Fonts.SetCurrentFont("courier_new_8_normal")
DrawText("FPS: " + UPS(), 10, GraphicsHeight() - 16 * 2)
Fonts.SetCurrentFont("courier_new_8_bold")
DrawText("FPS: " + UPS(), 10, GraphicsHeight() - 16)
...
' get current font
Local actualfont:TGLFont = Fonts.GetCurrentFont()

...
'set default font back
Fonts.SetCurrentFont("Arial9")

 

Click here to download this file

[HW] C2D Q6600, 4GB RAM, NV8800GTX, Vista Ultimate x64

[sW] Blide Plus, BlitzMax, Delphi, C++, 3DWS 5.53, Leadwerks 2.xx

 

76561197970156808.pngAndyGFX.png

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...