pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r4049 - in trunk/pingus/src: engine/display pingus pingus/c


From: grumbel at BerliOS
Subject: [Pingus-CVS] r4049 - in trunk/pingus/src: engine/display pingus pingus/components pingus/screens pingus/worldmap
Date: Fri, 6 Nov 2009 01:19:52 +0100

Author: grumbel
Date: 2009-11-06 01:19:48 +0100 (Fri, 06 Nov 2009)
New Revision: 4049

Added:
   trunk/pingus/src/engine/display/font.cpp
   trunk/pingus/src/engine/display/font.hpp
   trunk/pingus/src/engine/display/font_description.cpp
   trunk/pingus/src/engine/display/font_description.hpp
Removed:
   trunk/pingus/src/pingus/font.cpp
   trunk/pingus/src/pingus/font.hpp
   trunk/pingus/src/pingus/font_description.cpp
   trunk/pingus/src/pingus/font_description.hpp
Modified:
   trunk/pingus/src/engine/display/drawing_context.cpp
   trunk/pingus/src/pingus/capture_rectangle.hpp
   trunk/pingus/src/pingus/components/action_button.hpp
   trunk/pingus/src/pingus/components/label.hpp
   trunk/pingus/src/pingus/components/menu_button.hpp
   trunk/pingus/src/pingus/components/pingus_counter.hpp
   trunk/pingus/src/pingus/components/time_display.hpp
   trunk/pingus/src/pingus/fonts.hpp
   trunk/pingus/src/pingus/resource.cpp
   trunk/pingus/src/pingus/resource.hpp
   trunk/pingus/src/pingus/screens/credits.hpp
   trunk/pingus/src/pingus/screens/font_test_screen.cpp
   trunk/pingus/src/pingus/screens/font_test_screen.hpp
   trunk/pingus/src/pingus/string_format.cpp
   trunk/pingus/src/pingus/worldmap/level_dot.cpp
Log:
Moved Font to src/engine/display/


Modified: trunk/pingus/src/engine/display/drawing_context.cpp
===================================================================
--- trunk/pingus/src/engine/display/drawing_context.cpp 2009-11-06 00:10:50 UTC 
(rev 4048)
+++ trunk/pingus/src/engine/display/drawing_context.cpp 2009-11-06 00:19:48 UTC 
(rev 4049)
@@ -23,7 +23,7 @@
 #include "engine/display/framebuffer.hpp"
 #include "engine/display/display.hpp"
 #include "engine/display/sprite.hpp"
-#include "pingus/font.hpp"
+#include "engine/display/font.hpp"
 #include "math/origin.hpp"
 
 struct DrawingRequestsSorter

Copied: trunk/pingus/src/engine/display/font.cpp (from rev 4047, 
trunk/pingus/src/pingus/font.cpp)
===================================================================
--- trunk/pingus/src/pingus/font.cpp    2009-11-06 00:02:11 UTC (rev 4047)
+++ trunk/pingus/src/engine/display/font.cpp    2009-11-06 00:19:48 UTC (rev 
4049)
@@ -0,0 +1,253 @@
+//  Pingus - A free Lemmings clone
+//  Copyright (C) 2005 Ingo Ruhnke <address@hidden>
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//  
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//  
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+#include "engine/display/font.hpp"
+
+#include <iostream>
+#include <vector>
+#include <map>
+#include "SDL.h"
+#include "SDL_image.h"
+#include "engine/display/surface.hpp"
+#include "util/line_iterator.hpp"
+#include "util/utf8.hpp"
+#include "engine/display/font_description.hpp"
+#include "engine/display/framebuffer.hpp"
+#include "engine/display/display.hpp"
+
+class FontImpl
+{
+public:
+  std::vector<FramebufferSurface> framebuffer_surfaces;
+  typedef std::vector<GlyphDescription*> Glyphs;
+  Glyphs glyphs;
+  int    space_length;
+  float  char_spacing;
+  float  vertical_spacing;
+  int    size;
+  
+  FontImpl(const FontDescription& desc) :
+    framebuffer_surfaces(),
+    glyphs(),
+    space_length(),
+    char_spacing(desc.char_spacing),
+    vertical_spacing(),
+    size(desc.size)
+  {
+    vertical_spacing = static_cast<float>(size) * desc.vertical_spacing;
+   
+    glyphs.resize(65536, 0); // 16bit ought to be enough for everybody
+
+    // Copyh Unicode -> Glyph mapping 
+    for(std::vector<GlyphImageDescription>::size_type j = 0; j < 
desc.images.size(); ++j)
+      {
+        
framebuffer_surfaces.push_back(Display::get_framebuffer().create_surface(Surface(desc.images[j].pathname)));
+
+        if (!framebuffer_surfaces.back())
+          {
+            std::cout << "IMG: " << desc.images[j].pathname.str() << std::endl;
+            assert(false);
+          }
+
+        for(std::vector<GlyphDescription>::const_iterator i = 
desc.images[j].glyphs.begin();
+            i != desc.images[j].glyphs.end();
+            ++i)
+          {
+            if (i->unicode < glyphs.size())
+              {
+                if (glyphs[i->unicode] == 0)
+                  {
+                    glyphs[i->unicode] = new GlyphDescription(*i);
+                    glyphs[i->unicode]->image = framebuffer_surfaces.size()-1;
+                  }
+                else
+                  {
+                    std::cout << "Warning: unicode collision on " << 
i->unicode << std::endl;
+                  }            
+              }
+            else
+              {
+                std::cout << "Warning: unicode out of range: " << i->unicode 
<< std::endl;
+              }
+          }
+      }
+  }
+
+  ~FontImpl()
+  {
+    for(Glyphs::iterator i = glyphs.begin(); i != glyphs.end(); ++i)
+      {
+        delete *i;
+      }
+  }
+
+  void render(Origin origin, int x, int y_, const std::string& text, 
Framebuffer& fb)
+  {
+    y_ += get_height();
+
+    float y = float(y_);
+    // FIXME: only origins top_left, top_right and top_center do work right now
+    LineIterator it(text);
+    while(it.next()) {
+      render_line(origin, x, int(y), it.get(), fb);
+      y += vertical_spacing;
+    }
+  }
+
+  void render_line(Origin origin, int x, int y, const std::string& text, 
Framebuffer& fb)
+  {
+    Vector2i offset = calc_origin(origin, get_size(text));
+
+    float dstx = float(x - offset.x);
+    float dsty = float(y - offset.y);
+    
+    UTF8::iterator i(text);
+    while(i.next())
+      {
+        const uint32_t& unicode = *i;
+
+        if (unicode < glyphs.size() && glyphs[unicode])
+          {
+            const GlyphDescription& glyph = *glyphs[unicode];
+            fb.draw_surface(framebuffer_surfaces[glyph.image],
+                            glyph.rect, Vector2i(static_cast<int>(dstx), 
static_cast<int>(dsty)) + glyph.offset);
+            dstx += static_cast<float>(glyph.advance) + char_spacing;
+          }
+        else
+          {
+            // Draw placeholder char and issue a warning
+          }
+      }
+  }
+
+  int get_height() const
+  {
+    return size;
+  }
+
+  float get_width(uint32_t unicode) const
+  {
+    if (unicode < glyphs.size() && glyphs[unicode])
+      return static_cast<float>(glyphs[unicode]->advance);
+    else
+      return 0;
+  }
+
+  float get_width(const std::string& text) const
+  {
+    float width = 0.0f;
+    float last_width = 0;
+    
+    UTF8::iterator i(text);
+    while(i.next())
+      {
+        const uint32_t& unicode = *i;
+
+        if (unicode == '\n')
+          {
+            last_width = std::max(last_width, width);
+            width = 0;
+          }
+        else
+          {
+            width += get_width(unicode) + char_spacing;
+          }
+      }
+
+    return std::max(width, last_width);
+  }
+
+  Size get_size(const std::string& text) const
+  {
+    return Size(get_width(text), get_height());
+  }
+
+  Rect bounding_rect(int x, int y, const std::string& str) const
+  {
+    return Rect(Vector2i(x, y), get_size(str));
+  }
+};
+
+Font::Font() :
+  impl()
+{
+}
+
+Font::Font(const FontDescription& desc) :
+  impl(new FontImpl(desc))
+{
+}
+
+void
+Font::render(int x, int y, const std::string& text, Framebuffer& fb)
+{
+  if (impl)
+    impl->render(origin_top_left, x,y,text, fb);
+}
+
+void
+Font::render(Origin origin, int x, int y, const std::string& text, 
Framebuffer& fb)
+{
+  if (impl)
+    impl->render(origin, x,y,text, fb); 
+}
+
+int
+Font::get_height() const
+{
+  if (impl)
+    return impl->get_height();
+  else
+    return 0;
+}
+
+float
+Font::get_width(uint32_t unicode) const
+{
+  if (impl)
+    return impl->get_width(unicode);
+  else
+    return 0; 
+}
+
+float
+Font::get_width(const std::string& text) const
+{
+  if (impl)
+    return impl->get_width(text);
+  else
+    return 0;  
+}
+
+Size
+Font::get_size(const std::string& str) const
+{
+  if (impl)
+    return impl->get_size(str);
+  else
+    return Size(); 
+}
+
+Rect
+Font::bounding_rect(int x, int y, const std::string& str) const
+{
+  if (impl)
+    return impl->bounding_rect(x, y, str);
+  else
+    return Rect();
+}
+
+/* EOF */

Copied: trunk/pingus/src/engine/display/font.hpp (from rev 4037, 
trunk/pingus/src/pingus/font.hpp)

Copied: trunk/pingus/src/engine/display/font_description.cpp (from rev 4037, 
trunk/pingus/src/pingus/font_description.cpp)
===================================================================
--- trunk/pingus/src/pingus/font_description.cpp        2009-11-05 19:22:47 UTC 
(rev 4037)
+++ trunk/pingus/src/engine/display/font_description.cpp        2009-11-06 
00:19:48 UTC (rev 4049)
@@ -0,0 +1,93 @@
+//  Pingus - A free Lemmings clone
+//  Copyright (C) 2005 Ingo Ruhnke <address@hidden>
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//  
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//  
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+#include "engine/display/font_description.hpp"
+
+#include "pingus/pingus_error.hpp"
+#include "util/file_reader.hpp"
+
+GlyphDescription::GlyphDescription() :
+  image(0), 
+  unicode(0), 
+  offset(),
+  advance(0),
+  rect()
+{  
+}
+
+GlyphDescription::GlyphDescription(FileReader& reader) :
+  image(0), 
+  unicode(0), 
+  offset(),
+  advance(0),
+  rect()
+{
+  int lazy = 0; // FIXME: implement read_uint32
+  reader.read_int("unicode", lazy);
+  unicode = lazy;
+  reader.read_vector2i("offset",  offset);
+  reader.read_int("advance", advance);
+  reader.read_rect("rect",   rect);
+}
+
+FontDescription::FontDescription(const Pathname& pathname_) :
+  pathname(pathname_),
+  char_spacing(),
+  vertical_spacing(),
+  size(),
+  images()
+{
+  char_spacing     = 1.0f;
+  vertical_spacing = 1.0f;
+
+  FileReader reader = FileReader::parse(pathname);
+
+  if (reader.get_name() != "pingus-font")
+    {
+      PingusError::raise("FontDescription: not a pingus-font file");
+    }
+  else
+    {
+      reader.read_float("char-spacing",     char_spacing);
+      reader.read_float("vertical-spacing", vertical_spacing);
+      reader.read_int("size",               size);
+
+      FileReader images_reader;
+      if (reader.read_section("images", images_reader))
+        {
+          std::vector<FileReader> images_lst = images_reader.get_sections();
+
+          for(std::vector<FileReader>::iterator i = images_lst.begin(); i != 
images_lst.end(); ++i)
+            {
+              GlyphImageDescription image_desc;
+              i->read_path("filename",             image_desc.pathname);
+      
+              FileReader glyph_section;
+              if (i->read_section("glyphs", glyph_section))
+                {
+                  std::vector<FileReader> glyph_reader = 
glyph_section.get_sections();
+                  for(std::vector<FileReader>::iterator j = 
glyph_reader.begin(); j != glyph_reader.end(); ++j)
+                    {
+                      image_desc.glyphs.push_back(GlyphDescription(*j));
+                    }
+                }
+              images.push_back(image_desc);
+            }
+        }
+    }
+}
+
+/* EOF */

Copied: trunk/pingus/src/engine/display/font_description.hpp (from rev 4037, 
trunk/pingus/src/pingus/font_description.hpp)

Modified: trunk/pingus/src/pingus/capture_rectangle.hpp
===================================================================
--- trunk/pingus/src/pingus/capture_rectangle.hpp       2009-11-06 00:10:50 UTC 
(rev 4048)
+++ trunk/pingus/src/pingus/capture_rectangle.hpp       2009-11-06 00:19:48 UTC 
(rev 4049)
@@ -17,7 +17,7 @@
 #ifndef HEADER_PINGUS_PINGUS_CAPTURE_RECTANGLE_HPP
 #define HEADER_PINGUS_PINGUS_CAPTURE_RECTANGLE_HPP
 
-#include "pingus/font.hpp"
+#include "engine/display/font.hpp"
 #include "engine/display/sprite.hpp"
 
 class Font;

Modified: trunk/pingus/src/pingus/components/action_button.hpp
===================================================================
--- trunk/pingus/src/pingus/components/action_button.hpp        2009-11-06 
00:10:50 UTC (rev 4048)
+++ trunk/pingus/src/pingus/components/action_button.hpp        2009-11-06 
00:19:48 UTC (rev 4049)
@@ -18,7 +18,7 @@
 #define HEADER_PINGUS_COMPONENTS_ACTION_BUTTON_HPP
 
 #include <string>
-#include "pingus/font.hpp"
+#include "engine/display/font.hpp"
 #include "pingus/pingu_enums.hpp"
 #include "pingus/state_sprite.hpp"
 #include "engine/gui/component.hpp"

Modified: trunk/pingus/src/pingus/components/label.hpp
===================================================================
--- trunk/pingus/src/pingus/components/label.hpp        2009-11-06 00:10:50 UTC 
(rev 4048)
+++ trunk/pingus/src/pingus/components/label.hpp        2009-11-06 00:19:48 UTC 
(rev 4049)
@@ -18,7 +18,7 @@
 #define HEADER_PINGUS_COMPONENTS_LABEL_HPP
 
 #include <string>
-#include "pingus/font.hpp"
+#include "engine/display/font.hpp"
 #include "engine/gui/rect_component.hpp"
 
 /** */

Modified: trunk/pingus/src/pingus/components/menu_button.hpp
===================================================================
--- trunk/pingus/src/pingus/components/menu_button.hpp  2009-11-06 00:10:50 UTC 
(rev 4048)
+++ trunk/pingus/src/pingus/components/menu_button.hpp  2009-11-06 00:19:48 UTC 
(rev 4049)
@@ -19,7 +19,7 @@
 
 #include <string>
 #include "engine/display/sprite.hpp"
-#include "pingus/font.hpp"
+#include "engine/display/font.hpp"
 #include "math/vector2i.hpp"
 #include "engine/gui/component.hpp"
 

Modified: trunk/pingus/src/pingus/components/pingus_counter.hpp
===================================================================
--- trunk/pingus/src/pingus/components/pingus_counter.hpp       2009-11-06 
00:10:50 UTC (rev 4048)
+++ trunk/pingus/src/pingus/components/pingus_counter.hpp       2009-11-06 
00:19:48 UTC (rev 4049)
@@ -18,7 +18,7 @@
 #define HEADER_PINGUS_COMPONENTS_PINGUS_COUNTER_HPP
 
 #include "engine/gui/component.hpp"
-#include "pingus/font.hpp"
+#include "engine/display/font.hpp"
 #include "engine/display/sprite.hpp"
 
 class DrawingContext;

Modified: trunk/pingus/src/pingus/components/time_display.hpp
===================================================================
--- trunk/pingus/src/pingus/components/time_display.hpp 2009-11-06 00:10:50 UTC 
(rev 4048)
+++ trunk/pingus/src/pingus/components/time_display.hpp 2009-11-06 00:19:48 UTC 
(rev 4049)
@@ -19,7 +19,7 @@
 
 #include "engine/gui/component.hpp"
 #include "engine/display/sprite.hpp"
-#include "pingus/font.hpp"
+#include "engine/display/font.hpp"
 
 class Font;
 class Server;

Deleted: trunk/pingus/src/pingus/font.cpp
===================================================================
--- trunk/pingus/src/pingus/font.cpp    2009-11-06 00:10:50 UTC (rev 4048)
+++ trunk/pingus/src/pingus/font.cpp    2009-11-06 00:19:48 UTC (rev 4049)
@@ -1,253 +0,0 @@
-//  Pingus - A free Lemmings clone
-//  Copyright (C) 2005 Ingo Ruhnke <address@hidden>
-//
-//  This program is free software: you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-//  
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//  
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-#include "pingus/font.hpp"
-
-#include <iostream>
-#include <vector>
-#include <map>
-#include "SDL.h"
-#include "SDL_image.h"
-#include "engine/display/surface.hpp"
-#include "util/line_iterator.hpp"
-#include "util/utf8.hpp"
-#include "pingus/font_description.hpp"
-#include "engine/display/framebuffer.hpp"
-#include "engine/display/display.hpp"
-
-class FontImpl
-{
-public:
-  std::vector<FramebufferSurface> framebuffer_surfaces;
-  typedef std::vector<GlyphDescription*> Glyphs;
-  Glyphs glyphs;
-  int    space_length;
-  float  char_spacing;
-  float  vertical_spacing;
-  int    size;
-  
-  FontImpl(const FontDescription& desc) :
-    framebuffer_surfaces(),
-    glyphs(),
-    space_length(),
-    char_spacing(desc.char_spacing),
-    vertical_spacing(),
-    size(desc.size)
-  {
-    vertical_spacing = static_cast<float>(size) * desc.vertical_spacing;
-   
-    glyphs.resize(65536, 0); // 16bit ought to be enough for everybody
-
-    // Copyh Unicode -> Glyph mapping 
-    for(std::vector<GlyphImageDescription>::size_type j = 0; j < 
desc.images.size(); ++j)
-      {
-        
framebuffer_surfaces.push_back(Display::get_framebuffer().create_surface(Surface(desc.images[j].pathname)));
-
-        if (!framebuffer_surfaces.back())
-          {
-            std::cout << "IMG: " << desc.images[j].pathname.str() << std::endl;
-            assert(false);
-          }
-
-        for(std::vector<GlyphDescription>::const_iterator i = 
desc.images[j].glyphs.begin();
-            i != desc.images[j].glyphs.end();
-            ++i)
-          {
-            if (i->unicode < glyphs.size())
-              {
-                if (glyphs[i->unicode] == 0)
-                  {
-                    glyphs[i->unicode] = new GlyphDescription(*i);
-                    glyphs[i->unicode]->image = framebuffer_surfaces.size()-1;
-                  }
-                else
-                  {
-                    std::cout << "Warning: unicode collision on " << 
i->unicode << std::endl;
-                  }            
-              }
-            else
-              {
-                std::cout << "Warning: unicode out of range: " << i->unicode 
<< std::endl;
-              }
-          }
-      }
-  }
-
-  ~FontImpl()
-  {
-    for(Glyphs::iterator i = glyphs.begin(); i != glyphs.end(); ++i)
-      {
-        delete *i;
-      }
-  }
-
-  void render(Origin origin, int x, int y_, const std::string& text, 
Framebuffer& fb)
-  {
-    y_ += get_height();
-
-    float y = float(y_);
-    // FIXME: only origins top_left, top_right and top_center do work right now
-    LineIterator it(text);
-    while(it.next()) {
-      render_line(origin, x, int(y), it.get(), fb);
-      y += vertical_spacing;
-    }
-  }
-
-  void render_line(Origin origin, int x, int y, const std::string& text, 
Framebuffer& fb)
-  {
-    Vector2i offset = calc_origin(origin, get_size(text));
-
-    float dstx = float(x - offset.x);
-    float dsty = float(y - offset.y);
-    
-    UTF8::iterator i(text);
-    while(i.next())
-      {
-        const uint32_t& unicode = *i;
-
-        if (unicode < glyphs.size() && glyphs[unicode])
-          {
-            const GlyphDescription& glyph = *glyphs[unicode];
-            fb.draw_surface(framebuffer_surfaces[glyph.image],
-                            glyph.rect, Vector2i(static_cast<int>(dstx), 
static_cast<int>(dsty)) + glyph.offset);
-            dstx += static_cast<float>(glyph.advance) + char_spacing;
-          }
-        else
-          {
-            // Draw placeholder char and issue a warning
-          }
-      }
-  }
-
-  int get_height() const
-  {
-    return size;
-  }
-
-  float get_width(uint32_t unicode) const
-  {
-    if (unicode < glyphs.size() && glyphs[unicode])
-      return static_cast<float>(glyphs[unicode]->advance);
-    else
-      return 0;
-  }
-
-  float get_width(const std::string& text) const
-  {
-    float width = 0.0f;
-    float last_width = 0;
-    
-    UTF8::iterator i(text);
-    while(i.next())
-      {
-        const uint32_t& unicode = *i;
-
-        if (unicode == '\n')
-          {
-            last_width = std::max(last_width, width);
-            width = 0;
-          }
-        else
-          {
-            width += get_width(unicode) + char_spacing;
-          }
-      }
-
-    return std::max(width, last_width);
-  }
-
-  Size get_size(const std::string& text) const
-  {
-    return Size(get_width(text), get_height());
-  }
-
-  Rect bounding_rect(int x, int y, const std::string& str) const
-  {
-    return Rect(Vector2i(x, y), get_size(str));
-  }
-};
-
-Font::Font() :
-  impl()
-{
-}
-
-Font::Font(const FontDescription& desc) :
-  impl(new FontImpl(desc))
-{
-}
-
-void
-Font::render(int x, int y, const std::string& text, Framebuffer& fb)
-{
-  if (impl)
-    impl->render(origin_top_left, x,y,text, fb);
-}
-
-void
-Font::render(Origin origin, int x, int y, const std::string& text, 
Framebuffer& fb)
-{
-  if (impl)
-    impl->render(origin, x,y,text, fb); 
-}
-
-int
-Font::get_height() const
-{
-  if (impl)
-    return impl->get_height();
-  else
-    return 0;
-}
-
-float
-Font::get_width(uint32_t unicode) const
-{
-  if (impl)
-    return impl->get_width(unicode);
-  else
-    return 0; 
-}
-
-float
-Font::get_width(const std::string& text) const
-{
-  if (impl)
-    return impl->get_width(text);
-  else
-    return 0;  
-}
-
-Size
-Font::get_size(const std::string& str) const
-{
-  if (impl)
-    return impl->get_size(str);
-  else
-    return Size(); 
-}
-
-Rect
-Font::bounding_rect(int x, int y, const std::string& str) const
-{
-  if (impl)
-    return impl->bounding_rect(x, y, str);
-  else
-    return Rect();
-}
-
-/* EOF */

Deleted: trunk/pingus/src/pingus/font.hpp
===================================================================
--- trunk/pingus/src/pingus/font.hpp    2009-11-06 00:10:50 UTC (rev 4048)
+++ trunk/pingus/src/pingus/font.hpp    2009-11-06 00:19:48 UTC (rev 4049)
@@ -1,52 +0,0 @@
-//  Pingus - A free Lemmings clone
-//  Copyright (C) 2005 Ingo Ruhnke <address@hidden>
-//
-//  This program is free software: you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-//  
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//  
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_PINGUS_PINGUS_FONT_HPP
-#define HEADER_PINGUS_PINGUS_FONT_HPP
-
-#include <string>
-#include <boost/shared_ptr.hpp>
-#include "SDL.h"
-#include "math/origin.hpp"
-#include "math/rect.hpp"
-#include "math/size.hpp"
-
-class FontImpl;
-class FontDescription;
-class Framebuffer;
-
-class Font
-{
-public:
-  Font();
-  Font(const FontDescription& desc);
-
-  void render(int x, int y, const std::string& text, Framebuffer& fb);
-  void render(Origin origin, int x, int y, const std::string& text, 
Framebuffer& fb);
-
-  int  get_height() 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;
-
-private:
-  boost::shared_ptr<FontImpl> impl;
-};
-
-#endif
-
-/* EOF */

Deleted: trunk/pingus/src/pingus/font_description.cpp
===================================================================
--- trunk/pingus/src/pingus/font_description.cpp        2009-11-06 00:10:50 UTC 
(rev 4048)
+++ trunk/pingus/src/pingus/font_description.cpp        2009-11-06 00:19:48 UTC 
(rev 4049)
@@ -1,93 +0,0 @@
-//  Pingus - A free Lemmings clone
-//  Copyright (C) 2005 Ingo Ruhnke <address@hidden>
-//
-//  This program is free software: you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-//  
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//  
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-#include "pingus/font_description.hpp"
-
-#include "pingus/pingus_error.hpp"
-#include "util/file_reader.hpp"
-
-GlyphDescription::GlyphDescription() :
-  image(0), 
-  unicode(0), 
-  offset(),
-  advance(0),
-  rect()
-{  
-}
-
-GlyphDescription::GlyphDescription(FileReader& reader) :
-  image(0), 
-  unicode(0), 
-  offset(),
-  advance(0),
-  rect()
-{
-  int lazy = 0; // FIXME: implement read_uint32
-  reader.read_int("unicode", lazy);
-  unicode = lazy;
-  reader.read_vector2i("offset",  offset);
-  reader.read_int("advance", advance);
-  reader.read_rect("rect",   rect);
-}
-
-FontDescription::FontDescription(const Pathname& pathname_) :
-  pathname(pathname_),
-  char_spacing(),
-  vertical_spacing(),
-  size(),
-  images()
-{
-  char_spacing     = 1.0f;
-  vertical_spacing = 1.0f;
-
-  FileReader reader = FileReader::parse(pathname);
-
-  if (reader.get_name() != "pingus-font")
-    {
-      PingusError::raise("FontDescription: not a pingus-font file");
-    }
-  else
-    {
-      reader.read_float("char-spacing",     char_spacing);
-      reader.read_float("vertical-spacing", vertical_spacing);
-      reader.read_int("size",               size);
-
-      FileReader images_reader;
-      if (reader.read_section("images", images_reader))
-        {
-          std::vector<FileReader> images_lst = images_reader.get_sections();
-
-          for(std::vector<FileReader>::iterator i = images_lst.begin(); i != 
images_lst.end(); ++i)
-            {
-              GlyphImageDescription image_desc;
-              i->read_path("filename",             image_desc.pathname);
-      
-              FileReader glyph_section;
-              if (i->read_section("glyphs", glyph_section))
-                {
-                  std::vector<FileReader> glyph_reader = 
glyph_section.get_sections();
-                  for(std::vector<FileReader>::iterator j = 
glyph_reader.begin(); j != glyph_reader.end(); ++j)
-                    {
-                      image_desc.glyphs.push_back(GlyphDescription(*j));
-                    }
-                }
-              images.push_back(image_desc);
-            }
-        }
-    }
-}
-
-/* EOF */

Deleted: trunk/pingus/src/pingus/font_description.hpp
===================================================================
--- trunk/pingus/src/pingus/font_description.hpp        2009-11-06 00:10:50 UTC 
(rev 4048)
+++ trunk/pingus/src/pingus/font_description.hpp        2009-11-06 00:19:48 UTC 
(rev 4049)
@@ -1,79 +0,0 @@
-//  Pingus - A free Lemmings clone
-//  Copyright (C) 2005 Ingo Ruhnke <address@hidden>
-//
-//  This program is free software: you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-//  
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//  
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_PINGUS_PINGUS_FONT_DESCRIPTION_HPP
-#define HEADER_PINGUS_PINGUS_FONT_DESCRIPTION_HPP
-
-#include <string>
-#include <vector>
-
-#include "math/vector2i.hpp"
-#include "math/rect.hpp"
-#include "util/pathname.hpp"
-
-class FileReader;
-
-class GlyphDescription
-{
-public:
-  int      image;
-  uint32_t unicode; 
-  Vector2i offset;
-  int      advance; 
-  Rect     rect;
-
-  GlyphDescription();
-  GlyphDescription(FileReader& reader);
-};
-
-class GlyphImageDescription
-{
-public:
-  /** Image file from which the basic surface is loaded */
-  Pathname pathname;
-
-  /** Characters in the font image */
-  std::vector<GlyphDescription> glyphs;
-
-  GlyphImageDescription() :
-    pathname(),
-    glyphs()
-  {}
-};
-
-/** */
-class FontDescription
-{
-public:
-  Pathname    pathname;
-
-  /** Space between two characters, given in pixel */
-  float char_spacing;
-  
-  /** Spacing between lines, given in multiples of \a size */
-  float vertical_spacing;
-
-  /** Vertical height of the font */
-  int size;
-
-  std::vector<GlyphImageDescription> images;
-
-  FontDescription(const Pathname& filename);
-};
-
-#endif
-
-/* EOF */

Modified: trunk/pingus/src/pingus/fonts.hpp
===================================================================
--- trunk/pingus/src/pingus/fonts.hpp   2009-11-06 00:10:50 UTC (rev 4048)
+++ trunk/pingus/src/pingus/fonts.hpp   2009-11-06 00:19:48 UTC (rev 4049)
@@ -18,7 +18,7 @@
 #define HEADER_PINGUS_PINGUS_FONTS_HPP
 
 #include "engine/display/drawing_context.hpp"
-#include "pingus/font.hpp"
+#include "engine/display/font.hpp"
 
 namespace Fonts {
 

Modified: trunk/pingus/src/pingus/resource.cpp
===================================================================
--- trunk/pingus/src/pingus/resource.cpp        2009-11-06 00:10:50 UTC (rev 
4048)
+++ trunk/pingus/src/pingus/resource.cpp        2009-11-06 00:19:48 UTC (rev 
4049)
@@ -21,7 +21,7 @@
 #include "util/system.hpp"
 #include "pingus/path_manager.hpp"
 #include "pingus/globals.hpp"
-#include "pingus/font_description.hpp"
+#include "engine/display/font_description.hpp"
 #include "pingus/res_descriptor.hpp"
 #include "engine/display/blitter.hpp"
 #include "engine/display/sprite_description.hpp"

Modified: trunk/pingus/src/pingus/resource.hpp
===================================================================
--- trunk/pingus/src/pingus/resource.hpp        2009-11-06 00:10:50 UTC (rev 
4048)
+++ trunk/pingus/src/pingus/resource.hpp        2009-11-06 00:19:48 UTC (rev 
4049)
@@ -24,7 +24,7 @@
 #include "pingus/res_descriptor.hpp"
 #include "pingus/resource_manager.hpp"
 #include "pingus/collision_mask.hpp"
-#include "pingus/font.hpp"
+#include "engine/display/font.hpp"
 
 class Resource
 {

Modified: trunk/pingus/src/pingus/screens/credits.hpp
===================================================================
--- trunk/pingus/src/pingus/screens/credits.hpp 2009-11-06 00:10:50 UTC (rev 
4048)
+++ trunk/pingus/src/pingus/screens/credits.hpp 2009-11-06 00:19:48 UTC (rev 
4049)
@@ -20,7 +20,7 @@
 #include <string>
 #include <vector>
 #include "engine/screen/gui_screen.hpp"
-#include "pingus/font.hpp"
+#include "engine/display/font.hpp"
 #include "engine/display/scene_context.hpp"
 #include "engine/display/sprite.hpp"
 

Modified: trunk/pingus/src/pingus/screens/font_test_screen.cpp
===================================================================
--- trunk/pingus/src/pingus/screens/font_test_screen.cpp        2009-11-06 
00:10:50 UTC (rev 4048)
+++ trunk/pingus/src/pingus/screens/font_test_screen.cpp        2009-11-06 
00:19:48 UTC (rev 4049)
@@ -23,7 +23,7 @@
 #include "util/string_util.hpp"
 #include "engine/display/drawing_context.hpp"
 #include "engine/display/display.hpp"
-#include "pingus/font_description.hpp"
+#include "engine/display/font_description.hpp"
 
 FontTestScreen::FontTestScreen(const Pathname& fontfile) :
   Screen(Display::get_size()),

Modified: trunk/pingus/src/pingus/screens/font_test_screen.hpp
===================================================================
--- trunk/pingus/src/pingus/screens/font_test_screen.hpp        2009-11-06 
00:10:50 UTC (rev 4048)
+++ trunk/pingus/src/pingus/screens/font_test_screen.hpp        2009-11-06 
00:19:48 UTC (rev 4049)
@@ -18,7 +18,7 @@
 #define HEADER_PINGUS_PINGUS_FONT_TEST_SCREEN_HPP
 
 #include "engine/screen/screen.hpp"
-#include "pingus/font.hpp"
+#include "engine/display/font.hpp"
 
 class Pathname;
 

Modified: trunk/pingus/src/pingus/string_format.cpp
===================================================================
--- trunk/pingus/src/pingus/string_format.cpp   2009-11-06 00:10:50 UTC (rev 
4048)
+++ trunk/pingus/src/pingus/string_format.cpp   2009-11-06 00:19:48 UTC (rev 
4049)
@@ -18,7 +18,7 @@
 
 #include <sstream>
 
-#include "pingus/font.hpp"
+#include "engine/display/font.hpp"
 #include "util/utf8.hpp"
 
 std::string

Modified: trunk/pingus/src/pingus/worldmap/level_dot.cpp
===================================================================
--- trunk/pingus/src/pingus/worldmap/level_dot.cpp      2009-11-06 00:10:50 UTC 
(rev 4048)
+++ trunk/pingus/src/pingus/worldmap/level_dot.cpp      2009-11-06 00:19:48 UTC 
(rev 4049)
@@ -22,7 +22,7 @@
 #include "engine/display/drawing_context.hpp"
 #include "engine/input/control.hpp"
 #include "engine/input/controller.hpp"
-#include "pingus/font.hpp"
+#include "engine/display/font.hpp"
 #include "pingus/fonts.hpp"
 #include "pingus/gettext.h"
 #include "pingus/globals.hpp"





reply via email to

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