|
@@ -751,12 +751,19 @@ void Font::measureText(const char* text, unsigned int size, unsigned int* width,
|
|
|
GP_ASSERT(width);
|
|
GP_ASSERT(width);
|
|
|
GP_ASSERT(height);
|
|
GP_ASSERT(height);
|
|
|
|
|
|
|
|
- float scale = (float)size / _size;
|
|
|
|
|
const int length = strlen(text);
|
|
const int length = strlen(text);
|
|
|
|
|
+ if (length == 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ *width = 0;
|
|
|
|
|
+ *height = 0;
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ float scale = (float)size / _size;
|
|
|
const char* token = text;
|
|
const char* token = text;
|
|
|
|
|
|
|
|
*width = 0;
|
|
*width = 0;
|
|
|
- *height = 0;
|
|
|
|
|
|
|
+ *height = size;
|
|
|
|
|
|
|
|
// Measure a line at a time.
|
|
// Measure a line at a time.
|
|
|
while (token[0] != 0)
|
|
while (token[0] != 0)
|
|
@@ -784,6 +791,12 @@ void Font::measureText(const char* text, const Rectangle& clip, unsigned int siz
|
|
|
GP_ASSERT(text);
|
|
GP_ASSERT(text);
|
|
|
GP_ASSERT(out);
|
|
GP_ASSERT(out);
|
|
|
|
|
|
|
|
|
|
+ if (strlen(text) == 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ out->set(0, 0, 0, 0);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
float scale = (float)size / _size;
|
|
float scale = (float)size / _size;
|
|
|
Justify vAlign = static_cast<Justify>(justify & 0xF0);
|
|
Justify vAlign = static_cast<Justify>(justify & 0xF0);
|
|
|
if (vAlign == 0)
|
|
if (vAlign == 0)
|
|
@@ -802,8 +815,8 @@ void Font::measureText(const char* text, const Rectangle& clip, unsigned int siz
|
|
|
std::vector<Vector2> lines;
|
|
std::vector<Vector2> lines;
|
|
|
|
|
|
|
|
unsigned int lineWidth = 0;
|
|
unsigned int lineWidth = 0;
|
|
|
- int yPos = clip.y;
|
|
|
|
|
- const float viewportHeight = clip.height - size;
|
|
|
|
|
|
|
+ int yPos = clip.y + size;
|
|
|
|
|
+ const float viewportHeight = clip.height;
|
|
|
|
|
|
|
|
if (wrap)
|
|
if (wrap)
|
|
|
{
|
|
{
|