LibreOffice Module vcl (master) 1
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 <memory>
25#include <freetype/config/ftheader.h>
26#include FT_FREETYPE_H
27#include FT_GLYPH_H
28
29#include <tools/gen.hxx>
30#include <tools/solar.h>
31#include <unx/gendata.hxx>
32#include <vcl/dllapi.h>
33#include <vcl/outdev.hxx>
34
35#include <fontattributes.hxx>
36#include <fontinstance.hxx>
37#include <impfontmetricdata.hxx>
38
39#include <unordered_map>
40
41class FreetypeFont;
46namespace vcl::font
47{
48class PhysicalFontCollection;
49}
50class FreetypeFont;
51class SvpGcpHelper;
52
53namespace basegfx { class B2DPolyPolygon; }
54namespace vcl { struct FontCapabilities; }
55
79{
80public:
82
84
85 void AddFontFile(const OString& rNormalizedName,
86 int nFaceNum, int nVariantNum,
87 sal_IntPtr nFontId,
88 const FontAttributes&);
89
91
93
95
96private:
97 // to access the constructor (can't use InitFreetypeManager function, because it's private?!)
98 friend class GenericUnixSalData;
99 explicit FreetypeManager();
100
101 static void InitFreetype();
102 FreetypeFontFile* FindFontFile(const OString& rNativeFileName);
103
104 typedef std::unordered_map<sal_IntPtr, std::shared_ptr<FreetypeFontInfo>> FontInfoList;
105 typedef std::unordered_map<const char*, std::unique_ptr<FreetypeFontFile>, rtl::CStringHash, rtl::CStringEqual> FontFileList;
106
108
110};
111
113{
114public:
116
117 const OString& GetFontFileName() const;
118 int GetFontFaceIndex() const;
120 bool TestFont() const { return mbFaceOk;}
121 FT_Face GetFtFace() const;
123 bool NeedsArtificialBold() const { return mbArtBold; }
124 bool NeedsArtificialItalic() const { return mbArtItalic; }
125
127 const unsigned char* GetTable( const char* pName, sal_uLong* pLength ) const;
130
133 bool GetAntialiasAdvice() const;
134
135 void SetFontVariationsOnHBFont(hb_font_t* pHbFace) const;
136
137 // tdf#127189 FreeType <= 2.8 will fail to render stretched horizontal brace glyphs
138 // in starmath at a fairly low stretch ratio. This appears fixed in 2.9 with
139 // https://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=91015cb41d8f56777f93394f5a60914bc0c0f330
140 // "Improve complex rendering at high ppem"
142
143private:
145 friend class FreetypeManager;
146
147 explicit FreetypeFont(FreetypeFontInstance&, std::shared_ptr<FreetypeFontInfo> rFontInfo);
148
149 void ApplyGlyphTransform(bool bVertical, FT_Glyph) const;
150
152
153 // 16.16 fixed point values used for a rotated font
156
159 std::shared_ptr<FreetypeFontInfo> mxFontInfo;
161 double mfStretch;
162 FT_FaceRec_* maFaceFT;
163 FT_SizeRec_* maSizeFT;
164
165 mutable std::unique_ptr<FontConfigFontOptions> mxFontOptions;
166
170};
171
172/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
FT_Int mnLoadFlags
Definition: glyphcache.hxx:160
FT_FaceRec_ * maFaceFT
Definition: glyphcache.hxx:162
void GetFontMetric(ImplFontMetricDataRef const &) const
static bool AlmostHorizontalDrainsRenderingPool(int nRatio, const vcl::font::FontSelectPattern &rFSD)
FT_SizeRec_ * maSizeFT
Definition: glyphcache.hxx:163
std::unique_ptr< FontConfigFontOptions > mxFontOptions
Definition: glyphcache.hxx:165
tools::Long mnSin
Definition: glyphcache.hxx:155
bool GetAntialiasAdvice() const
const unsigned char * GetTable(const char *pName, sal_uLong *pLength) const
bool NeedsArtificialItalic() const
Definition: glyphcache.hxx:124
bool GetGlyphBoundRect(sal_GlyphId, tools::Rectangle &, bool) const
void SetFontVariationsOnHBFont(hb_font_t *pHbFace) const
bool TestFont() const
Definition: glyphcache.hxx:120
const OString & GetFontFileName() const
void ApplyGlyphTransform(bool bVertical, FT_Glyph) const
std::shared_ptr< FreetypeFontInfo > mxFontInfo
Definition: glyphcache.hxx:159
FT_Face GetFtFace() const
int GetFontFaceVariation() const
bool NeedsArtificialBold() const
Definition: glyphcache.hxx:123
tools::Long mnCos
Definition: glyphcache.hxx:154
FreetypeFontInstance & mrFontInstance
Definition: glyphcache.hxx:151
const FontConfigFontOptions * GetFontOptions() const
double mfStretch
Definition: glyphcache.hxx:161
bool GetFontCapabilities(vcl::FontCapabilities &) const
FreetypeFont(FreetypeFontInstance &, std::shared_ptr< FreetypeFontInfo > rFontInfo)
const FontCharMapRef & GetFontCharMap() const
int GetFontFaceIndex() const
bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon &, bool) const
The FreetypeManager caches various aspects of Freetype fonts.
Definition: glyphcache.hxx:79
std::unordered_map< sal_IntPtr, std::shared_ptr< FreetypeFontInfo > > FontInfoList
Definition: glyphcache.hxx:104
std::unordered_map< const char *, std::unique_ptr< FreetypeFontFile >, rtl::CStringHash, rtl::CStringEqual > FontFileList
Definition: glyphcache.hxx:105
FreetypeFont * CreateFont(FreetypeFontInstance *pLogicalFont)
FreetypeFontFile * FindFontFile(const OString &rNativeFileName)
static FreetypeManager & get()
static void InitFreetype()
void ClearFontCache()
FontInfoList m_aFontInfoList
Definition: glyphcache.hxx:107
void AnnounceFonts(vcl::font::PhysicalFontCollection *) const
void AddFontFile(const OString &rNormalizedName, int nFaceNum, int nVariantNum, sal_IntPtr nFontId, const FontAttributes &)
FontFileList m_aFontFileList
Definition: glyphcache.hxx:109
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
sal_uInt16 sal_GlyphId
Definition: glyphid.hxx:24
long Long
A PhysicalFontFaceCollection is created by a PhysicalFontCollection and becomes invalid when original...
sal_uIntPtr sal_uLong