2 * Copyright 2007, Haiku. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Maxim Shemanarev <mcseemagg@yahoo.com>
7 * Stephan Aßmus <superstippi@gmx.de>
8 * Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk>
11 //----------------------------------------------------------------------------
12 // Anti-Grain Geometry - Version 2.4
13 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
15 // Permission to copy, use, modify, sell and distribute this software
16 // is granted provided this copyright notice appears in all copies.
17 // This software is provided "as is" without express or implied
18 // warranty, and with no claim as to its suitability for any purpose.
20 //----------------------------------------------------------------------------
21 // Contact: mcseem@antigrain.com
22 // mcseemagg@yahoo.com
23 // http://www.antigrain.com
24 //----------------------------------------------------------------------------
29 #include <SupportDefs.h>
32 #include FT_FREETYPE_H
34 #include <agg_scanline_storage_aa.h>
35 #include <agg_scanline_storage_bin.h>
36 #include <agg_scanline_u.h>
37 #include <agg_scanline_bin.h>
38 #include <agg_path_storage_integer.h>
39 #include <agg_rasterizer_scanline_aa.h>
40 #include <agg_conv_curve.h>
41 #include <agg_trans_affine.h>
43 #include "agg_scanline_storage_subpix.h"
44 #include "agg_scanline_u_subpix.h"
45 #include "agg_scanline_u_subpix_avrg_filtering.h"
47 #include "GlobalSubpixelSettings.h"
50 enum glyph_rendering
{
51 glyph_ren_native_mono
,
52 glyph_ren_native_gray8
,
58 enum glyph_data_type
{
59 glyph_data_invalid
= 0,
62 glyph_data_outline
= 3,
69 typedef agg::serialized_scanlines_adaptor_subpix
<uint8
> SubpixAdapter
;
70 typedef agg::serialized_scanlines_adaptor_aa
<uint8
> Gray8Adapter
;
71 typedef agg::serialized_scanlines_adaptor_bin MonoAdapter
;
72 typedef agg::scanline_storage_aa8 ScanlineStorageAA
;
73 typedef agg::scanline_storage_subpix8 ScanlineStorageSubpix
;
74 typedef agg::scanline_storage_bin ScanlineStorageBin
;
75 typedef agg::serialized_integer_path_adaptor
<int32
, 6> PathAdapter
;
78 virtual ~FontEngine();
80 bool Init(const char* fontFilePath
,
81 unsigned face_index
, double size
,
83 glyph_rendering ren_type
,
85 const char* fontFileBuffer
= NULL
,
86 const long fontFileBufferSize
= 0);
89 { return fLastError
; }
90 unsigned CountFaces() const;
95 uint32
GlyphIndexForGlyphCode(uint32 glyphCode
) const;
96 bool PrepareGlyph(uint32 glyphIndex
);
98 uint32
DataSize() const
100 glyph_data_type
DataType() const
101 { return fDataType
; }
102 const agg::rect_i
& Bounds() const
104 double AdvanceX() const
105 { return fAdvanceX
; }
106 double AdvanceY() const
107 { return fAdvanceY
; }
108 double PreciseAdvanceX() const
109 { return fPreciseAdvanceX
; }
110 double PreciseAdvanceY() const
111 { return fPreciseAdvanceY
; }
112 double InsetLeft() const
113 { return fInsetLeft
; }
114 double InsetRight() const
115 { return fInsetRight
; }
117 void WriteGlyphTo(uint8
* data
) const;
120 bool GetKerning(uint32 first
, uint32 second
,
121 double* x
, double* y
);
125 FontEngine(const FontEngine
&);
126 const FontEngine
& operator=(const FontEngine
&);
129 bool fLibraryInitialized
;
130 FT_Library fLibrary
; // handle to library
131 FT_Face fFace
; // FreeType font face handle
133 glyph_rendering fGlyphRendering
;
136 // members needed to generate individual glyphs according
137 // to glyph rendering type
139 glyph_data_type fDataType
;
143 double fPreciseAdvanceX
;
144 double fPreciseAdvanceY
;
148 // these members are for caching memory allocations
149 // when rendering glyphs
150 typedef agg::path_storage_integer
<int32
, 6> PathStorageType
;
151 typedef agg::conv_curve
<PathStorageType
> CurveConverterType
;
153 PathStorageType fPath
;
154 CurveConverterType fCurves
;
155 agg::scanline_u8 fScanlineAA
;
156 agg::scanline_bin fScanlineBin
;
157 #ifdef AVERAGE_BASED_SUBPIXEL_FILTERING
158 agg::scanline_u8_subpix_avrg_filtering fScanlineSubpix
;
160 agg::scanline_u8_subpix fScanlineSubpix
;
163 ScanlineStorageAA fScanlineStorageAA
;
164 ScanlineStorageBin fScanlineStorageBin
;
165 ScanlineStorageSubpix fScanlineStorageSubpix
;
169 #endif // FONT_ENGINE_H