98 mFontHeight = _height;
101 static const char convert_colour[64] = {
102 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0,
103 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0};
107 RollBackPoint roll_back;
116 UString::utf32string::const_iterator end = _text.end();
117 UString::utf32string::const_iterator index = _text.begin();
124 for (; index != end; ++index)
126 Char character = *index;
133 UString::utf32string::const_iterator peeki = index;
139 line_info.
width = (int)std::ceil(width);
140 line_info.
count = count;
141 mLength += line_info.
count + 1;
148 mLineInfo.push_back(line_info);
156 if (character == L
'#')
168 if (character != L
'#')
171 uint32 colour = convert_colour[(character - 48) & 0x3F];
174 for (
char i = 0; i < 5; i++)
183 colour += convert_colour[((*index) - 48) & 0x3F];
189 line_info.
symbols.emplace_back(colour);
202 roll_back.set(line_info.
symbols.size(), index, count, width);
205 float char_width = info->
width;
206 float char_height = info->
height;
207 float char_advance = info->
advance;
208 float char_bearingX = info->
bearingX;
209 float char_bearingY = info->
bearingY;
211 if (_height != font_height)
213 float scale = (float)_height / font_height;
216 char_height *= scale;
217 char_advance *= scale;
218 char_bearingX *= scale;
219 char_bearingY *= scale;
222 float char_fullAdvance = char_bearingX + char_advance;
225 if (_maxWidth != -1 && (width + char_fullAdvance) > _maxWidth)
227 if (!roll_back.empty())
230 width = roll_back.getWidth();
231 count = roll_back.getCount();
232 index = roll_back.getTextIter();
233 line_info.
symbols.erase(line_info.
symbols.begin() + roll_back.getPosition(), line_info.
symbols.end());
237 line_info.
width = (int)std::ceil(width);
238 line_info.
count = count;
239 mLength += line_info.
count + 1;
246 mLineInfo.push_back(line_info);
250 if (!roll_back.empty())
257 .emplace_back(info->
uvRect, char_width, char_height, char_advance, char_bearingX, char_bearingY);
258 width += char_fullAdvance;
262 line_info.
width = (int)std::ceil(width);
263 line_info.
count = count;
264 mLength += line_info.
count;
266 mLineInfo.push_back(line_info);
271 for (
auto& line : mLineInfo)
274 line.offset = result.
width - line.width;
276 line.offset = (result.
width - line.width) / 2;
287 for (VectorLineInfo::const_iterator line = mLineInfo.begin(); line != mLineInfo.end(); ++line)
289 bool lastline = line + 1 == mLineInfo.end();
292 if (top + mFontHeight <= _value.
top && !lastline)
295 result += line->count + 1;
299 float left = (float)line->offset;
303 for (
const auto& sym : line->symbols)
308 float fullAdvance = sym.getAdvance() + sym.getBearingX();
309 if (left + fullAdvance / 2.0f > _value.
left)
size_t getCursorPosition(const IntPoint &_value) const
IntPoint getCursorPoint(size_t _position) const
size_t getTextLength() const
void update(const UString::utf32string &_text, IFont *_font, int _height, Align _align, VertexColourType _format, int _maxWidth=-1)
const VectorLineInfo & getData() const
const IntSize & getViewSize() const
void convertColour(uint32 &_colour, VertexColourType _format)
Convert from 32-bit ARGB to native colour (ABGR or ARGB).