1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _SV_GRAPHITEADAPTORS_HXX 29 #define _SV_GRAPHITEADAPTORS_HXX 30 31 // We need this to enable namespace support in libgrengine headers. 32 #define GR_NAMESPACE 33 34 // Standard Library 35 #include <stdexcept> 36 // Platform 37 38 #ifndef _SVWIN_H 39 #include <tools/svwin.h> 40 #endif 41 42 #ifndef _SV_SVSYS_HXX 43 #include <svsys.h> 44 #endif 45 46 #ifndef _SV_SALGDI_HXX 47 #include <salgdi.hxx> 48 #endif 49 50 #ifndef _SV_SALLAYOUT_HXX 51 #include <sallayout.hxx> 52 #endif 53 54 // Module 55 #include "vcl/dllapi.h" 56 57 // Libraries 58 #include <preextstl.h> 59 #include <graphite/GrClient.h> 60 #include <graphite/Font.h> 61 #include <graphite/ITextSource.h> 62 #include <postextstl.h> 63 64 // Module type definitions and forward declarations. 65 // 66 #ifndef MSC 67 // SAL/VCL types 68 class ServerFont; 69 class FreetypeServerFont; 70 71 // Graphite types 72 73 struct FontProperties : gr::FontProps 74 { 75 FontProperties(const FreetypeServerFont & font) throw(); 76 }; 77 78 namespace grutils 79 { 80 class GrFeatureParser; 81 } 82 83 // This class adapts the Sal font and graphics services to form required by 84 // the Graphite engine. 85 // @author tse 86 // 87 class VCL_PLUGIN_PUBLIC GraphiteFontAdaptor : public gr::Font 88 { 89 typedef std::map<const gr::gid16, std::pair<gr::Rect, gr::Point> > GlyphMetricMap; 90 friend class GrFontHasher; 91 public: 92 static bool IsGraphiteEnabledFont(ServerFont &) throw(); 93 94 GraphiteFontAdaptor(ServerFont & font, const sal_Int32 dpi_x, const sal_Int32 dpi_y); 95 GraphiteFontAdaptor(const GraphiteFontAdaptor &) throw(); 96 ~GraphiteFontAdaptor() throw(); 97 98 gr::Font * copyThis(); 99 100 // Basic attribute accessors. 101 virtual float ascent(); 102 virtual float descent(); 103 virtual bool bold(); 104 virtual bool italic(); 105 virtual float height(); 106 virtual unsigned int getDPIx(); 107 virtual unsigned int getDPIy(); 108 109 // Font access methods. 110 virtual const void * getTable(gr::fontTableId32 tableID, size_t * pcbSize); 111 virtual void getFontMetrics(float * ascent_out, float * descent_out = 0, float * em_square_out = 0); 112 113 // Glyph metrics. 114 virtual void getGlyphMetrics(gr::gid16 glyphID, gr::Rect & boundingBox, gr::Point & advances); 115 116 // Adaptor attributes. 117 const FontProperties & fontProperties() const throw(); 118 FreetypeServerFont & font() const throw(); 119 const grutils::GrFeatureParser * features() const { return mpFeatures; }; 120 121 private: 122 virtual void UniqueCacheInfo(ext_std::wstring &, bool &, bool &); 123 124 FreetypeServerFont& mrFont; 125 FontProperties maFontProperties; 126 const unsigned int mnDpiX, mnDpiY; 127 const float mfAscent, 128 mfDescent, 129 mfEmUnits; 130 grutils::GrFeatureParser * mpFeatures; 131 GlyphMetricMap maGlyphMetricMap; 132 }; 133 134 // Partial implementation of class GraphiteFontAdaptor. 135 // 136 inline const FontProperties & GraphiteFontAdaptor::fontProperties() const throw() { 137 return maFontProperties; 138 } 139 140 inline FreetypeServerFont & GraphiteFontAdaptor::font() const throw() { 141 return mrFont; 142 } 143 #endif // not MFC 144 145 // Partial implementation of class TextSourceAdaptor. 146 // 147 //inline const ImplLayoutArgs & TextSourceAdaptor::layoutArgs() const throw() { 148 // return _layout_args; 149 //} 150 151 152 #endif // _SV_GRAPHITEADAPTORS_HXX 153