CMiriTextLayoutCache
- Module
- Miri
- Header
#include "Miri/Text/CMiriTextLayout.h"- Namespace
Miri
Constructors
| Signature | Name | Description |
|---|---|---|
CMiriTextLayoutCache(const CMiriTextLayoutCache&) = delete | CMiriTextLayoutCache |
Public functions
| Returns | Name | Description |
|---|---|---|
CMiriTextLayoutCache& | Get | |
CMiriTextLayoutCache& | operator= | |
const CMiriTextLayout& | GetLayout | |
const CMiriTextLayout& | GetLayout | |
void | Touch | Reports a layout the caller is holding by pointer as still live. |
uint64_t | GetEvictionGeneration | Bumped whenever the sweep actually removed something. |
float | MeasureWidth | |
float | MeasureWidth | |
float | LineHeight | |
void | LineMetrics | 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). |
float | CentredLineTop | 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. |
float | CentredLineTop | |
float | CentredLayoutTop | 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. |
MiriVec2 | CentredGlyphOrigin | 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. |
void | PaintIcon | Paints an icon glyph with its ink centred in box: the one call every hand-painted icon goes through. |
void | Paint | Paints a layout through the batched renderer (bitmap atlas). |
bool | PaintField | |
void | Paint | The font-carrying form, kept for callers that already hold one. |
void | PaintRotatedCW | 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. |
void | BeginFrame | Frame bookkeeping: bump the age counter and periodically evict entries that have not been used recently. |
void | Clear | |
const FStats& | GetStats | |
void | ResetStats |
Function details
CMiriTextLayoutCache
CMiriTextLayoutCache(const CMiriTextLayoutCache&) = deleteGet
static CMiriTextLayoutCache& Get()operator=
CMiriTextLayoutCache& operator=(const CMiriTextLayoutCache&) = deleteGetLayout
const CMiriTextLayout& GetLayout(const std::string& text, const CMiriFontInfo& font, const CMiriTextLayoutParams& params)GetLayout
const CMiriTextLayout& GetLayout(const std::string& text, const CMiriFontInfo& font)Touch
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
uint64_t GetEvictionGeneration() constBumped whenever the sweep actually removed something. A memoized layout pointer is only valid while this still matches.
MeasureWidth
static float MeasureWidth(const std::string& text, const CMiriFontInfo& font)MeasureWidth
static float MeasureWidth(const std::string& text, float fontSize, const std::string& fontFamily = "Default", bool bold = false)LineHeight
static float LineHeight(const CMiriFontInfo& font)LineMetrics
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
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
static float CentredLineTop(const std::string& text, float size, const std::string& family, bool bold, float top, float height)CentredLayoutTop
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
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
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
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
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
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
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
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
void Clear()GetStats
const FStats& GetStats() constResetStats
void ResetStats()