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);
167 else if (character == L
'#')
179 if (character != L
'#')
182 uint32 colour = convert_colour[(character - 48) & 0x3F];
185 for (
char i = 0; i < 5; i++)
194 colour += convert_colour[ ((*index) - 48) & 0x3F ];
213 roll_back.set(line_info.
symbols.size(), index, count, width);
216 float char_width = info->
width;
217 float char_height = info->
height;
218 float char_advance = info->
advance;
219 float char_bearingX = info->
bearingX;
220 float char_bearingY = info->
bearingY;
222 if (_height != font_height)
224 float scale = (float)_height / font_height;
227 char_height *= scale;
228 char_advance *= scale;
229 char_bearingX *= scale;
230 char_bearingY *= scale;
233 float char_fullAdvance = char_bearingX + char_advance;
237 && (width + char_fullAdvance) > _maxWidth
238 && !roll_back.empty())
241 width = roll_back.getWidth();
242 count = roll_back.getCount();
243 index = roll_back.getTextIter();
244 line_info.
symbols.erase(line_info.
symbols.begin() + roll_back.getPosition(), line_info.
symbols.end());
247 line_info.
width = (int)std::ceil(width);
248 line_info.
count = count;
249 mLength += line_info.
count + 1;
256 mLineInfo.push_back(line_info);
265 line_info.
symbols.push_back(
CharInfo(info->
uvRect, char_width, char_height, char_advance, char_bearingX, char_bearingY));
266 width += char_fullAdvance;
270 line_info.
width = (int)std::ceil(width);
271 line_info.
count = count;
272 mLength += line_info.
count;
274 mLineInfo.push_back(line_info);
279 for (VectorLineInfo::iterator line = mLineInfo.begin(); line != mLineInfo.end(); ++line)
282 line->offset = result.
width - line->width;
284 line->offset = (result.
width - line->width) / 2;
295 for (VectorLineInfo::const_iterator line = mLineInfo.begin(); line != mLineInfo.end(); ++line)
297 bool lastline = line + 1 == mLineInfo.end();
300 if (top + mFontHeight <= _value.
top && !lastline)
303 result += line->count + 1;
307 float left = (float)line->offset;
311 for (
const auto& sim : line->symbols)
316 float fullAdvance = sim.getAdvance() + sim.getBearingX();
317 if (left + fullAdvance / 2.0f > _value.
left)
335 setMin(_position, mLength);
340 for (VectorLineInfo::const_iterator line = mLineInfo.begin(); line != mLineInfo.end(); ++line)
342 left = (float)line->offset;
343 if (position + line->count >= _position)
345 for (VectorCharInfo::const_iterator sim = line->symbols.begin(); sim != line->symbols.end(); ++sim)
350 if (position == _position)
354 left += sim->getBearingX() + sim->getAdvance();
358 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)
std::vector< LineInfo > VectorLineInfo
types::TPoint< int > IntPoint