CArcTextLayoutCache
- Module
- Arc
- Header
#include "Arc/Text/CArcTextLayout.h"- Namespace
Arcf
Constructors
| Signature | Name | Description |
|---|---|---|
CArcTextLayoutCache(const CArcTextLayoutCache&) = delete | CArcTextLayoutCache |
Public functions
| Returns | Name | Description |
|---|---|---|
CArcTextLayoutCache& | Get | |
CArcTextLayoutCache& | operator= | |
const CArcTextLayout& | GetLayout | |
const CArcTextLayout& | 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. |
ArcVec2 | 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). |
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
CArcTextLayoutCache
CArcTextLayoutCache(const CArcTextLayoutCache&) = deleteGet
static CArcTextLayoutCache& Get()operator=
CArcTextLayoutCache& operator=(const CArcTextLayoutCache&) = deleteGetLayout
const CArcTextLayout& GetLayout(const std::string& text, const CArcFontInfo& font, const CArcTextLayoutParams& params)GetLayout
const CArcTextLayout& GetLayout(const std::string& text, const CArcFontInfo& font)Touch
void Touch(const CArcTextLayout& 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 CArcFontInfo& font)MeasureWidth
static float MeasureWidth(const std::string& text, float fontSize, const std::string& fontFamily = "Default", bool bold = false)LineHeight
static float LineHeight(const CArcFontInfo& font)LineMetrics
static void LineMetrics(const CArcFontInfo& 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 CArcFontInfo& 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 CArcTextLayout& layout, CArcFont* 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 ArcVec2 CentredGlyphOrigin(const ArcRect& 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(CArcUIRenderer& renderer, const ArcRect& box, const std::string& glyph, float size, const ArcColor& 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(CArcUIRenderer& renderer, const ArcVec2& origin, const CArcTextLayout& layout, const ArcColor& 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).
Paint
static void Paint(CArcUIRenderer& renderer, const ArcVec2& origin, const CArcTextLayout& layout, const CArcFontInfo& font, const ArcColor& 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 CArcFontInfo just to call this cost a std::string copy per text run per frame. Prefer the overload above.
PaintRotatedCW
static void PaintRotatedCW(CArcUIRenderer& renderer, const ArcVec2& origin, const CArcTextLayout& layout, const CArcFontInfo& font, const ArcColor& 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()