~widelands-dev/widelands/trunk

« back to all changes in this revision

Viewing changes to src/font.h

  • Committer: sirver
  • Date: 2002-02-05 20:54:08 UTC
  • Revision ID: git-v1:df384fd3a5e53be1f37803d1c0381fa993844bf5
Initial revision


git-svn-id: https://widelands.svn.sourceforge.net/svnroot/widelands/trunk@2 37b2a8de-5219-0410-9f54-a31bc463ab9c

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2001 by Holger Rapp 
 
3
 * 
 
4
 * This program is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU General Public License
 
6
 * as published by the Free Software Foundation; either version 2
 
7
 * of the License, or (at your option) any later version.
 
8
 * 
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 * 
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
17
 *
 
18
 */
 
19
 
 
20
#ifndef __S__FONT_H
 
21
#define __S__FONT_H
 
22
 
 
23
#include "graphic.h"
 
24
#include "singleton.h"
 
25
 
 
26
// Ugly: Size of chars is hard coded for widelands. 
 
27
// Somebody's feeling like defining a font file format?
 
28
#define FONT_H  7
 
29
#define FONT_W          7
 
30
 
 
31
/** class Font_Handler
 
32
 *
 
33
 * This class generates font Pictures out of strings and returns them
 
34
 * This is sure that the user want's fixed font strings
 
35
 *
 
36
 * It's a singleton
 
37
 * 
 
38
 * DEPENDS: class       Graph::Pic
 
39
 * DEPENDS:     func    Graph::copy_pic
 
40
 */
 
41
class Font_Handler : public Singleton<Font_Handler> {
 
42
                  Font_Handler(const Font_Handler&);
 
43
                  Font_Handler& operator=(const Font_Handler&);
 
44
 
 
45
                  public:
 
46
                                         const static unsigned short MAX_FONTS=2;
 
47
                  
 
48
                                         Font_Handler();
 
49
                                         ~Font_Handler();
 
50
 
 
51
                                         
 
52
                                         void set_font(const unsigned short, Pic*, const unsigned short, const unsigned short);
 
53
                                         Pic* get_string(const char*, const unsigned short);
 
54
                                         
 
55
                                         /** inline unsigned short get_fh(unsigned short f) 
 
56
                                          *
 
57
                                          * This function returns the height of the given font
 
58
                                          * Args: f     which font to check
 
59
                                          * Returns: height
 
60
                                          */
 
61
                                         inline unsigned short get_fh(unsigned short f) { assert(f<MAX_FONTS); assert(h[f]); return h[f]; }
 
62
                                         
 
63
                                         /** inline unsigned short get_fw(unsigned short f) 
 
64
                                          *
 
65
                                          * This function returns the width of the given font
 
66
                                          * Args: f     which font to check
 
67
                                          * Returns: width
 
68
                                          */
 
69
                                         inline unsigned short get_fw(unsigned short f) { assert(f<MAX_FONTS); assert(w[f]); return w[f]; }
 
70
                                         
 
71
                  private:
 
72
                                         unsigned short w[MAX_FONTS];
 
73
                                         unsigned short h[MAX_FONTS];
 
74
                                         Pic*   pics[MAX_FONTS];
 
75
                  
 
76
};
 
77
 
 
78
#define g_fh    Font_Handler::get_singleton()
 
79
 
 
80
#endif /* __S__FONT_H */