Skip to content

Commit 04e2693

Browse files
authored
Merge pull request #973 from ecomfe/fix-charset
fix: Charsets like Cyrillic should break work the same as Latin
2 parents 75f0e88 + e37e7d2 commit 04e2693

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/graphic/helper/parseText.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,9 +591,17 @@ function pushTokens(
591591
}
592592

593593

594-
function isLatin(ch: string) {
594+
function isAlphabeticLetter(ch: string) {
595+
// Unicode Character Ranges
596+
// https://jrgraphix.net/research/unicode_blocks.php
597+
// The following ranges may not cover all letter ranges but only the more
598+
// popular ones. Developers could make pull requests when they find those
599+
// not covered.
595600
let code = ch.charCodeAt(0);
596-
return code >= 0x21 && code <= 0x17F;
601+
return code >= 0x20 && code <= 0x24F // Latin
602+
|| code >= 0x370 && code <= 0x10FF // Greek, Coptic, Cyrilic, and etc.
603+
|| code >= 0x1200 && code <= 0x13FF // Ethiopic and Cherokee
604+
|| code >= 0x1E00 && code <= 0x206F; // Latin and Greek extended
597605
}
598606

599607
const breakCharMap = reduce(',&?/;] '.split(''), function (obj, ch) {
@@ -604,7 +612,7 @@ const breakCharMap = reduce(',&?/;] '.split(''), function (obj, ch) {
604612
* If break by word. For latin languages.
605613
*/
606614
function isWordBreakChar(ch: string) {
607-
if (isLatin(ch)) {
615+
if (isAlphabeticLetter(ch)) {
608616
if (breakCharMap[ch]) {
609617
return true;
610618
}

0 commit comments

Comments
 (0)