summaryrefslogtreecommitdiff
path: root/src/mbgl/util/i18n.hpp
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2017-02-10 16:57:48 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-02-10 18:57:48 -0600
commite6c15d0f6f285bc604c0d93381b9b1d3957cb5c9 (patch)
treefefef07141b72a96d12f6ff788c8727b20420bab /src/mbgl/util/i18n.hpp
parent0bbc6b814cbec44be7026a0bac83d56e4d71a287 (diff)
downloadqtlocation-mapboxgl-e6c15d0f6f285bc604c0d93381b9b1d3957cb5c9.tar.gz
Upright CJK characters in vertically-oriented labels (#7114)
CJK characters and adjacent punctuation now remain upright in vertically oriented labels that have line placement. Fixes #1682.
Diffstat (limited to 'src/mbgl/util/i18n.hpp')
-rw-r--r--src/mbgl/util/i18n.hpp50
1 files changed, 48 insertions, 2 deletions
diff --git a/src/mbgl/util/i18n.hpp b/src/mbgl/util/i18n.hpp
index f1d3f53f72..186212f50d 100644
--- a/src/mbgl/util/i18n.hpp
+++ b/src/mbgl/util/i18n.hpp
@@ -8,7 +8,7 @@ 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(uint16_t chr);
+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
@@ -17,7 +17,53 @@ 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(uint16_t chr);
+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