LibreOffice Module vcl (master) 1
freetype_glyphcache.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <sal/config.h>
23
24#include <unx/glyphcache.hxx>
26#include <fontinstance.hxx>
27
28#include <glyphid.hxx>
29
30class CmapResult;
31
32// FreetypeFontFile has the responsibility that a font file is only mapped once.
33// (#86621#) the old directly ft-managed solution caused it to be mapped
34// in up to nTTC*nSizes*nOrientation*nSynthetic times
36{
37public:
38 bool Map();
39 void Unmap();
40
41 const unsigned char* GetBuffer() const { return mpFileMap; }
42 int GetFileSize() const { return mnFileSize; }
43 const OString& GetFileName() const { return maNativeFileName; }
44 int GetLangBoost() const { return mnLangBoost; }
45
46private:
47 friend class FreetypeManager;
48 explicit FreetypeFontFile( OString aNativeFileName );
49
50 const OString maNativeFileName;
51 unsigned char* mpFileMap;
55};
56
57// FreetypeFontInfo corresponds to an unscaled font face
59{
60public:
62
63 const unsigned char* GetTable( const char*, sal_uLong* pLength) const;
64
65 FT_FaceRec_* GetFaceFT();
67
68 const OString& GetFontFileName() const { return mpFontFile->GetFileName(); }
69 int GetFontFaceIndex() const { return mnFaceNum; }
70 int GetFontFaceVariation() const { return mnFaceVariation; }
71 sal_IntPtr GetFontId() const { return mnFontId; }
74
76
79
80private:
81 friend class FreetypeManager;
83 int nFaceNum, int nFaceVariation, sal_IntPtr nFontId);
84
85 FT_FaceRec_* maFaceFT;
87 const int mnFaceNum;
88 const int mnFaceVariation;
90 sal_IntPtr mnFontId;
92
94};
95
97{
98private:
100
101public:
103
105 virtual sal_IntPtr GetFontId() const override { return mpFreetypeFontInfo->GetFontId(); }
106
108 inline bool GetFontCapabilities(vcl::FontCapabilities&) const override;
109};
110
112{
113 return mpFreetypeFontInfo->GetFontCapabilities(rFontCapabilities);
114}
115
116class SAL_DLLPUBLIC_RTTI FreetypeFontInstance final : public LogicalFontInstance
117{
119
120 std::unique_ptr<FreetypeFont> mxFreetypeFont;
121
122 virtual hb_font_t* ImplInitHbFont() override;
123 virtual bool ImplGetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) const override;
124
126
127public:
128 virtual ~FreetypeFontInstance() override;
129
130 FreetypeFont& GetFreetypeFont() const { return *mxFreetypeFont; }
131
132 virtual bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) const override;
133};
134
135/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsSymbolFont() const
bool GetFontCapabilities(vcl::FontCapabilities &) const override
FreetypeFontFace(FreetypeFontInfo *, const FontAttributes &)
virtual rtl::Reference< LogicalFontInstance > CreateFontInstance(const vcl::font::FontSelectPattern &) const override
virtual sal_IntPtr GetFontId() const override
FontCharMapRef GetFontCharMap() const override
FreetypeFontInfo * mpFreetypeFontInfo
const OString maNativeFileName
const OString & GetFileName() const
FreetypeFontFile(OString aNativeFileName)
unsigned char * mpFileMap
const unsigned char * GetBuffer() const
FreetypeFontInfo(FontAttributes, FreetypeFontFile *const pFontFile, int nFaceNum, int nFaceVariation, sal_IntPtr nFontId)
sal_IntPtr GetFontId() const
FT_FaceRec_ * GetFaceFT()
FreetypeFontFile *const mpFontFile
FontCharMapRef mxFontCharMap
void AnnounceFont(vcl::font::PhysicalFontCollection *)
FontAttributes maDevFontAttributes
const OString & GetFontFileName() const
bool GetFontCapabilities(vcl::FontCapabilities &) const
const FontCharMapRef & GetFontCharMap() const
int GetFontFaceVariation() const
const unsigned char * GetTable(const char *, sal_uLong *pLength) const
int GetFontFaceIndex() const
const FontAttributes & GetFontAttributes() const
FreetypeFontInstance(const vcl::font::PhysicalFontFace &rPFF, const vcl::font::FontSelectPattern &rFSP)
virtual hb_font_t * ImplInitHbFont() override
virtual bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon &, bool) const override
virtual ~FreetypeFontInstance() override
FreetypeFont & GetFreetypeFont() const
std::unique_ptr< FreetypeFont > mxFreetypeFont
virtual bool ImplGetGlyphBoundRect(sal_GlyphId, tools::Rectangle &, bool) const override
The FreetypeManager caches various aspects of Freetype fonts.
Definition: glyphcache.hxx:79
abstract base class for physical font faces
sal_uInt16 sal_GlyphId
Definition: glyphid.hxx:24
sal_uIntPtr sal_uLong