9 #include FT_CACHE_IMAGE_H
10 #include FT_CACHE_SMALL_BITMAPS_H
12 typedef FTC_ImageCache FTC_Image_Cache;
13 typedef FTC_ImageTypeRec FTC_Image_Desc;
14 typedef FTC_SBitCache FTC_SBit_Cache;
18 #include <lib/gdi/fb.h>
19 #include <lib/gdi/esize.h>
20 #include <lib/gdi/epoint.h>
21 #include <lib/gdi/erect.h>
23 #include <lib/base/object.h>
27 class FontRenderClass;
38 friend class eTextPara;
42 std::string filename, face;
43 int scale; // 100 is 1:1
49 FTC_Manager cacheManager; /* the cache manager */
50 FTC_Image_Cache imageCache; /* the glyph image cache */
51 FTC_SBit_Cache sbitsCache; /* the glyph small bitmaps cache */
55 FTC_FaceID getFaceID(const std::string &face);
56 FT_Error getGlyphBitmap(FTC_Image_Desc *font, FT_ULong glyph_index, FTC_SBit *sbit);
57 FT_Error getGlyphImage(FTC_Image_Desc *font, FT_ULong glyph_index, FT_Glyph *glyph, FT_Glyph *borderglyph, int bordersize);
58 static fontRenderClass *instance;
64 float getLineHeight(const gFont& font);
65 static fontRenderClass *getInstance();
67 std::string AddFont(const std::string &filename, const std::string &name, int scale);
68 FT_Error FTC_Face_Requester(FTC_FaceID face_id, FT_Face* aface);
69 int getFont(ePtr<Font> &font, const std::string &face, int size, int tabwidth=-1);
86 #define GS_SOFTHYPHEN 16
88 #define GS_COLORCHANGE 64
89 #define GS_CANBREAK (GS_ISSPACE|GS_SOFTHYPHEN|GS_HYPHEN)
94 unsigned long newcolor;
99 FT_Glyph image, borderimage;
107 typedef std::vector<pGlyph> glyphString;
112 class eTextPara: public iObject
114 DECLARE_REF(eTextPara);
115 ePtr<Font> current_font, replacement_font;
116 FT_Face current_face, replacement_face;
119 static std::string replacement_facename;
120 static std::set<int> forced_replaces;
127 std::list<int> lineOffsets;
128 std::list<int> lineChars;
130 bool doTopBottomReordering;
132 int appendGlyph(Font *current_font, FT_Face current_face, FT_UInt glyphIndex, int flags, int rflags, int border, bool activate_newcolor, unsigned long newcolor);
133 void newLine(int flags);
134 void setFont(Font *font, Font *replacement_font);
140 eTextPara(eRect area, ePoint start=ePoint(-1, -1))
141 :current_font(0), replacement_font(0), current_face(0), replacement_face(0)
142 ,area(area), cursor(start), maximum(0, 0), left(start.x()), charCount(0)
143 ,doTopBottomReordering(false), bboxValid(0)
146 virtual ~eTextPara();
148 static void setReplacementFont(std::string font) { replacement_facename=font; }
149 static void forceReplacementGlyph(int unicode) { forced_replaces.insert(unicode); }
151 void setFont(const gFont *font);
152 int renderString(const char *string, int flags=0, int border=0);
156 void blit(gDC &dc, const ePoint &offset, const gRGB &background, const gRGB &foreground, bool border = false);
160 dirLeft, dirRight, dirCenter, dirBlock
163 void realign(int dir);
165 const eRect & getBoundBox()
173 const int size() const
175 return glyphs.size();
178 const eRect& getGlyphBBox(int num) const
181 ASSERT(num < (int)glyphs.size());
182 return glyphs[num].bbox;
185 void setGlyphFlag(int g, int f)
188 ASSERT(g < (int)glyphs.size());
189 glyphs[g].flags |= f;
192 void clearGlyphFlag(int g, int f)
195 ASSERT(g < (int)glyphs.size());
196 glyphs[g].flags |= f;
200 class Font: public iObject
204 FTC_ScalerRec scaler;
206 fontRenderClass *renderer;
207 FT_Error getGlyphBitmap(FT_ULong glyph_index, FTC_SBit *sbit);
208 FT_Error getGlyphImage(FT_ULong glyph_index, FT_Glyph *glyph, FT_Glyph *borderglyph, int bordersize);
214 Font(fontRenderClass *render, FTC_FaceID faceid, int isize, int tabwidth);
218 extern fontRenderClass *font;