NGUI: Next-Gen UI kit  3.7.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros
NGUIText Class Reference

Helper class containing functionality related to using dynamic fonts. More...

Classes

class  GlyphInfo
 

Public Types

enum  Alignment {
  Alignment.Automatic, Alignment.Left, Alignment.Center, Alignment.Right,
  Alignment.Justified
}
 
enum  SymbolStyle { SymbolStyle.None, SymbolStyle.Normal, SymbolStyle.Colored }
 

Static Public Member Functions

static void Update ()
 Recalculate the 'final' values. More...
 
static void Update (bool request)
 Recalculate the 'final' values. More...
 
static void Prepare (string text)
 Prepare to use the specified text. More...
 
static BMSymbol GetSymbol (string text, int index, int textLength)
 Get the specified symbol. More...
 
static float GetGlyphWidth (int ch, int prev)
 Get the width of the specified glyph. Returns zero if the glyph could not be retrieved. More...
 
static GlyphInfo GetGlyph (int ch, int prev)
 Get the specified glyph. More...
 
static float ParseAlpha (string text, int index)
 Parse Aa syntax alpha encoded in the string. More...
 
static Color ParseColor (string text, int offset)
 Parse a RrGgBb color encoded in the string. More...
 
static Color ParseColor24 (string text, int offset)
 Parse a RrGgBb color encoded in the string. More...
 
static Color ParseColor32 (string text, int offset)
 Parse a RrGgBbAa color encoded in the string. More...
 
static string EncodeColor (Color c)
 The reverse of ParseColor – encodes a color in RrGgBb format. More...
 
static string EncodeAlpha (float a)
 The reverse of ParseAlpha – encodes a color in Aa format. More...
 
static string EncodeColor24 (Color c)
 The reverse of ParseColor24 – encodes a color in RrGgBb format. More...
 
static string EncodeColor32 (Color c)
 The reverse of ParseColor32 – encodes a color in RrGgBb format. More...
 
static bool ParseSymbol (string text, ref int index)
 Parse an embedded symbol, such as [FFAA00] (set color) or [-] (undo color change). Returns whether the index was adjusted. More...
 
static bool ParseSymbol (string text, ref int index, BetterList< Color > colors, bool premultiply, ref int sub, ref bool bold, ref bool italic, ref bool underline, ref bool strike)
 Parse the symbol, if possible. Returns 'true' if the 'index' was adjusted. Advanced symbol support contributed by Rudy Pangestu. More...
 
static string StripSymbols (string text)
 Runs through the specified string and removes all color-encoding symbols. More...
 
static void Align (BetterList< Vector3 > verts, int indexOffset, float printedWidth)
 Align the vertices to be right or center-aligned given the line width specified by NGUIText.lineWidth. More...
 
static int GetExactCharacterIndex (BetterList< Vector3 > verts, BetterList< int > indices, Vector2 pos)
 Get the index of the closest character within the provided list of values. Meant to be used with the arrays created by PrintExactCharacterPositions(). More...
 
static int GetApproximateCharacterIndex (BetterList< Vector3 > verts, BetterList< int > indices, Vector2 pos)
 Get the index of the closest vertex within the provided list of values. This function first sorts by Y, and only then by X. Meant to be used with the arrays created by PrintApproximateCharacterPositions(). More...
 
static void EndLine (ref StringBuilder s)
 Convenience function that ends the line by either appending a new line character or replacing a space with one. More...
 
static Vector2 CalculatePrintedSize (string text)
 Get the printed size of the specified string. The returned value is in pixels. More...
 
static int CalculateOffsetToFit (string text)
 Calculate the character index offset required to print the end of the specified text. More...
 
static string GetEndOfLineThatFits (string text)
 Get the end of line that would fit into a field of given width. More...
 
static bool WrapText (string text, out string finalText)
 Text wrapping functionality. The 'width' and 'height' should be in pixels. More...
 
static bool WrapText (string text, out string finalText, bool keepCharCount)
 Text wrapping functionality. The 'width' and 'height' should be in pixels. More...
 
static void Print (string text, BetterList< Vector3 > verts, BetterList< Vector2 > uvs, BetterList< Color32 > cols)
 Print the specified text into the buffers. More...
 
static void PrintApproximateCharacterPositions (string text, BetterList< Vector3 > verts, BetterList< int > indices)
 Print character positions and indices into the specified buffer. Meant to be used with the "find closest vertex" calculations. More...
 
static void PrintExactCharacterPositions (string text, BetterList< Vector3 > verts, BetterList< int > indices)
 Print character positions and indices into the specified buffer. This function's data is meant to be used for precise character selection, such as clicking on a link. There are 2 vertices for every index: Bottom Left + Top Right. More...
 
static void PrintCaretAndSelection (string text, int start, int end, BetterList< Vector3 > caret, BetterList< Vector3 > highlight)
 Print the caret and selection vertices. Note that it's expected that 'text' has been stripped clean of symbols. More...
 

Static Public Attributes

static UIFont bitmapFont
 When printing text, a lot of additional data must be passed in. In order to save allocations, this data is not passed at all, but is rather set in a single place before calling the functions that use it. More...
 
static Font dynamicFont
 
static GlyphInfo glyph = new GlyphInfo()
 
static int fontSize = 16
 
static float fontScale = 1f
 
static float pixelDensity = 1f
 
static FontStyle fontStyle = FontStyle.Normal
 
static Alignment alignment = Alignment.Left
 
static Color tint = Color.white
 
static int rectWidth = 1000000
 
static int rectHeight = 1000000
 
static int regionWidth = 1000000
 
static int regionHeight = 1000000
 
static int maxLines = 0
 
static bool gradient = false
 
static Color gradientBottom = Color.white
 
static Color gradientTop = Color.white
 
static bool encoding = false
 
static float spacingX = 0f
 
static float spacingY = 0f
 
static bool premultiply = false
 
static SymbolStyle symbolStyle
 
static int finalSize = 0
 
static float finalSpacingX = 0f
 
static float finalLineHeight = 0f
 
static float baseline = 0f
 
static bool useSymbols = false
 

Detailed Description

Helper class containing functionality related to using dynamic fonts.

Member Enumeration Documentation

Enumerator
Automatic 
Left 
Center 
Right 
Justified 
Enumerator
None 
Normal 
Colored 

Member Function Documentation

static void NGUIText.Align ( BetterList< Vector3 >  verts,
int  indexOffset,
float  printedWidth 
)
static

Align the vertices to be right or center-aligned given the line width specified by NGUIText.lineWidth.

static int NGUIText.CalculateOffsetToFit ( string  text)
static

Calculate the character index offset required to print the end of the specified text.

static Vector2 NGUIText.CalculatePrintedSize ( string  text)
static

Get the printed size of the specified string. The returned value is in pixels.

static string NGUIText.EncodeAlpha ( float  a)
static

The reverse of ParseAlpha – encodes a color in Aa format.

static string NGUIText.EncodeColor ( Color  c)
static

The reverse of ParseColor – encodes a color in RrGgBb format.

static string NGUIText.EncodeColor24 ( Color  c)
static

The reverse of ParseColor24 – encodes a color in RrGgBb format.

static string NGUIText.EncodeColor32 ( Color  c)
static

The reverse of ParseColor32 – encodes a color in RrGgBb format.

static void NGUIText.EndLine ( ref StringBuilder  s)
static

Convenience function that ends the line by either appending a new line character or replacing a space with one.

static int NGUIText.GetApproximateCharacterIndex ( BetterList< Vector3 >  verts,
BetterList< int >  indices,
Vector2  pos 
)
static

Get the index of the closest vertex within the provided list of values. This function first sorts by Y, and only then by X. Meant to be used with the arrays created by PrintApproximateCharacterPositions().

static string NGUIText.GetEndOfLineThatFits ( string  text)
static

Get the end of line that would fit into a field of given width.

static int NGUIText.GetExactCharacterIndex ( BetterList< Vector3 >  verts,
BetterList< int >  indices,
Vector2  pos 
)
static

Get the index of the closest character within the provided list of values. Meant to be used with the arrays created by PrintExactCharacterPositions().

static GlyphInfo NGUIText.GetGlyph ( int  ch,
int  prev 
)
static

Get the specified glyph.

static float NGUIText.GetGlyphWidth ( int  ch,
int  prev 
)
static

Get the width of the specified glyph. Returns zero if the glyph could not be retrieved.

static BMSymbol NGUIText.GetSymbol ( string  text,
int  index,
int  textLength 
)
static

Get the specified symbol.

static float NGUIText.ParseAlpha ( string  text,
int  index 
)
static

Parse Aa syntax alpha encoded in the string.

static Color NGUIText.ParseColor ( string  text,
int  offset 
)
static

Parse a RrGgBb color encoded in the string.

static Color NGUIText.ParseColor24 ( string  text,
int  offset 
)
static

Parse a RrGgBb color encoded in the string.

static Color NGUIText.ParseColor32 ( string  text,
int  offset 
)
static

Parse a RrGgBbAa color encoded in the string.

static bool NGUIText.ParseSymbol ( string  text,
ref int  index 
)
static

Parse an embedded symbol, such as [FFAA00] (set color) or [-] (undo color change). Returns whether the index was adjusted.

static bool NGUIText.ParseSymbol ( string  text,
ref int  index,
BetterList< Color >  colors,
bool  premultiply,
ref int  sub,
ref bool  bold,
ref bool  italic,
ref bool  underline,
ref bool  strike 
)
static

Parse the symbol, if possible. Returns 'true' if the 'index' was adjusted. Advanced symbol support contributed by Rudy Pangestu.

static void NGUIText.Prepare ( string  text)
static

Prepare to use the specified text.

static void NGUIText.Print ( string  text,
BetterList< Vector3 >  verts,
BetterList< Vector2 >  uvs,
BetterList< Color32 >  cols 
)
static

Print the specified text into the buffers.

static void NGUIText.PrintApproximateCharacterPositions ( string  text,
BetterList< Vector3 >  verts,
BetterList< int >  indices 
)
static

Print character positions and indices into the specified buffer. Meant to be used with the "find closest vertex" calculations.

static void NGUIText.PrintCaretAndSelection ( string  text,
int  start,
int  end,
BetterList< Vector3 >  caret,
BetterList< Vector3 >  highlight 
)
static

Print the caret and selection vertices. Note that it's expected that 'text' has been stripped clean of symbols.

static void NGUIText.PrintExactCharacterPositions ( string  text,
BetterList< Vector3 >  verts,
BetterList< int >  indices 
)
static

Print character positions and indices into the specified buffer. This function's data is meant to be used for precise character selection, such as clicking on a link. There are 2 vertices for every index: Bottom Left + Top Right.

static string NGUIText.StripSymbols ( string  text)
static

Runs through the specified string and removes all color-encoding symbols.

static void NGUIText.Update ( )
static

Recalculate the 'final' values.

static void NGUIText.Update ( bool  request)
static

Recalculate the 'final' values.

static bool NGUIText.WrapText ( string  text,
out string  finalText 
)
static

Text wrapping functionality. The 'width' and 'height' should be in pixels.

static bool NGUIText.WrapText ( string  text,
out string  finalText,
bool  keepCharCount 
)
static

Text wrapping functionality. The 'width' and 'height' should be in pixels.

Member Data Documentation

Alignment NGUIText.alignment = Alignment.Left
static
float NGUIText.baseline = 0f
static
UIFont NGUIText.bitmapFont
static

When printing text, a lot of additional data must be passed in. In order to save allocations, this data is not passed at all, but is rather set in a single place before calling the functions that use it.

Font NGUIText.dynamicFont
static
bool NGUIText.encoding = false
static
float NGUIText.finalLineHeight = 0f
static
int NGUIText.finalSize = 0
static
float NGUIText.finalSpacingX = 0f
static
float NGUIText.fontScale = 1f
static
int NGUIText.fontSize = 16
static
FontStyle NGUIText.fontStyle = FontStyle.Normal
static
GlyphInfo NGUIText.glyph = new GlyphInfo()
static
bool NGUIText.gradient = false
static
Color NGUIText.gradientBottom = Color.white
static
Color NGUIText.gradientTop = Color.white
static
int NGUIText.maxLines = 0
static
float NGUIText.pixelDensity = 1f
static
bool NGUIText.premultiply = false
static
int NGUIText.rectHeight = 1000000
static
int NGUIText.rectWidth = 1000000
static
int NGUIText.regionHeight = 1000000
static
int NGUIText.regionWidth = 1000000
static
float NGUIText.spacingX = 0f
static
float NGUIText.spacingY = 0f
static
SymbolStyle NGUIText.symbolStyle
static
Color NGUIText.tint = Color.white
static
bool NGUIText.useSymbols = false
static

The documentation for this class was generated from the following file: