Show / Hide Table of Contents

Class DaggerfallFont

Daggerfall-specific implementation of a pixel font. Supports classic FONT0000-0004 with an SDF variant. Classic font has the same limitations of 256 characters starting from ASCII 33. SDF font uses a keyed dictionary so can support any number of glyph codes. Current implementation will load a TextMeshPro 2.0.x font asset directly for SDF variant.

Inheritance
Object
DaggerfallFont
Namespace: DaggerfallWorkshop.Game.UserInterface
Assembly: Assembly-CSharp.dll
Syntax
public class DaggerfallFont

Constructors

| Improve this Doc View Source

DaggerfallFont(DaggerfallFont.FontName)

Declaration
public DaggerfallFont(DaggerfallFont.FontName font = DaggerfallFont.FontName.FONT0003)
Parameters
Type Name Description
DaggerfallFont.FontName font
| Improve this Doc View Source

DaggerfallFont(String, DaggerfallFont.FontName)

Declaration
public DaggerfallFont(string arena2Path, DaggerfallFont.FontName font = DaggerfallFont.FontName.FONT0003)
Parameters
Type Name Description
String arena2Path
DaggerfallFont.FontName font

Fields

| Improve this Doc View Source

asciiStart

Declaration
protected int asciiStart
Field Value
Type Description
Int32
| Improve this Doc View Source

atlasRects

Declaration
protected Rect[] atlasRects
Field Value
Type Description
Rect[]
| Improve this Doc View Source

atlasTexture

Declaration
protected Texture2D atlasTexture
Field Value
Type Description
Texture2D
| Improve this Doc View Source

ErrorCode

Declaration
public const int ErrorCode = 63
Field Value
Type Description
Int32
| Improve this Doc View Source

invalidCode

Declaration
public const string invalidCode = "Font does not contain glyph for code: "
Field Value
Type Description
String
| Improve this Doc View Source

sdfFontInfo

Declaration
protected DaggerfallFont.SDFFontInfo? sdfFontInfo
Field Value
Type Description
Nullable<DaggerfallFont.SDFFontInfo>
| Improve this Doc View Source

SpaceCode

Declaration
public const int SpaceCode = 32
Field Value
Type Description
Int32

Properties

| Improve this Doc View Source

AsciiStart

Declaration
public int AsciiStart { get; }
Property Value
Type Description
Int32
| Improve this Doc View Source

FilterMode

Declaration
public FilterMode FilterMode { get; set; }
Property Value
Type Description
FilterMode
| Improve this Doc View Source

GlyphCount

Declaration
public int GlyphCount { get; }
Property Value
Type Description
Int32
| Improve this Doc View Source

GlyphHeight

Declaration
public int GlyphHeight { get; set; }
Property Value
Type Description
Int32
| Improve this Doc View Source

GlyphSpacing

Declaration
public float GlyphSpacing { get; }
Property Value
Type Description
Single
| Improve this Doc View Source

IsSDFCapable

Declaration
public bool IsSDFCapable { get; }
Property Value
Type Description
Boolean
| Improve this Doc View Source

SDFInfo

Declaration
public DaggerfallFont.SDFFontInfo SDFInfo { get; }
Property Value
Type Description
DaggerfallFont.SDFFontInfo

Methods

| Improve this Doc View Source

AddGlyph(Int32, DaggerfallFont.GlyphInfo)

Declaration
public void AddGlyph(int ascii, DaggerfallFont.GlyphInfo info)
Parameters
Type Name Description
Int32 ascii
DaggerfallFont.GlyphInfo info
| Improve this Doc View Source

CalculateTextWidth(String, Vector2, Int32, Int32)

Calculate width of text using whichever font path is active (classic or SDF).

Declaration
public float CalculateTextWidth(string text, Vector2 scale, int start = 0, int length = -1)
Parameters
Type Name Description
String text

Text to calculate width of.

Vector2 scale

Scale to use when calculating width.

Int32 start
Int32 length
Returns
Type Description
Single

Width of string in scaled pixels.

| Improve this Doc View Source

ClearGlyphs()

Declaration
public void ClearGlyphs()
| Improve this Doc View Source

DrawClassicGlyph(Byte, Rect, Color, Vector2, Color)

Draws a classic glyph with a drop-shadow.

Declaration
public void DrawClassicGlyph(byte rawAscii, Rect targetRect, Color color, Vector2 shadowPosition, Color shadowColor)
Parameters
Type Name Description
Byte rawAscii
Rect targetRect
Color color
Vector2 shadowPosition
Color shadowColor
| Improve this Doc View Source

DrawSDFGlyph(DaggerfallFont.SDFGlyphInfo, Vector2, Vector2, Color)

Declaration
public float DrawSDFGlyph(DaggerfallFont.SDFGlyphInfo glyph, Vector2 position, Vector2 scale, Color color)
Parameters
Type Name Description
DaggerfallFont.SDFGlyphInfo glyph
Vector2 position
Vector2 scale
Color color
Returns
Type Description
Single
| Improve this Doc View Source

DrawSDFGlyph(Int32, Vector2, Vector2, Color)

Declaration
public float DrawSDFGlyph(int code, Vector2 position, Vector2 scale, Color color)
Parameters
Type Name Description
Int32 code
Vector2 position
Vector2 scale
Color color
Returns
Type Description
Single
| Improve this Doc View Source

DrawSDFGlyph(Int32, Vector2, Vector2, Color, Vector2, Color)

Draws an SDF glyph with a drop-shadow.

Declaration
public float DrawSDFGlyph(int code, Vector2 position, Vector2 scale, Color color, Vector2 shadowPosition, Color shadowColor)
Parameters
Type Name Description
Int32 code
Vector2 position
Vector2 scale
Color color
Vector2 shadowPosition
Color shadowColor
Returns
Type Description
Single
| Improve this Doc View Source

DrawText(String, Vector2, Vector2, Color)

Draws string of classic or SDF glyphs.

Declaration
public void DrawText(string text, Vector2 position, Vector2 scale, Color color)
Parameters
Type Name Description
String text
Vector2 position
Vector2 scale
Color color
| Improve this Doc View Source

DrawText(String, Vector2, Vector2, Color, Color, Vector2)

Draws string of individual text glyphs with a shadow.

Declaration
public void DrawText(string text, Vector2 position, Vector2 scale, Color color, Color shadowColor, Vector2 shadowPos)
Parameters
Type Name Description
String text
Vector2 position
Vector2 scale
Color color
Color shadowColor
Vector2 shadowPos
| Improve this Doc View Source

GetGlyph(Int32)

Declaration
public DaggerfallFont.GlyphInfo GetGlyph(int ascii)
Parameters
Type Name Description
Int32 ascii
Returns
Type Description
DaggerfallFont.GlyphInfo
| Improve this Doc View Source

GetGlyphWidth(DaggerfallFont.SDFGlyphInfo, Vector2, Single)

Declaration
public float GetGlyphWidth(DaggerfallFont.SDFGlyphInfo glyph, Vector2 scale, float spacing = 0F)
Parameters
Type Name Description
DaggerfallFont.SDFGlyphInfo glyph
Vector2 scale
Single spacing
Returns
Type Description
Single
| Improve this Doc View Source

GetGlyphWidth(Int32, Vector2, Single)

Declaration
public float GetGlyphWidth(int code, Vector2 scale, float spacing = 0F)
Parameters
Type Name Description
Int32 code
Vector2 scale
Single spacing
Returns
Type Description
Single
| Improve this Doc View Source

GetMaterial()

Declaration
public Material GetMaterial()
Returns
Type Description
Material
| Improve this Doc View Source

GetSDFGlyph(Int32)

Declaration
public DaggerfallFont.SDFGlyphInfo GetSDFGlyph(int code)
Parameters
Type Name Description
Int32 code
Returns
Type Description
DaggerfallFont.SDFGlyphInfo
| Improve this Doc View Source

GetUnicodes()

Gets array of unicode values from currently loaded SDF font.

Declaration
public uint[] GetUnicodes()
Returns
Type Description
UInt32[]

Array of unicode characters. Can be null or empty.

| Improve this Doc View Source

HasGlyph(Int32)

Declaration
public bool HasGlyph(int ascii)
Parameters
Type Name Description
Int32 ascii
Returns
Type Description
Boolean
| Improve this Doc View Source

HasSDFGlyph(Int32)

Declaration
public bool HasSDFGlyph(int code)
Parameters
Type Name Description
Int32 code
Returns
Type Description
Boolean
| Improve this Doc View Source

LoadSDFFontAsset(String)

Load a TextMeshPro 2.0.x font asset to use for SDF rendering. Mods can use DaggerfallUI.Instance.Font0 through Font4 to access the instances used by other game windows. Custom font should be set only during startup. Note: Asset must be in a Resources folder.

Declaration
public bool LoadSDFFontAsset(string path)
Parameters
Type Name Description
String path

Path to a TextMeshPro 2.0.x font asset.

Returns
Type Description
Boolean

True if successful.

| Improve this Doc View Source

ReloadFont(Color)

Reloads font glyphs with a different base colour (default is Color.white for normal UI tinting). This is an expensive operation, only use this at font create time.

Declaration
public bool ReloadFont(Color color)
Parameters
Type Name Description
Color color

New colour of glyphs.

Returns
Type Description
Boolean

True if successful.

| Improve this Doc View Source

RemoveGlyph(Int32)

Declaration
public void RemoveGlyph(int ascii)
Parameters
Type Name Description
Int32 ascii
| Improve this Doc View Source

UseSDFFontAsset(TMP_FontAsset)

Use provided TextMeshPro 2.0.x font asset for SDF rendering.

Declaration
public void UseSDFFontAsset(TMP_FontAsset tmpFont)
Parameters
Type Name Description
TMPro.TMP_FontAsset tmpFont

TMP font asset to use for this font.

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX