HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Data Fields | Friends
v1::grapheme Struct Reference

#include <hikogui/unicode/grapheme.hpp>

Public Types

using value_type = uint64_t
 

Public Member Functions

constexpr grapheme (grapheme const &) noexcept=default
 
constexpr grapheme (grapheme &&) noexcept=default
 
constexpr graphemeoperator= (grapheme const &) noexcept=default
 
constexpr graphemeoperator= (grapheme &&) noexcept=default
 
constexpr grapheme (std::in_place_t, value_type value)
 
constexpr value_type & intrinsic () noexcept
 
constexpr value_type const & intrinsic () const noexcept
 
constexpr grapheme (char32_t code_point) noexcept
 Encode a single code-point.
 
constexpr grapheme (char ascii_char) noexcept
 
constexpr graphemeoperator= (char32_t code_point) noexcept
 Encode a single code-point.
 
constexpr graphemeoperator= (char ascii_char) noexcept
 Encode a single code-point.
 
template<typename CodePoints >
constexpr grapheme (composed_t, CodePoints &&code_points) noexcept
 Encode a grapheme from a list of code-points.
 
constexpr grapheme (std::u32string_view code_points) noexcept
 Encode a grapheme from a list of code-points.
 
constexpr uint32_t index () const noexcept
 Get the codepoint/index part of the grapheme.
 
constexpr iso_639 language () const noexcept
 
constexpr void set_language (iso_639 rhs) noexcept
 
constexpr iso_15924 starter_script () const noexcept
 Get the script of the starter code-point.
 
constexpr iso_15924 starter_script (iso_15924 default_script) const noexcept
 Get the script of the starter code-point.
 
constexpr iso_15924 script () const noexcept
 
constexpr void set_script (iso_15924 rhs) noexcept
 Set the script of the grapheme.
 
constexpr void set_script () noexcept
 Get the script of the grapheme to the starter script.
 
constexpr iso_3166 region () const noexcept
 
constexpr void set_region (iso_3166 rhs) noexcept
 
constexpr hi::language_tag language_tag () const noexcept
 
constexpr void set_language_tag (hi::language_tag rhs) noexcept
 
constexpr hi::phrasing phrasing () const noexcept
 
constexpr void set_phrasing (hi::phrasing rhs) noexcept
 
constexpr std::size_t size () const noexcept
 Return the number of code-points encoded in the grapheme.
 
constexpr char32_t starter () const noexcept
 
constexpr bool is_ascii () const noexcept
 
constexpr std::u32string composed () const noexcept
 Get a list of code-point normalized to NFC.
 
constexpr std::u32string decomposed (unicode_normalize_config config=unicode_normalize_config::NFD()) const noexcept
 Get a list of code-point normalized to NFD.
 

Data Fields

value_type _value
 The grapheme's value.
 

Friends

constexpr bool operator== (grapheme const &lhs, grapheme const &rhs) noexcept
 Compare equivalence of two graphemes.
 
constexpr bool operator== (grapheme const &lhs, char32_t const &rhs) noexcept
 
constexpr bool operator== (grapheme const &lhs, char const &rhs) noexcept
 
constexpr std::strong_ordering operator<=> (grapheme const &lhs, grapheme const &rhs) noexcept
 Compare two graphemes lexicographically.
 
constexpr std::strong_ordering operator<=> (grapheme const &lhs, char32_t const &rhs) noexcept
 
constexpr std::strong_ordering operator<=> (grapheme const &lhs, char const &rhs) noexcept
 
constexpr std::string to_string (grapheme const &rhs) noexcept
 
constexpr std::wstring to_wstring (grapheme const &rhs) noexcept
 
constexpr std::u32string to_u32string (grapheme const &rhs) noexcept
 

Detailed Description

A grapheme-cluster, what a user thinks a character is.

A grapheme should not include typographical ligatures such as 'fi' as the font should handle creating ligatures.

If a grapheme is initialized with more than 1 code-points a long_grapheme is allocated. This grapheme is never deleted from memory.

This class is trivial and constant-destructible so that it can be used as a character class in std::basic_string and used as a non-type template parameter.

Constructor & Destructor Documentation

◆ grapheme() [1/3]

constexpr v1::grapheme::grapheme ( char32_t code_point)
inlineconstexprnoexcept

Encode a single code-point.

◆ grapheme() [2/3]

template<typename CodePoints >
constexpr v1::grapheme::grapheme ( composed_t ,
CodePoints && code_points )
inlineconstexprnoexcept

Encode a grapheme from a list of code-points.

Parameters
code_pointsThe NFC/NKFC normalized and composed code-point of this grapheme.

◆ grapheme() [3/3]

constexpr v1::grapheme::grapheme ( std::u32string_view code_points)
inlineexplicitconstexprnoexcept

Encode a grapheme from a list of code-points.

Parameters
code_pointsThe non-normalized list of code-points.

Member Function Documentation

◆ composed()

constexpr std::u32string v1::grapheme::composed ( ) const
inlineconstexprnoexcept

Get a list of code-point normalized to NFC.

◆ decomposed()

constexpr std::u32string v1::grapheme::decomposed ( unicode_normalize_config config = unicode_normalize_config::NFD()) const
inlineconstexprnoexcept

Get a list of code-point normalized to NFD.

◆ index()

constexpr uint32_t v1::grapheme::index ( ) const
inlineconstexprnoexcept

Get the codepoint/index part of the grapheme.

◆ operator=() [1/2]

constexpr grapheme & v1::grapheme::operator= ( char ascii_char)
inlineconstexprnoexcept

Encode a single code-point.

◆ operator=() [2/2]

constexpr grapheme & v1::grapheme::operator= ( char32_t code_point)
inlineconstexprnoexcept

Encode a single code-point.

◆ set_script() [1/2]

constexpr void v1::grapheme::set_script ( )
inlineconstexprnoexcept

Get the script of the grapheme to the starter script.

◆ set_script() [2/2]

constexpr void v1::grapheme::set_script ( iso_15924 rhs)
inlineconstexprnoexcept

Set the script of the grapheme.

Parameters
rhsThe new script for the grapheme, if the starter-script is common or inherinted.

◆ size()

constexpr std::size_t v1::grapheme::size ( ) const
inlineconstexprnoexcept

Return the number of code-points encoded in the grapheme.

◆ starter_script() [1/2]

constexpr iso_15924 v1::grapheme::starter_script ( ) const
inlineconstexprnoexcept

Get the script of the starter code-point.

Returns
The script for the starter code-point retrieved from the Unicode Datastarter.

◆ starter_script() [2/2]

constexpr iso_15924 v1::grapheme::starter_script ( iso_15924 default_script) const
inlineconstexprnoexcept

Get the script of the starter code-point.

Parameters
default_scriptThe
Returns
The script for the starter code-point retrieved from the Unicode Datastarter; or the default_script if the starter-script is common or inherinted.

Friends And Related Symbol Documentation

◆ operator<=>

constexpr std::strong_ordering operator<=> ( grapheme const & lhs,
grapheme const & rhs )
friend

Compare two graphemes lexicographically.

◆ operator==

constexpr bool operator== ( grapheme const & lhs,
grapheme const & rhs )
friend

Compare equivalence of two graphemes.

This comparision ignores language-tag and phrasing of a grapheme.

Field Documentation

◆ _value

value_type v1::grapheme::_value

The grapheme's value.

This class will hold:

  • [20: 0] U+0000 to U+10ffff single code-point, 0x110000 to 0x1fffff index into long_grapheme table.
  • [35:21] ISO-639 language-code: 0 is wildcard.
  • [45:36] ISO-15924 script-code: 0 is wildcard.
  • [55:46] ISO-3166 region-code: 0 is wildcard.
  • [61:56] phrasing
  • [62:62] reserved = 0
  • [63:63] If bit is set this is a end-of-file.

The documentation for this struct was generated from the following file: