bump product version to 7.2.5.1
[LibreOffice.git] / vcl / inc / unx / freetype_glyphcache.hxx
blob625f7c828d8057d0041dba4b2a8bda29097a63ea
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_GENERIC_GLYPHS_GCACH_FTYP_HXX
21 #define INCLUDED_VCL_GENERIC_GLYPHS_GCACH_FTYP_HXX
23 #include <unx/glyphcache.hxx>
24 #include <PhysicalFontFace.hxx>
25 #include <fontinstance.hxx>
26 #include <vcl/glyphitem.hxx>
28 class CmapResult;
30 // FreetypeFontFile has the responsibility that a font file is only mapped once.
31 // (#86621#) the old directly ft-managed solution caused it to be mapped
32 // in up to nTTC*nSizes*nOrientation*nSynthetic times
33 class FreetypeFontFile final
35 public:
36 bool Map();
37 void Unmap();
39 const unsigned char* GetBuffer() const { return mpFileMap; }
40 int GetFileSize() const { return mnFileSize; }
41 const OString& GetFileName() const { return maNativeFileName; }
42 int GetLangBoost() const { return mnLangBoost; }
44 private:
45 friend class FreetypeManager;
46 explicit FreetypeFontFile( const OString& rNativeFileName );
48 const OString maNativeFileName;
49 unsigned char* mpFileMap;
50 int mnFileSize;
51 int mnRefCount;
52 int mnLangBoost;
55 // FreetypeFontInfo corresponds to an unscaled font face
56 class FreetypeFontInfo final
58 public:
59 ~FreetypeFontInfo();
61 const unsigned char* GetTable( const char*, sal_uLong* pLength) const;
63 FT_FaceRec_* GetFaceFT();
64 void ReleaseFaceFT();
66 const OString& GetFontFileName() const { return mpFontFile->GetFileName(); }
67 int GetFontFaceIndex() const { return mnFaceNum; }
68 int GetFontFaceVariation() const { return mnFaceVariation; }
69 sal_IntPtr GetFontId() const { return mnFontId; }
70 bool IsSymbolFont() const { return maDevFontAttributes.IsSymbolFont(); }
71 const FontAttributes& GetFontAttributes() const { return maDevFontAttributes; }
73 void AnnounceFont( PhysicalFontCollection* );
75 const FontCharMapRef & GetFontCharMap() const;
76 bool GetFontCapabilities(vcl::FontCapabilities&) const;
78 private:
79 friend class FreetypeManager;
80 explicit FreetypeFontInfo(const FontAttributes&, FreetypeFontFile* const pFontFile,
81 int nFaceNum, int nFaceVariation, sal_IntPtr nFontId);
83 FT_FaceRec_* maFaceFT;
84 FreetypeFontFile* const mpFontFile;
85 const int mnFaceNum;
86 const int mnFaceVariation;
87 int mnRefCount;
88 sal_IntPtr mnFontId;
89 FontAttributes maDevFontAttributes;
91 mutable FontCharMapRef mxFontCharMap;
94 class FreetypeFontFace : public PhysicalFontFace
96 private:
97 FreetypeFontInfo* mpFreetypeFontInfo;
99 public:
100 FreetypeFontFace( FreetypeFontInfo*, const FontAttributes& );
102 virtual rtl::Reference<LogicalFontInstance> CreateFontInstance( const FontSelectPattern& ) const override;
103 virtual sal_IntPtr GetFontId() const override { return mpFreetypeFontInfo->GetFontId(); }
105 FontCharMapRef GetFontCharMap() const override { return mpFreetypeFontInfo->GetFontCharMap(); }
106 inline bool GetFontCapabilities(vcl::FontCapabilities&) const override;
109 bool FreetypeFontFace::GetFontCapabilities(vcl::FontCapabilities& rFontCapabilities) const
111 return mpFreetypeFontInfo->GetFontCapabilities(rFontCapabilities);
114 class SAL_DLLPUBLIC_RTTI FreetypeFontInstance : public LogicalFontInstance
116 friend rtl::Reference<LogicalFontInstance> FreetypeFontFace::CreateFontInstance(const FontSelectPattern&) const;
118 std::unique_ptr<FreetypeFont> mxFreetypeFont;
120 virtual hb_font_t* ImplInitHbFont() override;
121 virtual bool ImplGetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) const override;
123 protected:
124 explicit FreetypeFontInstance(const PhysicalFontFace& rPFF, const FontSelectPattern& rFSP);
126 public:
127 virtual ~FreetypeFontInstance() override;
129 FreetypeFont& GetFreetypeFont() const { return *mxFreetypeFont; }
131 virtual bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) const override;
134 #endif // INCLUDED_VCL_GENERIC_GLYPHS_GCACH_FTYP_HXX
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */