surface.GetTextSize
Example
Prints out the size of Hello World
in the Trebuchet24 font.
surface.SetFont( "Trebuchet24" )
local text = "Hello World"
local width, height = surface.GetTextSize( text )
print("Text width: " .. width .. ", text height: " .. height)
Output:
Text width: 100, text height: 24