summaryrefslogtreecommitdiff
path: root/common/texfont.cpp
diff options
context:
space:
mode:
authorleo2005-02-11 19:06:36 +0000
committerleo2005-02-11 19:06:36 +0000
commitd8fb3cc03a749691a5a12096fdfb6ca0d130b276 (patch)
tree32f714d7d632d28fe739581f128adceac596e7ad /common/texfont.cpp
parentb8ab42ca9ac2b2e8cd5e10b3fa6fe13b08dc3e44 (diff)
Added GetStringDimensions() function.
git-svn-id: http://svn.leocad.org/trunk@375 c7d43263-9d01-0410-8a33-9dba5d9f93d6
Diffstat (limited to 'common/texfont.cpp')
-rw-r--r--common/texfont.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/common/texfont.cpp b/common/texfont.cpp
index fa3fe0f..4e53092 100644
--- a/common/texfont.cpp
+++ b/common/texfont.cpp
@@ -92,6 +92,39 @@ bool TexFont::FileLoad (File& file)
return true;
}
+void TexFont::GetStringDimensions(int* cx, int* cy, const char* Text) const
+{
+ *cx = 0;
+ *cy = m_nFontHeight;
+
+ while (*Text != 0)
+ {
+ *cx += m_Glyphs[*Text].width;
+ Text++;
+ }
+}
+
+void TexFont::PrintText(float Left, float Top, float ScaleX, float ScaleY, const char* Text) const
+{
+ float Height = m_nFontHeight * ScaleY;
+
+ while (*Text != 0)
+ {
+ glTexCoord2f(m_Glyphs[*Text].left, m_Glyphs[*Text].top);
+ glVertex2f(Left, Top);
+ glTexCoord2f(m_Glyphs[*Text].left, m_Glyphs[*Text].bottom);
+ glVertex2f(Left, Top - Height);
+ glTexCoord2f(m_Glyphs[*Text].right, m_Glyphs[*Text].bottom);
+ glVertex2f(Left + m_Glyphs[*Text].width * ScaleX, Top - Height);
+ glTexCoord2f(m_Glyphs[*Text].right, m_Glyphs[*Text].top);
+ glVertex2f(Left + m_Glyphs[*Text].width * ScaleX, Top);
+
+ Left += m_Glyphs[*Text].width * ScaleX;
+ Text++;
+ }
+}
+
+// Old function, should probably be removed.
void TexFont::PrintText (float left, float top, const char* text) const
{
while (*text != 0)