annotate font/font.h @ 37:f88d47a4bf87

* Modernize configure.ac * Improve a bit BGM playback
author thib
date Tue, 17 Mar 2009 17:47:26 +0000
parents 223b71206888
children 15a18fbe6f21
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
223b71206888 Initial import
thib
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
223b71206888 Initial import
thib
parents:
diff changeset
11 * 2. Redistributions in binary form must reproduce the above copyright
223b71206888 Initial import
thib
parents:
diff changeset
12 * notice, this list of conditions and the following disclaimer in the
223b71206888 Initial import
thib
parents:
diff changeset
13 * documentation and/or other materials provided with the distribution.
223b71206888 Initial import
thib
parents:
diff changeset
14 * 3. The name of the author may not be used to endorse or promote products
223b71206888 Initial import
thib
parents:
diff changeset
15 * derived from this software without specific prior written permission.
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
223b71206888 Initial import
thib
parents:
diff changeset
36 #include<vector>
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 {
223b71206888 Initial import
thib
parents:
diff changeset
43 class Font;
223b71206888 Initial import
thib
parents:
diff changeset
44 class Face;
223b71206888 Initial import
thib
parents:
diff changeset
45 class Peer;
223b71206888 Initial import
thib
parents:
diff changeset
46 class Glyph;
223b71206888 Initial import
thib
parents:
diff changeset
47 class Cache;
223b71206888 Initial import
thib
parents:
diff changeset
48
223b71206888 Initial import
thib
parents:
diff changeset
49 struct Font {
223b71206888 Initial import
thib
parents:
diff changeset
50 public:
223b71206888 Initial import
thib
parents:
diff changeset
51 Font(const char* fontname, int size);
223b71206888 Initial import
thib
parents:
diff changeset
52 ~Font();
223b71206888 Initial import
thib
parents:
diff changeset
53 Face* FaceLoad(double scale);
223b71206888 Initial import
thib
parents:
diff changeset
54 int vsize;
223b71206888 Initial import
thib
parents:
diff changeset
55 private:
223b71206888 Initial import
thib
parents:
diff changeset
56 class FontImpl* pimpl;
223b71206888 Initial import
thib
parents:
diff changeset
57 };
223b71206888 Initial import
thib
parents:
diff changeset
58
223b71206888 Initial import
thib
parents:
diff changeset
59 struct Face {
223b71206888 Initial import
thib
parents:
diff changeset
60 public:
223b71206888 Initial import
thib
parents:
diff changeset
61 Face(const char *name, int index, int hsize, int vsize);
223b71206888 Initial import
thib
parents:
diff changeset
62 ~Face();
223b71206888 Initial import
thib
parents:
diff changeset
63 Glyph* GlyphLoad(unsigned int code);
223b71206888 Initial import
thib
parents:
diff changeset
64
223b71206888 Initial import
thib
parents:
diff changeset
65 private:
223b71206888 Initial import
thib
parents:
diff changeset
66 Cache* cache;
223b71206888 Initial import
thib
parents:
diff changeset
67 typedef std::vector<Peer*>::iterator iterator;
223b71206888 Initial import
thib
parents:
diff changeset
68 std::vector<Peer*> peer;
223b71206888 Initial import
thib
parents:
diff changeset
69 };
223b71206888 Initial import
thib
parents:
diff changeset
70
223b71206888 Initial import
thib
parents:
diff changeset
71 struct Peer {
223b71206888 Initial import
thib
parents:
diff changeset
72 Peer(void) {}
223b71206888 Initial import
thib
parents:
diff changeset
73 virtual ~Peer() {};
223b71206888 Initial import
thib
parents:
diff changeset
74 virtual bool GlyphCreate(unsigned int code, Glyph* glyph) = 0;
223b71206888 Initial import
thib
parents:
diff changeset
75 };
223b71206888 Initial import
thib
parents:
diff changeset
76
223b71206888 Initial import
thib
parents:
diff changeset
77 struct Glyph {
223b71206888 Initial import
thib
parents:
diff changeset
78 int bitmap_left;
223b71206888 Initial import
thib
parents:
diff changeset
79 int bitmap_top;
223b71206888 Initial import
thib
parents:
diff changeset
80 struct _bitmap {
223b71206888 Initial import
thib
parents:
diff changeset
81 int width;
223b71206888 Initial import
thib
parents:
diff changeset
82 int rows;
223b71206888 Initial import
thib
parents:
diff changeset
83 unsigned char *buffer;
223b71206888 Initial import
thib
parents:
diff changeset
84 _bitmap() : buffer(0) {}
223b71206888 Initial import
thib
parents:
diff changeset
85 ~_bitmap() { delete[] buffer;}
223b71206888 Initial import
thib
parents:
diff changeset
86 } bitmap;
223b71206888 Initial import
thib
parents:
diff changeset
87 #if 0
223b71206888 Initial import
thib
parents:
diff changeset
88 struct _metrics {
223b71206888 Initial import
thib
parents:
diff changeset
89 int ascender;
223b71206888 Initial import
thib
parents:
diff changeset
90 int descender;
223b71206888 Initial import
thib
parents:
diff changeset
91 } metrics;
223b71206888 Initial import
thib
parents:
diff changeset
92 #endif
223b71206888 Initial import
thib
parents:
diff changeset
93 struct _advance {
223b71206888 Initial import
thib
parents:
diff changeset
94 int x;
223b71206888 Initial import
thib
parents:
diff changeset
95 int y;
223b71206888 Initial import
thib
parents:
diff changeset
96 } advance;
223b71206888 Initial import
thib
parents:
diff changeset
97 Glyph() : bitmap() {}
223b71206888 Initial import
thib
parents:
diff changeset
98 ~Glyph() {}
223b71206888 Initial import
thib
parents:
diff changeset
99 };
223b71206888 Initial import
thib
parents:
diff changeset
100
223b71206888 Initial import
thib
parents:
diff changeset
101 struct HorizLayout {
223b71206888 Initial import
thib
parents:
diff changeset
102 HorizLayout(const char* fontname, int size);
223b71206888 Initial import
thib
parents:
diff changeset
103 ~HorizLayout();
223b71206888 Initial import
thib
parents:
diff changeset
104 void Layout(::TextStream& stream, ::TextGlyphStream& glyph, std::vector<int>& lineheights, int width);
223b71206888 Initial import
thib
parents:
diff changeset
105 ::TextGlyphStream Layout(const char* str, int width, int r=0xff, int g=0xff, int b=0xff);
223b71206888 Initial import
thib
parents:
diff changeset
106 private:
223b71206888 Initial import
thib
parents:
diff changeset
107 Font* font;
223b71206888 Initial import
thib
parents:
diff changeset
108 class ::TextHorizLayout* pimpl;
223b71206888 Initial import
thib
parents:
diff changeset
109 };
223b71206888 Initial import
thib
parents:
diff changeset
110
223b71206888 Initial import
thib
parents:
diff changeset
111 }; /* end of namespace XKFont */
223b71206888 Initial import
thib
parents:
diff changeset
112
223b71206888 Initial import
thib
parents:
diff changeset
113 #endif