6#include "TTauri/Text/FontGlyphIDs.hpp"
7#include "TTauri/Text/AttributedGrapheme.hpp"
8#include "TTauri/Text/GlyphMetrics.hpp"
9#include "TTauri/Foundation/mat.hpp"
32 GeneralCharacterClass charClass;
60 return index >= first && index < last;
63 [[nodiscard]]
bool isLetter() const noexcept {
return charClass == GeneralCharacterClass::Letter; }
64 [[nodiscard]]
bool isDigit() const noexcept {
return charClass == GeneralCharacterClass::Digit; }
65 [[nodiscard]]
bool isWord() const noexcept {
return isLetter() || isDigit(); }
66 [[nodiscard]]
bool isWhiteSpace() const noexcept {
return charClass == GeneralCharacterClass::WhiteSpace; }
67 [[nodiscard]]
bool isParagraphSeparator() const noexcept {
return charClass == GeneralCharacterClass::ParagraphSeparator; }
68 [[nodiscard]]
bool isVisible() const noexcept {
return isWord() || charClass == GeneralCharacterClass::Unknown; }
79 case GeneralCharacterClass::ParagraphSeparator:
return 0;
80 case GeneralCharacterClass::Digit:
81 case GeneralCharacterClass::Letter:
return 1;
82 case GeneralCharacterClass::Unknown:
return 2;
83 case GeneralCharacterClass::WhiteSpace:
return 3;
84 default: tt_no_default;
102 ttlet relativePositionPerGrapheme = relativePositionInGlyph * numeric_cast<float>(
graphemeCount);
103 return numeric_cast<ssize_t>(
std::round(relativePositionPerGrapheme));
106 [[nodiscard]]
Path get_path() const noexcept;
Class which represents an axis-aligned rectangle.
Definition aarect.hpp:13
Optimized 2D translate matrix.
Definition mat.hpp:184
A 4D vector.
Definition vec.hpp:37
Definition AttributedGlyph.hpp:15
TextStyle style
Copied from the original attributed-grapheme.
Definition AttributedGlyph.hpp:35
bool containsLogicalIndex(ssize_t index) const noexcept
Check if this glyph contains the grapheme at index.
Definition AttributedGlyph.hpp:57
ssize_t logicalIndex
The logical index of the grapheme before bidi-algorithm.
Definition AttributedGlyph.hpp:20
ssize_t relativeIndexAtCoordinate(vec coordinate) const noexcept
Find the logical index closest to the coordinate.
Definition AttributedGlyph.hpp:100
int selectionWordClusterID() const noexcept
return a cluster id for word selection.
Definition AttributedGlyph.hpp:77
GlyphMetrics metrics
Metrics taken from the font file, pre-scaled to the font-size.
Definition AttributedGlyph.hpp:23
vec position
Position of the glyph.
Definition AttributedGlyph.hpp:27
int8_t graphemeCount
Number of graphemes merged (ligature) into this attributed-glyph.
Definition AttributedGlyph.hpp:30
AttributedGlyph(AttributedGrapheme const &attr_grapheme, AttributedGlyph const *next_attr_glyph=nullptr) noexcept
Constructed an attributed glyph from an attributed grapheme.
aarect boundingBox(float border) const noexcept
Get the bounding box for this glyph.
Definition AttributedGlyph.hpp:92
Definition AttributedGrapheme.hpp:12
Definition FontGlyphIDs.hpp:77
Definition GlyphMetrics.hpp:17
vec advance
Definition GlyphMetrics.hpp:58
aarect boundingBox
Definition GlyphMetrics.hpp:20
Definition TextStyle.hpp:15