Sparkle 0.0.1
Loading...
Searching...
No Matches
spk::FontMesh::Builder Class Reference

Builder that converts text into glyph polygons. More...

#include <spk_font_painter.hpp>

Collaboration diagram for spk::FontMesh::Builder:
Collaboration graph

Public Member Functions

 Builder ()=default
 Builds an empty builder.
 Builder (Font *p_font, const Font::Size &p_fontSize, size_t p_tabSize=4)
 Builds a builder for a font and size.
BuildersetTabSize (size_t p_tabSize)
 Sets the tab size used for layout.
Builderclear ()
 Clears any accumulated text and layout state.
BuilderaddText (const std::wstring &p_text)
 Appends text to the layout buffer.
BuilderaddNewline ()
 Inserts a line break in the layout buffer.
spk::Vector2UInt computeTextSize (const std::wstring &p_text) const
 Computes the pixel size for a text string.
FontMesh construct (const spk::Vector2Int &p_anchor, spk::HorizontalAlignment p_horizontalAlignment=spk::HorizontalAlignment::Centered, spk::VerticalAlignment p_verticalAlignment=spk::VerticalAlignment::Centered)
 Builds a FontMesh with alignment around an anchor.

Detailed Description

Builder that converts text into glyph polygons.

spk::FontMesh::Builder builder(font, {16, 0});
builder.addText(L"Hello");
auto mesh = builder.construct({0, 0});
Builder that converts text into glyph polygons.
Definition spk_font_painter.hpp:64
FontMesh construct(const spk::Vector2Int &p_anchor, spk::HorizontalAlignment p_horizontalAlignment=spk::HorizontalAlignment::Centered, spk::VerticalAlignment p_verticalAlignment=spk::VerticalAlignment::Centered)
Builds a FontMesh with alignment around an anchor.
Definition spk_font_painter.cpp:236
Builder & addText(const std::wstring &p_text)
Appends text to the layout buffer.
Definition spk_font_painter.cpp:162
const Font * font() const
Returns the font used by this mesh.
Definition spk_font_painter.cpp:303

Constructor & Destructor Documentation

◆ Builder()

spk::FontMesh::Builder::Builder ( Font * p_font,
const Font::Size & p_fontSize,
size_t p_tabSize = 4 )

Builds a builder for a font and size.

Parameters
p_fontFont to use for glyphs.
p_fontSizeRequested font size.
p_tabSizeNumber of spaces per tab.

Member Function Documentation

◆ addNewline()

FontMesh::Builder & spk::FontMesh::Builder::addNewline ( )

Inserts a line break in the layout buffer.

Returns
Reference to this builder.

◆ addText()

FontMesh::Builder & spk::FontMesh::Builder::addText ( const std::wstring & p_text)

Appends text to the layout buffer.

Parameters
p_textText to append.
Returns
Reference to this builder.
Here is the call graph for this function:

◆ clear()

FontMesh::Builder & spk::FontMesh::Builder::clear ( )

Clears any accumulated text and layout state.

Returns
Reference to this builder.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ computeTextSize()

spk::Vector2UInt spk::FontMesh::Builder::computeTextSize ( const std::wstring & p_text) const

Computes the pixel size for a text string.

Parameters
p_textText to measure.
Returns
Size in pixels.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ construct()

FontMesh spk::FontMesh::Builder::construct ( const spk::Vector2Int & p_anchor,
spk::HorizontalAlignment p_horizontalAlignment = spk::HorizontalAlignment::Centered,
spk::VerticalAlignment p_verticalAlignment = spk::VerticalAlignment::Centered )

Builds a FontMesh with alignment around an anchor.

Parameters
p_anchorAnchor position.
p_horizontalAlignmentHorizontal alignment.
p_verticalAlignmentVertical alignment.
Returns
Constructed FontMesh.
Here is the call graph for this function:

◆ setTabSize()

FontMesh::Builder & spk::FontMesh::Builder::setTabSize ( size_t p_tabSize)

Sets the tab size used for layout.

Parameters
p_tabSizeNumber of spaces per tab.
Returns
Reference to this builder.

The documentation for this class was generated from the following files:
  • includes/structure/graphics/painter/spk_font_painter.hpp
  • srcs/structure/graphics/painter/spk_font_painter.cpp