class

CMiriTextLayoutCache

Module
Miri
Header
#include "Miri/Text/CMiriTextLayout.h"
Namespace
Miri

Constructors

SignatureNameDescription
CMiriTextLayoutCache(const CMiriTextLayoutCache&) = deleteCMiriTextLayoutCache

Public functions

ReturnsNameDescription
CMiriTextLayoutCache&Get
CMiriTextLayoutCache&operator=
const CMiriTextLayout&GetLayout
const CMiriTextLayout&GetLayout
voidTouchReports a layout the caller is holding by pointer as still live.
uint64_tGetEvictionGenerationBumped whenever the sweep actually removed something.
floatMeasureWidth
floatMeasureWidth
floatLineHeight
voidLineMetricsThe one definition of a line: baseline offset from the line top and the distance between baselines, from the primary face's vertical metrics at the device pixel size (or the style's LineHeight, with the difference split above and below).
floatCentredLineTopWhere to draw one line of text so its capital height is centred in [top, top + height): the ink a reader sees, not the line box, whose descent sat every centred label a pixel or two low.
floatCentredLineTop
floatCentredLayoutTopThe same for a layout already in hand, centred on face's capital (its primary face): what a widget that shaped its text itself calls.
MiriVec2CentredGlyphOriginWhere to draw an icon glyph (first code point of glyph, in family) so its ink is centred in box, not its advance box: the em's top is not the line top and an outline does not fill the em evenly.
voidPaintIconPaints an icon glyph with its ink centred in box: the one call every hand-painted icon goes through.
voidPaintPaints a layout through the batched renderer (bitmap atlas).
boolPaintField
voidPaintThe font-carrying form, kept for callers that already hold one.
voidPaintRotatedCWPaints a single-line layout rotated 90 degrees clockwise (reads top-to-bottom); origin is the vertical column's top-left, the column width is the layout's line height.
voidBeginFrameFrame bookkeeping: bump the age counter and periodically evict entries that have not been used recently.
voidClear
const FStats&GetStats
voidResetStats

Function details

CMiriTextLayoutCache

C++
CMiriTextLayoutCache(const CMiriTextLayoutCache&) = delete

Get

C++
static CMiriTextLayoutCache& Get()

operator=

C++
CMiriTextLayoutCache& operator=(const CMiriTextLayoutCache&) = delete

GetLayout

C++
const CMiriTextLayout& GetLayout(const std::string& text, const CMiriFontInfo& font, const CMiriTextLayoutParams& params)

GetLayout

C++
const CMiriTextLayout& GetLayout(const std::string& text, const CMiriFontInfo& font)

Touch

C++
void Touch(const CMiriTextLayout& layout)

Reports a layout the caller is holding by pointer as still live. A widget that memoizes its layout stops asking for it by key, and without this the age sweep would drop the entry under it — which would be a dangling pointer, and, once every entry aged out at once, a frame that re-shaped the whole shell.

GetEvictionGeneration

C++
uint64_t GetEvictionGeneration() const

Bumped whenever the sweep actually removed something. A memoized layout pointer is only valid while this still matches.

MeasureWidth

C++
static float MeasureWidth(const std::string& text, const CMiriFontInfo& font)

MeasureWidth

C++
static float MeasureWidth(const std::string& text, float fontSize, const std::string& fontFamily = "Default", bool bold = false)

LineHeight

C++
static float LineHeight(const CMiriFontInfo& font)

LineMetrics

C++
static void LineMetrics(const CMiriFontInfo& font, float rasterScale, float& outBaseline, float& outLineAdvance)

The one definition of a line: baseline offset from the line top and the distance between baselines, from the primary face's vertical metrics at the device pixel size (or the style's LineHeight, with the difference split above and below). Logical units on the device grid.

CentredLineTop

C++
static float CentredLineTop(const std::string& text, const CMiriFontInfo& font, float top, float height)

Where to draw one line of text so its capital height is centred in [top, top + height): the ink a reader sees, not the line box, whose descent sat every centred label a pixel or two low. The baseline, not the line top, lands on a whole pixel: a fractional baseline let a capital's top edge spill one row and read a pixel high.

CentredLineTop

C++
static float CentredLineTop(const std::string& text, float size, const std::string& family, bool bold, float top, float height)

CentredLayoutTop

C++
static float CentredLayoutTop(const CMiriTextLayout& layout, CMiriFont* face, float top, float height)

The same for a layout already in hand, centred on face's capital (its primary face): what a widget that shaped its text itself calls.

CentredGlyphOrigin

C++
static MiriVec2 CentredGlyphOrigin(const MiriRect& box, const char* glyph, float size, const std::string& family)

Where to draw an icon glyph (first code point of glyph, in family) so its ink is centred in box, not its advance box: the em's top is not the line top and an outline does not fill the em evenly.

PaintIcon

C++
static void PaintIcon(CMiriRenderer& renderer, const MiriRect& box, const std::string& glyph, float size, const MiriColor& color, const std::string& family = "Icons")

Paints an icon glyph with its ink centred in box: the one call every hand-painted icon goes through. A DrawString at the box's centre less half the size centres the em, and a Lucide outline stands on the baseline at the em's left, so such an icon sat low and to the left.

Paint

C++
static void Paint(CMiriRenderer& renderer, const MiriVec2& origin, const CMiriTextLayout& layout, const MiriColor& color, int32_t justify = 0, float justifyWidth = 0.0f)

Paints a layout through the batched renderer (bitmap atlas). Tofu glyphs draw as an outlined box. justifyWidth applies per-line center/right alignment (0 = left).

PaintField

C++
static bool PaintField(CMiriRenderer& renderer, const MiriVec2& origin, const CMiriTextLayout& layout, EMiriFontRaster raster, const MiriColor& color, int32_t justify = 0, float justifyWidth = 0.0f, const CMiriTextEffects* effects = nullptr)

Paint

C++
static void Paint(CMiriRenderer& renderer, const MiriVec2& origin, const CMiriTextLayout& layout, const CMiriFontInfo& font, const MiriColor& color, int32_t justify = 0, float justifyWidth = 0.0f)

The font-carrying form, kept for callers that already hold one. The paint itself reads nothing from it — the layout carries the shaped result and the atlas is global — so building a CMiriFontInfo just to call this cost a std::string copy per text run per frame. Prefer the overload above.

PaintRotatedCW

C++
static void PaintRotatedCW(CMiriRenderer& renderer, const MiriVec2& origin, const CMiriTextLayout& layout, const CMiriFontInfo& font, const MiriColor& color)

Paints a single-line layout rotated 90 degrees clockwise (reads top-to-bottom); origin is the vertical column's top-left, the column width is the layout's line height. Vertical sidebar tabs.

BeginFrame

C++
void BeginFrame()

Frame bookkeeping: bump the age counter and periodically evict entries that have not been used recently. Called from the renderer's per-window Begin().

Clear

C++
void Clear()

GetStats

C++
const FStats& GetStats() const

ResetStats

C++
void ResetStats()
Generated from Miri/Text/CMiriTextLayout.h via miri.json · Dec 5, 2026Version 1.1.0