pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] r3978 - trunk/pingus/src


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3978 - trunk/pingus/src
Date: Thu, 26 Feb 2009 17:07:14 +0100

Author: grumbel
Date: 2009-02-26 17:07:14 +0100 (Thu, 26 Feb 2009)
New Revision: 3978

Modified:
   trunk/pingus/src/font.cpp
   trunk/pingus/src/font.hpp
Log:
Font get_width() returns now float, to avoid rounding errors

Modified: trunk/pingus/src/font.cpp
===================================================================
--- trunk/pingus/src/font.cpp   2009-02-26 14:56:54 UTC (rev 3977)
+++ trunk/pingus/src/font.cpp   2009-02-26 16:07:14 UTC (rev 3978)
@@ -132,7 +132,7 @@
     return size;
   }
 
-  int get_width(uint32_t unicode) const
+  float get_width(uint32_t unicode) const
   {
     if (unicode < glyphs.size() && glyphs[unicode])
       return glyphs[unicode]->advance;
@@ -140,7 +140,7 @@
       return 0;
   }
 
-  int  get_width(const std::string& text) const
+  float get_width(const std::string& text) const
   {
     float width = 0.0f;
     float last_width = 0;
@@ -158,7 +158,7 @@
             width += get_width(unicode) + char_spacing;
           }
       }
-    return int(std::max(width, last_width));
+    return std::max(width, last_width);
   }
 
   Size get_size(const std::string& text) const
@@ -204,7 +204,7 @@
     return 0;
 }
 
-int
+float
 Font::get_width(uint32_t unicode) const
 {
   if (impl)
@@ -213,7 +213,7 @@
     return 0; 
 }
 
-int
+float
 Font::get_width(const std::string& text) const
 {
   if (impl)

Modified: trunk/pingus/src/font.hpp
===================================================================
--- trunk/pingus/src/font.hpp   2009-02-26 14:56:54 UTC (rev 3977)
+++ trunk/pingus/src/font.hpp   2009-02-26 16:07:14 UTC (rev 3978)
@@ -38,8 +38,8 @@
   void render(Origin origin, int x, int y, const std::string& text, 
Framebuffer& fb);
 
   int  get_height() const;
-  int  get_width(uint32_t unicode) const;
-  int  get_width(const std::string& text) const;
+  float get_width(uint32_t unicode) const;
+  float get_width(const std::string& text) const;
   Size get_size(const std::string& text) const;
   Rect bounding_rect(int , int, const std::string& str) const;
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]