1 #pragma once
2 
3 #include <string>
4 
5 namespace mbgl {
6 namespace util {
7 namespace i18n {
8 
9 /** Returns whether a line break can be inserted after the character indicated
10     by the given Unicode codepoint due to word breaking. */
11 bool allowsWordBreaking(char16_t chr);
12 
13 /** Returns whether the given string can be displayed with letter-spacing.
14     False for Arabic scripts, where letter-spacing will break ligatures. */
15 bool allowsLetterSpacing(const std::u16string& string);
16 
17 /** Returns whether a line break can be inserted after any character in the
18     given string. If false, line breaking should occur on word boundaries
19     instead. */
20 bool allowsIdeographicBreaking(const std::u16string& string);
21 
22 /** Returns whether a line break can be inserted after the character indicated
23     by the given Unicode codepoint due to ideographic breaking. */
24 bool allowsIdeographicBreaking(char16_t chr);
25 
26 /** Conservative set of characters expected to have relatively fixed sizes and
27     advances */
28 bool allowsFixedWidthGlyphGeneration(char16_t chr);
29 
30 /** Returns whether any substring of the given string can be drawn as vertical
31     text with upright glyphs. */
32 bool allowsVerticalWritingMode(const std::u16string& string);
33 
34 /** Returns true if the given Unicode codepoint identifies a character with
35     upright orientation.
36 
37     A character has upright orientation if it is drawn upright (unrotated)
38     whether the line is oriented horizontally or vertically, even if both
39     adjacent characters can be rotated. For example, a Chinese character is
40     always drawn upright. An uprightly oriented character causes an adjacent
41     “neutral” character to be drawn upright as well. */
42 bool hasUprightVerticalOrientation(char16_t chr);
43 
44 /** Returns true if the given Unicode codepoint identifies a character with
45     neutral orientation.
46 
47     A character has neutral orientation if it may be drawn rotated or unrotated
48     when the line is oriented vertically, depending on the orientation of the
49     adjacent characters. For example, along a verticlly oriented line, the
50     vulgar fraction ½ is drawn upright among Chinese characters but rotated
51     among Latin letters. A neutrally oriented character does not influence
52     whether an adjacent character is drawn upright or rotated.
53  */
54 bool hasNeutralVerticalOrientation(char16_t chr);
55 
56 /** Returns true if the given Unicode codepoint identifies a character with
57     rotated orientation.
58 
59     A character has rotated orientation if it is drawn rotated when the line is
60     oriented vertically, even if both adjacent characters are upright. For
61     example, a Latin letter is drawn rotated along a vertical line. A rotated
62     character causes an adjacent “neutral” character to be drawn rotated as
63     well.
64  */
65 bool hasRotatedVerticalOrientation(char16_t chr);
66 
67 /** Returns a copy of the given string with punctuation characters replaced with
68     their vertical forms wherever applicable. */
69 std::u16string verticalizePunctuation(const std::u16string& input);
70 
71 /** Returns the form of the given character appropriate for vertical text.
72 
73     @return The character’s specialized vertical form; 0 if not applicable. */
74 char16_t verticalizePunctuation(char16_t chr);
75 
76 bool isStringInSupportedScript(const std::string& input);
77 
78 } // namespace i18n
79 } // namespace util
80 } // namespace mbgl
81