font(f),
mesh((TEXCOORD2, VERTEX2)),
horz_align(0.0f),
- vert_offset(0.0f)
+ vert_offset(0.0f),
+ width(0.0f)
{
object.set_mesh(&mesh);
if(tech)
if(tech)
{
technique = *tech;
- technique.replace_texture("diffusemap", font.get_texture());
+ technique.replace_texture("diffuse_map", font.get_texture());
object.set_technique(&technique);
}
else
{
clear();
width = font.get_string_width(text, dec);
- GL::MeshBuilder bld(mesh);
- bld.matrix() *= Matrix::translation(Vector3(-horz_align*width, vert_offset, 0.0f));
+ MeshBuilder bld(mesh);
+ bld.transform(Matrix::translation(Vector3(-horz_align*width, vert_offset, 0.0f)));
font.build_string(text, dec, bld);
}
{
case DESCENT: v = -font.get_descent(); break;
case BASELINE: v = 0.0f; break;
- case MIDLINE: v = font.get_ascent()/2; break; // XXX Midline should be cap height / 2
+ case MIDLINE: v = font.get_cap_height()/2; break;
case ASCENT: v = font.get_ascent(); break;
default: throw invalid_argument("Text::set_alignment");
}
void Text::set_alignment(float h, float v)
{
+ if(h==horz_align && -v==vert_offset)
+ return;
+
float horz_adjust = (horz_align-h)*width;
float vert_adjust = -v-vert_offset;
horz_align = h;