Selaa lähdekoodia

Merge pull request #519 from blackberry-gaming/next-ablake

Next ablake
Sean Paul Taylor 13 vuotta sitten
vanhempi
sitoutus
e1b0335552
1 muutettua tiedostoa jossa 17 lisäystä ja 4 poistoa
  1. 17 4
      gameplay/src/Font.cpp

+ 17 - 4
gameplay/src/Font.cpp

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