static fonts should support explicit space advance specified from font file

This commit is contained in:
David Rose 2011-11-21 18:59:54 +00:00
parent ffa6d1bf16
commit 75ac6c1bae
3 changed files with 19 additions and 5 deletions

View File

@ -1818,6 +1818,11 @@
0 1 0
}
}
<Group> 32 {
<PointLight> {
<VertexRef> { 160 <Ref> { vpool } }
}
}
<Group> 33 {
<Polygon> {
<TRef> { chars }

View File

@ -70,6 +70,14 @@ StaticTextFont(PandaNode *font_def) {
find_characters(font_def, RenderState::make_empty());
_is_valid = !_glyphs.empty();
// Check for an explicit space width.
int character = 32;
Glyphs::iterator gi = _glyphs.find(character);
if (gi != _glyphs.end()) {
TextGlyph *glyph = (*gi).second;
_space_advance = glyph->get_advance();
}
set_name(font_def->get_name());
}
@ -287,15 +295,16 @@ find_characters(PandaNode *root, const RenderState *net_state) {
CPT(Geom) dot;
const RenderState *state = NULL;
find_character_gsets(root, ch, dot, state, next_net_state);
if (ch != (Geom *)NULL && dot != (Geom *)NULL) {
PN_stdfloat width = 0.0;
if (dot != (Geom *)NULL) {
// Get the first vertex from the "dot" geoset. This will be the
// origin of the next character.
GeomVertexReader reader(dot->get_vertex_data(), InternalName::get_vertex());
PN_stdfloat width = reader.get_data1f();
_glyphs[character] = new TextGlyph(character, ch, state, width);
width = reader.get_data1f();
}
_glyphs[character] = new TextGlyph(character, ch, state, width);
} else if (name == "ds") {
// The group "ds" is a special node that indicates the font's
// design size, or line height.

View File

@ -8,7 +8,7 @@
#define OTHER_LIBS \
egg:c pandaegg:m \
pipeline:c event:c pstatclient:c panda:m \
pandabase:c pnmimage:c pnmtext:c \
pandabase:c pnmimage:c pnmimagetypes:c pnmtext:c \
mathutil:c linmath:c putil:c express:c \
pandaexpress:m \
interrogatedb:c prc:c dconfig:c dtoolconfig:m \