summaryrefslogtreecommitdiff
path: root/src/mbgl/util/i18n.hpp
blob: 186212f50d2ab969cac61b5c9a2940517896ada8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#pragma once

#include <string>

namespace mbgl {
namespace util {
namespace i18n {

/** Returns whether a line break can be inserted after the character indicated
    by the given Unicode codepoint due to word breaking. */
bool allowsWordBreaking(char16_t chr);

/** Returns whether a line break can be inserted after any character in the
    given string. If false, line breaking should occur on word boundaries
    instead. */
bool allowsIdeographicBreaking(const std::u16string& string);

/** Returns whether a line break can be inserted after the character indicated
    by the given Unicode codepoint due to ideographic breaking. */
bool allowsIdeographicBreaking(char16_t chr);

/** Returns whether any substring of the given string can be drawn as vertical
    text with upright glyphs. */
bool allowsVerticalWritingMode(const std::u16string& string);

/** Returns true if the given Unicode codepoint identifies a character with
    upright orientation.

    A character has upright orientation if it is drawn upright (unrotated)
    whether the line is oriented horizontally or vertically, even if both
    adjacent characters can be rotated. For example, a Chinese character is
    always drawn upright. An uprightly oriented character causes an adjacent
    “neutral” character to be drawn upright as well. */
bool hasUprightVerticalOrientation(char16_t chr);

/** Returns true if the given Unicode codepoint identifies a character with
    neutral orientation.

    A character has neutral orientation if it may be drawn rotated or unrotated
    when the line is oriented vertically, depending on the orientation of the
    adjacent characters. For example, along a verticlly oriented line, the
    vulgar fraction ½ is drawn upright among Chinese characters but rotated
    among Latin letters. A neutrally oriented character does not influence
    whether an adjacent character is drawn upright or rotated.
 */
bool hasNeutralVerticalOrientation(char16_t chr);

/** Returns true if the given Unicode codepoint identifies a character with
    rotated orientation.

    A character has rotated orientation if it is drawn rotated when the line is
    oriented vertically, even if both adjacent characters are upright. For
    example, a Latin letter is drawn rotated along a vertical line. A rotated
    character causes an adjacent “neutral” character to be drawn rotated as
    well.
 */
bool hasRotatedVerticalOrientation(char16_t chr);

/** Returns a copy of the given string with punctuation characters replaced with
    their vertical forms wherever applicable. */
std::u16string verticalizePunctuation(const std::u16string& input);

/** Returns the form of the given character appropriate for vertical text.

    @return The character’s specialized vertical form; 0 if not applicable. */
char16_t verticalizePunctuation(char16_t chr);

} // namespace i18n
} // namespace util
} // namespace mbgl