17 void setMin(T& _var,
const T& _newValue)
24 void setMax(T& _var,
const T& _newValue)
46 space_point = _space_point;
62 float getWidth()
const
68 size_t getCount()
const
74 size_t getPosition()
const
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;
132 for (; index != end; ++index)
134 Char character = *index;
149 line_info.
width = (int)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.
simbols.size(), index, count, width);
217 roll_back.set(line_info.
simbols.size(), index, count, width);
220 float char_width = info->
width;
221 float char_height = info->
height;
222 float char_advance = info->
advance;
223 float char_bearingX = info->
bearingX;
224 float char_bearingY = info->
bearingY;
226 if (_height != font_height)
228 float scale = (float)_height / font_height;
231 char_height *= scale;
232 char_advance *= scale;
233 char_bearingX *= scale;
234 char_bearingY *= scale;
237 float char_fullAdvance = char_bearingX + char_advance;
241 && (width + char_fullAdvance) > _maxWidth
242 && !roll_back.empty())
245 width = roll_back.getWidth();
246 count = roll_back.getCount();
247 index = roll_back.getTextIter();
248 line_info.
simbols.erase(line_info.
simbols.begin() + roll_back.getPosition(), line_info.
simbols.end());
251 line_info.
width = (int)ceil(width);
252 line_info.
count = count;
253 mLength += line_info.
count + 1;
260 mLineInfo.push_back(line_info);
269 line_info.
simbols.push_back(
CharInfo(info->
uvRect, char_width, char_height, char_advance, char_bearingX, char_bearingY));
270 width += char_fullAdvance;
274 line_info.
width = (int)ceil(width);
275 line_info.
count = count;
276 mLength += line_info.
count;
278 mLineInfo.push_back(line_info);
283 for (VectorLineInfo::iterator line = mLineInfo.begin(); line != mLineInfo.end(); ++line)
286 line->offset = result.
width - line->width;
288 line->offset = (result.
width - line->width) / 2;
296 const int height = mFontHeight;
300 for (VectorLineInfo::const_iterator line = mLineInfo.begin(); line != mLineInfo.end(); ++line)
303 bool lastline = !(line + 1 != mLineInfo.end());
306 if (top + height > _value.
top || lastline)
309 float left = (float)line->offset;
313 for (VectorCharInfo::const_iterator sim = line->simbols.begin(); sim != line->simbols.end(); ++sim)
318 float fullAdvance = sim->getAdvance() + sim->getBearingX();
319 if (left + fullAdvance / 2.0f > _value.
left)
334 result += line->count + 1;
343 setMin(_position, mLength);
348 for (VectorLineInfo::const_iterator line = mLineInfo.begin(); line != mLineInfo.end(); ++line)
350 left = (float)line->offset;
351 if (position + line->count >= _position)
353 for (VectorCharInfo::const_iterator sim = line->simbols.begin(); sim != line->simbols.end(); ++sim)
358 if (position == _position)
362 left += sim->getBearingX() + sim->getAdvance();
366 position += line->count + 1;