1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_VCL_GENERIC_GLYPHS_GCACH_FTYP_HXX
21 #define INCLUDED_VCL_GENERIC_GLYPHS_GCACH_FTYP_HXX
23 #include "unx/glyphcache.hxx"
24 #include "PhysicalFontFace.hxx"
26 // FreetypeFontFile has the responsibility that a font file is only mapped once.
27 // (#86621#) the old directly ft-managed solution caused it to be mapped
28 // in up to nTTC*nSizes*nOrientation*nSynthetic times
29 class FreetypeFontFile
32 static FreetypeFontFile
* FindFontFile( const OString
& rNativeFileName
);
37 const unsigned char* GetBuffer() const { return mpFileMap
; }
38 int GetFileSize() const { return mnFileSize
; }
39 const OString
& GetFileName() const { return maNativeFileName
; }
40 int GetLangBoost() const { return mnLangBoost
; }
43 explicit FreetypeFontFile( const OString
& rNativeFileName
);
45 const OString maNativeFileName
;
46 unsigned char* mpFileMap
;
52 // FreetypeFontInfo corresponds to an unscaled font face
53 class FreetypeFontInfo
56 FreetypeFontInfo( const FontAttributes
&,
57 const OString
& rNativeFileName
,
58 int nFaceNum
, sal_IntPtr nFontId
);
61 const unsigned char* GetTable( const char*, sal_uLong
* pLength
=nullptr ) const;
63 FT_FaceRec_
* GetFaceFT();
66 const OString
& GetFontFileName() const { return mpFontFile
->GetFileName(); }
67 int GetFontFaceIndex() const { return mnFaceNum
; }
68 sal_IntPtr
GetFontId() const { return mnFontId
; }
69 bool IsSymbolFont() const { return maDevFontAttributes
.IsSymbolFont(); }
70 const FontAttributes
& GetFontAttributes() const { return maDevFontAttributes
; }
72 void AnnounceFont( PhysicalFontCollection
* );
74 bool GetFontCodeRanges( CmapResult
& ) const;
75 const FontCharMapRef
& GetFontCharMap();
78 FT_FaceRec_
* maFaceFT
;
79 FreetypeFontFile
* mpFontFile
;
83 FontAttributes maDevFontAttributes
;
85 FontCharMapRef mxFontCharMap
;
94 void AddFontFile( const OString
& rNormalizedName
,
95 int nFaceNum
, sal_IntPtr nFontId
, const FontAttributes
&);
96 void AnnounceFonts( PhysicalFontCollection
* ) const;
99 FreetypeFont
* CreateFont( const FontSelectPattern
& );
102 typedef std::unordered_map
<sal_IntPtr
,FreetypeFontInfo
*> FontList
;
105 sal_IntPtr mnMaxFontId
;
108 class FreetypeFontFace
: public PhysicalFontFace
111 FreetypeFontInfo
* mpFreetypeFontInfo
;
114 FreetypeFontFace( FreetypeFontInfo
*, const FontAttributes
& );
116 virtual LogicalFontInstance
* CreateFontInstance( FontSelectPattern
& ) const override
;
117 virtual PhysicalFontFace
* Clone() const override
{ return new FreetypeFontFace( *this ); }
118 virtual sal_IntPtr
GetFontId() const override
{ return mpFreetypeFontInfo
->GetFontId(); }
121 #endif // INCLUDED_VCL_GENERIC_GLYPHS_GCACH_FTYP_HXX
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */