Font
Declaration
public class Strawberry.Graphics.Text.Font
Font resource and glyph atlas used by the text renderer.
Constructors
Font
void Font(IGraphicsContext graphicsContext, byte[] data)
Parameters:
| Name | Type | Description |
|---|---|---|
graphicsContext |
Strawberry.Graphics.IGraphicsContext |
|
data |
System.Byte[] |
Properties
Size
Gets the native size of the font
byte Size { get }
Characters
Gets the character map of the font
Dictionary<ushort, Character> Characters { get }
Texture
Gets the texture atlas of the font
Texture Texture { get }
Minor
Gets the minor version of the font
byte Minor { get }
Major
Gets the major version of the font file
byte Major { get }
UseSDF
Gets whether this font uses signed-distance field rendering or not
bool UseSDF { get }
Methods
GetCharacterInfo
Get character info
Character GetCharacterInfo(ushort chr)
Parameters:
| Name | Type | Description |
|---|---|---|
chr |
System.UInt16 |
Code of the requested character |
GetWidth
Measures the width of the given text using font's native size
double GetWidth(string text)
Parameters:
| Name | Type | Description |
|---|---|---|
text |
System.String |
The text to be measured |
Returns: The width of the given string in pixels
GetWidth
Measures the width of the given text using the specified size
double GetWidth(string text, float size)
Parameters:
| Name | Type | Description |
|---|---|---|
text |
System.String |
The text to be measured |
size |
System.Single |
Size of the font |
Returns: The width of the given string in pixels