• Derma Question.
    6 replies, posted
Well, i'm working on a Derma and i need to set a texts size, i can't seem to find the right function. I've tried everything. DLabel:SetSize(40) Doesn't work, neither does DLabel:SetSize(40,40)
You mean as the text itself or the area the text is in? For text size, I'd take a look at [b][url=http://wiki.garrysmod.com/?title=Surface.CreateFont]Surface.CreateFont [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] For the size of the 'box' the text is in, you could always use [b][url=http://wiki.garrysmod.com/?title=Panel.SizeToContents]Panel.SizeToContents [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
So, I would make a Surface.CreatFont with the example shown on the Wiki page, then make a DLabel that sets the font to, in my case, "coolvetica" [quote] surface.CreateFont ("coolvetica", 20, 400, true, false, "CV20") --unscaled surface.CreateFont ("coolvetica", ScreenScale(20), 400, true, false, "CV20Scaled") --scaled local frame = vgui.Create("DFrame") frame:SetSize(500,500) local label = vgui.Create("DLabel", frame) label:SetText("Hello") label:Center() label:SetFont("coolvetica") [/quote] That didn't work. [b]Edit[/b] Excuse my stupidity, i'm fairly new to Derma. I figured that it was CV20. Thanks. Quick question, where in that example is the size function?
Argument two
Tried changing the value right next to the font name but nothing happens, am i doing something wrong?
This here works. (Im using it myself) [lua] local Text = vgui.Create( "DLabel", smenu )-- Change smenu to your DPanel Text:SetText( "Put your text here\n -- Doing that goes to next line.!" ) -- Test to be displayed Text:SetPos( 190, 350 ) -- The pos of the text Text:SetFont( "Trebuchet24" ) Text:SetTextColor( Color( 255,102,0,255 ) ) -- Color of text Text:SizeToContents() -- You NEED this! [/lua] Go here for a list of fonts: [url]http://wiki.garrysmod.com/?title=Working_with_Fonts[/url]
Thanks guys, got it working.
Sorry, you need to Log In to post a reply to this thread.