Table of Contents

Class FontAttribute

Namespace
GB
Assembly
GBSharp.Framework.dll

Converts a font sheet into background tiles and a character-to-tile lookup at build time.

[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
public sealed class FontAttribute : Attribute
Inheritance
FontAttribute
Inherited Members

Examples

[Font("font.png", Characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 .,!?")]
private static FontAsset Alphabet;

Remarks

The sheet is one row of 8x8 glyphs, one tile per character in Characters, left to right, so the image must be exactly Characters.Length tiles wide and exactly one tile (8 pixels) tall. That is a deliberate v1 simplification, not a missing feature: proportional glyph widths need a per-glyph advance table and a text layout GB# does not have yet, and monospaced text is what most Game Boy games draw anyway.

A font carries no colour of its own. A background cell already has whatever palette or attribute is active there, so drawing text never touches either - see Draw(FontAsset, byte, byte, byte, byte, byte[]).

Constructors

FontAttribute(string)

public FontAttribute(string path)

Parameters

path string

Properties

Characters

The character set, in the order the glyphs appear on the sheet, left to right. Required: there is no default set of characters to fall back to.

public string Characters { get; set; }

Property Value

string

MaxTiles

A tighter tile budget than the hardware's. 0 uses the hardware limit.

public int MaxTiles { get; set; }

Property Value

int

Path

The image, relative to the declaring file or the Assets folder.

public string Path { get; }

Property Value

string