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>
27
28#include <glyphid.hxx>
29
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
34{
35public:
36 bool Map();
37 void Unmap();
38
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; }
43
44private:
45 friend class FreetypeManager;
46 explicit FreetypeFontFile( OString aNativeFileName );
47
48 const OString maNativeFileName;
49 unsigned char* mpFileMap;
53};
54
55// FreetypeFontInfo corresponds to an unscaled font face
57{
58public:
60
61 FT_FaceRec_* GetFaceFT();
63
65 const OString& GetFontFileName() const { return mpFontFile->GetFileName(); }
66 int GetFontFaceIndex() const { return mnFaceNum; }
67 int GetFontFaceVariation() const { return mnFaceVariation; }
68 sal_IntPtr GetFontId() const { return mnFontId; }
70
72
73private:
74 friend class FreetypeManager;
76 int nFaceNum, int nFaceVariation, sal_IntPtr nFontId);
77
78 FT_FaceRec_* maFaceFT;
80 const int mnFaceNum;
81 const int mnFaceVariation;
83 sal_IntPtr mnFontId;
85
86};
87
89{
90private:
92
93public:
95
97 virtual sal_IntPtr GetFontId() const override { return mpFreetypeFontInfo->GetFontId(); }
98
99 virtual hb_face_t* GetHbFace() const override;
100 virtual hb_blob_t* GetHbTable(hb_tag_t nTag) const override;
101
102 const std::vector<hb_variation_t>& GetVariations(const LogicalFontInstance&) const override;
103};
104
105class SAL_DLLPUBLIC_RTTI FreetypeFontInstance final : public LogicalFontInstance
106{
108
109 std::unique_ptr<FreetypeFont> mxFreetypeFont;
110
112
113public:
114 virtual ~FreetypeFontInstance() override;
115
116 FreetypeFont& GetFreetypeFont() const { return *mxFreetypeFont; }
117
118 virtual bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) const override;
119};
120
121/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const std::vector< hb_variation_t > & GetVariations(const LogicalFontInstance &) const override
FreetypeFontFace(FreetypeFontInfo *, const FontAttributes &)
virtual hb_face_t * GetHbFace() const override
virtual rtl::Reference< LogicalFontInstance > CreateFontInstance(const vcl::font::FontSelectPattern &) const override
virtual sal_IntPtr GetFontId() const override
FreetypeFontInfo * mpFreetypeFontInfo
virtual hb_blob_t * GetHbTable(hb_tag_t nTag) const override
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
void AnnounceFont(vcl::font::PhysicalFontCollection *)
FontAttributes maDevFontAttributes
FreetypeFontFile * GetFontFile() const
const OString & GetFontFileName() const
int GetFontFaceVariation() const
int GetFontFaceIndex() const
const FontAttributes & GetFontAttributes() const
FreetypeFontInstance(const vcl::font::PhysicalFontFace &rPFF, const vcl::font::FontSelectPattern &rFSP)
virtual bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon &, bool) const override
virtual ~FreetypeFontInstance() override
FreetypeFont & GetFreetypeFont() const
std::unique_ptr< FreetypeFont > mxFreetypeFont
The FreetypeManager caches various aspects of Freetype fonts.
Definition: glyphcache.hxx:79
abstract base class for physical font faces
uint32_t sal_GlyphId
Definition: glyphid.hxx:24