• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

orion-ecs / keen-eye / 20737823009

06 Jan 2026 04:16AM UTC coverage: 71.324% (-2.6%) from 73.964%
20737823009

push

github

tyevco
feat(localization): Add RTL layout support and advanced localization features

- Add TextDirection enum for distinguishing LTR/RTL text flow
- Add IsRightToLeft property and RTL locale constants to Locale struct
- Add MirrorForRtl property to UIRect for automatic layout mirroring
- Update UILayoutSystem to handle RTL-aware anchor and flexbox layouts
- Add text shaping infrastructure with ITextShaper interface
- Implement ArabicTextShaper for contextual letter forms
- Add BidirectionalTextShaper for mixed LTR/RTL text handling
- Add ComplexScriptInfo for Thai, Hindi, Bengali, Tamil shaping info
- Add CsvStringSource for CSV import/export translator workflows
- Add comprehensive unit tests for all new functionality

Closes #635

5865 of 7851 branches covered (74.7%)

Branch coverage included in aggregate %.

26 of 764 new or added lines in 9 files covered. (3.4%)

452 existing lines in 6 files now uncovered.

37040 of 52304 relevant lines covered (70.82%)

1.02 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/KeenEyes.Localization/TextShaping/ScriptType.cs
1
namespace KeenEyes.Localization.TextShaping;
2

3
/// <summary>
4
/// Identifies writing script types for text shaping.
5
/// </summary>
6
/// <remarks>
7
/// <para>
8
/// Script types categorize writing systems by their shaping requirements.
9
/// Simple scripts like Latin need minimal shaping, while complex scripts
10
/// like Arabic require contextual glyph selection.
11
/// </para>
12
/// </remarks>
13
public enum ScriptType : byte
14
{
15
    /// <summary>
16
    /// Unknown or unspecified script.
17
    /// </summary>
18
    Unknown = 0,
19

20
    /// <summary>
21
    /// Latin script (English, Spanish, French, German, etc.).
22
    /// </summary>
23
    /// <remarks>
24
    /// Simple script with no contextual shaping requirements.
25
    /// </remarks>
26
    Latin = 1,
27

28
    /// <summary>
29
    /// Cyrillic script (Russian, Ukrainian, Bulgarian, etc.).
30
    /// </summary>
31
    /// <remarks>
32
    /// Simple script with no contextual shaping requirements.
33
    /// </remarks>
34
    Cyrillic = 2,
35

36
    /// <summary>
37
    /// Greek script.
38
    /// </summary>
39
    /// <remarks>
40
    /// Simple script with no contextual shaping requirements.
41
    /// </remarks>
42
    Greek = 3,
43

44
    /// <summary>
45
    /// Arabic script (Arabic, Persian, Urdu, etc.).
46
    /// </summary>
47
    /// <remarks>
48
    /// <para>
49
    /// Complex script requiring contextual shaping. Arabic letters have
50
    /// different forms depending on their position in a word:
51
    /// </para>
52
    /// <list type="bullet">
53
    ///   <item><description>Isolated - standalone letter</description></item>
54
    ///   <item><description>Initial - beginning of word</description></item>
55
    ///   <item><description>Medial - middle of word</description></item>
56
    ///   <item><description>Final - end of word</description></item>
57
    /// </list>
58
    /// <para>
59
    /// Arabic is also a right-to-left script.
60
    /// </para>
61
    /// </remarks>
62
    Arabic = 4,
63

64
    /// <summary>
65
    /// Hebrew script.
66
    /// </summary>
67
    /// <remarks>
68
    /// Right-to-left script with simpler shaping than Arabic.
69
    /// Some letters have final forms.
70
    /// </remarks>
71
    Hebrew = 5,
72

73
    /// <summary>
74
    /// Thai script.
75
    /// </summary>
76
    /// <remarks>
77
    /// Complex script with stacking diacritics (tone marks, vowels)
78
    /// that appear above or below base consonants.
79
    /// </remarks>
80
    Thai = 6,
81

82
    /// <summary>
83
    /// Devanagari script (Hindi, Sanskrit, Marathi, etc.).
84
    /// </summary>
85
    /// <remarks>
86
    /// Complex script with stacking diacritics and conjunct consonants.
87
    /// Requires proper handling of the virama (halant) character.
88
    /// </remarks>
89
    Devanagari = 7,
90

91
    /// <summary>
92
    /// CJK (Chinese, Japanese, Korean) ideographs.
93
    /// </summary>
94
    /// <remarks>
95
    /// <para>
96
    /// Generally simple shaping, but may require:
97
    /// </para>
98
    /// <list type="bullet">
99
    ///   <item><description>Vertical text layout support</description></item>
100
    ///   <item><description>Full-width punctuation handling</description></item>
101
    ///   <item><description>Ruby text (furigana) support for Japanese</description></item>
102
    /// </list>
103
    /// </remarks>
104
    CJK = 8,
105

106
    /// <summary>
107
    /// Japanese Hiragana syllabary.
108
    /// </summary>
109
    Hiragana = 9,
110

111
    /// <summary>
112
    /// Japanese Katakana syllabary.
113
    /// </summary>
114
    Katakana = 10,
115

116
    /// <summary>
117
    /// Korean Hangul syllabary.
118
    /// </summary>
119
    /// <remarks>
120
    /// May require syllable block composition from individual jamo.
121
    /// </remarks>
122
    Hangul = 11,
123

124
    /// <summary>
125
    /// Tamil script.
126
    /// </summary>
127
    /// <remarks>
128
    /// Complex script with stacking diacritics and special character combinations.
129
    /// </remarks>
130
    Tamil = 12,
131

132
    /// <summary>
133
    /// Bengali script.
134
    /// </summary>
135
    /// <remarks>
136
    /// Complex script similar to Devanagari with conjunct consonants.
137
    /// </remarks>
138
    Bengali = 13
139
}
140

141
/// <summary>
142
/// Provides extension methods for <see cref="ScriptType"/>.
143
/// </summary>
144
public static class ScriptTypeExtensions
145
{
146
    /// <summary>
147
    /// Determines whether the script uses right-to-left text direction.
148
    /// </summary>
149
    /// <param name="script">The script type to check.</param>
150
    /// <returns><c>true</c> if the script is RTL; otherwise, <c>false</c>.</returns>
NEW
151
    public static bool IsRightToLeft(this ScriptType script) => script switch
×
NEW
152
    {
×
NEW
153
        ScriptType.Arabic => true,
×
NEW
154
        ScriptType.Hebrew => true,
×
NEW
155
        _ => false
×
NEW
156
    };
×
157

158
    /// <summary>
159
    /// Determines whether the script requires contextual shaping.
160
    /// </summary>
161
    /// <param name="script">The script type to check.</param>
162
    /// <returns><c>true</c> if the script needs contextual shaping; otherwise, <c>false</c>.</returns>
NEW
163
    public static bool RequiresContextualShaping(this ScriptType script) => script switch
×
NEW
164
    {
×
NEW
165
        ScriptType.Arabic => true,
×
NEW
166
        ScriptType.Hebrew => true, // Final forms
×
NEW
167
        ScriptType.Thai => true,
×
NEW
168
        ScriptType.Devanagari => true,
×
NEW
169
        ScriptType.Tamil => true,
×
NEW
170
        ScriptType.Bengali => true,
×
NEW
171
        _ => false
×
NEW
172
    };
×
173

174
    /// <summary>
175
    /// Determines whether the script uses stacking diacritics.
176
    /// </summary>
177
    /// <param name="script">The script type to check.</param>
178
    /// <returns><c>true</c> if the script uses stacking marks; otherwise, <c>false</c>.</returns>
NEW
179
    public static bool UsesStackingDiacritics(this ScriptType script) => script switch
×
NEW
180
    {
×
NEW
181
        ScriptType.Thai => true,
×
NEW
182
        ScriptType.Devanagari => true,
×
NEW
183
        ScriptType.Tamil => true,
×
NEW
184
        ScriptType.Bengali => true,
×
NEW
185
        _ => false
×
NEW
186
    };
×
187

188
    /// <summary>
189
    /// Determines whether the script supports vertical text layout.
190
    /// </summary>
191
    /// <param name="script">The script type to check.</param>
192
    /// <returns><c>true</c> if the script supports vertical layout; otherwise, <c>false</c>.</returns>
NEW
193
    public static bool SupportsVerticalLayout(this ScriptType script) => script switch
×
NEW
194
    {
×
NEW
195
        ScriptType.CJK => true,
×
NEW
196
        ScriptType.Hiragana => true,
×
NEW
197
        ScriptType.Katakana => true,
×
NEW
198
        ScriptType.Hangul => true,
×
NEW
199
        _ => false
×
NEW
200
    };
×
201
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc