Lua Fonts: Difference between revisions

From Spring
Jump to navigationJump to search
Jk (talk | contribs)
mNo edit summary
Jk (talk | contribs)
Line 10: Line 10:
=Userdata Functions=
=Userdata Functions=
'''font:Print'''
'''font:Print'''
   (string "text", number x, number y [, number size [, string <span class=note>"options"</span>] ] )
   (string "text", number x, number y [, number size [, string <span class=note>"options"</span>] ] ) -> nil
<span class=note>
<span class=note>
   options are:
   options are:

Revision as of 02:18, 1 July 2010

Development < Lua Scripting < Lua Fonts

Load/Delete

gl.LoadFont

 ( string fontfilename, number size = 14, number outlineWidth = 2, number outlineWeight = 15 ) -> userdata font

gl.DeleteFont

 ( userdata font ) -> nil


Userdata Functions

font:Print

 (string "text", number x, number y [, number size [, string "options"] ] ) -> nil

 options are:
   horizontal alignment:
      'c' = center
      'r' = right
   vertical alignment:
      'a' = ascender
      't' = top
      'v' = vertical center
      'x' = baseline
      'b' = bottom
      'd' = descender
   decorations:
      'o' = black outline
      'O' = white outline
      's' = shadow
   other:
      'n' = don't round vertex coords to nearest integer (font may get blurry)

fontlines.png


font:SetTextColor

 ( number r, number g, number b [, number a ] ) -> nil
 ( {r,g,b,a} ) -> nil

font:SetOutlineColor

 ( number r, number g, number b [, number a ] ) -> nil
 ( {r,g,b,a} ) -> nil

font:SetAutoOutlineColor

 ( boolean enable ) -> nil


font:GetTextWidth

 (string "text") -> number width  (in pixels, with a font size of 1.0)

font:GetTextHeight

 ( string "text" ) -> nil | number height, number descender, number numlines (in pixels, with a font size of 1.0)
 further descriptions here: GetTextHeight


font:WrapText

 ( string "text", number max_width [, number max_height [, number size ] ]) -> nil | string wrappedText, number lines

font:BindTexture

 (  ) -> nil


If you have multiple font:Print calls, then you can bunch them between a font:Begin() and font:End() to speedup the rendering.
font:Begin

 (  ) -> nil

font:End

 (  ) -> nil

Userdata Properties (ReadOnly)

string font.path
string font.family
string font.style
number font.size
number font.height a.k.a. font.lineheight
number font.descender
number font.outlinewidth
number font.outlineweight
number font.texturewidth
number font.textureheight