Mercurial > otakunoraifu
comparison font/text.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 * All rights reserved. | |
4 * | |
5 * Redistribution and use in source and binary forms, with or without | |
6 * modification, are permitted provided that the following conditions | |
7 * are met: | |
8 * 1. Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * 2. Redistributions in binary form must reproduce the above copyright | |
11 * notice, this list of conditions and the following disclaimer in the | |
12 * documentation and/or other materials provided with the distribution. | |
13 * 3. The name of the author may not be used to endorse or promote products | |
14 * derived from this software without specific prior written permission. | |
15 * | |
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
26 */ | |
27 | |
28 #ifndef __TEXT_H__ | |
29 #define __TEXT_H__ | |
30 | |
31 #include<vector> | |
32 #include<string> | |
33 | |
34 struct TextElem { | |
35 typedef enum {glyph, escape, color, size} ElemType; | |
36 typedef enum { ret, pos_reset, name_start, name_end, ruby_start, ruby_startruby, ruby_end} EscapeType; | |
37 ElemType type; | |
38 union Impl { | |
39 struct { | |
40 int code; | |
41 } Glyph; | |
42 struct { | |
43 EscapeType type; | |
44 } Escape; | |
45 struct { | |
46 unsigned char r, g, b; | |
47 } Color; | |
48 struct { | |
49 float scale; | |
50 } Size; | |
51 } impl; | |
52 }; | |
53 | |
54 struct TextStream { | |
55 std::vector<TextElem> container; | |
56 typedef std::vector<TextElem>::iterator Iterator; | |
57 enum {sjis, euc} kanji_type; | |
58 | |
59 std::string Save(void); | |
60 void Load(const std::string&); | |
61 | |
62 void SetSize(double size); | |
63 void SetColor(unsigned char r, unsigned char g, unsigned char b); | |
64 void SetDefaultColor(unsigned char r, unsigned char g, unsigned char b); | |
65 void InsertColor(int begin_pos, int end_pos, unsigned char r, unsigned char g, unsigned char b); | |
66 void Clear(void); | |
67 void Add(const char* str); | |
68 void AddReturn(void); | |
69 void AddName(const char* name); | |
70 void AddRuby(const char* str, const char* ruby); | |
71 | |
72 void RemoveName(char* name, int namelen); | |
73 | |
74 TextStream(void); | |
75 TextStream& operator =(const TextStream& from) { | |
76 container = from.container; | |
77 kanji_type = from.kanji_type; | |
78 return *this; | |
79 } | |
80 }; | |
81 | |
82 namespace XKFont { | |
83 class Glyph; | |
84 class Font; | |
85 }; | |
86 | |
87 struct TextGlyph { | |
88 int x,y; | |
89 enum Flag { Group = 1, LineEnd = 2, Kinsoku = 4, PhraseEnd = 8} flag; | |
90 unsigned char r, g, b; | |
91 bool is_rev; | |
92 XKFont::Glyph* glyph; | |
93 }; | |
94 | |
95 struct TextGlyphStream : public std::vector<TextGlyph> { | |
96 XKFont::Font* font; | |
97 int width(void); | |
98 int height(void); | |
99 void SetColor(int r, int g, int b); | |
100 void SetReverse(bool rev); | |
101 }; | |
102 | |
103 #endif /* __TEXT_H__ */ |