Xteink-X4-crosspoint-reader/lib/Utf8/Utf8.h
Jesse Vincent e39562e1c8 feat: Add f-ligature support (ff, fi, fl, ffi, ffl)
Add ligature codepoints (U+FB00–FB06) to font conversion so all fonts
include ligature glyphs. Implement utf8NextCodepointWithLigatures() that
does lookahead substitution for f-ligature sequences. Use it in text
rendering and measurement so ligatures render correctly and word-wrapping
accounts for the ligature glyph widths.
2026-02-01 23:07:08 -08:00

15 lines
607 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include <cstdint>
#include <string>
#define REPLACEMENT_GLYPH 0xFFFD
uint32_t utf8NextCodepoint(const unsigned char** string);
// Like utf8NextCodepoint, but substitutes f-ligature sequences (fi, fl, ff, ffi, ffl)
// with their Unicode ligature codepoints (U+FB00FB04).
uint32_t utf8NextCodepointWithLigatures(const unsigned char** string);
// Remove the last UTF-8 codepoint from a std::string and return the new size.
size_t utf8RemoveLastChar(std::string& str);
// Truncate string by removing N UTF-8 codepoints from the end.
void utf8TruncateChars(std::string& str, size_t numChars);