Garry's Mod Wiki

surface.SetFont

surface.SetFont( string fontName )

Description

Set the current font to be used for text operations later.

The fonts must first be created with surface.CreateFont or be one of the Default Fonts.

Arguments

1 string fontName
The name of the font to use.

Example

Draws 'Hello World' on the screen, with the 'Default' font.

hook.Add( "HUDPaint", "HUDPaint_DrawABox", function() surface.SetDrawColor( 0, 0, 0, 128 ) -- Set color for background surface.DrawRect( 100, 100, 128, 20 ) -- Draw background surface.SetTextColor( 255, 255, 255 ) -- Set text color surface.SetTextPos( 136, 104 ) -- Set text position, top left corner surface.SetFont( "Default" ) -- Set the font surface.DrawText( "Hello World" ) -- Draw the text end )

Page Links


Special Pages


Wikis

?

Render Time: 29ms

DB GetPage 4
Generate Html 3
SaveChanges (1) 13
Render Body 0
Render Sidebar 6