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>
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
124 void GetFontMetric(FontMetricDataRef const &) const;
125
127 bool GetAntialiasAdvice() const;
128
129private:
131 friend class FreetypeManager;
132
133 explicit FreetypeFont(FreetypeFontInstance&, std::shared_ptr<FreetypeFontInfo> rFontInfo);
134
135 void ApplyGlyphTransform(bool bVertical, FT_Glyph) const;
136
138
139 // 16.16 fixed point values used for a rotated font
142
145 std::shared_ptr<FreetypeFontInfo> mxFontInfo;
146 double mfStretch;
147 FT_FaceRec_* maFaceFT;
148 FT_SizeRec_* maSizeFT;
149
150 mutable std::unique_ptr<FontConfigFontOptions> mxFontOptions;
151
153};
154
155/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
FT_FaceRec_ * maFaceFT
Definition: glyphcache.hxx:147
FT_SizeRec_ * maSizeFT
Definition: glyphcache.hxx:148
std::unique_ptr< FontConfigFontOptions > mxFontOptions
Definition: glyphcache.hxx:150
tools::Long mnSin
Definition: glyphcache.hxx:141
bool GetAntialiasAdvice() 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:145
FT_Face GetFtFace() const
int GetFontFaceVariation() const
void GetFontMetric(FontMetricDataRef const &) const
tools::Long mnCos
Definition: glyphcache.hxx:140
FreetypeFontInstance & mrFontInstance
Definition: glyphcache.hxx:137
const FontConfigFontOptions * GetFontOptions() const
double mfStretch
Definition: glyphcache.hxx:146
FreetypeFont(FreetypeFontInstance &, std::shared_ptr< FreetypeFontInfo > rFontInfo)
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
uint32_t sal_GlyphId
Definition: glyphid.hxx:24
long Long
A PhysicalFontFaceCollection is created by a PhysicalFontCollection and becomes invalid when original...