annotate font/text.h @ 74:f8751d74918b default tip

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