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);
78 #define GS_SOFTHYPHEN 16
80 #define GS_CANBREAK (GS_ISSPACE|GS_SOFTHYPHEN|GS_HYPHEN)
91 typedef std::vector<pGlyph> glyphString;
96 class eTextPara: public iObject
98 DECLARE_REF(eTextPara);
100 ePtr<Font> current_font, replacement_font;
101 FT_Face current_face, replacement_face;
104 static std::string replacement_facename;
105 static std::set<int> forced_replaces;
113 int appendGlyph(Font *current_font, FT_Face current_face, FT_UInt glyphIndex, int flags, int rflags);
114 void newLine(int flags);
115 void setFont(Font *font, Font *replacement_font);
120 eTextPara(eRect area, ePoint start=ePoint(-1, -1))
121 : current_font(0), replacement_font(0), current_face(0), replacement_face(0),
122 area(area), cursor(start), maximum(0, 0), left(start.x()), bboxValid(0)
125 virtual ~eTextPara();
127 static void setReplacementFont(std::string font) { replacement_facename=font; }
128 static void forceReplacementGlyph(int unicode) { forced_replaces.insert(unicode); }
130 void setFont(const gFont *font);
131 int renderString(const char *string, int flags=0);
135 void blit(gDC &dc, const ePoint &offset, const gRGB &background, const gRGB &foreground);
139 dirLeft, dirRight, dirCenter, dirBlock
142 void realign(int dir);
144 const eRect & getBoundBox()
152 const int size() const
154 return glyphs.size();
157 const eRect& getGlyphBBox(int num) const
160 assert(num < (int)glyphs.size());
161 return glyphs[num].bbox;
164 void setGlyphFlag(int g, int f)
167 assert(g < (int)glyphs.size());
168 glyphs[g].flags |= f;
171 void clearGlyphFlag(int g, int f)
174 assert(g < (int)glyphs.size());
175 glyphs[g].flags |= f;
179 class Font: public iObject
184 fontRenderClass *renderer;
185 FT_Error getGlyphBitmap(FT_ULong glyph_index, FTC_SBit *sbit);
191 Font(fontRenderClass *render, FTC_FaceID faceid, int isize, int tabwidth);
195 extern fontRenderClass *font;