Branch libreoffice-5-0-4
[LibreOffice.git] / vcl / inc / cairotextrender.hxx
blob26ab3c98bc28af5e9f2554398794dbcb82957faa
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_VCL_INC_UNX_CAIROTEXTRENDER_HXX
21 #define INCLUDED_VCL_INC_UNX_CAIROTEXTRENDER_HXX
23 #include "textrender.hxx"
24 #include <vcl/region.hxx>
25 #include <deque>
27 typedef struct FT_FaceRec_* FT_Face;
29 class PspSalPrinter;
30 class PspSalInfoPrinter;
31 class ServerFont;
32 class GlyphCache;
33 class ImplLayoutArgs;
34 class ServerFontLayout;
35 class PhysicalFontCollection;
36 class PhysicalFontFace;
37 typedef struct _cairo cairo_t;
39 class VCL_DLLPUBLIC CairoFontsCache
41 public:
42 struct CacheId
44 FT_Face maFace;
45 const void *mpOptions;
46 bool mbEmbolden;
47 bool mbVerticalMetrics;
48 bool operator ==(const CacheId& rOther) const
50 return maFace == rOther.maFace &&
51 mpOptions == rOther.mpOptions &&
52 mbEmbolden == rOther.mbEmbolden &&
53 mbVerticalMetrics == rOther.mbVerticalMetrics;
57 private:
58 static int mnRefCount;
59 typedef std::deque< std::pair<void *, CacheId> > LRUFonts;
60 static LRUFonts maLRUFonts;
61 public:
62 CairoFontsCache();
63 ~CairoFontsCache();
65 static void CacheFont(void *pFont, const CacheId &rId);
66 static void* FindCachedFont(const CacheId &rId);
69 class VCL_DLLPUBLIC CairoTextRender : public TextRenderImpl
71 ServerFont* mpServerFont[ MAX_FALLBACK ];
73 SalColor mnTextColor;
74 CairoFontsCache m_aCairoFontsCache;
76 bool bDisableGraphite_;
78 protected:
79 virtual GlyphCache& getPlatformGlyphCache() = 0;
80 virtual cairo_t* getCairoContext() = 0;
81 virtual void getSurfaceOffset(double& nDX, double& nDY) = 0;
82 virtual void drawSurface(cairo_t* cr) = 0;
84 bool setFont( const FontSelectPattern *pEntry, int nFallbackLevel );
86 virtual void clipRegion(cairo_t* cr) = 0;
88 public:
89 CairoTextRender();
92 virtual void SetTextColor( SalColor nSalColor ) SAL_OVERRIDE;
93 virtual sal_uInt16 SetFont( FontSelectPattern*, int nFallbackLevel ) SAL_OVERRIDE;
94 virtual void GetFontMetric( ImplFontMetricData*, int nFallbackLevel ) SAL_OVERRIDE;
95 virtual const FontCharMapPtr GetFontCharMap() const SAL_OVERRIDE;
96 virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const SAL_OVERRIDE;
97 virtual void GetDevFontList( PhysicalFontCollection* ) SAL_OVERRIDE;
98 virtual void ClearDevFontCache() SAL_OVERRIDE;
99 virtual bool AddTempDevFont( PhysicalFontCollection*, const OUString& rFileURL, const OUString& rFontName ) SAL_OVERRIDE;
100 virtual bool CreateFontSubset(
101 const OUString& rToFile,
102 const PhysicalFontFace*,
103 const sal_GlyphId* pGlyphIDs,
104 const sal_uInt8* pEncoding,
105 sal_Int32* pWidths,
106 int nGlyphs,
107 FontSubsetInfo& rInfo) SAL_OVERRIDE;
109 virtual const Ucs2SIntMap* GetFontEncodingVector( const PhysicalFontFace*, const Ucs2OStrMap** ppNonEncoded, std::set<sal_Unicode> const**) SAL_OVERRIDE;
110 virtual const void* GetEmbedFontData(
111 const PhysicalFontFace*,
112 const sal_Ucs* pUnicodes,
113 sal_Int32* pWidths,
114 size_t nLen,
115 FontSubsetInfo& rInfo,
116 long* pDataLen ) SAL_OVERRIDE;
118 virtual void FreeEmbedFontData( const void* pData, long nDataLen ) SAL_OVERRIDE;
119 virtual void GetGlyphWidths(
120 const PhysicalFontFace*,
121 bool bVertical,
122 Int32Vector& rWidths,
123 Ucs2UIntMap& rUnicodeEnc ) SAL_OVERRIDE;
125 virtual bool GetGlyphBoundRect( sal_GlyphId nIndex, Rectangle& ) SAL_OVERRIDE;
126 virtual bool GetGlyphOutline( sal_GlyphId nIndex, ::basegfx::B2DPolyPolygon& ) SAL_OVERRIDE;
127 virtual SalLayout* GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) SAL_OVERRIDE;
128 virtual void DrawServerFontLayout( const ServerFontLayout& ) SAL_OVERRIDE;
129 virtual SystemFontData GetSysFontData( int nFallbackLevel ) const SAL_OVERRIDE;
132 #endif
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */