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 #ifndef INCLUDED_VCL_GENERIC_GLYPHS_GCACH_FTYP_HXX
21 #define INCLUDED_VCL_GENERIC_GLYPHS_GCACH_FTYP_HXX
22 
23 #include <unx/glyphcache.hxx>
24 #include <PhysicalFontFace.hxx>
25 #include <fontinstance.hxx>
26 #include <vcl/glyphitem.hxx>
27 
28 class CmapResult;
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 {
35 public:
36  static FreetypeFontFile* FindFontFile( const OString& rNativeFileName );
37 
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 
46 private:
47  explicit FreetypeFontFile( const OString& rNativeFileName );
48 
49  const OString maNativeFileName;
50  unsigned char* mpFileMap;
54 };
55 
56 // FreetypeFontInfo corresponds to an unscaled font face
58 {
59 public:
60  FreetypeFontInfo(const FontAttributes&, const OString& rNativeFileName,
61  int nFaceNum, int nFaceVariation, sal_IntPtr nFontId);
63 
64  const unsigned char* GetTable( const char*, sal_uLong* pLength) const;
65 
66  FT_FaceRec_* GetFaceFT();
67  void ReleaseFaceFT();
68 
69  const OString& GetFontFileName() const { return mpFontFile->GetFileName(); }
70  int GetFontFaceIndex() const { return mnFaceNum; }
71  int GetFontFaceVariation() const { return mnFaceVariation; }
72  sal_IntPtr GetFontId() const { return mnFontId; }
73  bool IsSymbolFont() const { return maDevFontAttributes.IsSymbolFont(); }
75 
77 
79 
80 private:
81  FT_FaceRec_* maFaceFT;
83  const int mnFaceNum;
84  const int mnFaceVariation;
86  sal_IntPtr const mnFontId;
88 
90 };
91 
93 {
94 private:
96 
97 public:
99 
101  virtual sal_IntPtr GetFontId() const override { return mpFreetypeFontInfo->GetFontId(); }
102 };
103 
104 // a class for cache entries for physical font instances that are based on serverfonts
106 {
108 
110 
111  virtual hb_font_t* ImplInitHbFont() override;
112  virtual bool ImplGetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) const override;
113 
114 protected:
115  explicit FreetypeFontInstance(const PhysicalFontFace& rPFF, const FontSelectPattern& rFSP);
116 
117 public:
118  virtual ~FreetypeFontInstance() override;
119 
120  void SetFreetypeFont(FreetypeFont* p);
122 
123  virtual bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) const override;
124 };
125 
126 #endif // INCLUDED_VCL_GENERIC_GLYPHS_GCACH_FTYP_HXX
127 
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ~FreetypeFontInstance() override
FontCharMapRef mxFontCharMap
const FontCharMapRef & GetFontCharMap()
void AnnounceFont(PhysicalFontCollection *)
FreetypeFontInfo *const mpFreetypeFontInfo
sal_uIntPtr sal_uLong
sal_IntPtr GetFontId() const
FreetypeFontInstance(const PhysicalFontFace &rPFF, const FontSelectPattern &rFSP)
FreetypeFontInfo(const FontAttributes &, const OString &rNativeFileName, int nFaceNum, int nFaceVariation, sal_IntPtr nFontId)
const OString maNativeFileName
virtual bool ImplGetGlyphBoundRect(sal_GlyphId, tools::Rectangle &, bool) const override
sal_uInt16 sal_GlyphId
Definition: glyphitem.hxx:26
virtual sal_IntPtr GetFontId() const override
virtual hb_font_t * ImplInitHbFont() override
int GetFontFaceVariation() const
abstract base class for physical font faces
FreetypeFontFile *const mpFontFile
unsigned char * mpFileMap
int GetFontFaceIndex() const
const OString & GetFileName() const
const unsigned char * GetBuffer() const
FreetypeFontFile(const OString &rNativeFileName)
const OString & GetFontFileName() const
static FreetypeFontFile * FindFontFile(const OString &rNativeFileName)
FreetypeFont * GetFreetypeFont() const
FontAttributes maDevFontAttributes
virtual bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon &, bool) const override
virtual rtl::Reference< LogicalFontInstance > CreateFontInstance(const FontSelectPattern &) const override
sal_IntPtr const mnFontId
const FontAttributes & GetFontAttributes() const
FreetypeFontFace(FreetypeFontInfo *, const FontAttributes &)
bool IsSymbolFont() const
void SetFreetypeFont(FreetypeFont *p)
FT_FaceRec_ * GetFaceFT()
bool IsSymbolFont() const
const unsigned char * GetTable(const char *, sal_uLong *pLength) const