17 void setMin(T& _var,
const T& _newValue)
24 void setMax(T& _var,
const T& _newValue)
43 void set(
size_t _position,
const UString::utf32string::const_iterator& _space_point,
size_t _count,
float _width)
46 space_point = _space_point;
62 float getWidth()
const
68 size_t getCount()
const
74 size_t getPosition()
const
80 UString::utf32string::const_iterator getTextIter()
const
88 UString::utf32string::const_iterator space_point;
102 mFontHeight = _height;
105 static const char convert_colour[64] =
107 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0,
108 0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0,
109 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
110 0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0
115 RollBackPoint roll_back;
124 UString::utf32string::const_iterator end = _text.end();
125 UString::utf32string::const_iterator index = _text.begin();
132 for (; index != end; ++index)
134 Char character = *index;
143 UString::utf32string::const_iterator peeki = index;
149 line_info.
width = (int)std::ceil(width);
150 line_info.
count = count;
151 mLength += line_info.
count + 1;
158 mLineInfo.push_back(line_info);
166 else if (character == L
'#')
178 if (character != L
'#')
181 uint32 colour = convert_colour[(character - 48) & 0x3F];
184 for (
char i = 0; i < 5; i++)
193 colour += convert_colour[ ((*index) - 48) & 0x3F ];
212 roll_back.set(line_info.
symbols.size(), index, count, width);
215 float char_width = info->
width;
216 float char_height = info->
height;
217 float char_advance = info->
advance;
218 float char_bearingX = info->
bearingX;
219 float char_bearingY = info->
bearingY;
221 if (_height != font_height)
223 float scale = (float)_height / font_height;
226 char_height *= scale;
227 char_advance *= scale;
228 char_bearingX *= scale;
229 char_bearingY *= scale;
232 float char_fullAdvance = char_bearingX + char_advance;
236 && (width + char_fullAdvance) > _maxWidth
237 && !roll_back.empty())
240 width = roll_back.getWidth();
241 count = roll_back.getCount();
242 index = roll_back.getTextIter();
243 line_info.
symbols.erase(line_info.
symbols.begin() + roll_back.getPosition(), line_info.
symbols.end());
246 line_info.
width = (int)std::ceil(width);
247 line_info.
count = count;
248 mLength += line_info.
count + 1;
255 mLineInfo.push_back(line_info);
264 line_info.
symbols.push_back(
CharInfo(info->
uvRect, char_width, char_height, char_advance, char_bearingX, char_bearingY));
265 width += char_fullAdvance;
269 line_info.
width = (int)std::ceil(width);
270 line_info.
count = count;
271 mLength += line_info.
count;
273 mLineInfo.push_back(line_info);
278 for (VectorLineInfo::iterator line = mLineInfo.begin(); line != mLineInfo.end(); ++line)
281 line->offset = result.
width - line->width;
283 line->offset = (result.
width - line->width) / 2;
294 for (VectorLineInfo::const_iterator line = mLineInfo.begin(); line != mLineInfo.end(); ++line)
296 bool lastline = line + 1 == mLineInfo.end();
299 if (top + mFontHeight <= _value.
top && !lastline)
302 result += line->count + 1;
306 float left = (float)line->offset;
310 for (
const auto& sim : line->symbols)
315 float fullAdvance = sim.getAdvance() + sim.getBearingX();
316 if (left + fullAdvance / 2.0f > _value.
left)
334 setMin(_position, mLength);
339 for (VectorLineInfo::const_iterator line = mLineInfo.begin(); line != mLineInfo.end(); ++line)
341 left = (float)line->offset;
342 if (position + line->count >= _position)
344 for (VectorCharInfo::const_iterator sim = line->symbols.begin(); sim != line->symbols.end(); ++sim)
349 if (position == _position)
353 left += sim->getBearingX() + sim->getAdvance();
357 position += line->count + 1;
#define MYGUI_DEBUG_ASSERT(exp, dest)
virtual int getDefaultHeight() const =0
virtual const GlyphInfo * getGlyphInfo(Char _id) const =0
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
std::basic_string< unicode_char > utf32string
string type used for returning UTF-32 formatted data
void convertColour(uint32 &_colour, VertexColourType _format)
Convert from 32-bit ARGB to native colour (ABGR or ARGB)
std::vector< LineInfo > VectorLineInfo
types::TPoint< int > IntPoint