gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog Makefile.am configure.ac server...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog Makefile.am configure.ac server...
Date: Tue, 12 Jun 2007 12:33:22 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/06/12 12:33:22

Modified files:
        .              : ChangeLog Makefile.am configure.ac 
        server         : FreetypeRasterizer.cpp FreetypeRasterizer.h 
                         Makefile.am edit_text_character.cpp font.cpp 
                         font.h 
        server/parser  : Makefile.am bitmap_character_def.h 

Log message:
                * configure.ac: Look for libfreetype using GNASH_PKG_FIND
                * server/FreetypeRasterizer.{cpp,h}: use HAVE_FREETYPE_H,
                  use intrusive_ptr for bitmap_info, not auto_ptr; add missing
                  includes, make it actually buildable.
                * server/Makefile.am: Build FreetypeRasterizer
                * server/parser/Makefile.am: add FREETYPE_CFLAGS
                * server/edit_text_character.cpp (format_text): stop relying
                  on font::get_glyph_count, as for device fonts count of glyph
                  is not known in advance (grows as needed).
                * server/font.{cpp,h}: Add private methods for initialization
                  and use of a freetype rasterizer; get_glyph_index() will now
                  try to create a missing glyph.
                * server/parser/bitmap_character_def.h: add forward declaration
                  for image::rgb

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3511&r2=1.3512
http://cvs.savannah.gnu.org/viewcvs/gnash/Makefile.am?cvsroot=gnash&r1=1.75&r2=1.76
http://cvs.savannah.gnu.org/viewcvs/gnash/configure.ac?cvsroot=gnash&r1=1.337&r2=1.338
http://cvs.savannah.gnu.org/viewcvs/gnash/server/FreetypeRasterizer.cpp?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/server/FreetypeRasterizer.h?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/server/Makefile.am?cvsroot=gnash&r1=1.115&r2=1.116
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.cpp?cvsroot=gnash&r1=1.65&r2=1.66
http://cvs.savannah.gnu.org/viewcvs/gnash/server/font.cpp?cvsroot=gnash&r1=1.32&r2=1.33
http://cvs.savannah.gnu.org/viewcvs/gnash/server/font.h?cvsroot=gnash&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/Makefile.am?cvsroot=gnash&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/bitmap_character_def.h?cvsroot=gnash&r1=1.16&r2=1.17

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3511
retrieving revision 1.3512
diff -u -b -r1.3511 -r1.3512
--- ChangeLog   12 Jun 2007 09:00:17 -0000      1.3511
+++ ChangeLog   12 Jun 2007 12:33:20 -0000      1.3512
@@ -1,3 +1,20 @@
+2007-06-12 Sandro Santilli <address@hidden>
+
+       * configure.ac: Look for libfreetype using GNASH_PKG_FIND
+       * server/FreetypeRasterizer.{cpp,h}: use HAVE_FREETYPE_H,
+         use intrusive_ptr for bitmap_info, not auto_ptr; add missing
+         includes, make it actually buildable.
+       * server/Makefile.am: Build FreetypeRasterizer
+       * server/parser/Makefile.am: add FREETYPE_CFLAGS
+       * server/edit_text_character.cpp (format_text): stop relying
+         on font::get_glyph_count, as for device fonts count of glyph
+         is not known in advance (grows as needed).
+       * server/font.{cpp,h}: Add private methods for initialization
+         and use of a freetype rasterizer; get_glyph_index() will now
+         try to create a missing glyph.
+       * server/parser/bitmap_character_def.h: add forward declaration
+         for image::rgb
+
 2007-06-12 Zou Lunkai <address@hidden>
 
        * testsuite/misc-ming.all/loop_test8.c:

Index: Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/Makefile.am,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -b -r1.75 -r1.76
--- Makefile.am 6 Jun 2007 06:58:19 -0000       1.75
+++ Makefile.am 12 Jun 2007 12:33:21 -0000      1.76
@@ -15,7 +15,7 @@
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 # 
 
-# $Id: Makefile.am,v 1.75 2007/06/06 06:58:19 strk Exp $
+# $Id: Makefile.am,v 1.76 2007/06/12 12:33:21 strk Exp $
 
 ## Process this file with automake to produce Makefile.in
 AUTOMAKE_OPTIONS = 1.6.0
@@ -193,6 +193,8 @@
        @echo " Z_LIBS is $(Z_LIBS)"
        @echo " LIBXML_CFLAGS is $(LIBXML_CFLAGS)"
        @echo " LIBXML_LIBS is $(LIBXML_LIBS)"
+       @echo " FREETYPE_CFLAGS is $(FREETYPE_CFLAGS)"
+       @echo " FREETYPE_LIBS is $(FREETYPE_LIBS)"
 if HAVE_DMALLOC
        @echo " DMALLOC_CFLAGS is $(DMALLOC_CFLAGS)"
        @echo " DMALLOC_LIBS is $(DMALLOC_LIBS)"

Index: configure.ac
===================================================================
RCS file: /sources/gnash/gnash/configure.ac,v
retrieving revision 1.337
retrieving revision 1.338
diff -u -b -r1.337 -r1.338
--- configure.ac        9 Jun 2007 19:42:05 -0000       1.337
+++ configure.ac        12 Jun 2007 12:33:21 -0000      1.338
@@ -15,7 +15,7 @@
 dnl  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 dnl  
 
-dnl $Id: configure.ac,v 1.337 2007/06/09 19:42:05 bjacques Exp $
+dnl $Id: configure.ac,v 1.338 2007/06/12 12:33:21 strk Exp $
 
 AC_PREREQ(2.50)
 AC_INIT(gnash, cvs)
@@ -706,6 +706,9 @@
 GNASH_PKG_FIND(jpeg, [jpeglib.h], [jpeg images], jpeg_mem_init)
 GNASH_PKG_INCLUDES([dejagnu], [dejagnu.h])
 
+dnl Find freetype
+GNASH_PKG_FIND(freetype, [freetype/freetype.h], [freetype2 font library], 
FT_Load_Char)
+
 AC_PATH_MING
 AM_CONDITIONAL(ENABLE_MING, [ test x"$MAKESWF" != x ])
 AM_CONDITIONAL(MAKESWF_SUPPORTS_PREBUILT_CLIPS,
@@ -1765,6 +1768,22 @@
   echo "                 It may still be possible to configure without zlib."
 fi
 
+if test x"$FREETYPE_LIBS" != x; then
+  if test x"$FREETYPE_CFLAGS" != x; then
+    echo "        FreeType flags are: $FREETYPE_CFLAGS"
+  else
+    echo "        FreeType flags are: default include path"
+  fi
+  echo "        FreeType libs are: $FREETYPE_LIBS"
+else
+  echo "        WARNING: You need to have the freetype development packages 
installed"
+  echo "                 to use device fonts."
+  echo "                 Install it from http://www.freetype.org";
+  echo "                 or .deb users: apt-get install libfreetype6-dev"
+  echo "                 or .rpm users: yum install libfreetype6-dev (??)"
+  echo "                 It may still be possible to configure without 
freetype."
+fi
+
 if test x$ext_mysql = xyes; then
   if test x$mysql != xno; then
     if test x"$MYSQL_LIBS" != x; then

Index: server/FreetypeRasterizer.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/FreetypeRasterizer.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- server/FreetypeRasterizer.cpp       11 Jun 2007 15:51:17 -0000      1.3
+++ server/FreetypeRasterizer.cpp       12 Jun 2007 12:33:21 -0000      1.4
@@ -11,6 +11,10 @@
 #endif
 
 #include "FreetypeRasterizer.h"
+#include "smart_ptr.h" // for intrusive_ptr
+#include "image.h" // for create_alpha
+#include "GnashException.h"
+#include "render.h"
 #include "log.h"
 
 #include <cstdio> // for snprintf
@@ -21,7 +25,7 @@
 
 namespace gnash {
 
-#ifdef HAVE_LIBFREETYPE 
+#ifdef HAVE_FREETYPE2 
 
 // static
 FT_Library FreetypeRasterizer::m_lib;
@@ -62,8 +66,8 @@
        // copy image to alpha
        for (int i = 0; i < bitmap.rows; i++)
        {
-               uint8*  src = bitmap.buffer + bitmap.pitch * i;
-               uint8*  dst = alpha->m_data + alpha->m_pitch * i;
+               uint8_t*        src = bitmap.buffer + bitmap.pitch * i;
+               uint8_t*        dst = alpha->m_data + alpha->m_pitch * i;
                int     x = bitmap.width;
                while (x-- > 0)
                {
@@ -74,6 +78,7 @@
        return alpha;
 }
 
+#if 0
 // private
 float
 FreetypeRasterizer::get_advance_x(uint16_t code)
@@ -85,6 +90,7 @@
        }
        return (float) m_face->glyph->metrics.horiAdvance * s_advance_scale;
 }
+#endif
 
 // private
 bool
@@ -92,18 +98,19 @@
                bool bold, bool italic, std::string& filename)
 {
        // TODO: implement
+       log_error("FIXME: font name to filename mapping unimplemented");
        return false;
 }
 
-#endif // HAVE_LIBFREETYPE 
+#endif // HAVE_FREETYPE2 
 
-#ifdef HAVE_LIBFREETYPE 
+#ifdef HAVE_FREETYPE2 
 // static
 std::auto_ptr<FreetypeRasterizer>
 FreetypeRasterizer::createFace(const std::string& name, bool bold, bool italic)
 {
 
-       std::auto_ptr<FreetypeRasterizer> ret( 
+       std::auto_ptr<FreetypeRasterizer> ret;
 
        try { 
                ret.reset( new FreetypeRasterizer(name, bold, italic) );
@@ -115,16 +122,16 @@
        return ret;
 
 }
-#else // ndef HAVE_LIBFREETYPE 
+#else // ndef HAVE_FREETYPE2 
 std::auto_ptr<FreetypeRasterizer>
 FreetypeRasterizer::createFace(const std::string&, bool, bool)
 {
        log_error("Freetype not supported");
        return std::auto_ptr<FreetypeRasterizer>(NULL);
 }
-#endif // ndef HAVE_LIBFREETYPE 
+#endif // ndef HAVE_FREETYPE2 
 
-#ifdef HAVE_LIBFREETYPE 
+#ifdef HAVE_FREETYPE2 
 FreetypeRasterizer::FreetypeRasterizer(const std::string& name, bool bold, 
bool italic)
        :
        m_face(NULL)
@@ -142,7 +149,7 @@
        {
                snprintf(buf, maxerrlen, _("Can't find font file for font 
'%s'"), name.c_str());
                buf[maxerrlen-1] = '\0';
-               throw GnashException(buf):
+               throw GnashException(buf);
        }
 
        int error = FT_New_Face(m_lib, filename.c_str(), 0, &m_face);
@@ -152,33 +159,31 @@
                        break;
 
                case FT_Err_Unknown_File_Format:
-                       char buf[64];
                        snprintf(buf, maxerrlen, _("Font file '%s' has bad 
format"), filename.c_str());
                        buf[maxerrlen-1] = '\0';
-                       throw GnashException(buf):
+                       throw GnashException(buf);
                        break;
 
                default:
                        // TODO: return a better error message !
-                       char buf[64];
                        snprintf(buf, maxerrlen, _("Some error opening font 
'%s'"), filename.c_str());
                        buf[maxerrlen-1] = '\0';
-                       throw GnashException(buf):
+                       throw GnashException(buf);
                        break;
        }
 }
-#else // ndef(HAVE_LIBFREETYPE)
+#else // ndef(HAVE_FREETYPE2)
 FreetypeRasterizer::FreetypeRasterizer(const std::string&, bool, bool)
 {
        assert(0); // should never be called
 }
-#endif // ndef HAVE_LIBFREETYPE 
+#endif // ndef HAVE_FREETYPE2 
 
-#ifdef HAVE_LIBFREETYPE
-std::auto_ptr<bitmap_info>
+#ifdef HAVE_FREETYPE2
+boost::intrusive_ptr<bitmap_info>
 FreetypeRasterizer::getRenderedGlyph(uint16_t code, rect& box, float& advance)
 {
-       std::auto_ptr<bitmap_info> bi;
+       boost::intrusive_ptr<bitmap_info> bi;
 
        FT_Set_Pixel_Sizes(m_face, 0, FREETYPE_MAX_FONTSIZE);
        if (FT_Load_Char(m_face, code, FT_LOAD_RENDER))
@@ -188,27 +193,33 @@
 
 
        std::auto_ptr<image::alpha> im ( draw_bitmap(m_face->glyph->bitmap) );
-       bi.reset( render::create_bitmap_info_alpha(im->m_width, im->m_height, 
im->m_data) );
+       bi = render::create_bitmap_info_alpha(im->m_width, im->m_height, 
im->m_data);
 
-       box.m_x_max = float(m_face->glyph->bitmap.width) / 
float(bi->m_suspended_image->m_width);
-       box.m_y_max = float(m_face->glyph->bitmap.rows) / 
float(bi->m_suspended_image->m_height);
+       float xmax = float(m_face->glyph->bitmap.width) / 
float(bi->m_suspended_image->m_width);
+       float ymax = float(m_face->glyph->bitmap.rows) / 
float(bi->m_suspended_image->m_height);
 
-       box.m_x_min = float(m_face->glyph->metrics.horiBearingX) / 
float(m_face->glyph->metrics.width);
-       box.m_y_min = float(m_face->glyph->metrics.horiBearingY) / 
float(m_face->glyph->metrics.height);
-       box.m_x_min *= -box.m_x_max;
-       box.m_y_min *= box.m_y_max;
+       float xmin = float(m_face->glyph->metrics.horiBearingX) / 
float(m_face->glyph->metrics.width);
+       float ymin = float(m_face->glyph->metrics.horiBearingY) / 
float(m_face->glyph->metrics.height);
        
+       // ???
+       xmin *= -xmax;
+       ymin *= ymax;
+
+       box.enclose_point(xmin, ymin);
+       box.expand_to_point(xmax, ymax);
+       
+       static float s_advance_scale = 0.16666666f; //vv hack
        advance = (float) m_face->glyph->metrics.horiAdvance * s_advance_scale;
 
        return bi;
 }
-#else // ndef(HAVE_LIBFREETYPE)
-std::auto_ptr<bitmap_info>
+#else // ndef(HAVE_FREETYPE2)
+boost::intrusive_ptr<bitmap_info>
 FreetypeRasterizer::getRenderedGlyph(uint16_t, rect& , float&)
 {
        assert(0); // should never be called... 
 }
-#endif // ndef(HAVE_LIBFREETYPE)
+#endif // ndef(HAVE_FREETYPE2)
 
 } // namespace gnash
 

Index: server/FreetypeRasterizer.h
===================================================================
RCS file: /sources/gnash/gnash/server/FreetypeRasterizer.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- server/FreetypeRasterizer.h 11 Jun 2007 13:23:22 -0000      1.2
+++ server/FreetypeRasterizer.h 12 Jun 2007 12:33:21 -0000      1.3
@@ -10,24 +10,29 @@
 #include "config.h"
 #endif
 
+
+#ifdef HAVE_FREETYPE_FREETYPE_H
+# define HAVE_FREETYPE2 1
+#endif
+
 #include "rect.h"
+#include "smart_ptr.h" // for intrusive_ptr
 
 #include <string>
 #include <memory> // for auto_ptr
 
-#ifdef HAVE_LIBFREETYPE 
+#ifdef HAVE_FREETYPE2 
 # include <ft2build.h>
-# include <freetype.h>
-# include <ftglyph.h>
+# include FT_FREETYPE_H
 # include FT_GLYPH_H
 #endif
 
 // Forward declarations
 namespace gnash {
        class bitmap_info;
-       namespace image {
+}
+namespace image {
                class alpha;
-       }
 }
 
 
@@ -44,6 +49,9 @@
 ///
 class FreetypeRasterizer 
 {
+
+public:
+
        /// Named constructor for a face-bound rasterizer.
        //
        /// @param name
@@ -75,7 +83,7 @@
        /// @return A bitmap_info, or a NULL pointer if the given character code
        ///         doesn't exist in this font.
        ///
-       std::auto_ptr<bitmap_info> getRenderedGlyph(uint16_t code, rect& box, 
float& advance);
+       boost::intrusive_ptr<bitmap_info> getRenderedGlyph(uint16_t code, rect& 
box, float& advance);
 
 private:
 
@@ -85,10 +93,10 @@
        ///
        FreetypeRasterizer(const std::string& fontname, bool bold, bool italic);
 
-#ifdef HAVE_LIBFREETYPE 
+#ifdef HAVE_FREETYPE2 
 
        // TODO: drop ?
-       float get_advance_x(uint16_t code);
+       //float get_advance_x(uint16_t code);
 
        /// Get filename containing given font
        //
@@ -126,7 +134,7 @@
        static FT_Library       m_lib;
        FT_Face m_face;
 
-#endif // HAVE_LIBFREETYPE
+#endif // HAVE_FREETYPE2
 
 };
 

Index: server/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/server/Makefile.am,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -b -r1.115 -r1.116
--- server/Makefile.am  7 Jun 2007 14:59:08 -0000       1.115
+++ server/Makefile.am  12 Jun 2007 12:33:21 -0000      1.116
@@ -18,7 +18,7 @@
 # 
 #
 
-# $Id: Makefile.am,v 1.115 2007/06/07 14:59:08 strk Exp $
+# $Id: Makefile.am,v 1.116 2007/06/12 12:33:21 strk Exp $
 
 AUTOMAKE_OPTIONS = 
 
@@ -28,6 +28,9 @@
 lib_LTLIBRARIES = libgnashserver.la
 # noinst_SCRIPTS = gen-files.sh
 
+# TODO: use a conditional to optionally link ?
+FREETYPE_SOURCES = FreetypeRasterizer.h FreetypeRasterizer.cpp
+
 # Only enable if we're configured with --enable-mp3
 AM_CPPFLAGS = \
        -I$(top_srcdir)/backend \
@@ -45,6 +48,7 @@
        $(GSTREAMER_CFLAGS) \
        $(BOOST_CFLAGS) \
        $(LIBXML_CFLAGS) \
+       $(FREETYPE_CFLAGS) \
        $(NULL)
 
 libgnashserver_la_SOURCES = \
@@ -92,6 +96,7 @@
        textformat.cpp \
        timers.cpp \
        types.cpp       \
+       $(FREETYPE_SOURCES) \
        $(NULL)
 
 noinst_HEADERS = \
@@ -166,6 +171,7 @@
        $(LIBXML_LIBS) \
        $(BOOST_LIBS) \
        $(PTHREAD_LIBS) \
+       $(FREETYPE_LIBS) \
        $(NULL)
 
 if USE_SOUND_GST

Index: server/edit_text_character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.cpp,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -b -r1.65 -r1.66
--- server/edit_text_character.cpp      8 Jun 2007 12:11:50 -0000       1.65
+++ server/edit_text_character.cpp      12 Jun 2007 12:33:21 -0000      1.66
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: edit_text_character.cpp,v 1.65 2007/06/08 12:11:50 zoulunkai Exp $ */
+/* $Id: edit_text_character.cpp,v 1.66 2007/06/12 12:33:21 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -922,6 +922,7 @@
                return;
        }
 
+#if 0 // device fonts has an unknown (unless we scan them) number of glyphs
        // @@ mostly for debugging
        // Font substitution -- if the font has no
        // glyphs, try some other defined font!
@@ -960,6 +961,7 @@
                }
 
        }
+#endif
 
 
        float   scale = m_def->get_font_height() / 1024.0f;     // the EM 
square is 1024 x 1024

Index: server/font.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/font.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- server/font.cpp     15 May 2007 09:59:08 -0000      1.32
+++ server/font.cpp     12 Jun 2007 12:33:21 -0000      1.33
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: font.cpp,v 1.32 2007/05/15 09:59:08 strk Exp $ */
+/* $Id: font.cpp,v 1.33 2007/06/12 12:33:21 strk Exp $ */
 
 // Based on the public domain work of Thatcher Ulrich <address@hidden> 2003
 
@@ -131,6 +131,11 @@
                        assert (tag == SWF::DEFINEFONT2 || tag == 
SWF::DEFINEFONT3);
                        readDefineFont2_or_3(in, m);
                }
+
+               if ( m_name && ! initDeviceFontRasterizer() )
+               {
+                       log_error("Could not initialize device font face '%s'", 
m_name);
+               }
        }
 
        // Read a DefineFont tag
@@ -433,10 +438,11 @@
 
        int     font::get_glyph_index(uint16_t code) const
        {
+               int glyph_index = -1;
                code_table::const_iterator it = m_code_table.find(code);
                if ( it != m_code_table.end() )
                {
-                       int glyph_index = it->second;
+                       glyph_index = it->second;
 #if 0
                        log_msg(_("get_glyph_index(%u) returning %d"),
                                code, glyph_index);
@@ -444,10 +450,15 @@
                        return glyph_index;
                }
 
+               // Try adding an os font, of possible
+               if ( _ftRasterizer.get() )
+               {
+                       glyph_index = 
const_cast<font*>(this)->add_os_glyph(code);
+               }
 #if 0
                log_msg(_("get_glyph_index(%u) returning -1"), code);
 #endif
-               return -1;
+               return glyph_index;
        }
 
        float   font::get_advance(int glyph_index) const
@@ -547,6 +558,61 @@
 #endif // 0
        }
 
+       int
+       font::add_os_glyph(uint16_t code)
+       {
+               assert ( _ftRasterizer.get() );
+               assert(m_code_table.find(code) == m_code_table.end());
+
+               rect box;
+               float advance;
+               boost::intrusive_ptr<bitmap_info> bi ( 
_ftRasterizer->getRenderedGlyph(code, box, advance) );
+
+               if ( ! bi.get() )
+               {
+                       log_error("Could not create glyph for character code %u 
with device font %s (%p)", code, m_name, _ftRasterizer.get());
+                       return -1;
+               }
+
+               // Create textured glyph from the bitmap info
+               texture_glyph tg;
+               tg.m_uv_bounds.enclose_point(0, 0);
+               tg.m_uv_bounds.expand_to_point(box.get_x_max(), 
box.get_y_max());
+               // the origin
+               tg.m_uv_origin.m_x = box.get_x_min();
+               tg.m_uv_origin.m_y = box.get_y_min();
+               tg.set_bitmap_info(bi.get());
+
+               // Add the textured glyph
+               int newOffset = m_texture_glyphs.size();
+               m_code_table[code] = newOffset;
+               m_advance_table.push_back(advance);
+               m_texture_glyphs.push_back(tg);
+               m_glyphs.push_back(NULL);
+
+               testInvariant();
+
+               return newOffset;
+       }
+
+       bool
+       font::initDeviceFontRasterizer()
+       {
+               if ( ! m_name )
+               {
+                       log_error("No name associated with this font, can't use 
device fonts (should I use a default one?)");
+                       return false;
+               }
+
+               _ftRasterizer = FreetypeRasterizer::createFace(m_name, 
m_is_bold, m_is_italic);
+               if ( ! _ftRasterizer.get() )
+               {
+                       log_error("Could not create a freetype face %s", 
m_name);
+                       return false;
+               }
+               return true;
+       }
+
 
 }      // end namespace gnash
 

Index: server/font.h
===================================================================
RCS file: /sources/gnash/gnash/server/font.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- server/font.h       21 Feb 2007 11:35:51 -0000      1.20
+++ server/font.h       12 Jun 2007 12:33:21 -0000      1.21
@@ -17,6 +17,8 @@
 #include "ref_counted.h" // for inheritance of texture_glyph
 #include "swf.h" // for tag_type definition
 #include "bitmap_info.h" // for dtor visibility by smart pointer
+#include "FreetypeRasterizer.h" // for device fonts support
+#include "log.h"
 
 #include <map>
 
@@ -110,10 +112,31 @@
                ~font();
 
                // override from resource.
-               virtual font*   cast_to_font() { return this; }
+               font*   cast_to_font() { return this; }
+
+               void testInvariant()
+               {
+                       assert(m_texture_glyphs.size() == m_glyphs.size());
+                       assert(m_texture_glyphs.size() == 
m_advance_table.size());
+               }
 
                /// Get number of glyphs defined for this font
-               int     get_glyph_count() const { return m_glyphs.size(); }
+               //
+               /// NOTE: for device fonts, this method will returns whatever
+               ///       number of glyphs the cache happens to have at time of
+               ///       calls. Anyway, the cache will grow if any font user
+               ///       requests more glyphs... 
+               ///       
+               /// Callers of this function are:
+               ///
+               ///     - fontlib, for writing cache data (known to be not 
working anyway).
+               ///     - edit_text_character, for validating the font 
(obsoleted too).
+               ///
+               int     get_glyph_count() const
+               {
+                       log_error("FIXME: font::get_glyph_count() is a 
deprecated method");
+                       return m_glyphs.size();
+               }
 
                /// Get glyph by index. Return NULL if out of range
                shape_character_def*    get_glyph(int glyph_index) const;
@@ -161,10 +184,14 @@
                /// texture_glyph.
                ///
                const texture_glyph&    get_texture_glyph(int glyph_index) 
const;
+
                /// \brief
                /// Register some texture info for the glyph at the specified
                /// index.  The texture_glyph can be used later to render the
                /// glyph.
+               //
+               /// TODO: deprecate this, probably only used by the caching 
mechanism
+               ///
                void    add_texture_glyph(int glyph_index, const texture_glyph& 
glyph);
 
                void    set_texture_glyph_nominal_size(int size) { 
m_texture_glyph_nominal_size = imax(1, size); }
@@ -189,9 +216,24 @@
                /// Read a DefineFont2 or DefineFont3 tag
                void readDefineFont2_or_3(stream* in, movie_definition* m);
 
-               // Read a DefineFont tag
+               /// Read a DefineFont tag
                void readDefineFont(stream* in, movie_definition* m);
 
+               /// Add a glyph from the os font.
+               //
+               /// It is assumed that the glyph tables do NOT contain
+               /// an entry for the given code.
+               /// Initializes the rasterizer if not already done so.
+               ///
+               /// @return index of the newly added glyph, or -1 on error.
+               ///
+               int add_os_glyph(uint16_t code);
+
+               /// Initialize the freetype rasterizer
+               //
+               /// Return true on success, false on error
+               bool initDeviceFontRasterizer();
+
                std::vector< boost::intrusive_ptr<shape_character_def> >        
m_glyphs;
 
                std::vector< texture_glyph >    m_texture_glyphs;       // 
cached info, built by gnash_fontlib.
@@ -210,17 +252,6 @@
                bool    m_wide_codes;
 
                // This table maps from Unicode character number to glyph index.
-               // m_code_table[character_code] = glyph_index
-               //
-               // @@ TODO: avoid little allocs; replace this with a flat hash, 
or else a sorted array (binary search)
-//             template<class T>
-//             class simple_code_hash
-//             // Dummy hash functor.
-//             {
-               public:
-//                     size_t  operator()(const T& data) const { return data; }
-//             };
-//             hash<uint16_t, int, simple_code_hash<uint16_t> > m_code_table;
                typedef std::map<uint16_t, int> code_table;
                code_table m_code_table; 
 
@@ -229,13 +260,11 @@
                float   m_descent;
                float   m_leading;
                std::vector<float>      m_advance_table;
-               // @@ we don't seem to use this thing at all, so don't bother 
keeping it.
-               // std::vector<rect>    m_bounds_table; // @@ this thing should 
be optional.
 
-
-               //hash<kerning_pair, float>     m_kerning_pairs;
                typedef std::map<kerning_pair, float> kernings_table;
                kernings_table m_kerning_pairs;
+
+               std::auto_ptr<FreetypeRasterizer> _ftRasterizer;
        };
 
 

Index: server/parser/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/server/parser/Makefile.am,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- server/parser/Makefile.am   4 Jun 2007 18:00:09 -0000       1.34
+++ server/parser/Makefile.am   12 Jun 2007 12:33:22 -0000      1.35
@@ -15,7 +15,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-# $Id: Makefile.am,v 1.34 2007/06/04 18:00:09 rsavoye Exp $
+# $Id: Makefile.am,v 1.35 2007/06/12 12:33:22 strk Exp $
 
 AUTOMAKE_OPTIONS = 
 
@@ -40,7 +40,9 @@
        $(GLIB_CFLAGS) \
        $(PTHREAD_CFLAGS) \
        $(DMALLOC_CFLAGS) \
-        $(BOOST_CFLAGS) 
+        $(BOOST_CFLAGS) \
+       $(FREETYPE_CFLAGS) \
+       $(NULL)
 
 libgnashparser_la_SOURCES = \
        action_buffer.cpp \

Index: server/parser/bitmap_character_def.h
===================================================================
RCS file: /sources/gnash/gnash/server/parser/bitmap_character_def.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- server/parser/bitmap_character_def.h        28 May 2007 15:41:09 -0000      
1.16
+++ server/parser/bitmap_character_def.h        12 Jun 2007 12:33:22 -0000      
1.17
@@ -38,6 +38,10 @@
 #include <cassert>
 #include <memory> // for auto_ptr
 
+namespace image {
+       class rgb;
+}
+
 namespace gnash {
 
 /// Definition of a bitmap character




reply via email to

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