File include/brisk/graphics/Fonts.hpp
¶
EUnicode
class¶
EUnicode
EFreeType
class¶
EFreeType
BidiText
class¶
BidiText
TextSpan
class¶
TextSpan
TextWithOptions
class¶
TextWithOptions
OpenTypeFeatureFlag
class¶
OpenTypeFeatureFlag
FontManager
class¶
FontManager
FontMetrics
class¶
FontMetrics
FontMetricsRepresents metrics for a font, providing details about its dimensions and spacing.
size
variable (FontMetrics::size
)¶
float size
The size of the font in points.
ascender
variable (FontMetrics::ascender
)¶
float ascender
The ascender height, always positive and points upwards.
descender
variable (FontMetrics::descender
)¶
float descender
The descender height, always negative and points downwards.
height
variable (FontMetrics::height
)¶
float height
The total height of the font, including ascender, descender, and line gap.
spaceAdvanceX
variable (FontMetrics::spaceAdvanceX
)¶
float spaceAdvanceX
The horizontal advance width for a space character.
lineThickness
variable (FontMetrics::lineThickness
)¶
float lineThickness
The thickness of lines, such as for underline or strikethrough.
xHeight
variable (FontMetrics::xHeight
)¶
float xHeight
The height of the lowercase 'x' character.
capitalHeight
variable (FontMetrics::capitalHeight
)¶
float capitalHeight
The height of uppercase characters.
linegap
function (FontMetrics::linegap
)¶
float linegap() const noexcept
Computes the line gap, the vertical space between lines of text.
Returns The line gap value.
vertBounds
function (FontMetrics::vertBounds
)¶
float vertBounds() const noexcept
Computes the vertical bounds of the font.
Returns The total vertical bounds (ascender - descender).
underlineOffset
function (FontMetrics::underlineOffset
)¶
float underlineOffset() const noexcept
Computes the offset for an underline relative to the baseline.
Returns The underline offset.
overlineOffset
function (FontMetrics::overlineOffset
)¶
float overlineOffset() const noexcept
Computes the offset for an overline relative to the baseline.
Returns The overline offset.
lineThroughOffset
function (FontMetrics::lineThroughOffset
)¶
float lineThroughOffset() const noexcept
Computes the offset for a line through the text.
Returns The line-through offset.
operator==
function (FontMetrics::operator==
)¶
bool operator==(const FontMetrics &b) const noexcept =
default
Compares two FontMetrics objects for equality.
Param b
The FontMetrics object to compare against.
Returns True if the objects are equal, false otherwise.
GlyphRun
class¶
GlyphRun
Represents a sequence of glyphs along with their associated properties.
The GlyphRun
struct encapsulates the properties and operations of a run of glyphs,
including positioning, font information, and range calculations.
FontFace
class (Internal::FontFace
)¶
FontFace
GlyphData
class (Internal::GlyphData
)¶
GlyphData
Contains detailed data about a single glyph, including its metrics and rendered sprite.
TextRun
class (Internal::TextRun
)¶
TextRun
Represents a segment of text with uniform properties such as direction and font face.
TextRun
Represents a segment of text with uniform properties such as direction and font face.
direction
variable (Internal::TextRun::direction
)¶
TextDirection direction
The direction of the text in this run (e.g., left-to-right or right-to-left).
begin
variable (Internal::TextRun::begin
)¶
int32_t begin
The starting index of the text run within the text.
end
variable (Internal::TextRun::end
)¶
int32_t end
The ending index of the text run within the text.
visualOrder
variable (Internal::TextRun::visualOrder
)¶
int32_t visualOrder
The visual order of the text run.
This indicates the position of the run when rendered visually.
face
variable (Internal::TextRun::face
)¶
FontFace *face
Pointer to the font face associated with the text run.
operator==
function (Internal::TextRun::operator==
)¶
bool operator==(const TextRun &) const noexcept = default
Equality comparison operator for TextRun
.
splitTextRuns
function (Internal::splitTextRuns
)¶
std::vector<TextRun>
splitTextRuns(std::u32string_view text,
TextDirection defaultDirection,
bool visualOrder)
Splits a string of text into multiple TextRun
objects based on directionality.
This function analyzes the given text and segments it into runs of uniform properties. It takes into
account the specified default text direction and optionally applies visual order for bidirectional text.
Param text
The text to be split into text runs.
Param defaultDirection
The default text direction to use if no explicit directionality is detected.
Param visualOrder
If true
, the resulting text runs will be reordered to match the visual order of the
text.
Returns std::vector<TextRun> A vector of TextRun
objects representing the segmented text.
GlyphFlags
enum (Internal::GlyphFlags
)¶
enum class GlyphFlags : uint8_t
GlyphFlagsFlags used to define various properties of glyphs.
This enum class defines a set of flags used to represent different characteristics of glyphs, which are typically used in text rendering or processing.
None
enumerator (Internal::GlyphFlags::None
)¶
No special properties.
The glyph has no special attributes or flags.
SafeToBreak
enumerator (Internal::GlyphFlags::SafeToBreak
)¶
Glyph can be safely broken across lines.
Indicates that this glyph can be safely broken when wrapping text across multiple lines.
AtLineBreak
enumerator (Internal::GlyphFlags::AtLineBreak
)¶
Glyph is at a line break position.
Marks this glyph as occurring at a line break (e.g., the glyph is at the end of a line or paragraph).
IsControl
enumerator (Internal::GlyphFlags::IsControl
)¶
Glyph represents a control character.
This flag indicates that the glyph is a control character, such as a non-printing character used for text formatting or control.
IsPrintable
enumerator (Internal::GlyphFlags::IsPrintable
)¶
Glyph is printable.
Indicates that this glyph is part of the visible text and can be printed or displayed on screen.
IsCompactedWhitespace
enumerator (Internal::GlyphFlags::IsCompactedWhitespace
)¶
Glyph is compacted whitespace.
Denotes that the glyph represents whitespace at a line break which doesn't extend the visual line bounds. This is commonly used to indicate collapsed or compacted whitespace characters.
Glyph
class (Internal::Glyph
)¶
Glyph
Represents an individual glyph with its properties and positioning information.
glyph
variable (Internal::Glyph::glyph
)¶
uint32_t glyph = UINT32_MAX
The glyph ID, identifying the specific glyph in the font.
codepoint
variable (Internal::Glyph::codepoint
)¶
char32_t codepoint = UINT32_MAX
The Unicode codepoint represented by this glyph.
pos
variable (Internal::Glyph::pos
)¶
PointF pos
Position of the glyph relative to its parent context.
left_caret
variable (Internal::Glyph::left_caret
)¶
float left_caret = -1.f
The position of the left caret for the glyph.
right_caret
variable (Internal::Glyph::right_caret
)¶
float right_caret = -1.f
The position of the right caret for the glyph.
begin_char
variable (Internal::Glyph::begin_char
)¶
uint32_t begin_char = UINT32_MAX
The index of the first character in the cluster associated with the glyph.
end_char
variable (Internal::Glyph::end_char
)¶
uint32_t end_char = UINT32_MAX
The index of the first character after the cluster associated with the glyph. This marks the position immediately following the last character in the cluster.
dir
variable (Internal::Glyph::dir
)¶
TextDirection dir = TextDirection::LTR
The text direction for this glyph (e.g., left-to-right or right-to-left).
flags
variable (Internal::Glyph::flags
)¶
GlyphFlags flags = GlyphFlags::None
Flags providing additional properties or states of the glyph.
caretForDirection
function (Internal::Glyph::caretForDirection
)¶
float caretForDirection(bool inverse) const
Computes the caret position for the glyph based on the text direction.
Param inverse
If true, calculates the caret in the opposite direction.
Returns float The computed caret position.
Note This is an internal method and should not be used directly.
load
function (Internal::Glyph::load
)¶
optional<GlyphData> load(const GlyphRun &run) const
Loads and renders the glyph into SpriteResource
.
Param run
The glyph run containing this glyph.
Returns optional<GlyphData> The loaded glyph data if available, or an empty value otherwise.
Note This is an internal method and should not be used directly.
GlyphData
class (Internal::GlyphData
)¶
GlyphData
Contains detailed data about a single glyph, including its metrics and rendered sprite.
size
variable (Internal::GlyphData::size
)¶
Size size
The size of the glyph in its rendered form.
sprite
variable (Internal::GlyphData::sprite
)¶
RC<SpriteResource> sprite
A reference-counted resource pointing to the sprite used to render the glyph.
offset_x
variable (Internal::GlyphData::offset_x
)¶
float offset_x
The horizontal offset from the glyph's origin to the start of its shape.
Known as the "left bearing," this value determines the space between the glyph's origin and the leftmost edge of its bounding box.
offset_y
variable (Internal::GlyphData::offset_y
)¶
int offset_y
The vertical offset from the glyph's origin to the top of its shape.
Known as the "top bearing," this value is positive for upwards Y-coordinates and determines the space between the glyph's baseline and the topmost edge of its bounding box.
advance_x
variable (Internal::GlyphData::advance_x
)¶
float advance_x
The horizontal distance to advance to the next glyph's origin.
This is the space the glyph occupies horizontally, including the glyph itself and any trailing whitespace.
GlyphRunBounds
enum¶
enum class GlyphRunBounds
Specifies the types of bounds that can be calculated for a glyph run.
Text
enumerator (GlyphRunBounds::Text
)¶
Bounds that consider all glyphs in the run, including whitespace.
Alignment
enumerator (GlyphRunBounds::Alignment
)¶
Bounds that exclude whitespace at line breaks.
Printable
enumerator (GlyphRunBounds::Printable
)¶
Bounds that consider only printable glyphs in the run.
AscenderDescender
class¶
AscenderDescender
GlyphRun
class¶
GlyphRun
Represents a sequence of glyphs along with their associated properties.
The GlyphRun
struct encapsulates the properties and operations of a run of glyphs,
including positioning, font information, and range calculations.
glyphs
variable (GlyphRun::glyphs
)¶
Internal::GlyphList glyphs
List of glyphs contained in this run in visual order (left-to-right).
face
variable (GlyphRun::face
)¶
Internal::FontFace *face
Pointer to the font face associated with the glyph run.
fontSize
variable (GlyphRun::fontSize
)¶
float fontSize = 0
Font size of the glyph run.
metrics
variable (GlyphRun::metrics
)¶
FontMetrics metrics
Metrics of the font used in the glyph run.
decoration
variable (GlyphRun::decoration
)¶
TextDecoration decoration = TextDecoration::None
Text decoration applied to the glyph run (e.g., underline, strikethrough).
direction
variable (GlyphRun::direction
)¶
TextDirection direction
Text direction of the glyph run (left-to-right or right-to-left).
rangesValid
variable (GlyphRun::rangesValid
)¶
mutable bool rangesValid = false
Indicates whether the horizontal ranges are valid and up-to-date.
textHRange
variable (GlyphRun::textHRange
)¶
mutable InclusiveRange<float> textHRange
Horizontal range of all glyphs in the run.
alignmentHRange
variable (GlyphRun::alignmentHRange
)¶
mutable InclusiveRange<float> alignmentHRange
Horizontal range of glyphs, excluding whitespace at line breaks.
printableHRange
variable (GlyphRun::printableHRange
)¶
mutable InclusiveRange<float> printableHRange
Horizontal range of printable glyphs in the run.
visualOrder
variable (GlyphRun::visualOrder
)¶
int32_t visualOrder
Visual order of the glyph run within the text.
verticalAlign
variable (GlyphRun::verticalAlign
)¶
float verticalAlign
Vertical offset of the glyph run relative to the text baseline.
position
variable (GlyphRun::position
)¶
PointF position
Position of the left-most point of the glyph run at the text baseline.
bounds
function (GlyphRun::bounds
)¶
RectangleF bounds(GlyphRunBounds boundsType) const
Returns the bounds of the glyph run.
Param boundsType
Specifies the type of bounds to compute.
Returns RectangleF The computed bounds of the glyph run.
size
function (GlyphRun::size
)¶
SizeF size(GlyphRunBounds boundsType) const
Returns the size of the glyph run.
Param boundsType
Specifies the type of bounds to consider for size calculation.
Returns SizeF The size of the glyph run.
invalidateRanges
function (GlyphRun::invalidateRanges
)¶
void invalidateRanges()
Marks the horizontal ranges of the glyph run as invalid.
Call this function whenever glyph modifications require recalculating ranges.
updateRanges
function (GlyphRun::updateRanges
)¶
void updateRanges() const
Updates the horizontal ranges of the glyph run.
Ensures the ranges (e.g., textHRange
, alignmentHRange
, printableHRange
)
are valid and accurate.
breakAt
function (GlyphRun::breakAt
)¶
GlyphRun breakAt(float width, bool allowEmpty,
bool wrapAnywhere) &
Returns the widest glyph run that fits within the specified width and removes those glyphs.
Param width
The maximum width available for the glyph run.
Param allowEmpty
A boolean flag that determines whether an empty glyph run is allowed as a result.
Returns GlyphRun The widest glyph run that fits within the specified width.
flags
function (GlyphRun::flags
)¶
Internal::GlyphFlags flags() const
Retrieves the glyph flags associated with the glyph run.
Returns Internal::GlyphFlags The flags indicating properties or states of the glyphs.
charRange
function (GlyphRun::charRange
)¶
Range<uint32_t> charRange() const
Retrieves the character range covered by the glyph run.
Returns Range<uint32_t> The range of characters covered by this glyph run.
Font
class¶
Font
Represents font properties and settings for text rendering.
PreparedText
class¶
PreparedText
Represents text that has been processed and prepared for rendering or layout.
The PreparedText
struct manages glyph runs, logical and visual orders, grapheme boundaries,
caret positions, and alignment for efficient text layout and rendering.
runs
variable (PreparedText::runs
)¶
GlyphRuns runs
The glyph runs associated with the text, stored in logical order.
visualOrder
variable (PreparedText::visualOrder
)¶
std::vector<uint32_t> visualOrder
The visual order of the glyph runs.
Each entry corresponds to an index in runs
, and visualOrder.size()
must equal runs.size()
.
options
variable (PreparedText::options
)¶
LayoutOptions options = LayoutOptions::Default
Layout options applied during text preparation.
graphemeBoundaries
variable (PreparedText::graphemeBoundaries
)¶
std::vector<uint32_t> graphemeBoundaries
Caret offsets (grapheme boundaries) within the text.
Each entry indicates the a grapheme boundary, providing a mapping between graphemes and characters.
caretPositions
variable (PreparedText::caretPositions
)¶
std::vector<float> caretPositions
The caret positions for each grapheme boundary.
This vector is populated by updateCaretData
and contains one entry per grapheme boundary.
ranges
variable (PreparedText::ranges
)¶
std::vector<InclusiveRange<float>> ranges
The ranges of horizontal positions for each grapheme.
This vector is populated by updateCaretData
and contains one entry per grapheme.
GlyphLine
class (PreparedText::GlyphLine
)¶
GlyphLine
Represents a line of glyphs, including its range and metrics.
runRange
variable (PreparedText::GlyphLine::runRange
)¶
Range<uint32_t> runRange
Range of runs (sequence of glyphs sharing the same style) in the line.
This range is empty if the line contains no runs.
graphemeRange
variable (PreparedText::GlyphLine::graphemeRange
)¶
Range<uint32_t> graphemeRange
Range of grapheme boundaries (caret positions) in the line.
This range is always non-empty, even if the line contains no visible content.
ascDesc
variable (PreparedText::GlyphLine::ascDesc
)¶
AscenderDescender ascDesc
The ascender and descender metrics for the line.
Contains the maximum ascender and descender values for the glyphs in the line.
baseline
variable (PreparedText::GlyphLine::baseline
)¶
float baseline = 0.f
The baseline position for the line.
Represents the vertical offset between this line's baseline and the baseline of the first line.
empty
function (PreparedText::GlyphLine::empty
)¶
bool empty() const noexcept
Checks if the line is empty.
A line is considered empty if it contains no runs.
Returns true
if the line is empty, false
otherwise.
lines
variable (PreparedText::lines
)¶
std::vector<GlyphLine> lines
A collection of GlyphLine objects, representing multiple lines of text.
updateCaretData
function (PreparedText::updateCaretData
)¶
void updateCaretData()
Updates the caret positions and horizontal ranges for graphemes.
This function calculates and fills the caretPositions
and ranges
fields based on the current text
properties.
caretToGrapheme
function (PreparedText::caretToGrapheme
)¶
uint32_t caretToGrapheme(PointF pt) const
Maps a point to the nearest grapheme boundary.
Determines the grapheme boundary index corresponding to the provided point in text layout space.
Param pt
The point in text layout space.
Returns uint32_t The index of the nearest grapheme boundary.
graphemeToCaret
function (PreparedText::graphemeToCaret
)¶
PointF graphemeToCaret(uint32_t graphemeIndex) const
Maps a grapheme boundary index to its caret position.
Calculates the position of the caret corresponding to the given grapheme boundary in text layout space.
Param graphemeIndex
The index of the grapheme boundary.
Returns PointF The caret position for the specified grapheme.
yToLine
function (PreparedText::yToLine
)¶
int32_t yToLine(float y) const
Maps a vertical position to the nearest text line.
Determines the line index corresponding to the given vertical position in text layout space.
Param y
The vertical position in text layout space.
Returns int32_t The index of the nearest line, or -1 if the position is outside the layout.
runVisual
function (PreparedText::runVisual
)¶
const GlyphRun &runVisual(uint32_t index) const
Retrieves a glyph run in visual order.
Param index
The index in visual order to retrieve.
Returns const GlyphRun& The glyph run at the specified visual order index.
GlyphRun &runVisual(uint32_t index)
Retrieves a modifiable glyph run in visual order.
Param index
The index in visual order to retrieve.
Returns GlyphRun& The modifiable glyph run at the specified visual order index.
bounds
function (PreparedText::bounds
)¶
RectangleF bounds(GlyphRunBounds boundsType =
GlyphRunBounds::Alignment) const
Calculates the bounds of the text based on the specified bounds type.
Param boundsType
The type of bounds to calculate (e.g., text, alignment, printable).
Returns RectangleF The calculated bounds of the text.
wrap
function (PreparedText::wrap
)¶
PreparedText wrap(float maxWidth,
bool wrapAnywhere = false) &&
Wraps text to fit within the given width, modifying the current object.
Wraps lines of text to fit within the specified maxWidth
. If wrapAnywhere
is true,
the text can break between any graphemes. Otherwise, breaks occur at word boundaries.
Param maxWidth
Maximum allowed width for the text.
Param wrapAnywhere
If true, allows breaking between any graphemes; otherwise, breaks at word
boundaries.
Returns PreparedText The modified object with wrapped lines.
PreparedText wrap(float maxWidth,
bool wrapAnywhere = false) const &
Wraps text to fit within the given width, returning a copy.
Wraps lines of text so that they fit within the specified maxWidth
. If wrapAnywhere
is true,
the text can break between any graphemes. Otherwise, breaks occur at word boundaries.
Param maxWidth
Maximum allowed width for the text.
Param wrapAnywhere
If true, allows breaking between any graphemes; otherwise, breaks at word
boundaries.
Returns PreparedText A copy with wrapped lines.
alignLines
function (PreparedText::alignLines
)¶
PointF alignLines(float alignment_x,
float alignment_y = 0.f)
Aligns text lines horizontally and vertically.
Adjusts the horizontal offsets of each line based on alignment_x
and returns a PointF with overall
horizontal and vertical offsets. Apply the returned offset when painting PreparedText for proper
vertical alignment.
Param alignment_x
Horizontal alignment factor (0: left, 0.5: center, 1: right).
Param alignment_y
Vertical alignment factor (0: top, 0.5: center, 1: bottom).
Returns PointF Offsets for alignment.
characterToGrapheme
function (PreparedText::characterToGrapheme
)¶
uint32_t characterToGrapheme(uint32_t charIndex) const
Converts a character index to its corresponding grapheme index.
Param charIndex
The character index to convert.
Returns uint32_t The corresponding grapheme index.
graphemeToCharacter
function (PreparedText::graphemeToCharacter
)¶
uint32_t graphemeToCharacter(uint32_t graphemeIndex) const
Converts a grapheme index to its corresponding character index.
Param graphemeIndex
The grapheme index to convert.
Returns uint32_t The corresponding character index.
graphemeToCharacters
function (PreparedText::graphemeToCharacters
)¶
Range<uint32_t>
graphemeToCharacters(uint32_t graphemeIndex) const
Retrieves the range of characters corresponding to a grapheme index.
Param graphemeIndex
The grapheme index to query.
Returns Range<uint32_t> The range of character indices covered by the grapheme.
OpenTypeFeatureFlags
typedef¶
OpenTypeFeatureFlags = inline_vector<OpenTypeFeatureFlag, 7>
A collection of OpenType feature flags.
Font
class¶
Font
Represents font properties and settings for text rendering.
fontFamily
variable (Font::fontFamily
)¶
FontFamily fontFamily = FontFamily::Default
The font family.
fontSize
variable (Font::fontSize
)¶
float fontSize = 10.f
The size of the font in points.
style
variable (Font::style
)¶
FontStyle style = FontStyle::Normal
The style of the font (e.g., normal, italic).
weight
variable (Font::weight
)¶
FontWeight weight = FontWeight::Regular
The weight of the font (e.g., regular, bold).
textDecoration
variable (Font::textDecoration
)¶
TextDecoration textDecoration = TextDecoration::None
Text decoration (e.g., underline, none).
lineHeight
variable (Font::lineHeight
)¶
float lineHeight = 1.2f
Line height as a multiplier.
tabWidth
variable (Font::tabWidth
)¶
float tabWidth = 8.f
Tab width in space units.
letterSpacing
variable (Font::letterSpacing
)¶
float letterSpacing = 0.f
Additional space between letters.
wordSpacing
variable (Font::wordSpacing
)¶
float wordSpacing = 0.f
Additional space between words.
verticalAlign
variable (Font::verticalAlign
)¶
float verticalAlign = 0.f
Vertical alignment offset.
features
variable (Font::features
)¶
OpenTypeFeatureFlags features
OpenType features for advanced text styling.
operator()
function (Font::operator()
)¶
Font operator()(FontFamily fontFamily) const
Creates a copy of the font with a new font family.
Param fontFamily
The new font family.
Returns Font A copy with the updated font family.
Font operator()(float fontSize) const
Creates a copy of the font with a new font size.
Param fontSize
The new font size.
Returns Font A copy with the updated font size.
Font operator()(FontStyle style) const
Creates a copy of the font with a new style.
Param style
The new font style.
Returns Font A copy with the updated font style.
Font operator()(FontWeight weight) const
Creates a copy of the font with a new weight.
Param weight
The new font weight.
Returns Font A copy with the updated font weight.
operator==
function (Font::operator==
)¶
bool operator==(const Font &b) const noexcept = default
Compares two fonts for equality.
FontStyleAndWeight
class¶
FontStyleAndWeight
Combines font style and weight for simplified handling.
style
variable (FontStyleAndWeight::style
)¶
FontStyle style = FontStyle::Normal
The font style (e.g., normal, italic).
weight
variable (FontStyleAndWeight::weight
)¶
FontWeight weight = FontWeight::Regular
The font weight (e.g., regular, bold).
operator==
function (FontStyleAndWeight::operator==
)¶
bool operator==(
const FontStyleAndWeight &b) const noexcept = default
Compares two FontStyleAndWeight objects for equality.
FontError
class¶
FontError
OSFont
class¶
OSFont
FontManager
class¶
FontManager
ShapeCacheEntry
class (FontManager::ShapeCacheEntry
)¶
ShapeCacheEntry
icuAvailable
variable¶
extern bool icuAvailable
Indicates whether the ICU library is available for full Unicode support.
When icuAvailable
is true
, the font functions will have full Unicode support
for Bidirectional (BiDi) text processing (using splitTextRuns) and grapheme/line
breaking functionality (textBreakPositions).
Auto-generated from sources, Revision , https://github.com/brisklib/brisk/blob//include/brisk/