Donner SVG main
0.8.0 ยท 382bd0190.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
TextTransform.h File Reference
#include <cstddef>
#include <cstdint>
#include <optional>
#include <string>
#include <string_view>
#include <vector>
Include dependency graph for TextTransform.h:

Classes

struct  donner::svg::text_transform::FullWidthText
 Transformed shaping text with the original byte offset of each Unicode codepoint. More...

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.
namespace  donner::svg
 Donner SVG library, which can load, manipulate and render SVG files.

Functions

char32_t donner::svg::text_transform::FullWidthCodepoint (char32_t codepoint, bool preserveSpaces)
 Return the Unicode full-width mapping, retaining a collapsed ASCII space unchanged.
bool donner::svg::text_transform::NeedsFullWidth (std::string_view text, bool preserveSpaces)
 Whether text contains a character whose full-width form differs.
std::optional< FullWidthText > donner::svg::text_transform::MakeFullWidth (std::string_view text, bool preserveSpaces, size_t maximumBytes=kMaximumFullWidthBytes)
 Transform one source span, preserving codepoint count and original byte indices.

Variables

constexpr size_t donner::svg::text_transform::kMaximumFullWidthBytes = 64u * 1024u * 1024u
 Maximum transient UTF-8 and source-index payload retained for one transformed span.

Function Documentation

◆ FullWidthCodepoint()

char32_t donner::svg::text_transform::FullWidthCodepoint ( char32_t codepoint,
bool preserveSpaces )

Return the Unicode full-width mapping, retaining a collapsed ASCII space unchanged.

Parameters
codepointOriginal Unicode codepoint.
preserveSpacesWhether a U+0020 space was preserved by whitespace normalization.

◆ MakeFullWidth()

std::optional< FullWidthText > donner::svg::text_transform::MakeFullWidth ( std::string_view text,
bool preserveSpaces,
size_t maximumBytes = kMaximumFullWidthBytes )

Transform one source span, preserving codepoint count and original byte indices.

Parameters
textOriginal normalized text, which remains unchanged.
preserveSpacesWhether U+0020 survived whitespace normalization as preserved space.
maximumBytesMaximum combined UTF-8 and source-index payload, checked before allocation.
Returns
No result when the payload exceeds the bound or 32-bit shaping cluster indices.

◆ NeedsFullWidth()

bool donner::svg::text_transform::NeedsFullWidth ( std::string_view text,
bool preserveSpaces )

Whether text contains a character whose full-width form differs.

Parameters
textOriginal normalized UTF-8 text.
preserveSpacesWhether U+0020 spaces were preserved by whitespace normalization.