CommonLibSSE (powerof3)
GFxWWHelper.h
Go to the documentation of this file.
1 #pragma once
2 
3 namespace RE
4 {
5  class GFxWWHelper
6  {
7  public:
8  enum class BreakInfoFlags
9  {
10  kNone = 0,
11  kNonStartingChar = 1 << 0,
12  kNonTerminatingChar = 1 << 1,
14  };
15 
16  // An enumeration that describes bits in word-wrapping mode bit mask parameter of the Translator constructor.
17  enum class WordWrappingType
18  {
19  kNone = 0,
20  kDefault = static_cast<std::underlying_type_t<WordWrappingType>>(kNone), // - Custom word-wrapping is off, OnWordWrapping will not be invoked
21  kAsian = 1 << 0, // - Turns on Chinese word-wrapping rules
22  kProhibition = 1 << 1, // - Prohibits certain chars at start/end of line (turns on Japanese prohibition rule)
23  kNoHangulWrap = 1 << 2, // - Turns on Korean-specific word-wrapping rules
24  kCustom = 1 << 7,
25  kLast = static_cast<std::underlying_type_t<WordWrappingType>>(kNoHangulWrap),
26  kHyphenation = kLast < 1,
27  kKorean = kProhibition | kNoHangulWrap,
28  kJapanese = static_cast<std::underlying_type_t<WordWrappingType>>(kProhibition),
29  kChinese = kProhibition | kAsian,
30  kAll = kAsian | kProhibition | kNoHangulWrap
31  };
32 
34  {
35  wchar_t ch; // 0
37  std::uint8_t pad3; // 3
38  };
39  static_assert(sizeof(CharBreakInfo) == 0x4);
40 
41  static bool FindCharWithFlags(WordWrappingType a_wwMode, wchar_t a_ch, BreakInfoFlags a_charBreakFlags);
42  static bool IsAsianChar(WordWrappingType a_wwMode, wchar_t a_ch);
43  static bool IsNonStartingChar(WordWrappingType a_wwMode, wchar_t a_ch);
44  static bool IsNonTerminatingChar(WordWrappingType a_wwMode, wchar_t a_ch);
45  static bool IsWhiteSpaceChar(wchar_t a_ch);
46  static bool IsLineFeedChar(wchar_t a_ch);
47  static bool IsLineBreakOpportunityAt(WordWrappingType a_wwMode, const wchar_t* a_wstr, UPInt a_index);
48  static bool IsLineBreakOpportunityAt(WordWrappingType a_wwMode, wchar_t a_prevChar, wchar_t a_curChar);
49  static UPInt FindNextNonWhiteSpace(const wchar_t* a_wstr, UPInt a_pos, UPInt a_maxPos);
50  static UPInt FindPrevNonWhiteSpace(const wchar_t* a_wstr, UPInt a_pos);
51  static bool IsVowel(wchar_t a_ch);
52  static UPInt FindWordWrapPos(WordWrappingType a_wwMode, UPInt a_wordWrapPos, const wchar_t* a_paraText, UPInt a_paraLen, UPInt a_lineStartPos, UPInt a_lineLen);
53 
54  static inline CharBreakInfo charBreakInfoArray[] = {
55  { 0x2010, BreakInfoFlags::kNonStartingChar, 0 },
56  { 0x2012, BreakInfoFlags::kNonStartingChar, 0 },
57  { 0x2013, BreakInfoFlags::kNonStartingChar, 0 },
58  { 0x2014, BreakInfoFlags::kNonStartingChar, 0 },
60  { 0x2019, BreakInfoFlags::kNonStartingChar, 0 },
62  { 0x201D, BreakInfoFlags::kNonStartingChar, 0 },
63  { 0x2024, BreakInfoFlags::kNonStartingChar, 0 },
64  { 0x2025, BreakInfoFlags::kNonStartingChar, 0 },
65  { 0x2026, BreakInfoFlags::kNonStartingChar, 0 },
66  { 0x2027, BreakInfoFlags::kNonStartingChar, 0 },
67  { 0x2032, BreakInfoFlags::kNonStartingChar, 0 },
68  { 0x2033, BreakInfoFlags::kNonStartingChar, 0 },
71  { 0x2103, BreakInfoFlags::kNonStartingChar, 0 },
72  { 0x2109, BreakInfoFlags::kNonStartingChar, 0 },
76  { 0x2122, BreakInfoFlags::kNonStartingChar, 0 },
77  { 0x2574, BreakInfoFlags::kNonStartingChar, 0 },
79  { 0x3001, BreakInfoFlags::kNonStartingChar, 0 },
80  { 0x3002, BreakInfoFlags::kNonStartingChar, 0 },
81  { 0x3005, BreakInfoFlags::kNonStartingChar, 0 },
83  { 0x3009, BreakInfoFlags::kNonStartingChar, 0 },
85  { 0x300B, BreakInfoFlags::kNonStartingChar, 0 },
87  { 0x300D, BreakInfoFlags::kNonStartingChar, 0 },
89  { 0x300F, BreakInfoFlags::kNonStartingChar, 0 },
91  { 0x3011, BreakInfoFlags::kNonStartingChar, 0 },
94  { 0x3015, BreakInfoFlags::kNonStartingChar, 0 },
95  { 0x301C, BreakInfoFlags::kNonStartingChar, 0 },
97  { 0x301E, BreakInfoFlags::kNonStartingChar, 0 },
98  { 0x301F, BreakInfoFlags::kNonStartingChar, 0 },
99  { 0x3041, BreakInfoFlags::kNonStartingChar, 0 },
100  { 0x3043, BreakInfoFlags::kNonStartingChar, 0 },
101  { 0x3045, BreakInfoFlags::kNonStartingChar, 0 },
102  { 0x3047, BreakInfoFlags::kNonStartingChar, 0 },
103  { 0x3049, BreakInfoFlags::kNonStartingChar, 0 },
104  { 0x3063, BreakInfoFlags::kNonStartingChar, 0 },
105  { 0x3083, BreakInfoFlags::kNonStartingChar, 0 },
106  { 0x3085, BreakInfoFlags::kNonStartingChar, 0 },
107  { 0x3087, BreakInfoFlags::kNonStartingChar, 0 },
108  { 0x308E, BreakInfoFlags::kNonStartingChar, 0 },
109  { 0x309B, BreakInfoFlags::kNonStartingChar, 0 },
110  { 0x309C, BreakInfoFlags::kNonStartingChar, 0 },
111  { 0x309D, BreakInfoFlags::kNonStartingChar, 0 },
112  { 0x309E, BreakInfoFlags::kNonStartingChar, 0 },
113  { 0x30A1, BreakInfoFlags::kNonStartingChar, 0 },
114  { 0x30A3, BreakInfoFlags::kNonStartingChar, 0 },
115  { 0x30A5, BreakInfoFlags::kNonStartingChar, 0 },
116  { 0x30A7, BreakInfoFlags::kNonStartingChar, 0 },
117  { 0x30A9, BreakInfoFlags::kNonStartingChar, 0 },
118  { 0x30C3, BreakInfoFlags::kNonStartingChar, 0 },
119  { 0x30E3, BreakInfoFlags::kNonStartingChar, 0 },
120  { 0x30E5, BreakInfoFlags::kNonStartingChar, 0 },
121  { 0x30E7, BreakInfoFlags::kNonStartingChar, 0 },
122  { 0x30EE, BreakInfoFlags::kNonStartingChar, 0 },
123  { 0x30F5, BreakInfoFlags::kNonStartingChar, 0 },
124  { 0x30F6, BreakInfoFlags::kNonStartingChar, 0 },
125  { 0x30FB, BreakInfoFlags::kNonStartingChar, 0 },
126  { 0x30FC, BreakInfoFlags::kNonStartingChar, 0 },
127  { 0x30FD, BreakInfoFlags::kNonStartingChar, 0 },
128  { 0x30FE, BreakInfoFlags::kNonStartingChar, 0 },
129  { 0x0FDFC, BreakInfoFlags::kNonStartingChar, 0 },
130  { 0x0FE50, BreakInfoFlags::kNonStartingChar, 0 },
131  { 0x0FE51, BreakInfoFlags::kNonStartingChar, 0 },
132  { 0x0FE52, BreakInfoFlags::kNonStartingChar, 0 },
133  { 0x0FE54, BreakInfoFlags::kNonStartingChar, 0 },
134  { 0x0FE55, BreakInfoFlags::kNonStartingChar, 0 },
135  { 0x0FE56, BreakInfoFlags::kNonStartingChar, 0 },
136  { 0x0FE57, BreakInfoFlags::kNonStartingChar, 0 },
137  { 0x0FE59, BreakInfoFlags::kNonTerminatingChar, 0 },
138  { 0x0FE5A, BreakInfoFlags::kNonStartingChar, 0 },
139  { 0x0FE5B, BreakInfoFlags::kNonTerminatingChar, 0 },
140  { 0x0FE5C, BreakInfoFlags::kNonStartingChar, 0 },
141  { 0x0FE5D, BreakInfoFlags::kNonTerminatingChar, 0 },
142  { 0x0FE5E, BreakInfoFlags::kNonStartingChar, 0 },
143  { 0x0FE6A, BreakInfoFlags::kNonStartingChar, 0 },
144  { 0x0FF01, BreakInfoFlags::kNonStartingChar, 0 },
145  { 0x0FF04, BreakInfoFlags::kNonTerminatingChar, 0 },
146  { 0x0FF05, BreakInfoFlags::kNonStartingChar, 0 },
147  { 0x0FF08, BreakInfoFlags::kNonTerminatingChar, 0 },
148  { 0x0FF09, BreakInfoFlags::kNonStartingChar, 0 },
149  { 0x0FF0C, BreakInfoFlags::kNonStartingChar, 0 },
150  { 0x0FF0E, BreakInfoFlags::kNonStartingChar, 0 },
151  { 0x0FF1A, BreakInfoFlags::kNonStartingChar, 0 },
152  { 0x0FF1B, BreakInfoFlags::kNonStartingChar, 0 },
153  { 0x0FF1F, BreakInfoFlags::kNonStartingChar, 0 },
154  { 0x0FF20, BreakInfoFlags::kNonTerminatingChar, 0 },
155  { 0x0FF3B, BreakInfoFlags::kNonTerminatingChar, 0 },
156  { 0x0FF3D, BreakInfoFlags::kNonStartingChar, 0 },
157  { 0x0FF5B, BreakInfoFlags::kNonTerminatingChar, 0 },
158  { 0x0FF5D, BreakInfoFlags::kNonStartingChar, 0 },
159  { 0x0FF61, BreakInfoFlags::kNonStartingChar, 0 },
160  { 0x0FF64, BreakInfoFlags::kNonStartingChar, 0 },
161  { 0x0FFE0, BreakInfoFlags::kAll, 0 },
162  { 0x0FFE1, BreakInfoFlags::kNonTerminatingChar, 0 },
163  { 0x0FFE5, BreakInfoFlags::kNonTerminatingChar, 0 },
165  };
166  };
167  static_assert(sizeof(GFxWWHelper) == 0x1);
168 }
Definition: GFxWWHelper.h:6
static bool IsAsianChar(WordWrappingType a_wwMode, wchar_t a_ch)
static bool IsNonTerminatingChar(WordWrappingType a_wwMode, wchar_t a_ch)
BreakInfoFlags
Definition: GFxWWHelper.h:9
static UPInt FindPrevNonWhiteSpace(const wchar_t *a_wstr, UPInt a_pos)
static UPInt FindNextNonWhiteSpace(const wchar_t *a_wstr, UPInt a_pos, UPInt a_maxPos)
static bool IsVowel(wchar_t a_ch)
static bool IsNonStartingChar(WordWrappingType a_wwMode, wchar_t a_ch)
WordWrappingType
Definition: GFxWWHelper.h:18
static bool IsWhiteSpaceChar(wchar_t a_ch)
static CharBreakInfo charBreakInfoArray[]
Definition: GFxWWHelper.h:54
static bool IsLineBreakOpportunityAt(WordWrappingType a_wwMode, const wchar_t *a_wstr, UPInt a_index)
static bool IsLineBreakOpportunityAt(WordWrappingType a_wwMode, wchar_t a_prevChar, wchar_t a_curChar)
static bool FindCharWithFlags(WordWrappingType a_wwMode, wchar_t a_ch, BreakInfoFlags a_charBreakFlags)
static UPInt FindWordWrapPos(WordWrappingType a_wwMode, UPInt a_wordWrapPos, const wchar_t *a_paraText, UPInt a_paraLen, UPInt a_lineStartPos, UPInt a_lineLen)
static bool IsLineFeedChar(wchar_t a_ch)
Definition: AbsorbEffect.h:6
std::size_t UPInt
Definition: SFTypes.h:5
Definition: GFxWWHelper.h:34
std::uint8_t pad3
Definition: GFxWWHelper.h:37
wchar_t ch
Definition: GFxWWHelper.h:35
REX::EnumSet< BreakInfoFlags, std::uint8_t > flags
Definition: GFxWWHelper.h:36