LibreOffice Module vcl (master) 1
FontSelectPattern.cxx
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#include <sal/config.h>
21#include <o3tl/safeint.hxx>
22#include <tools/gen.hxx>
23
24#include <utility>
25#include <vcl/font.hxx>
26
29
30namespace vcl::font
31{
32
33// These mustn't conflict with font name lists which use ; and ,
34const char FontSelectPattern::FEAT_PREFIX = ':';
36
38 OUString aSearchName, const Size& rSize, float fExactHeight, bool bNonAntialias)
39 : maSearchName(std::move( aSearchName ))
40 , mnWidth( rSize.Width() )
41 , mnHeight( rSize.Height() )
42 , mfExactHeight( fExactHeight)
43 , mnOrientation( rFont.GetOrientation() )
44 , meLanguage( rFont.GetLanguage() )
45 , mbVertical( rFont.IsVertical() )
46 , mbNonAntialiased(bNonAntialias)
47 , mbEmbolden( false )
48{
50
51 rFont.GetFontAttributes( *this );
52
53 // normalize orientation between 0 and 3600
54 if( mnOrientation < 0_deg10 || mnOrientation >= 3600_deg10 )
55 {
56 if( mnOrientation >= 0_deg10 )
57 mnOrientation %= 3600_deg10;
58 else
59 mnOrientation = 3600_deg10 - (-mnOrientation % 3600_deg10);
60 }
61
62 // normalize width and height
63 if( mnHeight < 0 )
65 if( mnWidth < 0 )
67}
68
69
70// NOTE: this ctor is still used on Windows. Do not remove.
71#ifdef _WIN32
73 const Size& rSize, float fExactHeight, int nOrientation, bool bVertical )
74 : FontAttributes( rFontData )
75 , mnWidth( rSize.Width() )
76 , mnHeight( rSize.Height() )
77 , mfExactHeight( fExactHeight )
78 , mnOrientation( nOrientation )
79 , meLanguage( 0 )
80 , mbVertical( bVertical )
81 , mbNonAntialiased( false )
82 , mbEmbolden( false )
83{
85 // NOTE: no normalization for width/height/orientation
86}
87
88#endif
89
91{
92 // TODO: does it pay off to improve this hash function?
93 size_t nHash;
94 // check for features and generate a unique hash if necessary
96 != -1)
97 {
98 nHash = maTargetName.hashCode();
99 }
100 else
101 {
102 nHash = maSearchName.hashCode();
103 }
104 nHash += 11U * mnHeight;
105 nHash += 19 * GetWeight();
106 nHash += 29 * GetItalic();
107 nHash += 37 * mnOrientation.get();
108 nHash += 41 * static_cast<sal_uInt16>(meLanguage);
109 if( mbVertical )
110 nHash += 53;
111 return nHash;
112}
113
115{
117 return false;
118
119 if (maTargetName != rOther.maTargetName)
120 return false;
121
122 if (maSearchName != rOther.maSearchName)
123 return false;
124
125 if (mnWidth != rOther.mnWidth)
126 return false;
127
128 if (mnHeight != rOther.mnHeight)
129 return false;
130
131 if (mfExactHeight != rOther.mfExactHeight)
132 return false;
133
134 if (mnOrientation != rOther.mnOrientation)
135 return false;
136
137 if (meLanguage != rOther.meLanguage)
138 return false;
139
140 if (mbVertical != rOther.mbVertical)
141 return false;
142
144 return false;
145
146 if (mbEmbolden != rOther.mbEmbolden)
147 return false;
148
149 if (maItalicMatrix != rOther.maItalicMatrix)
150 return false;
151
152 return true;
153}
154}
155
156/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
FontItalic GetItalic() const
FontWeight GetWeight() const
bool CompareDeviceIndependentFontAttributes(const FontAttributes &rOther) const
const OUString & GetFamilyName() const
void GetFontAttributes(FontAttributes &rAttrs) const
Definition: font/font.cxx:408
FontSelectPattern(const vcl::Font &, OUString aSearchName, const Size &, float fExactHeight, bool bNonAntialias=false)
bool operator==(const FontSelectPattern &rOther) const
abstract base class for physical font faces
LanguageType meLanguage
LanguageType GetLanguage(SfxItemSet const &aSet, sal_uInt16 nLangWhichId)
std::enable_if< std::is_signed< T >::value, T >::type saturating_toggle_sign(T a)
A PhysicalFontFaceCollection is created by a PhysicalFontCollection and becomes invalid when original...
double mnWidth
double mnHeight
UNDERLYING_TYPE get() const