IgorBgz90 Posted March 31, 2015 Share Posted March 31, 2015 Hi! I cannot understand how to use your font for button. And then use a standard font. --Font local context = Context:GetCurrent() button.font = Font:Load("Fonts/Test.ttf",32) --Custom button.defaultfont = context:GetFont() --Arial button.color = Vec4(1.0) Pay attention! I do not release fonts from memory. function Button:Draw() local context = Context:GetCurrent() local window = Window:GetCurrent() if self.enable then if self.visible then context:SetBlendMode(Blend.Alpha) --Set user font if self.font then context:SetFont(self.font) else self.font = self.defaultfont end context:DrawText(self.title,25,25) --Set default font context:SetFont(self.defaultfont) context:SetBlendMode(Blend.Solid) end end end Log: Executing "C:\Users\Igor\Documents\Leadwerks\Projects\MyGame\MyGame.exe"... Initializing Lua... Lua sandboxing enabled. Executing file "C:/Users/Igor/Documents/Leadwerks/Projects/MyGame/Scripts/Error.lua" Executing file "C:/Users/Igor/Documents/Leadwerks/Projects/MyGame/Scripts/App.lua" Initializing OpenGL4 graphics driver... OpenGL version 441 GLSL version 440 Device: AMD Radeon HD 6320 Graphics Loading map "C:/Users/Igor/Documents/Leadwerks/Projects/MyGame/Maps/start.map"... Loading texture "C:/Users/Igor/Documents/Leadwerks/Projects/MyGame/Materials/Common/bfn.tex"... Loading texture "C:/Users/Igor/Documents/Leadwerks/Projects/MyGame/materials/sky/skybox_texture.tex"... Loading font "C:/Windows/Fonts/Arial.ttf"... Loading font "C:/Users/Igor/Documents/Leadwerks/Projects/MyGame/Fonts/test.ttf"... Loading shader "C:/Users/Igor/Documents/Leadwerks/Projects/MyGame/Shaders/Editor/skybox.shader"... Loading shader "C:/Users/Igor/Documents/Leadwerks/Projects/MyGame/Shaders/Misc/occlusionquery.shader"... Loading shader "C:/Users/Igor/Documents/Leadwerks/Projects/MyGame/Shaders/Lighting/ambientlight.shader"... Deleting font "C:/Windows/Fonts/Arial.ttf" Loading shader "C:/Users/Igor/Documents/Leadwerks/Projects/MyGame/Shaders/Drawing/drawtext.shader"... Loading font "C:/Windows/Fonts/Arial.ttf"... Deleting font "C:/Windows/Fonts/Arial.ttf" Loading font "C:/Windows/Fonts/Arial.ttf"... Deleting font "C:/Windows/Fonts/Arial.ttf" Loading font "C:/Windows/Fonts/Arial.ttf"... Deleting font "C:/Windows/Fonts/Arial.ttf" Loading font "C:/Windows/Fonts/Arial.ttf"... Deleting font "C:/Windows/Fonts/Arial.ttf" Loading font "C:/Windows/Fonts/Arial.ttf"... Deleting font "C:/Windows/Fonts/Arial.ttf" Loading font "C:/Windows/Fonts/Arial.ttf"... Deleting font "C:/Windows/Fonts/Arial.ttf" Loading font "C:/Windows/Fonts/Arial.ttf"... Deleting font "C:/Windows/Fonts/Arial.ttf" Loading font "C:/Windows/Fonts/Arial.ttf"... Deleting font "C:/Windows/Fonts/Arial.ttf" Loading font "C:/Windows/Fonts/Arial.ttf"... Deleting font "C:/Windows/Fonts/Arial.ttf" Loading font "C:/Windows/Fonts/Arial.ttf"... Deleting font "C:/Windows/Fonts/Arial.ttf" Loading font "C:/Windows/Fonts/Arial.ttf"... Deleting font "C:/Windows/Fonts/Arial.ttf" Loading font "C:/Windows/Fonts/Arial.ttf"... Deleting font "C:/Windows/Fonts/Arial.ttf" Loading font "C:/Windows/Fonts/Arial.ttf"... Deleting font "C:/Windows/Fonts/Arial.ttf" Loading font "C:/Windows/Fonts/Arial.ttf"... Deleting font "C:/Windows/Fonts/Arial.ttf" Loading font "C:/Windows/Fonts/Arial.ttf"... Deleting font "C:/Windows/Fonts/Arial.ttf" Loading font "C:/Windows/Fonts/Arial.ttf"... Deleting font "C:/Windows/Fonts/Arial.ttf" Process Complet Maybe I'm doing something wrong? Quote Link to comment Share on other sites More sharing options...
IgorBgz90 Posted March 31, 2015 Author Share Posted March 31, 2015 Problem here: button.defaultfont = context:GetFont() It works: button.defaultfont = Font:Load("Fonts/Arial.ttf",15) Quote Link to comment Share on other sites More sharing options...
beo6 Posted April 1, 2015 Share Posted April 1, 2015 Yes. you can either define a specific default font, or if you really want to know the used default font by the engine if you haven´t defined any you need to do button.defaultfont = context:GetFont() button.defaultfont:AddRef() so the actual reference to it is added. 1 Quote 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.