Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/text/config_text.cxx

Go to the documentation of this file.
00001 // Filename: config_text.cxx
00002 // Created by:  drose (02Mar00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "config_text.h"
00020 #include "staticTextFont.h"
00021 #include "textFont.h"
00022 #include "textNode.h"
00023 #include "dynamicTextFont.h"
00024 #include "dynamicTextPage.h"
00025 #include "geomTextGlyph.h"
00026 #include "unicodeLatinMap.h"
00027 
00028 #include "dconfig.h"
00029 
00030 Configure(config_text);
00031 NotifyCategoryDef(text, "");
00032 
00033 ConfigureFn(config_text) {
00034   init_libtext();
00035 }
00036 
00037 const bool text_flatten = config_text.GetBool("text-flatten", true);
00038 const bool text_update_cleared_glyphs = config_text.GetBool("text-update-cleared-glyphs", false);
00039 const int text_anisotropic_degree = config_text.GetInt("text-anisotropic-degree", 1);
00040 const int text_texture_margin = config_text.GetInt("text-texture-margin", 2);
00041 const float text_poly_margin = config_text.GetFloat("text-poly-margin", 0.0f);
00042 const int text_page_x_size = config_text.GetInt("text-page-x-size", 256);
00043 const int text_page_y_size = config_text.GetInt("text-page-y-size", 256);
00044 const float text_point_size = config_text.GetFloat("text-point-size", 10.0f);
00045 const float text_pixels_per_unit = config_text.GetFloat("text-pixels-per-unit", 30.0f);
00046 const float text_scale_factor = config_text.GetFloat("text-scale-factor", 2.0f);
00047 const bool text_small_caps = config_text.GetBool("text-small-caps", false);
00048 const float text_small_caps_scale = config_text.GetFloat("text-small-caps-scale", 0.8f);
00049 const string text_default_font = config_text.GetString("text-default-font", "");
00050 
00051 Texture::FilterType text_minfilter = Texture::FT_invalid;
00052 Texture::FilterType text_magfilter = Texture::FT_invalid;
00053 
00054 
00055 ////////////////////////////////////////////////////////////////////
00056 //     Function: init_libtext
00057 //  Description: Initializes the library.  This must be called at
00058 //               least once before any of the functions or classes in
00059 //               this library can be used.  Normally it will be
00060 //               called by the static initializers and need not be
00061 //               called explicitly, but special cases exist.
00062 ////////////////////////////////////////////////////////////////////
00063 void
00064 init_libtext() {
00065   static bool initialized = false;
00066   if (initialized) {
00067     return;
00068   }
00069   initialized = true;
00070 
00071   StaticTextFont::init_type();
00072   TextFont::init_type();
00073   TextNode::init_type();
00074 
00075 #ifdef HAVE_FREETYPE
00076   DynamicTextFont::init_type();
00077   DynamicTextPage::init_type();
00078   GeomTextGlyph::init_type();
00079   GeomTextGlyph::register_with_read_factory();
00080 #endif
00081 
00082   // FT_linear_mipmap_nearest (that is, choose the nearest mipmap
00083   // level and bilinear filter the pixels from there) gives us some
00084   // mipmapping to avoid dropping pixels, but avoids the hideous
00085   // artifacts that we get from some cards (notably TNT2) from
00086   // filtering between two different mipmap levels.
00087 
00088   // But, full mipmapping still gives smoother blending from small to
00089   // large, so maybe we'll use it as the default anyway.
00090   string text_minfilter_str = config_text.GetString("text-minfilter", "linear_mipmap_linear");
00091   string text_magfilter_str = config_text.GetString("text-magfilter", "linear");
00092 
00093   text_minfilter = Texture::string_filter_type(text_minfilter_str);
00094   if (text_minfilter == Texture::FT_invalid) {
00095     text_cat.error()
00096       << "Invalid text-minfilter: " << text_minfilter_str << "\n";
00097     text_minfilter = Texture::FT_linear;
00098   }
00099 
00100   text_magfilter = Texture::string_filter_type(text_magfilter_str);
00101   if (text_magfilter == Texture::FT_invalid) {
00102     text_cat.error()
00103       << "Invalid text-magfilter: " << text_magfilter_str << "\n";
00104     text_magfilter = Texture::FT_linear;
00105   }
00106   
00107 }

Generated on Fri May 2 00:44:13 2003 for Panda by doxygen1.3