1*161f4cd1SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*161f4cd1SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*161f4cd1SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*161f4cd1SAndrew Rist * distributed with this work for additional information
6*161f4cd1SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*161f4cd1SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*161f4cd1SAndrew Rist * "License"); you may not use this file except in compliance
9*161f4cd1SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*161f4cd1SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*161f4cd1SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*161f4cd1SAndrew Rist * software distributed under the License is distributed on an
15*161f4cd1SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*161f4cd1SAndrew Rist * KIND, either express or implied. See the License for the
17*161f4cd1SAndrew Rist * specific language governing permissions and limitations
18*161f4cd1SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*161f4cd1SAndrew Rist *************************************************************/
21*161f4cd1SAndrew Rist
22*161f4cd1SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #ifndef _SV_GRAPHITEADAPTORS_HXX
25cdf0e10cSrcweir #define _SV_GRAPHITEADAPTORS_HXX
26cdf0e10cSrcweir
27cdf0e10cSrcweir // We need this to enable namespace support in libgrengine headers.
28cdf0e10cSrcweir #define GR_NAMESPACE
29cdf0e10cSrcweir
30cdf0e10cSrcweir // Standard Library
31cdf0e10cSrcweir #include <stdexcept>
32cdf0e10cSrcweir // Platform
33cdf0e10cSrcweir
34cdf0e10cSrcweir #ifndef _SVWIN_H
35cdf0e10cSrcweir #include <tools/svwin.h>
36cdf0e10cSrcweir #endif
37cdf0e10cSrcweir
38cdf0e10cSrcweir #ifndef _SV_SVSYS_HXX
39cdf0e10cSrcweir #include <svsys.h>
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir
42cdf0e10cSrcweir #ifndef _SV_SALGDI_HXX
43cdf0e10cSrcweir #include <salgdi.hxx>
44cdf0e10cSrcweir #endif
45cdf0e10cSrcweir
46cdf0e10cSrcweir #ifndef _SV_SALLAYOUT_HXX
47cdf0e10cSrcweir #include <sallayout.hxx>
48cdf0e10cSrcweir #endif
49cdf0e10cSrcweir
50cdf0e10cSrcweir // Module
51cdf0e10cSrcweir #include "vcl/dllapi.h"
52cdf0e10cSrcweir
53cdf0e10cSrcweir // Libraries
54cdf0e10cSrcweir #include <preextstl.h>
55cdf0e10cSrcweir #include <graphite/GrClient.h>
56cdf0e10cSrcweir #include <graphite/Font.h>
57cdf0e10cSrcweir #include <graphite/ITextSource.h>
58cdf0e10cSrcweir #include <postextstl.h>
59cdf0e10cSrcweir
60cdf0e10cSrcweir // Module type definitions and forward declarations.
61cdf0e10cSrcweir //
62cdf0e10cSrcweir #ifndef MSC
63cdf0e10cSrcweir // SAL/VCL types
64cdf0e10cSrcweir class ServerFont;
65cdf0e10cSrcweir class FreetypeServerFont;
66cdf0e10cSrcweir
67cdf0e10cSrcweir // Graphite types
68cdf0e10cSrcweir
69cdf0e10cSrcweir struct FontProperties : gr::FontProps
70cdf0e10cSrcweir {
71cdf0e10cSrcweir FontProperties(const FreetypeServerFont & font) throw();
72cdf0e10cSrcweir };
73cdf0e10cSrcweir
74cdf0e10cSrcweir namespace grutils
75cdf0e10cSrcweir {
76cdf0e10cSrcweir class GrFeatureParser;
77cdf0e10cSrcweir }
78cdf0e10cSrcweir
79cdf0e10cSrcweir // This class adapts the Sal font and graphics services to form required by
80cdf0e10cSrcweir // the Graphite engine.
81cdf0e10cSrcweir // @author tse
82cdf0e10cSrcweir //
83cdf0e10cSrcweir class VCL_PLUGIN_PUBLIC GraphiteFontAdaptor : public gr::Font
84cdf0e10cSrcweir {
85cdf0e10cSrcweir typedef std::map<const gr::gid16, std::pair<gr::Rect, gr::Point> > GlyphMetricMap;
86cdf0e10cSrcweir friend class GrFontHasher;
87cdf0e10cSrcweir public:
88cdf0e10cSrcweir static bool IsGraphiteEnabledFont(ServerFont &) throw();
89cdf0e10cSrcweir
90cdf0e10cSrcweir GraphiteFontAdaptor(ServerFont & font, const sal_Int32 dpi_x, const sal_Int32 dpi_y);
91cdf0e10cSrcweir GraphiteFontAdaptor(const GraphiteFontAdaptor &) throw();
92cdf0e10cSrcweir ~GraphiteFontAdaptor() throw();
93cdf0e10cSrcweir
94cdf0e10cSrcweir gr::Font * copyThis();
95cdf0e10cSrcweir
96cdf0e10cSrcweir // Basic attribute accessors.
97cdf0e10cSrcweir virtual float ascent();
98cdf0e10cSrcweir virtual float descent();
99cdf0e10cSrcweir virtual bool bold();
100cdf0e10cSrcweir virtual bool italic();
101cdf0e10cSrcweir virtual float height();
102cdf0e10cSrcweir virtual unsigned int getDPIx();
103cdf0e10cSrcweir virtual unsigned int getDPIy();
104cdf0e10cSrcweir
105cdf0e10cSrcweir // Font access methods.
106cdf0e10cSrcweir virtual const void * getTable(gr::fontTableId32 tableID, size_t * pcbSize);
107cdf0e10cSrcweir virtual void getFontMetrics(float * ascent_out, float * descent_out = 0, float * em_square_out = 0);
108cdf0e10cSrcweir
109cdf0e10cSrcweir // Glyph metrics.
110cdf0e10cSrcweir virtual void getGlyphMetrics(gr::gid16 glyphID, gr::Rect & boundingBox, gr::Point & advances);
111cdf0e10cSrcweir
112cdf0e10cSrcweir // Adaptor attributes.
113cdf0e10cSrcweir const FontProperties & fontProperties() const throw();
114cdf0e10cSrcweir FreetypeServerFont & font() const throw();
features() const115cdf0e10cSrcweir const grutils::GrFeatureParser * features() const { return mpFeatures; };
116cdf0e10cSrcweir
117cdf0e10cSrcweir private:
118cdf0e10cSrcweir virtual void UniqueCacheInfo(ext_std::wstring &, bool &, bool &);
119cdf0e10cSrcweir
120cdf0e10cSrcweir FreetypeServerFont& mrFont;
121cdf0e10cSrcweir FontProperties maFontProperties;
122cdf0e10cSrcweir const unsigned int mnDpiX, mnDpiY;
123cdf0e10cSrcweir const float mfAscent,
124cdf0e10cSrcweir mfDescent,
125cdf0e10cSrcweir mfEmUnits;
126cdf0e10cSrcweir grutils::GrFeatureParser * mpFeatures;
127cdf0e10cSrcweir GlyphMetricMap maGlyphMetricMap;
128cdf0e10cSrcweir };
129cdf0e10cSrcweir
130cdf0e10cSrcweir // Partial implementation of class GraphiteFontAdaptor.
131cdf0e10cSrcweir //
fontProperties() const132cdf0e10cSrcweir inline const FontProperties & GraphiteFontAdaptor::fontProperties() const throw() {
133cdf0e10cSrcweir return maFontProperties;
134cdf0e10cSrcweir }
135cdf0e10cSrcweir
font() const136cdf0e10cSrcweir inline FreetypeServerFont & GraphiteFontAdaptor::font() const throw() {
137cdf0e10cSrcweir return mrFont;
138cdf0e10cSrcweir }
139cdf0e10cSrcweir #endif // not MFC
140cdf0e10cSrcweir
141cdf0e10cSrcweir // Partial implementation of class TextSourceAdaptor.
142cdf0e10cSrcweir //
143cdf0e10cSrcweir //inline const ImplLayoutArgs & TextSourceAdaptor::layoutArgs() const throw() {
144cdf0e10cSrcweir // return _layout_args;
145cdf0e10cSrcweir //}
146cdf0e10cSrcweir
147cdf0e10cSrcweir
148cdf0e10cSrcweir #endif // _SV_GRAPHITEADAPTORS_HXX
149