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