27#include "unicode/errorcode.h"
28#include "unicode/normlzr.h"
29#include "unicode/unistr.h"
30#include "unicode/utypes.h"
36static std::string EncodeAsUTF8(
const char32 ch32) {
38 return std::string(uni_ch.utf8(), uni_ch.utf8_len());
60 : min_lig_length_(0), max_lig_length_(0), min_norm_length_(0), max_norm_length_(0) {}
67 std::string lig8 = EncodeAsUTF8(lig);
68 icu::UnicodeString unicode_lig8(
static_cast<UChar32
>(lig));
69 icu::UnicodeString normed8_result;
70 icu::ErrorCode status;
73 normed8_result.toUTF8String(normed8);
74 int lig_length = lig8.length();
75 int norm_length = normed8.size();
76 if (normed8 != lig8 && lig_length > 1 && norm_length > 1) {
116 len = it.get_utf8(tmp);
120 result += lig_it->second;
136 len = it.get_utf8(tmp);
155 int len = str.size();
161 if (
i + liglen <= len) {
162 std::string lig_cand = str.substr(
i, liglen);
165 tlog(3,
"Considering %s -> %s\n", lig_cand.c_str(), it->second.c_str());
174 result += it->second;
175 tlog(2,
"Substituted %s -> %s\n", lig_cand.c_str(), it->second.c_str());
185 result += str.substr(
i, len -
i);
static const_iterator begin(const char *utf8_str, int byte_length)
static const_iterator end(const char *utf8_str, int byte_length)
static const char * kCustomLigatures[][2]
std::string AddLigatures(const std::string &str, const PangoFontInfo *font) const
static std::unique_ptr< LigatureTable > instance_
LigHash norm_to_lig_table_
std::string RemoveLigatures(const std::string &str) const
static LigatureTable * Get()
std::string RemoveCustomLigatures(const std::string &str) const
LigHash lig_to_norm_table_
bool CanRenderString(const char *utf8_word, int len, std::vector< std::string > *graphemes) const