[GUIFontTTF] Fixed rounding X coordinate of a char if it has negative value.
authorAnton Fedchin <afedchin@ruswizards.com>
Mon, 10 Aug 2015 16:06:31 +0000 (19:06 +0300)
committerAnton Fedchin <afedchin@ruswizards.com>
Mon, 10 Aug 2015 16:06:31 +0000 (19:06 +0300)
Now caching font data algorithm allows negative coordinates of vertices. Rounding X coord does not consider negative values and it causes a font blurry in some cases.

xbmc/guilib/GUIFontTTF.cpp

index 2b3bbfe..422bc75 100644 (file)
@@ -839,10 +839,14 @@ void CGUIFontTTFBase::RenderCharacter(float posX, float posY, const Character *c
     float rx3 = (float)MathUtils::round_int(x[3]);
     x[1] = (float)MathUtils::truncate_int(x[1]);
     x[2] = (float)MathUtils::truncate_int(x[2]);
-    if (rx0 > x[0])
+    if (x[0] > 0.0f && rx0 > x[0])
       x[1] += 1;
-    if (rx3 > x[3])
+    else if (x[0] < 0.0f && rx0 < x[0])
+      x[1] -= 1;
+    if (x[3] > 0.0f && rx3 > x[3])
       x[2] += 1;
+    else if (x[3] < 0.0f && rx3 < x[3])
+      x[2] -= 1;
     x[0] = rx0;
     x[3] = rx3;
   }