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;
19 #include <lib/gdi/fb.h>
20 #include <lib/gdi/esize.h>
21 #include <lib/gdi/epoint.h>
22 #include <lib/gdi/erect.h>
24 #include <lib/base/object.h>
28 class FontRenderClass;
39 friend class eTextPara;
43 std::string filename, face;
44 int scale; // 100 is 1:1
50 FTC_Manager cacheManager; /* the cache manager */
51 FTC_Image_Cache imageCache; /* the glyph image cache */
52 FTC_SBit_Cache sbitsCache; /* the glyph small bitmaps cache */
54 FTC_FaceID getFaceID(const std::string &face);
55 FT_Error getGlyphBitmap(FTC_Image_Desc *font, FT_ULong glyph_index, FTC_SBit *sbit);
56 static fontRenderClass *instance;
62 float getLineHeight(const gFont& font);
63 static fontRenderClass *getInstance();
65 std::string AddFont(const std::string &filename, const std::string &name, int scale);
66 FT_Error FTC_Face_Requester(FTC_FaceID face_id, FT_Face* aface);
67 int getFont(ePtr<Font> &font, const std::string &face, int size, int tabwidth=-1);
84 #define GS_SOFTHYPHEN 16
86 #define GS_CANBREAK (GS_ISSPACE|GS_SOFTHYPHEN|GS_HYPHEN)
97 typedef std::vector<pGlyph> glyphString;
102 class eTextPara: public iObject
104 DECLARE_REF(eTextPara);
105 ePtr<Font> current_font, replacement_font;
106 FT_Face current_face, replacement_face;
109 static std::string replacement_facename;
110 static std::set<int> forced_replaces;
117 std::list<int> lineOffsets;
118 std::list<int> lineChars;
120 bool doTopBottomReordering;
122 int appendGlyph(Font *current_font, FT_Face current_face, FT_UInt glyphIndex, int flags, int rflags);
123 void newLine(int flags);
124 void setFont(Font *font, Font *replacement_font);
130 eTextPara(eRect area, ePoint start=ePoint(-1, -1))
131 :current_font(0), replacement_font(0), current_face(0), replacement_face(0)
132 ,area(area), cursor(start), maximum(0, 0), left(start.x()), charCount(0)
133 ,doTopBottomReordering(false), bboxValid(0)
136 virtual ~eTextPara();
138 static void setReplacementFont(std::string font) { replacement_facename=font; }
139 static void forceReplacementGlyph(int unicode) { forced_replaces.insert(unicode); }
141 void setFont(const gFont *font);
142 int renderString(const char *string, int flags=0);
146 void blit(gDC &dc, const ePoint &offset, const gRGB &background, const gRGB &foreground);
150 dirLeft, dirRight, dirCenter, dirBlock
153 void realign(int dir);
155 const eRect & getBoundBox()
163 const int size() const
165 return glyphs.size();
168 const eRect& getGlyphBBox(int num) const
171 ASSERT(num < (int)glyphs.size());
172 return glyphs[num].bbox;
175 void setGlyphFlag(int g, int f)
178 ASSERT(g < (int)glyphs.size());
179 glyphs[g].flags |= f;
182 void clearGlyphFlag(int g, int f)
185 ASSERT(g < (int)glyphs.size());
186 glyphs[g].flags |= f;
190 class Font: public iObject
194 #ifdef HAVE_FREETYPE2
195 FTC_ScalerRec scaler;
198 fontRenderClass *renderer;
199 FT_Error getGlyphBitmap(FT_ULong glyph_index, FTC_SBit *sbit);
205 Font(fontRenderClass *render, FTC_FaceID faceid, int isize, int tabwidth);
209 extern fontRenderClass *font;