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 && !roll_back.empty())
228 width = roll_back.getWidth();
229 count = roll_back.getCount();
230 index = roll_back.getTextIter();
231 line_info.
symbols.erase(line_info.
symbols.begin() + roll_back.getPosition(), line_info.
symbols.end());
234 line_info.
width = (int)std::ceil(width);
235 line_info.
count = count;
236 mLength += line_info.
count + 1;
243 mLineInfo.push_back(line_info);
253 .emplace_back(info->
uvRect, char_width, char_height, char_advance, char_bearingX, char_bearingY);
254 width += char_fullAdvance;
258 line_info.
width = (int)std::ceil(width);
259 line_info.
count = count;
260 mLength += line_info.
count;
262 mLineInfo.push_back(line_info);
267 for (
auto& line : mLineInfo)
270 line.offset = result.
width - line.width;
272 line.offset = (result.
width - line.width) / 2;
283 for (VectorLineInfo::const_iterator line = mLineInfo.begin(); line != mLineInfo.end(); ++line)
285 bool lastline = line + 1 == mLineInfo.end();
288 if (top + mFontHeight <= _value.
top && !lastline)
291 result += line->count + 1;
295 float left = (float)line->offset;
299 for (
const auto& sym : line->symbols)
304 float fullAdvance = sym.getAdvance() + sym.getBearingX();
305 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)