Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages   Examples  

glt/font.cpp

Go to the documentation of this file.
00001 #include "font.h"
00002 
00015 #include <math/real.h>
00016 
00017 #include <cstdio>
00018 #include <cassert>
00019 using namespace std;
00020 
00021 GltFont::GltFont()
00022 : _hStep(0), _vStep(0), _init(false)
00023 {
00024 }
00025 
00026 GltFont::GltFont(const GltFont &)
00027 {
00028     // Can't copy fonts
00029     assert(0);
00030 }
00031 
00032 GltFont &
00033 GltFont::operator=(const GltFont &)
00034 {
00035     // Can't copy fonts
00036     assert(0);
00037     return *this;
00038 }
00039 
00040 GltFont::~GltFont()
00041 {
00042     _init = false;
00043 }
00044 
00045 void 
00046 GltFont::size(int &w,int &h,const std::wstring &str) const
00047 {
00048     h = 0;
00049     w = 0;
00050 
00051     // Get the first line of text
00052 
00053     string::size_type i = 0;
00054     string::size_type j = str.find('\n',i);
00055 
00056     // Process each line of text
00057 
00058     while (i<str.size())
00059     {
00060         h++;
00061 
00062         int lWidth = 0;
00063         for (string::size_type k=i; k<j && k<str.size(); k++)
00064             lWidth += width(str[k]);
00065 
00066         //
00067 
00068         w = MAX(w,lWidth);
00069 
00070         //
00071 
00072         if (j==wstring::npos)
00073             break;
00074         
00075         i = j+1;
00076         j = str.find('\n',i);
00077     }
00078 
00079     //
00080 
00081     h *= _vStep;
00082 }
00083 
00084 int 
00085 GltFont::width(const wchar_t ch) const
00086 {
00087     return _hStep;
00088 }
00089 
00090 const int GltFont::hStep()  const { return _hStep; }
00091 const int GltFont::vStep()  const { return _vStep; }
00092 

Generated on Tue Nov 5 11:11:03 2002 for GLT by doxygen1.2.18