00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "win_font.h"
00015
00016 win_font::win_font()
00017 {
00018 cursor=NULL;
00019 }
00020
00021 win_font::win_font(char * fic)
00022 {
00023 cursor=NULL;
00024 load(fic);
00025 }
00026
00027 win_font::win_font(win_font & tmpfont)
00028 {
00029 *this=tmpfont;
00030 }
00031
00032 win_font::~win_font()
00033 {
00034 erase();
00035 }
00036 void win_font::erase()
00037 {
00038 if(cursor) delete cursor;
00039 glyphs.clear ();
00040 }
00041
00042
00043 void win_font::load(char * rep)
00044 {
00045 erase();
00046
00047
00048 igzstream f;
00049
00050
00051 string path = WIN_DIRECTORY;
00052
00053
00054 path += WIN_FONT_DIRECTORY;
00055
00056
00057 path += string (rep) + "/";
00058
00059
00060 path += WIN_FONT_FILE;
00061
00062
00063 if (!f.open (path))
00064 {
00065 cout << path << " not found !\n";
00066 exit(1);
00067 }
00068
00069
00070 image *font=new image();
00071 font->get(f);
00072
00073
00074 cursor=new image();
00075 cursor->get(f);
00076
00077 char i;
00078 u_int16 pos,tl;
00079
00080 while(!f.eof())
00081 {
00082
00083 i << f;
00084 pos << f;
00085 tl << f;
00086 if(i>0 && i<WIN_NB_TABLE_CHAR)
00087 {
00088 image *glph = new image (tl + 1,font->height()-1);
00089 font->draw (0, 0, pos, 0, tl + 1, font->height () -1, NULL, glph);
00090 glyphs[i] = glph;
00091 }
00092 }
00093
00094 height_=font->height()-1;
00095
00096 length_=glyphs[' ']->length();
00097
00098 if(font)delete font;
00099
00100 f.close ();
00101 }
00102
00103
00104 bool win_font::in_table(u_int16 tmp)
00105 {
00106 if (glyphs.find (tmp) != glyphs.end ()) return true;
00107 else return false;
00108 }
00109
00110 image & win_font::operator[](u_int16 i)
00111 {
00112 if (in_table (i)) return *(glyphs[i]);
00113 else return *(glyphs[' ']);
00114 }
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132