1 /* 2 * Copyright 2005-2007, Stephan Aßmus <superstippi@gmx.de>. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef AGG_TEXT_RENDERER_H 6 #define AGG_TEXT_RENDERER_H 7 8 9 #include "defines.h" 10 11 #include "FontCacheEntry.h" 12 #include "ServerFont.h" 13 #include "Transformable.h" 14 15 #include <agg_conv_curve.h> 16 #include <agg_conv_contour.h> 17 #include <agg_scanline_u.h> 18 19 20 class FontCacheReference; 21 22 class AGGTextRenderer { 23 public: 24 AGGTextRenderer(renderer_type& solidRenderer, 25 renderer_bin_type& binRenderer, 26 scanline_unpacked_type& scanline); 27 virtual ~AGGTextRenderer(); 28 29 void SetFont(const ServerFont &font); 30 inline const ServerFont& Font() const 31 { return fFont; } 32 33 void SetHinting(bool hinting); 34 bool Hinting() const 35 { return fHinted; } 36 37 void SetAntialiasing(bool antialiasing); 38 bool Antialiasing() const 39 { return fAntialias; } 40 41 void SetKerning(bool kerning); 42 bool Kerning() const 43 { return fKerning; } 44 45 BRect RenderString(const char* utf8String, 46 uint32 length, 47 const BPoint& baseLine, 48 const BRect& clippingFrame, 49 bool dryRun, 50 BPoint* nextCharPos, 51 const escapement_delta* delta, 52 FontCacheReference* cacheReference); 53 54 private: 55 56 class StringRenderer; 57 friend class StringRenderer; 58 59 // Pipeline to process the vectors glyph paths (curves + contour) 60 FontCacheEntry::GlyphPathAdapter fPathAdaptor; 61 FontCacheEntry::GlyphGray8Adapter fGray8Adaptor; 62 FontCacheEntry::GlyphGray8Scanline fGray8Scanline; 63 FontCacheEntry::GlyphMonoAdapter fMonoAdaptor; 64 FontCacheEntry::GlyphMonoScanline fMonoScanline; 65 66 FontCacheEntry::CurveConverter fCurves; 67 FontCacheEntry::ContourConverter fContour; 68 69 renderer_type& fSolidRenderer; 70 renderer_bin_type& fBinRenderer; 71 scanline_unpacked_type& fScanline; 72 rasterizer_type fRasterizer; 73 // NOTE: the object has it's own rasterizer object 74 // since it might be using a different gamma setting 75 // to support non-anti-aliased text rendering 76 77 ServerFont fFont; 78 bool fHinted; // is glyph hinting active? 79 bool fAntialias; 80 bool fKerning; 81 Transformable fEmbeddedTransformation; // rotated or sheared font? 82 83 static AGGTextRenderer sDefaultInstance; 84 }; 85 86 #endif // AGG_TEXT_RENDERER_H 87