|
resonance 1.0.1
|
Measured metrics of one glyph. More...
#include <font.h>
Public Member Functions | |
| CharInfo ()=default | |
| Construct zeroed metrics, the value a new mCharMap entry starts with. | |
| CharInfo (int nRow, int nCol, const Font *pFont) | |
| Measure the glyph occupying one cell of the atlas of pFont. | |
Public Attributes | |
| float | mAdvance |
| float | mU0 |
| float | mV0 |
| float | mU1 |
| float | mV1 |
Measured metrics of one glyph.
The record is a plain value with no RTTI and no allocation tag. It is 0x14 bytes of five floats. The 0x28-byte red-black tree node of mCharMap pins the size (0x10 bytes of node header, a 4-byte key, then this record), and the five words the measuring constructor zeroes for a font with no texture confirm it independently.
The two texture corners are stored rather than a corner and an extent. The tail of the measuring constructor adds the cell extent to the first corner through the two-component vector addition at 0x00169818 and stores the sum into the last two fields, and GetCharUV() hands the two pairs out unchanged as the two corners of the glyph quad.
Every value is normalised. The corners are texture coordinates in the range 0 to 1, and the advance is already scaled by mSize, so it arrives in the units Rnd::Text builds its mesh in rather than in pixels.
|
default |
Construct zeroed metrics, the value a new mCharMap entry starts with.
| Rnd::Font::CharInfo::CharInfo | ( | int | nRow, |
| int | nCol, | ||
| const Font * | pFont ) |
Measure the glyph occupying one cell of the atlas of pFont.
Locks the first texture of the font's material, scans the cell column by column for the first and the last column with any pixel whose alpha byte is set, and derives the advance and the two corners from the span it finds. A cell that is entirely transparent yields a span of a quarter of the cell. A space character takes its width from the quarter-cell span.
A font with no material, with an empty stage vector, or with no texture bitmap yields five zeroes instead.
| nRow | The cell row. |
| nCol | The cell column. |
| pFont | The font whose atlas includes the cell. |
| float Rnd::Font::CharInfo::mAdvance |
Horizontal advance, mSize scaled by the measured glyph width as a fraction of its cell. +0x00
| float Rnd::Font::CharInfo::mU0 |
Left texture coordinate of the glyph. +0x04
| float Rnd::Font::CharInfo::mV0 |
Top texture coordinate of the glyph. +0x08
| float Rnd::Font::CharInfo::mU1 |
Right texture coordinate of the glyph. +0x0c
| float Rnd::Font::CharInfo::mV1 |
Bottom texture coordinate of the glyph. +0x10