From 6154ac04bf89bcbaab4cb25995c48fabe41157c3 Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 30 Jan 2007 13:26:55 +0000 Subject: [PATCH] one more try --- panda/src/text/config_text.cxx | 4 +- panda/src/text/config_text.h | 5 +- panda/src/text/dynamicTextFont.cxx | 116 ---------------------------- panda/src/text/dynamicTextFont.h | 8 -- panda/src/text/textFont.cxx | 117 +++++++++++++++++++++++++++++ panda/src/text/textFont.h | 8 ++ 6 files changed, 127 insertions(+), 131 deletions(-) diff --git a/panda/src/text/config_text.cxx b/panda/src/text/config_text.cxx index 65085c8b08..5a3a737e41 100644 --- a/panda/src/text/config_text.cxx +++ b/panda/src/text/config_text.cxx @@ -182,11 +182,9 @@ ConfigVariableEnum text_wrap_mode ("text-wrap-mode", Texture::WM_border_color, PRC_DESC("The default wrap mode for dynamic text fonts")); -#ifdef HAVE_FREETYPE -ConfigVariableEnum text_render_mode +ConfigVariableEnum text_render_mode ("text-render-mode", DynamicTextFont::RM_texture, PRC_DESC("The default render mode for dynamic text fonts")); -#endif diff --git a/panda/src/text/config_text.h b/panda/src/text/config_text.h index 37f0be915b..6595eac454 100644 --- a/panda/src/text/config_text.h +++ b/panda/src/text/config_text.h @@ -55,10 +55,7 @@ extern ConfigVariableInt text_max_never_break; extern ConfigVariableEnum text_minfilter; extern ConfigVariableEnum text_magfilter; extern ConfigVariableEnum text_wrap_mode; - -#ifdef HAVE_FREETYPE -extern ConfigVariableEnum text_render_mode; -#endif +extern ConfigVariableEnum text_render_mode; extern EXPCL_PANDA void init_libtext(); diff --git a/panda/src/text/dynamicTextFont.cxx b/panda/src/text/dynamicTextFont.cxx index 290723a259..571a1ea261 100644 --- a/panda/src/text/dynamicTextFont.cxx +++ b/panda/src/text/dynamicTextFont.cxx @@ -254,50 +254,6 @@ get_glyph(int character, const TextGlyph *&glyph) { } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::string_render_mode -// Access: Public -// Description: Returns the RenderMode value associated with the given -// string representation, or RM_invalid if the string -// does not match any known RenderMode value. -//////////////////////////////////////////////////////////////////// -DynamicTextFont::RenderMode DynamicTextFont:: -string_render_mode(const string &string) { - if (cmp_nocase_uh(string, "texture") == 0) { - return RM_texture; - } else if (cmp_nocase_uh(string, "wireframe") == 0) { - return RM_wireframe; - } else if (cmp_nocase_uh(string, "polygon") == 0) { - return RM_polygon; - } else if (cmp_nocase_uh(string, "extruded") == 0) { - return RM_extruded; - } else if (cmp_nocase_uh(string, "solid") == 0) { - return RM_solid; - } else { - return RM_invalid; - } -} - -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::string_winding_order -// Access: Public -// Description: Returns the WindingOrder value associated with the given -// string representation, or WO_invalid if the string -// does not match any known WindingOrder value. -//////////////////////////////////////////////////////////////////// -DynamicTextFont::WindingOrder DynamicTextFont:: -string_winding_order(const string &string) { - if (cmp_nocase_uh(string, "default") == 0) { - return WO_default; - } else if (cmp_nocase_uh(string, "left") == 0) { - return WO_left; - } else if (cmp_nocase_uh(string, "right") == 0) { - return WO_right; - } else { - return WO_invalid; - } -} - //////////////////////////////////////////////////////////////////// // Function: DynamicTextFont::initialize // Access: Private @@ -1023,76 +979,4 @@ outline_nurbs(NurbsCurveResult *ncr) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::RenderMode output operator -// Description: -//////////////////////////////////////////////////////////////////// -ostream & -operator << (ostream &out, DynamicTextFont::RenderMode rm) { - switch (rm) { - case DynamicTextFont::RM_texture: - return out << "texture"; - case DynamicTextFont::RM_wireframe: - return out << "wireframe"; - case DynamicTextFont::RM_polygon: - return out << "polygon"; - case DynamicTextFont::RM_extruded: - return out << "extruded"; - case DynamicTextFont::RM_solid: - return out << "solid"; - - case DynamicTextFont::RM_invalid: - return out << "invalid"; - } - - return out << "(**invalid DynamicTextFont::RenderMode(" << (int)rm << ")**)"; -} - -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::RenderMode input operator -// Description: -//////////////////////////////////////////////////////////////////// -istream & -operator >> (istream &in, DynamicTextFont::RenderMode &rm) { - string word; - in >> word; - - rm = DynamicTextFont::string_render_mode(word); - return in; -} - -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::WindingOrder output operator -// Description: -//////////////////////////////////////////////////////////////////// -ostream & -operator << (ostream &out, DynamicTextFont::WindingOrder wo) { - switch (wo) { - case DynamicTextFont::WO_default: - return out << "default"; - case DynamicTextFont::WO_left: - return out << "left"; - case DynamicTextFont::WO_right: - return out << "right"; - - case DynamicTextFont::WO_invalid: - return out << "invalid"; - } - - return out << "(**invalid DynamicTextFont::WindingOrder(" << (int)wo << ")**)"; -} - -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::WindingOrder input operator -// Description: -//////////////////////////////////////////////////////////////////// -istream & -operator >> (istream &in, DynamicTextFont::WindingOrder &wo) { - string word; - in >> word; - - wo = DynamicTextFont::string_winding_order(word); - return in; -} - #endif // HAVE_FREETYPE diff --git a/panda/src/text/dynamicTextFont.h b/panda/src/text/dynamicTextFont.h index 51383aeeb6..4400036876 100644 --- a/panda/src/text/dynamicTextFont.h +++ b/panda/src/text/dynamicTextFont.h @@ -101,9 +101,6 @@ PUBLISHED: public: virtual bool get_glyph(int character, const TextGlyph *&glyph); - static RenderMode string_render_mode(const string &string); - static WindingOrder string_winding_order(const string &string); - private: void initialize(); void update_filters(); @@ -195,11 +192,6 @@ private: INLINE ostream &operator << (ostream &out, const DynamicTextFont &dtf); -EXPCL_PANDA ostream &operator << (ostream &out, DynamicTextFont::RenderMode rm); -EXPCL_PANDA istream &operator >> (istream &in, DynamicTextFont::RenderMode &rm); -EXPCL_PANDA ostream &operator << (ostream &out, DynamicTextFont::WindingOrder wo); -EXPCL_PANDA istream &operator >> (istream &in, DynamicTextFont::WindingOrder &wo); - #include "dynamicTextFont.I" #endif // HAVE_FREETYPE diff --git a/panda/src/text/textFont.cxx b/panda/src/text/textFont.cxx index c865efcdf0..6b78fb77c8 100644 --- a/panda/src/text/textFont.cxx +++ b/panda/src/text/textFont.cxx @@ -18,6 +18,7 @@ #include "textFont.h" #include "config_text.h" +#include "string_utils.h" #include TypeHandle TextFont::_type_handle; @@ -53,3 +54,119 @@ write(ostream &out, int indent_level) const { indent(out, indent_level) << "TextFont " << get_name() << "\n"; } + +//////////////////////////////////////////////////////////////////// +// Function: TextFont::string_render_mode +// Access: Public +// Description: Returns the RenderMode value associated with the given +// string representation, or RM_invalid if the string +// does not match any known RenderMode value. +//////////////////////////////////////////////////////////////////// +TextFont::RenderMode TextFont:: +string_render_mode(const string &string) { + if (cmp_nocase_uh(string, "texture") == 0) { + return RM_texture; + } else if (cmp_nocase_uh(string, "wireframe") == 0) { + return RM_wireframe; + } else if (cmp_nocase_uh(string, "polygon") == 0) { + return RM_polygon; + } else if (cmp_nocase_uh(string, "extruded") == 0) { + return RM_extruded; + } else if (cmp_nocase_uh(string, "solid") == 0) { + return RM_solid; + } else { + return RM_invalid; + } +} + +//////////////////////////////////////////////////////////////////// +// Function: TextFont::string_winding_order +// Access: Public +// Description: Returns the WindingOrder value associated with the given +// string representation, or WO_invalid if the string +// does not match any known WindingOrder value. +//////////////////////////////////////////////////////////////////// +TextFont::WindingOrder TextFont:: +string_winding_order(const string &string) { + if (cmp_nocase_uh(string, "default") == 0) { + return WO_default; + } else if (cmp_nocase_uh(string, "left") == 0) { + return WO_left; + } else if (cmp_nocase_uh(string, "right") == 0) { + return WO_right; + } else { + return WO_invalid; + } +} + +//////////////////////////////////////////////////////////////////// +// Function: TextFont::RenderMode output operator +// Description: +//////////////////////////////////////////////////////////////////// +ostream & +operator << (ostream &out, TextFont::RenderMode rm) { + switch (rm) { + case TextFont::RM_texture: + return out << "texture"; + case TextFont::RM_wireframe: + return out << "wireframe"; + case TextFont::RM_polygon: + return out << "polygon"; + case TextFont::RM_extruded: + return out << "extruded"; + case TextFont::RM_solid: + return out << "solid"; + + case TextFont::RM_invalid: + return out << "invalid"; + } + + return out << "(**invalid TextFont::RenderMode(" << (int)rm << ")**)"; +} + +//////////////////////////////////////////////////////////////////// +// Function: TextFont::RenderMode input operator +// Description: +//////////////////////////////////////////////////////////////////// +istream & +operator >> (istream &in, TextFont::RenderMode &rm) { + string word; + in >> word; + + rm = TextFont::string_render_mode(word); + return in; +} + +//////////////////////////////////////////////////////////////////// +// Function: TextFont::WindingOrder output operator +// Description: +//////////////////////////////////////////////////////////////////// +ostream & +operator << (ostream &out, TextFont::WindingOrder wo) { + switch (wo) { + case TextFont::WO_default: + return out << "default"; + case TextFont::WO_left: + return out << "left"; + case TextFont::WO_right: + return out << "right"; + + case TextFont::WO_invalid: + return out << "invalid"; + } + + return out << "(**invalid TextFont::WindingOrder(" << (int)wo << ")**)"; +} + +//////////////////////////////////////////////////////////////////// +// Function: TextFont::WindingOrder input operator +// Description: +//////////////////////////////////////////////////////////////////// +istream & +operator >> (istream &in, TextFont::WindingOrder &wo) { + string word; + in >> word; + + wo = TextFont::string_winding_order(word); + return in; +} diff --git a/panda/src/text/textFont.h b/panda/src/text/textFont.h index 2415ecad78..6c885a6135 100644 --- a/panda/src/text/textFont.h +++ b/panda/src/text/textFont.h @@ -86,6 +86,9 @@ PUBLISHED: public: virtual bool get_glyph(int character, const TextGlyph *&glyph)=0; + static RenderMode string_render_mode(const string &string); + static WindingOrder string_winding_order(const string &string); + protected: bool _is_valid; float _line_height; @@ -109,6 +112,11 @@ private: static TypeHandle _type_handle; }; +EXPCL_PANDA ostream &operator << (ostream &out, TextFont::RenderMode rm); +EXPCL_PANDA istream &operator >> (istream &in, TextFont::RenderMode &rm); +EXPCL_PANDA ostream &operator << (ostream &out, TextFont::WindingOrder wo); +EXPCL_PANDA istream &operator >> (istream &in, TextFont::WindingOrder &wo); + #include "textFont.I" #endif