annotate font/font.h @ 66:d112357a0ec1

Fix a bug with savegames introduced with changeset c7bcc0ec2267. Warning: savegames created since c7bcc0ec2267 are probably corrupted, you may have to start the game over. If you chose not to do so, you should replace all occurrences of 'TextWindow' by 'TextImplWindow', and 'Text Window' by 'TextImpl Window' in your save files.
author Thibaut Girka <thib@sitedethib.com>
date Sat, 11 Dec 2010 18:36:20 +0100
parents ddbcbd000206
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
223b71206888 Initial import
thib
parents:
diff changeset
1 /*
223b71206888 Initial import
thib
parents:
diff changeset
2 * Copyright (c) 2004 Kazunori "jagarl" Ueno
223b71206888 Initial import
thib
parents:
diff changeset
3 * Copyright (c) 2000, 2001 Yuki Sawada
223b71206888 Initial import
thib
parents:
diff changeset
4 * All rights reserved.
223b71206888 Initial import
thib
parents:
diff changeset
5 *
223b71206888 Initial import
thib
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
223b71206888 Initial import
thib
parents:
diff changeset
7 * modification, are permitted provided that the following conditions
223b71206888 Initial import
thib
parents:
diff changeset
8 * are met:
223b71206888 Initial import
thib
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
10 * notice, this list of conditions and the following disclaimer.
0
223b71206888 Initial import
thib
parents:
diff changeset
11 * 2. Redistributions in binary form must reproduce the above copyright
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
12 * notice, this list of conditions and the following disclaimer in the
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
13 * documentation and/or other materials provided with the distribution.
0
223b71206888 Initial import
thib
parents:
diff changeset
14 * 3. The name of the author may not be used to endorse or promote products
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
15 * derived from this software without specific prior written permission.
0
223b71206888 Initial import
thib
parents:
diff changeset
16 *
223b71206888 Initial import
thib
parents:
diff changeset
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
223b71206888 Initial import
thib
parents:
diff changeset
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
223b71206888 Initial import
thib
parents:
diff changeset
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
223b71206888 Initial import
thib
parents:
diff changeset
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
223b71206888 Initial import
thib
parents:
diff changeset
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
223b71206888 Initial import
thib
parents:
diff changeset
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
223b71206888 Initial import
thib
parents:
diff changeset
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
223b71206888 Initial import
thib
parents:
diff changeset
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
223b71206888 Initial import
thib
parents:
diff changeset
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
223b71206888 Initial import
thib
parents:
diff changeset
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
223b71206888 Initial import
thib
parents:
diff changeset
27 */
223b71206888 Initial import
thib
parents:
diff changeset
28
223b71206888 Initial import
thib
parents:
diff changeset
29 #ifndef __FONT_TYPES_H__
223b71206888 Initial import
thib
parents:
diff changeset
30 #define __FONT_TYPES_H__
223b71206888 Initial import
thib
parents:
diff changeset
31
223b71206888 Initial import
thib
parents:
diff changeset
32 #ifdef HAVE_CONFIG_H
223b71206888 Initial import
thib
parents:
diff changeset
33 # include "config.h"
223b71206888 Initial import
thib
parents:
diff changeset
34 #endif
223b71206888 Initial import
thib
parents:
diff changeset
35
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
36 #include <vector>
0
223b71206888 Initial import
thib
parents:
diff changeset
37
223b71206888 Initial import
thib
parents:
diff changeset
38 class TextHorizLayout;
223b71206888 Initial import
thib
parents:
diff changeset
39 class TextStream;
223b71206888 Initial import
thib
parents:
diff changeset
40 class TextGlyphStream;
223b71206888 Initial import
thib
parents:
diff changeset
41
223b71206888 Initial import
thib
parents:
diff changeset
42 namespace XKFont {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
43 class Font;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
44 class Face;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
45 class Peer;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
46 class Glyph;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
47 class Cache;
0
223b71206888 Initial import
thib
parents:
diff changeset
48
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
49 struct Font {
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
50 public:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
51 Font(const char* fontname, int size);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
52 ~Font();
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
53 Face* FaceLoad(double scale);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
54 int vsize;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
55 private:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
56 class FontImpl* pimpl;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
57 };
0
223b71206888 Initial import
thib
parents:
diff changeset
58
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
59 struct Face {
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
60 public:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
61 Face(const char *name, int index, int hsize, int vsize);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
62 ~Face();
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
63 Glyph* GlyphLoad(unsigned int code);
0
223b71206888 Initial import
thib
parents:
diff changeset
64
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
65 private:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
66 Cache* cache;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
67 typedef std::vector<Peer*>::iterator iterator;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
68 std::vector<Peer*> peer;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
69 };
0
223b71206888 Initial import
thib
parents:
diff changeset
70
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
71 struct Peer {
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
72 public:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
73 Peer(void) {}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
74 virtual ~Peer() {};
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
75 virtual bool GlyphCreate(unsigned int code, Glyph* glyph) = 0;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
76 };
0
223b71206888 Initial import
thib
parents:
diff changeset
77
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
78 struct Glyph {
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
79 public:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
80 struct _bitmap {
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
81 int width;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
82 int rows;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
83 unsigned char *buffer;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
84 _bitmap() : buffer(0) {}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
85 ~_bitmap() { delete[] buffer;}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
86 } bitmap;
0
223b71206888 Initial import
thib
parents:
diff changeset
87 #if 0
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
88 struct _metrics {
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
89 int ascender;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
90 int descender;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
91 } metrics;
0
223b71206888 Initial import
thib
parents:
diff changeset
92 #endif
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
93 struct _advance {
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
94 int x;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
95 int y;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
96 } advance;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
97
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
98 Glyph() : bitmap() {}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
99 ~Glyph() {}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
100 int bitmap_left;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
101 int bitmap_top;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
102 };
0
223b71206888 Initial import
thib
parents:
diff changeset
103
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
104 struct HorizLayout {
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
105 public:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
106 HorizLayout(const char* fontname, int size);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
107 ~HorizLayout();
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
108 void Layout(::TextStream& stream, ::TextGlyphStream& glyph, std::vector<int>& lineheights, int width);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
109 ::TextGlyphStream Layout(const char* str, int width, int r=0xff, int g=0xff, int b=0xff);
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
110 ::TextGlyphStream Layout(TextStream ts, int width);
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
111 private:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
112 Font* font;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
113 class ::TextHorizLayout* pimpl;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
114 };
0
223b71206888 Initial import
thib
parents:
diff changeset
115
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
116 } /* end of namespace XKFont */
0
223b71206888 Initial import
thib
parents:
diff changeset
117
223b71206888 Initial import
thib
parents:
diff changeset
118 #endif