00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "config_text.h"
00016 #include "staticTextFont.h"
00017 #include "textFont.h"
00018 #include "textNode.h"
00019 #include "textProperties.h"
00020 #include "dynamicTextFont.h"
00021 #include "dynamicTextPage.h"
00022 #include "geomTextGlyph.h"
00023 #include "geomTextGlyph.h"
00024 #include "unicodeLatinMap.h"
00025 #include "pandaSystem.h"
00026
00027 #include "dconfig.h"
00028 #include "config_express.h"
00029
00030 Configure(config_text);
00031 NotifyCategoryDef(text, "");
00032
00033 ConfigureFn(config_text) {
00034 init_libtext();
00035 }
00036
00037 ConfigVariableBool text_flatten
00038 ("text-flatten", true,
00039 PRC_DESC("Set this true to flatten text when it is generated, or false to "
00040 "keep it as a deep hierarchy. Usually it's a performance "
00041 "advantage to keep this true, but this also depends on the setting "
00042 "of text-dynamic-merge. See TextNode::set_flatten_flags()."));
00043
00044 ConfigVariableBool text_dynamic_merge
00045 ("text-dynamic-merge", true,
00046 PRC_DESC("Set this true to merge generated glyphs into the GeomVertexData "
00047 "as the text is assembled, or false to wait for the flatten "
00048 "operation. Usually it's a performance "
00049 "advantage to keep this true. See TextNode::set_flatten_flags()."));
00050
00051 ConfigVariableInt text_anisotropic_degree
00052 ("text-anisotropic-degree", 1,
00053 PRC_DESC("This is the default anisotropic-degree that is set on dynamic "
00054 "font textures. Setting this to a value greater than 1 can help "
00055 "smooth out the antialiasing for small letters."));
00056
00057 ConfigVariableInt text_texture_margin
00058 ("text-texture-margin", 2,
00059 PRC_DESC("This is the number of texels of empty space reserved around each "
00060 "glyph in the texture. Setting this value larger will decrease "
00061 "the tendency for adjacent glyphs to bleed into each other at "
00062 "small sizes, but it will increase amount of wasted texture "
00063 "memory."));
00064
00065 ConfigVariableDouble text_poly_margin
00066 ("text-poly-margin", 0.0f,
00067 PRC_DESC("This is the amount by which to make each glyph polygon larger "
00068 "than strictly necessary, in screen units that are added to each "
00069 "margin. Increasing this value will decrease the tendency for "
00070 "letters to get chopped off at the edges, but it will also "
00071 "increase the tendency for adjacent glyphs to bleed into each "
00072 "other (unless you also increase text-texture-margin)."));
00073
00074 ConfigVariableInt text_page_size
00075 ("text-page-size", "256 256",
00076 PRC_DESC("This is the default size for new textures created for dynamic "
00077 "fonts."));
00078
00079 ConfigVariableBool text_small_caps
00080 ("text-small-caps", false,
00081 PRC_DESC("This controls the default setting for "
00082 "TextNode::set_small_caps()."));
00083
00084 ConfigVariableDouble text_small_caps_scale
00085 ("text-small-caps-scale", 0.8f,
00086 PRC_DESC("This controls the default setting for "
00087 "TextNode::set_small_caps_scale()."));
00088
00089 ConfigVariableFilename text_default_font
00090 ("text-default-font", "",
00091 PRC_DESC("This names a filename that will be loaded at startup time as "
00092 "the default font for any TextNode that does not specify a font "
00093 "otherwise. The default is to use a special font that is "
00094 "compiled into Panda, if available."));
00095
00096 ConfigVariableDouble text_tab_width
00097 ("text-tab-width", 5.0f,
00098 PRC_DESC("This controls the default setting for "
00099 "TextNode::set_tab_width()."));
00100
00101 ConfigVariableInt text_push_properties_key
00102 ("text-push-properties-key", 1,
00103 PRC_DESC("This is the decimal character number that, embedded in "
00104 "a string, is used to bracket the name of a TextProperties "
00105 "structure added to the TextPropertiesManager object, to "
00106 "control the appearance of subsequent text."));
00107
00108 ConfigVariableInt text_pop_properties_key
00109 ("text-pop-properties-key", 2,
00110 PRC_DESC("This is the decimal character number that undoes the "
00111 "effect of a previous appearance of text_push_properties_key."));
00112
00113 ConfigVariableInt text_soft_hyphen_key
00114 ("text-soft-hyphen-key", 3,
00115 PRC_DESC("This is the decimal character number that, embedded in a "
00116 "string, is identified as the soft-hyphen character."));
00117
00118 ConfigVariableInt text_soft_break_key
00119 ("text-soft-break-key", 4,
00120 PRC_DESC("This is similar to text-soft-hyphen-key, except that "
00121 "when it is used as a break point, no character is "
00122 "introduced in its place."));
00123
00124 ConfigVariableInt text_embed_graphic_key
00125 ("text-embed-graphic-key", 5,
00126 PRC_DESC("This is the decimal character number that, embedded in "
00127 "a string, is used to bracket the name of a model "
00128 "added to the TextPropertiesManager object, to "
00129 "embed an arbitrary graphic image within a paragraph."));
00130
00131 wstring
00132 get_text_soft_hyphen_output() {
00133 static wstring *text_soft_hyphen_output = NULL;
00134 static ConfigVariableString
00135 cv("text-soft-hyphen-output", "-",
00136 PRC_DESC("This is the string that is output, encoded in the default "
00137 "encoding, to represent the hyphen character that is "
00138 "introduced when the line is broken at a soft-hyphen key."));
00139
00140 if (text_soft_hyphen_output == NULL) {
00141 TextEncoder encoder;
00142 text_soft_hyphen_output = new wstring(encoder.decode_text(cv));
00143 }
00144
00145 return *text_soft_hyphen_output;
00146 }
00147
00148 ConfigVariableDouble text_hyphen_ratio
00149 ("text-hyphen-ratio", 0.7,
00150 PRC_DESC("If the rightmost whitespace character falls before this "
00151 "fraction of the line, hyphenate a word to the right of that "
00152 "if possible."));
00153
00154 wstring
00155 get_text_never_break_before() {
00156 static wstring *text_never_break_before = NULL;
00157 static ConfigVariableString
00158 cv("text-never-break-before", ",.-:?!;",
00159 PRC_DESC("This string represents a list of individual characters "
00160 "that should never appear at the beginning of a line "
00161 "following a forced break. Typically these will be "
00162 "punctuation characters."));
00163
00164 if (text_never_break_before == NULL) {
00165 TextEncoder encoder;
00166 text_never_break_before = new wstring(encoder.decode_text(cv));
00167 }
00168
00169 return *text_never_break_before;
00170 }
00171
00172 ConfigVariableInt text_max_never_break
00173 ("text-max-never-break", 3,
00174 PRC_DESC("If we have more than this number of text-never-break-before "
00175 "characters in a row, do not treat any of them as special and "
00176 "instead break the line wherever we can."));
00177
00178 ConfigVariableDouble text_default_underscore_height
00179 ("text-default-underscore-height", -0.2,
00180 PRC_DESC("Specifies the default height of the underscore line, relative "
00181 "to the text baseline, when underscoring is enabled."));
00182
00183 ConfigVariableEnum<Texture::FilterType> text_minfilter
00184 ("text-minfilter", Texture::FT_linear_mipmap_linear,
00185 PRC_DESC("The default texture minfilter type for dynamic text fonts"));
00186 ConfigVariableEnum<Texture::FilterType> text_magfilter
00187 ("text-magfilter", Texture::FT_linear,
00188 PRC_DESC("The default texture magfilter type for dynamic text fonts"));
00189 ConfigVariableEnum<Texture::WrapMode> text_wrap_mode
00190 ("text-wrap-mode", Texture::WM_border_color,
00191 PRC_DESC("The default wrap mode for dynamic text fonts"));
00192 ConfigVariableEnum<Texture::QualityLevel> text_quality_level
00193 ("text-quality-level", Texture::QL_best,
00194 PRC_DESC("The default quality level for dynamic text fonts; see Texture::set_quality_level()."));
00195
00196 ConfigVariableEnum<TextFont::RenderMode> text_render_mode
00197 ("text-render-mode", TextFont::RM_texture,
00198 PRC_DESC("The default render mode for dynamic text fonts"));
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210 void
00211 init_libtext() {
00212 static bool initialized = false;
00213 if (initialized) {
00214 return;
00215 }
00216 initialized = true;
00217
00218 StaticTextFont::init_type();
00219 TextFont::init_type();
00220 TextNode::init_type();
00221 TextProperties::init_type();
00222
00223 #ifdef HAVE_FREETYPE
00224 DynamicTextFont::init_type();
00225 DynamicTextPage::init_type();
00226 GeomTextGlyph::init_type();
00227 GeomTextGlyph::init_type();
00228
00229 GeomTextGlyph::register_with_read_factory();
00230 GeomTextGlyph::register_with_read_factory();
00231
00232 PandaSystem *ps = PandaSystem::get_global_ptr();
00233 ps->add_system("Freetype");
00234 #endif
00235 }