Skip to main content

diffenator3_lib/render/
wordlists.rs

1use harfrust::{script, Direction, Script};
2use static_lang_word_lists::WordList;
3
4pub(crate) fn get_wordlist(script: &str) -> Option<&WordList> {
5    let wl = match script {
6        "Adlam" => &static_lang_word_lists::DIFFENATOR_ADLAM,
7        "Arabic" => &static_lang_word_lists::DIFFENATOR_ARABIC,
8        "Armenian" => &static_lang_word_lists::DIFFENATOR_ARMENIAN,
9        "Avestan" => &static_lang_word_lists::DIFFENATOR_AVESTAN,
10        "Bengali" => &static_lang_word_lists::DIFFENATOR_BENGALI,
11        "Bopomofo" => &static_lang_word_lists::DIFFENATOR_BOPOMOFO,
12        "Canadian_Aboriginal" => &static_lang_word_lists::DIFFENATOR_CANADIAN_ABORIGINAL,
13        "Chakma" => &static_lang_word_lists::DIFFENATOR_CHAKMA,
14        "Cherokee" => &static_lang_word_lists::DIFFENATOR_CHEROKEE,
15        "Common" => &static_lang_word_lists::DIFFENATOR_COMMON,
16        "Cyrillic" => &static_lang_word_lists::DIFFENATOR_CYRILLIC,
17        "Devanagari" => &static_lang_word_lists::DIFFENATOR_DEVANAGARI,
18        "Ethiopic" => &static_lang_word_lists::DIFFENATOR_ETHIOPIC,
19        "Georgian" => &static_lang_word_lists::DIFFENATOR_GEORGIAN,
20        // "Grantha" => &static_lang_word_lists::DIFFENATOR_GRANTHA,
21        "Greek" => &static_lang_word_lists::DIFFENATOR_GREEK,
22        "Gujarati" => &static_lang_word_lists::DIFFENATOR_GUJARATI,
23        "Gurmukhi" => &static_lang_word_lists::DIFFENATOR_GURMUKHI,
24        "Hebrew" => &static_lang_word_lists::DIFFENATOR_HEBREW,
25        "Hiragana" => &static_lang_word_lists::DIFFENATOR_HIRAGANA,
26        "Japanese" => &static_lang_word_lists::DIFFENATOR_JAPANESE,
27        // "Kannada" => &static_lang_word_lists::DIFFENATOR_KANNADA,
28        "Katakana" => &static_lang_word_lists::DIFFENATOR_KATAKANA,
29        "Khmer" => &static_lang_word_lists::DIFFENATOR_KHMER,
30        "Lao" => &static_lang_word_lists::DIFFENATOR_LAO,
31        "Latin" => &static_lang_word_lists::DIFFENATOR_LATIN,
32        "Lisu" => &static_lang_word_lists::DIFFENATOR_LISU,
33        "Malayalam" => &static_lang_word_lists::DIFFENATOR_MALAYALAM,
34        "Mongolian" => &static_lang_word_lists::DIFFENATOR_MONGOLIAN,
35        "Myanmar" => &static_lang_word_lists::DIFFENATOR_MYANMAR,
36        "Ol_Chiki" => &static_lang_word_lists::DIFFENATOR_OL_CHIKI,
37        "Oriya" => &static_lang_word_lists::DIFFENATOR_ORIYA,
38        "Osage" => &static_lang_word_lists::DIFFENATOR_OSAGE,
39        "Sinhala" => &static_lang_word_lists::DIFFENATOR_SINHALA,
40        "Syriac" => &static_lang_word_lists::DIFFENATOR_SYRIAC,
41        "Tamil" => &static_lang_word_lists::DIFFENATOR_TAMIL,
42        "Telugu" => &static_lang_word_lists::DIFFENATOR_TELUGU,
43        "Thai" => &static_lang_word_lists::DIFFENATOR_THAI,
44        "Thanaa" => &static_lang_word_lists::DIFFENATOR_THANAA,
45        "Tibetan" => &static_lang_word_lists::DIFFENATOR_TIBETAN,
46        "Tifinagh" => &static_lang_word_lists::DIFFENATOR_TIFINAGH,
47        "Vai" => &static_lang_word_lists::DIFFENATOR_VAI,
48
49        _ => return None,
50    };
51    Some(wl)
52}
53
54// pub(crate) in harfrust, annoyingly.
55pub fn direction_from_script(script: Script) -> Option<Direction> {
56    // https://docs.google.com/spreadsheets/d/1Y90M0Ie3MUJ6UVCRDOypOtijlMDLNNyyLk36T6iMu0o
57
58    match script {
59            // Unicode-1.1 additions
60            script::ARABIC |
61            script::HEBREW |
62
63            // Unicode-3.0 additions
64            script::SYRIAC |
65            script::THAANA |
66
67            // Unicode-4.0 additions
68            script::CYPRIOT |
69
70            // Unicode-4.1 additions
71            script::KHAROSHTHI |
72
73            // Unicode-5.0 additions
74            script::PHOENICIAN |
75            script::NKO |
76
77            // Unicode-5.1 additions
78            script::LYDIAN |
79
80            // Unicode-5.2 additions
81            script::AVESTAN |
82            script::IMPERIAL_ARAMAIC |
83            script::INSCRIPTIONAL_PAHLAVI |
84            script::INSCRIPTIONAL_PARTHIAN |
85            script::OLD_SOUTH_ARABIAN |
86            script::OLD_TURKIC |
87            script::SAMARITAN |
88
89            // Unicode-6.0 additions
90            script::MANDAIC |
91
92            // Unicode-6.1 additions
93            script::MEROITIC_CURSIVE |
94            script::MEROITIC_HIEROGLYPHS |
95
96            // Unicode-7.0 additions
97            script::MANICHAEAN |
98            script::MENDE_KIKAKUI |
99            script::NABATAEAN |
100            script::OLD_NORTH_ARABIAN |
101            script::PALMYRENE |
102            script::PSALTER_PAHLAVI |
103
104            // Unicode-8.0 additions
105            script::HATRAN |
106
107            // Unicode-9.0 additions
108            script::ADLAM |
109
110            // Unicode-11.0 additions
111            script::HANIFI_ROHINGYA |
112            script::OLD_SOGDIAN |
113            script::SOGDIAN |
114
115            // Unicode-12.0 additions
116            script::ELYMAIC |
117
118            // Unicode-13.0 additions
119            script::CHORASMIAN |
120            script::YEZIDI |
121
122            // Unicode-14.0 additions
123            script::OLD_UYGHUR |
124
125            // Unicode-16.0 additions
126            script::GARAY => {
127                Some(Direction::RightToLeft)
128            }
129
130            // https://github.com/harfbuzz/harfbuzz/issues/1000
131            script::OLD_HUNGARIAN |
132            script::OLD_ITALIC |
133            script::RUNIC |
134            script::TIFINAGH => {
135                None
136            }
137
138            _ => Some(Direction::LeftToRight),
139        }
140}