ROLAND  0.70
Amstrad Emulator based on Caprice Source rewritten in C++.
imagefont.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) by Fred Klaus *
3  * development@fkweb.de *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 #ifndef SDLTK_IMAGE_FONT_H
21 #define SDLTK_IMAGE_FONT_H
22 
23 #include "image.h"
24 #include <string>
25 
26 namespace sdltk
27 {
28 
29  class Rect;
30 
33  class ImageFont
34  {
35 
36  public:
38  ImageFont() : mSpacing(0) {};
41  ImageFont(const String & fname, const String & glyphs);
44 
46  void init();
48  void clear();
49 
52  void load(const String & fname, const String & glyphs, uchar alpha=255);
53 
54  inline const Rect & glyph(Uint8 chr) const;
55 
56  const Image & image() {return mImage;}
57 
58  void setSpacing(Uint16 spacing);
59  Uint16 spacing() const {return mSpacing;}
60 
61  private:
64  Rect mGlyphRect[256]; // @todo maximum Glyphs !?!
65  Uint16 mSpacing;
66 
67  };
68 
69 
70  inline const Rect & ImageFont::glyph(Uint8 chr) const
71  {
72  String::size_type i = mGlyphs.find(chr);
73  if (i == String::npos) i = 0;
74  return mGlyphRect[i];
75  }
76 
77 } // sdltk
78 
79 #endif // SDLTK_IMAGE_FONT_H
void init()
Definition: roland.cpp:97
const Image & image()
Definition: imagefont.h:56
Image to display either on an OpenGL- or plain SDL-Surface.
Definition: image.h:39
ImageFont()
Standardconstructor.
Definition: imagefont.h:38
Uint16 spacing() const
Definition: imagefont.h:59
unsigned char uchar
Definition: types.h:127
void clear()
Frees all used resources.
Definition: imagefont.cpp:51
Image mImage
Definition: imagefont.h:62
const Rect & glyph(Uint8 chr) const
Definition: imagefont.h:70
Uint16 mSpacing
Definition: imagefont.h:65
#define ROLAND_DEFAULT
Definition: compspec.h:46
void load(const String &fname, const String &glyphs, uchar alpha=255)
Definition: imagefont.cpp:56
Definition: rect.h:32
a font created from an Image
Definition: imagefont.h:33
std::string String
Definition: types.h:29
~ImageFont() ROLAND_DEFAULT void init()
Standarddestructor.
String mGlyphs
Definition: imagefont.h:63
the SDL based Stuff
Definition: audio.cpp:22
Rect mGlyphRect[256]
Definition: imagefont.h:64
void setSpacing(Uint16 spacing)