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