AndyGFX Posted July 3, 2010 Share Posted July 3, 2010 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 Quote [HW] C2D Q6600, 4GB RAM, NV8800GTX, Vista Ultimate x64 [sW] Blide Plus, BlitzMax, Delphi, C++, 3DWS 5.53, Leadwerks 2.xx Link to comment Share on other sites More sharing options...
Recommended Posts
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.