Mercurial > otakunoraifu
comparison font/font.h @ 52:15a18fbe6f21
* Known bugs added to the README
* Code cleaning (0 -> NULL when needed, indentation, spaces, ...)
author | thib |
---|---|
date | Sat, 18 Apr 2009 18:35:39 +0000 |
parents | 223b71206888 |
children | ddbcbd000206 |
comparison
equal
deleted
inserted
replaced
51:cbb301016a4e | 52:15a18fbe6f21 |
---|---|
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
11 * 2. Redistributions in binary form must reproduce the above copyright | 11 * 2. Redistributions in binary form must reproduce the above copyright |
12 * notice, this list of conditions and the following disclaimer in the | 12 * notice, this list of conditions and the following disclaimer in the |
13 * documentation and/or other materials provided with the distribution. | 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 | 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. | 15 * derived from this software without specific prior written permission. |
16 * | 16 * |
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | 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 | 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
31 | 31 |
32 #ifdef HAVE_CONFIG_H | 32 #ifdef HAVE_CONFIG_H |
33 # include "config.h" | 33 # include "config.h" |
34 #endif | 34 #endif |
35 | 35 |
36 #include<vector> | 36 #include <vector> |
37 | 37 |
38 class TextHorizLayout; | 38 class TextHorizLayout; |
39 class TextStream; | 39 class TextStream; |
40 class TextGlyphStream; | 40 class TextGlyphStream; |
41 | 41 |
42 namespace XKFont { | 42 namespace XKFont { |
43 class Font; | 43 class Font; |
44 class Face; | 44 class Face; |
45 class Peer; | 45 class Peer; |
46 class Glyph; | 46 class Glyph; |
47 class Cache; | 47 class Cache; |
48 | 48 |
49 struct Font { | 49 struct Font { |
50 public: | 50 public: |
51 Font(const char* fontname, int size); | 51 Font(const char* fontname, int size); |
52 ~Font(); | 52 ~Font(); |
53 Face* FaceLoad(double scale); | 53 Face* FaceLoad(double scale); |
54 int vsize; | 54 int vsize; |
55 private: | 55 private: |
56 class FontImpl* pimpl; | 56 class FontImpl* pimpl; |
57 }; | 57 }; |
58 | 58 |
59 struct Face { | 59 struct Face { |
60 public: | 60 public: |
61 Face(const char *name, int index, int hsize, int vsize); | 61 Face(const char *name, int index, int hsize, int vsize); |
62 ~Face(); | 62 ~Face(); |
63 Glyph* GlyphLoad(unsigned int code); | 63 Glyph* GlyphLoad(unsigned int code); |
64 | 64 |
65 private: | 65 private: |
66 Cache* cache; | 66 Cache* cache; |
67 typedef std::vector<Peer*>::iterator iterator; | 67 typedef std::vector<Peer*>::iterator iterator; |
68 std::vector<Peer*> peer; | 68 std::vector<Peer*> peer; |
69 }; | 69 }; |
70 | 70 |
71 struct Peer { | 71 struct Peer { |
72 Peer(void) {} | 72 public: |
73 virtual ~Peer() {}; | 73 Peer(void) {} |
74 virtual bool GlyphCreate(unsigned int code, Glyph* glyph) = 0; | 74 virtual ~Peer() {}; |
75 }; | 75 virtual bool GlyphCreate(unsigned int code, Glyph* glyph) = 0; |
76 }; | |
76 | 77 |
77 struct Glyph { | 78 struct Glyph { |
78 int bitmap_left; | 79 public: |
79 int bitmap_top; | 80 struct _bitmap { |
80 struct _bitmap { | 81 int width; |
81 int width; | 82 int rows; |
82 int rows; | 83 unsigned char *buffer; |
83 unsigned char *buffer; | 84 _bitmap() : buffer(0) {} |
84 _bitmap() : buffer(0) {} | 85 ~_bitmap() { delete[] buffer;} |
85 ~_bitmap() { delete[] buffer;} | 86 } bitmap; |
86 } bitmap; | |
87 #if 0 | 87 #if 0 |
88 struct _metrics { | 88 struct _metrics { |
89 int ascender; | 89 int ascender; |
90 int descender; | 90 int descender; |
91 } metrics; | 91 } metrics; |
92 #endif | 92 #endif |
93 struct _advance { | 93 struct _advance { |
94 int x; | 94 int x; |
95 int y; | 95 int y; |
96 } advance; | 96 } advance; |
97 Glyph() : bitmap() {} | |
98 ~Glyph() {} | |
99 }; | |
100 | 97 |
101 struct HorizLayout { | 98 Glyph() : bitmap() {} |
102 HorizLayout(const char* fontname, int size); | 99 ~Glyph() {} |
103 ~HorizLayout(); | 100 int bitmap_left; |
104 void Layout(::TextStream& stream, ::TextGlyphStream& glyph, std::vector<int>& lineheights, int width); | 101 int bitmap_top; |
105 ::TextGlyphStream Layout(const char* str, int width, int r=0xff, int g=0xff, int b=0xff); | 102 }; |
106 private: | |
107 Font* font; | |
108 class ::TextHorizLayout* pimpl; | |
109 }; | |
110 | 103 |
111 }; /* end of namespace XKFont */ | 104 struct HorizLayout { |
105 public: | |
106 HorizLayout(const char* fontname, int size); | |
107 ~HorizLayout(); | |
108 void Layout(::TextStream& stream, ::TextGlyphStream& glyph, std::vector<int>& lineheights, int width); | |
109 ::TextGlyphStream Layout(const char* str, int width, int r=0xff, int g=0xff, int b=0xff); | |
110 private: | |
111 Font* font; | |
112 class ::TextHorizLayout* pimpl; | |
113 }; | |
114 | |
115 } /* end of namespace XKFont */ | |
112 | 116 |
113 #endif | 117 #endif |