9 #include FT_CACHE_IMAGE_H
10 #include FT_CACHE_SMALL_BITMAPS_H
13 #include <lib/gdi/fb.h>
14 #include <lib/gdi/esize.h>
15 #include <lib/gdi/epoint.h>
16 #include <lib/gdi/erect.h>
18 #include <lib/base/object.h>
22 class FontRenderClass;
33 friend class eTextPara;
37 std::string filename, face;
38 int scale; // 100 is 1:1
44 FTC_Manager cacheManager; /* the cache manager */
45 FTC_Image_Cache imageCache; /* the glyph image cache */
46 FTC_SBit_Cache sbitsCache; /* the glyph small bitmaps cache */
48 FTC_FaceID getFaceID(const std::string &face);
49 FT_Error getGlyphBitmap(FTC_Image_Desc *font, FT_ULong glyph_index, FTC_SBit *sbit);
50 static fontRenderClass *instance;
56 float getLineHeight(const gFont& font);
57 static fontRenderClass *getInstance();
59 std::string AddFont(const std::string &filename, const std::string &name, int scale);
60 FT_Error FTC_Face_Requester(FTC_FaceID face_id, FT_Face* aface);
61 int getFont(ePtr<Font> &font, const std::string &face, int size, int tabwidth=-1);
89 typedef std::vector<pGlyph> glyphString;
94 class eTextPara: public iObject
96 DECLARE_REF(eTextPara);
98 ePtr<Font> current_font, replacement_font;
99 FT_Face current_face, replacement_face;
102 static std::string replacement_facename;
103 static std::set<int> forced_replaces;
111 int appendGlyph(Font *current_font, FT_Face current_face, FT_UInt glyphIndex, int flags, int rflags);
112 void newLine(int flags);
113 void setFont(Font *font, Font *replacement_font);
118 eTextPara(eRect area, ePoint start=ePoint(-1, -1))
119 : current_font(0), replacement_font(0), current_face(0), replacement_face(0),
120 area(area), cursor(start), maximum(0, 0), left(start.x()), bboxValid(0)
123 virtual ~eTextPara();
125 static void setReplacementFont(std::string font) { replacement_facename=font; }
126 static void forceReplacementGlyph(int unicode) { forced_replaces.insert(unicode); }
128 void setFont(const gFont *font);
129 int renderString(const char *string, int flags=0);
133 void blit(gDC &dc, const ePoint &offset, const gRGB &background, const gRGB &foreground);
137 dirLeft, dirRight, dirCenter, dirBlock
140 void realign(int dir);
142 const eRect & getBoundBox()
150 const int size() const
152 return glyphs.size();
155 const eRect& getGlyphBBox(int num) const
158 assert(num < (int)glyphs.size());
159 return glyphs[num].bbox;
162 void setGlyphFlag(int g, int f)
165 assert(g < (int)glyphs.size());
166 glyphs[g].flags |= f;
169 void clearGlyphFlag(int g, int f)
172 assert(g < (int)glyphs.size());
173 glyphs[g].flags |= f;
177 class Font: public iObject
182 fontRenderClass *renderer;
183 FT_Error getGlyphBitmap(FT_ULong glyph_index, FTC_SBit *sbit);
189 Font(fontRenderClass *render, FTC_FaceID faceid, int isize, int tabwidth);
193 extern fontRenderClass *font;