7#include "font_glyph_ids.hpp"
8#include "attributed_grapheme.hpp"
9#include "glyph_metrics.hpp"
10#include "../graphic_path.hpp"
11#include "../geometry/translate.hpp"
34 unicode_general_category general_category;
65 return index >= first && index < last;
68 [[nodiscard]]
bool isLetter() const noexcept
70 return is_L(general_category);
73 [[nodiscard]]
bool isDigit() const noexcept
75 return is_N(general_category);
78 [[nodiscard]]
bool isIdentifier() const noexcept {
return isLetter() || isDigit(); }
80 [[nodiscard]]
bool isWhiteSpace() const noexcept
82 return general_category == unicode_general_category::Zs || general_category == unicode_general_category::Zl;
85 [[nodiscard]]
bool isParagraphSeparator() const noexcept
87 return general_category == unicode_general_category::Zp;
89 [[nodiscard]]
bool isVisible() const noexcept
91 return is_visible(general_category);
102 if (isParagraphSeparator()) {
104 }
else if (isIdentifier()) {
106 }
else if (isVisible()) {
127 ttlet relativePositionPergrapheme = relativePositionInGlyph * narrow_cast<float>(
graphemeCount);
128 return narrow_cast<ssize_t>(
std::round(relativePositionPergrapheme));
Class which represents an axis-aligned rectangle.
Definition axis_aligned_rectangle.hpp:20
constexpr float & x() noexcept
Access the x element from the point.
Definition point.hpp:86
constexpr float & x() noexcept
Access the x element from the vector.
Definition vector.hpp:83
A path is a vector graphics object.
Definition graphic_path.hpp:28
Definition attributed_glyph.hpp:17
ssize_t relativeIndexAtCoordinate(point2 coordinate) const noexcept
Find the logical index closest to the coordinate.
Definition attributed_glyph.hpp:125
int selectionWordClusterID() const noexcept
return a cluster id for word selection.
Definition attributed_glyph.hpp:101
point2 position
Position of the glyph.
Definition attributed_glyph.hpp:29
ssize_t logicalIndex
The logical index of the grapheme before bidi-algorithm.
Definition attributed_glyph.hpp:22
int8_t graphemeCount
Number of graphemes merged (ligature) into this attributed-glyph.
Definition attributed_glyph.hpp:32
text_style style
Copied from the original attributed-grapheme.
Definition attributed_glyph.hpp:37
attributed_glyph(tt::font_book const &font_book, attributed_grapheme const &attr_grapheme, attributed_glyph const *next_attr_glyph=nullptr) noexcept
Constructed an attributed glyph from an attributed grapheme.
aarectangle boundingBox(float border) const noexcept
Get the bounding box for this glyph.
Definition attributed_glyph.hpp:117
glyph_metrics metrics
Metrics taken from the font file, pre-scaled to the font-size.
Definition attributed_glyph.hpp:25
bool containsLogicalIndex(ssize_t index) const noexcept
Check if this glyph contains the grapheme at index.
Definition attributed_glyph.hpp:62
Definition attributed_grapheme.hpp:14
font_book keeps track of multiple fonts.
Definition font_book.hpp:30
Definition font_glyph_ids.hpp:80
Definition glyph_metrics.hpp:17
aarectangle boundingBox
Definition glyph_metrics.hpp:20
vector2 advance
Definition glyph_metrics.hpp:58
Definition text_style.hpp:17