[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/edit_text_character.cpp ...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/edit_text_character.cpp ... |
Date: |
Wed, 11 Jul 2007 16:16:51 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/07/11 16:16:51
Modified files:
. : ChangeLog
server : edit_text_character.cpp font.cpp font.h
fontlib.cpp fontlib.h
server/parser : edit_text_character_def.cpp
Log message:
* server/font.{cpp,h}: Store name by std::string
rather then by char*, Provide a constructor for
device-only font.
* server/fontlib.{cpp,h}: Add a get_default_font.
* server/edit_text_character.cpp: Use the default
font if no font is specified in the definition.
* server/parser/edit_text_character_def.cpp: not having
a font in the definition isn't an error, turn it into
a debugging message instead.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3715&r2=1.3716
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.cpp?cvsroot=gnash&r1=1.72&r2=1.73
http://cvs.savannah.gnu.org/viewcvs/gnash/server/font.cpp?cvsroot=gnash&r1=1.41&r2=1.42
http://cvs.savannah.gnu.org/viewcvs/gnash/server/font.h?cvsroot=gnash&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/gnash/server/fontlib.cpp?cvsroot=gnash&r1=1.30&r2=1.31
http://cvs.savannah.gnu.org/viewcvs/gnash/server/fontlib.h?cvsroot=gnash&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/edit_text_character_def.cpp?cvsroot=gnash&r1=1.10&r2=1.11
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3715
retrieving revision 1.3716
diff -u -b -r1.3715 -r1.3716
--- ChangeLog 11 Jul 2007 16:01:50 -0000 1.3715
+++ ChangeLog 11 Jul 2007 16:16:50 -0000 1.3716
@@ -1,3 +1,15 @@
+2007-07-11 Sandro Santilli <address@hidden>
+
+ * server/font.{cpp,h}: Store name by std::string
+ rather then by char*, Provide a constructor for
+ device-only font.
+ * server/fontlib.{cpp,h}: Add a get_default_font.
+ * server/edit_text_character.cpp: Use the default
+ font if no font is specified in the definition.
+ * server/parser/edit_text_character_def.cpp: not having
+ a font in the definition isn't an error, turn it into
+ a debugging message instead.
+
2007-07-11 Timothy Lee <address@hidden>
* backend/render_handler_cairo.cpp: correct scaling and offset
Index: server/edit_text_character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.cpp,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -b -r1.72 -r1.73
--- server/edit_text_character.cpp 3 Jul 2007 01:12:44 -0000 1.72
+++ server/edit_text_character.cpp 11 Jul 2007 16:16:51 -0000 1.73
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: edit_text_character.cpp,v 1.72 2007/07/03 01:12:44 strk Exp $ */
+/* $Id: edit_text_character.cpp,v 1.73 2007/07/11 16:16:51 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -352,7 +352,9 @@
set_prototype(getTextFieldInterface());
// WARNING! remember to set the font *before* setting text value!
- set_font( m_def->get_font() );
+ const font* definedFont = m_def->get_font();
+ if ( definedFont ) set_font( m_def->get_font() );
+ else set_font( fontlib::get_default_font().get() );
// set default text *before* calling registerTextVariable
// (if the textvariable already exist and has a value
@@ -927,48 +929,6 @@
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!
- if (_font->get_glyph_count() == 0)
- {
-
- // Find a better font.
- const font* newfont = _font;
- for (int i = 0, n = fontlib::get_font_count(); i < n; i++)
- {
- font* f = fontlib::get_font(i);
- assert(f);
-
- if (f->get_glyph_count() > 0)
- {
- // This one looks good.
- newfont = f;
- break;
- }
- }
-
- if (_font != newfont)
- {
- log_error(_("substituting font! font '%s' has "
- "no glyphs, using font '%s'"),
- fontlib::get_font_name(_font),
- fontlib::get_font_name(newfont)
- );
-
- _font = newfont;
- }
- else
- {
- log_error(_("Current font has no glyphs and I couldn't"
- " find another font with glyphs... :("));
- }
-
- }
-#endif
-
-
float scale = m_def->get_font_height() / 1024.0f; // the EM
square is 1024 x 1024
text_glyph_record rec; // one to work on
@@ -1115,7 +1075,7 @@
" Make sure character shapes for
font %s are being exported "
"into your SWF file."),
__PRETTY_FUNCTION__,
- _font->get_name());
+ _font->get_name().c_str());
);
}
else
@@ -1155,7 +1115,7 @@
"into your SWF file"),
__PRETTY_FUNCTION__,
code,
- _font->get_name()
+ _font->get_name().c_str()
);
}
Index: server/font.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/font.cpp,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -b -r1.41 -r1.42
--- server/font.cpp 1 Jul 2007 10:54:22 -0000 1.41
+++ server/font.cpp 11 Jul 2007 16:16:51 -0000 1.42
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: font.cpp,v 1.41 2007/07/01 10:54:22 bjacques Exp $ */
+/* $Id: font.cpp,v 1.42 2007/07/11 16:16:51 strk Exp $ */
// Based on the public domain work of Thatcher Ulrich <address@hidden> 2003
@@ -36,7 +36,7 @@
font::font()
:
m_texture_glyph_nominal_size(96), // Default is not
important; gets overridden during glyph generation
- m_name(NULL),
+ m_name(),
m_owning_movie(NULL),
m_unicode_chars(false),
m_shift_jis_chars(false),
@@ -50,12 +50,32 @@
{
}
+ font::font(const std::string& name)
+ :
+ m_texture_glyph_nominal_size(96), // Default is not
important; gets overridden during glyph generation
+ m_name(name),
+ m_owning_movie(NULL),
+ m_unicode_chars(false),
+ m_shift_jis_chars(false),
+ m_ansi_chars(true),
+ m_is_italic(false),
+ m_is_bold(false),
+ m_wide_codes(false),
+ m_ascent(0.0f),
+ m_descent(0.0f),
+ m_leading(0.0f)
+ {
+ assert(!m_name.empty());
+
+ if ( ! initDeviceFontProvider() )
+ {
+ log_error(_("Could not initialize device font face
'%s'"), m_name.c_str());
+ }
+ }
+
font::~font()
{
m_glyphs.resize(0); // there's no need for this !
-
- // Delete the name string.
- delete [] m_name;
}
shape_character_def* font::get_glyph(int index) const
@@ -131,9 +151,9 @@
readDefineFont2_or_3(in, m);
}
- if ( m_name && ! initDeviceFontProvider() )
+ if ( ! m_name.empty() && ! initDeviceFontProvider() )
{
- log_error("Could not initialize device font face '%s'",
m_name);
+ log_error("Could not initialize device font face '%s'",
m_name.c_str());
}
}
@@ -213,7 +233,12 @@
// Inhibit compiler warning.
reserved = reserved;
- m_name = in->read_string_with_length();
+ char* name = in->read_string_with_length();
+ if ( name )
+ {
+ m_name = name;
+ delete [] name;
+ }
uint16_t glyph_count = in->read_u16();
@@ -385,9 +410,16 @@
}
}
- delete [] m_name;
-
- m_name = in->read_string_with_length();
+ char* name = in->read_string_with_length();
+ if ( name )
+ {
+ m_name = name;
+ delete [] name;
+ }
+ else
+ {
+ m_name.clear();
+ }
unsigned char flags = in->read_u8();
@@ -575,7 +607,7 @@
{
log_error("Could not create shape "
"glyph for character code %u (%c) with "
- "device font %s (%p)", code, code,
m_name,
+ "device font %s (%p)", code, code,
m_name.c_str(),
_ftProvider.get());
return -1;
}
@@ -603,16 +635,16 @@
bool
font::initDeviceFontProvider()
{
- if ( ! m_name )
+ if ( m_name.empty() )
{
log_error("No name associated with this font, can't use
device fonts (should I use a default one?)");
return false;
}
- _ftProvider = FreetypeGlyphsProvider::createFace(m_name,
m_is_bold, m_is_italic);
+ _ftProvider =
FreetypeGlyphsProvider::createFace(m_name.c_str(), m_is_bold, m_is_italic);
if ( ! _ftProvider.get() )
{
- log_error("Could not create a freetype face %s",
m_name);
+ log_error("Could not create a freetype face %s",
m_name.c_str());
return false;
}
return true;
Index: server/font.h
===================================================================
RCS file: /sources/gnash/gnash/server/font.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- server/font.h 16 Jun 2007 06:30:29 -0000 1.25
+++ server/font.h 11 Jul 2007 16:16:51 -0000 1.26
@@ -121,6 +121,10 @@
{
public:
font();
+
+ // Create a device-font only font, using the given name to find
it
+ font(const std::string& name);
+
~font();
// override from resource.
@@ -133,7 +137,7 @@
if (m_texture_glyphs.size() != m_advance_table.size())
{
log_error("Font '%s': Number of texture glyphs:
%lu, advance records: %lu",
- m_name,
+ m_name.c_str(),
static_cast<unsigned
long>(m_texture_glyphs.size()),
static_cast<unsigned
long>(m_advance_table.size()));
abort();
@@ -191,7 +195,7 @@
void wipe_texture_glyphs();
/// Get name of this font. Warning: can be NULL.
- const char* get_name() const { return m_name; }
+ const std::string& get_name() const { return m_name; }
/// Return the movie_definition "owning" this font
movie_definition* get_owning_movie() const { return
m_owning_movie; }
@@ -263,7 +267,7 @@
int m_texture_glyph_nominal_size;
- char* m_name;
+ std::string m_name;
movie_definition* m_owning_movie;
bool m_has_layout;
Index: server/fontlib.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/fontlib.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- server/fontlib.cpp 23 Jun 2007 12:34:32 -0000 1.30
+++ server/fontlib.cpp 11 Jul 2007 16:16:51 -0000 1.31
@@ -5,7 +5,7 @@
// A module to take care of all of gnash's loaded fonts.
-/* $Id: fontlib.cpp,v 1.30 2007/06/23 12:34:32 bjacques Exp $ */
+/* $Id: fontlib.cpp,v 1.31 2007/07/11 16:16:51 strk Exp $ */
#include "container.h"
#include "tu_file.h"
@@ -21,10 +21,16 @@
#include "render.h"
#include "movie_definition.h"
+// Define to the name of a default font.
+#define DEFAULT_FONT_NAME "_sans"
namespace gnash {
namespace fontlib {
+
+namespace {
std::vector< boost::intrusive_ptr<font> > s_fonts;
+ boost::intrusive_ptr<font> _defaultFont;
+}
// Size (in TWIPS) of the box that the glyph should
// stay within.
@@ -1220,7 +1226,7 @@
log_error("invalid glyph index %d in
cached font data, limit is %d, font is '%s'\n",
glyph_index,
fnt->get_glyph_count(),
- fnt->get_name());
+ fnt->get_name().c_str());
}
else
{
@@ -1244,6 +1250,13 @@
s_fonts.clear();
}
+boost::intrusive_ptr<font>
+get_default_font()
+{
+ if ( _defaultFont ) return _defaultFont;
+ _defaultFont = new font(DEFAULT_FONT_NAME);
+ return _defaultFont;
+}
int get_font_count()
// Return the number of fonts in our library.
@@ -1264,7 +1277,7 @@
}
- font* get_font(const char* name)
+ font* get_font(const std::string& name)
// Return the named font.
{
// Dumb linear search.
@@ -1273,7 +1286,7 @@
font* f = s_fonts[i].get();
if (f != NULL)
{
- if (strcmp(f->get_name(), name) == 0)
+ if (f->get_name() == name)
{
return f;
}
@@ -1282,19 +1295,6 @@
return NULL;
}
-
- const char* get_font_name(const font* f)
- // Return the name of the given font. (This basically exists
- // so that font* can be opaque to the host app).
- {
- if (f == NULL)
- {
- return "<null>";
- }
- return f->get_name();
- }
-
-
void add_font(font* f)
// Add the given font to our library.
{
Index: server/fontlib.h
===================================================================
RCS file: /sources/gnash/gnash/server/fontlib.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- server/fontlib.h 11 Jul 2007 02:57:59 -0000 1.6
+++ server/fontlib.h 11 Jul 2007 16:16:51 -0000 1.7
@@ -99,6 +99,9 @@
font* get_font(const char* name);
+ /// Return a default device font.
+ boost::intrusive_ptr<font> get_default_font();
+
const char* get_font_name(const font* f);
// @@ also need to add color controls (or just set the diffuse color
Index: server/parser/edit_text_character_def.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/parser/edit_text_character_def.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- server/parser/edit_text_character_def.cpp 1 Jul 2007 10:54:34 -0000
1.10
+++ server/parser/edit_text_character_def.cpp 11 Jul 2007 16:16:51 -0000
1.11
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: edit_text_character_def.cpp,v 1.10 2007/07/01 10:54:34 bjacques Exp $
*/
+/* $Id: edit_text_character_def.cpp,v 1.11 2007/07/11 16:16:51 strk Exp $ */
// Based on the public domain text.cpp of Thatcher Ulrich <address@hidden> 2003
@@ -118,7 +118,8 @@
m_font = m_root_def->get_font(m_font_id);
if (m_font == NULL)
{
- log_error(_("error: text style with undefined font;
font_id = %d"), m_font_id);
+ // this is fine, the textfield would use a default
device font
+ log_debug(_("text style with undefined font; font_id =
%d"), m_font_id);
}
}