9 #include FT_CACHE_IMAGE_H
10 #include FT_CACHE_SMALL_BITMAPS_H
11 typedef FTC_ImageCache FTC_Image_Cache;
12 typedef FTC_ImageTypeRec FTC_Image_Desc;
13 typedef FTC_SBitCache FTC_SBit_Cache;
17 #include <lib/gdi/fb.h>
18 #include <lib/gdi/esize.h>
19 #include <lib/gdi/epoint.h>
20 #include <lib/gdi/erect.h>
22 #include <lib/base/object.h>
26 class FontRenderClass;
37 friend class eTextPara;
41 std::string filename, face;
42 int scale; // 100 is 1:1
48 FTC_Manager cacheManager; /* the cache manager */
49 FTC_Image_Cache imageCache; /* the glyph image cache */
50 FTC_SBit_Cache sbitsCache; /* the glyph small bitmaps cache */
52 FTC_FaceID getFaceID(const std::string &face);
53 FT_Error getGlyphBitmap(FTC_Image_Desc *font, FT_ULong glyph_index, FTC_SBit *sbit);
54 static fontRenderClass *instance;
60 float getLineHeight(const gFont& font);
61 static fontRenderClass *getInstance();
63 std::string AddFont(const std::string &filename, const std::string &name, int scale);
64 FT_Error FTC_Face_Requester(FTC_FaceID face_id, FT_Face* aface);
65 int getFont(ePtr<Font> &font, const std::string &face, int size, int tabwidth=-1);
82 #define GS_SOFTHYPHEN 16
84 #define GS_CANBREAK (GS_ISSPACE|GS_SOFTHYPHEN|GS_HYPHEN)
95 typedef std::vector<pGlyph> glyphString;
100 class eTextPara: public iObject
102 DECLARE_REF(eTextPara);
103 ePtr<Font> current_font, replacement_font;
104 FT_Face current_face, replacement_face;
107 static std::string replacement_facename;
108 static std::set<int> forced_replaces;
115 std::list<int> lineOffsets;
116 std::list<int> lineChars;
118 bool doTopBottomReordering;
120 int appendGlyph(Font *current_font, FT_Face current_face, FT_UInt glyphIndex, int flags, int rflags);
121 void newLine(int flags);
122 void setFont(Font *font, Font *replacement_font);
128 eTextPara(eRect area, ePoint start=ePoint(-1, -1))
129 :current_font(0), replacement_font(0), current_face(0), replacement_face(0)
130 ,area(area), cursor(start), maximum(0, 0), left(start.x()), charCount(0)
131 ,doTopBottomReordering(false), bboxValid(0)
134 virtual ~eTextPara();
136 static void setReplacementFont(std::string font) { replacement_facename=font; }
137 static void forceReplacementGlyph(int unicode) { forced_replaces.insert(unicode); }
139 void setFont(const gFont *font);
140 int renderString(const char *string, int flags=0);
144 void blit(gDC &dc, const ePoint &offset, const gRGB &background, const gRGB &foreground);
148 dirLeft, dirRight, dirCenter, dirBlock
151 void realign(int dir);
153 const eRect & getBoundBox()
161 const int size() const
163 return glyphs.size();
166 const eRect& getGlyphBBox(int num) const
169 ASSERT(num < (int)glyphs.size());
170 return glyphs[num].bbox;
173 void setGlyphFlag(int g, int f)
176 ASSERT(g < (int)glyphs.size());
177 glyphs[g].flags |= f;
180 void clearGlyphFlag(int g, int f)
183 ASSERT(g < (int)glyphs.size());
184 glyphs[g].flags |= f;
188 class Font: public iObject
192 FTC_ScalerRec scaler;
194 fontRenderClass *renderer;
195 FT_Error getGlyphBitmap(FT_ULong glyph_index, FTC_SBit *sbit);
201 Font(fontRenderClass *render, FTC_FaceID faceid, int isize, int tabwidth);
205 extern fontRenderClass *font;