1 /* 2 * Copyright 2005-2009, 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( 26 renderer_subpix_type& subpixRenderer, 27 renderer_type& solidRenderer, 28 renderer_bin_type& binRenderer, 29 scanline_unpacked_type& scanline, 30 scanline_unpacked_subpix_type& 31 subpixScanline, 32 rasterizer_subpix_type& subpixRasterizer, 33 scanline_unpacked_masked_type*& 34 maskedScanline, 35 agg::trans_affine& viewTransformation); 36 virtual ~AGGTextRenderer(); 37 38 void SetFont(const ServerFont &font); 39 inline const ServerFont& Font() const 40 { return fFont; } 41 42 void SetHinting(bool hinting); 43 bool Hinting() const 44 { return fHinted; } 45 46 void SetAntialiasing(bool antialiasing); 47 bool Antialiasing() const 48 { return fAntialias; } 49 50 void SetKerning(bool kerning); 51 bool Kerning() const 52 { return fKerning; } 53 54 BRect RenderString(const char* utf8String, 55 uint32 length, const BPoint& baseLine, 56 const BRect& clippingFrame, bool dryRun, 57 BPoint* nextCharPos, 58 const escapement_delta* delta, 59 FontCacheReference* cacheReference); 60 61 BRect RenderString(const char* utf8String, 62 uint32 length, const BPoint* offsets, 63 const BRect& clippingFrame, bool dryRun, 64 BPoint* nextCharPos, 65 FontCacheReference* cacheReference); 66 67 private: 68 69 class StringRenderer; 70 friend class StringRenderer; 71 72 // Pipeline to process the vectors glyph paths (curves + contour) 73 FontCacheEntry::GlyphPathAdapter fPathAdaptor; 74 FontCacheEntry::GlyphGray8Adapter fGray8Adaptor; 75 FontCacheEntry::GlyphGray8Scanline fGray8Scanline; 76 FontCacheEntry::GlyphMonoAdapter fMonoAdaptor; 77 FontCacheEntry::GlyphMonoScanline fMonoScanline; 78 FontCacheEntry::SubpixAdapter fSubpixAdaptor; 79 80 FontCacheEntry::CurveConverter fCurves; 81 FontCacheEntry::ContourConverter fContour; 82 83 renderer_type& fSolidRenderer; 84 renderer_bin_type& fBinRenderer; 85 renderer_subpix_type& fSubpixRenderer; 86 scanline_unpacked_type& fScanline; 87 scanline_unpacked_subpix_type& fSubpixScanline; 88 rasterizer_subpix_type& fSubpixRasterizer; 89 scanline_unpacked_masked_type*& fMaskedScanline; 90 91 rasterizer_type fRasterizer; 92 // NOTE: the object has it's own rasterizer object 93 // since it might be using a different gamma setting 94 // to support non-anti-aliased text rendering 95 96 ServerFont fFont; 97 bool fHinted; 98 // is glyph hinting active? 99 bool fAntialias; 100 bool fKerning; 101 Transformable fEmbeddedTransformation; 102 // rotated or sheared font? 103 agg::trans_affine& fViewTransformation; 104 }; 105 106 #endif // AGG_TEXT_RENDERER_H 107