Пример #1
0
 const TextRun& getTextRun(const TextRun& originalRun)
 {
     // Convert the |originalRun| to NFC normalized form if combining diacritical marks
     // (U+0300..) are used in the run. This conversion is necessary since most OpenType
     // fonts (e.g., Arial) don't have substitution rules for the diacritical marks in
     // their GSUB tables.
     //
     // Note that we don't use the icu::Normalizer::isNormalized(UNORM_NFC) API here since
     // the API returns FALSE (= not normalized) for complex runs that don't require NFC
     // normalization (e.g., Arabic text). Unless the run contains the diacritical marks,
     // Harfbuzz will do the same thing for us using the GSUB table.
     for (unsigned i = 0; i < originalRun.length(); ++i) {
         UBlockCode block = ::ublock_getCode(originalRun[i]);
         if (block == UBLOCK_COMBINING_DIACRITICAL_MARKS) {
             return getNormalizedTextRun(originalRun);
         }
     }
     return originalRun;
 }
Пример #2
0
 const TextRun& getTextRun(const TextRun& originalRun)
 {
     // Normalize the text run in two ways:
     // 1) Convert the |originalRun| to NFC normalized form if combining diacritical marks
     // (U+0300..) are used in the run. This conversion is necessary since most OpenType
     // fonts (e.g., Arial) don't have substitution rules for the diacritical marks in
     // their GSUB tables.
     //
     // Note that we don't use the icu::Normalizer::isNormalized(UNORM_NFC) API here since
     // the API returns FALSE (= not normalized) for complex runs that don't require NFC
     // normalization (e.g., Arabic text). Unless the run contains the diacritical marks,
     // Harfbuzz will do the same thing for us using the GSUB table.
     // 2) Convert spacing characters into plain spaces, as some fonts will provide glyphs
     // for characters like '\n' otherwise.
     for (unsigned i = 0; i < originalRun.length(); ++i) {
         UChar ch = originalRun[i];
         UBlockCode block = ::ublock_getCode(ch);
         if (block == UBLOCK_COMBINING_DIACRITICAL_MARKS || (Font::treatAsSpace(ch) && ch != ' ')) {
             return getNormalizedTextRun(originalRun);
         }
     }
     return originalRun;
 }