/src/libreoffice/include/vcl/font.hxx
Line | Count | Source |
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_FONT_HXX |
21 | | #define INCLUDED_VCL_FONT_HXX |
22 | | |
23 | | #include <rtl/ustring.hxx> |
24 | | #include <sal/types.h> |
25 | | #include <vcl/dllapi.h> |
26 | | #include <tools/color.hxx> |
27 | | #include <tools/fontenum.hxx> |
28 | | #include <tools/long.hxx> |
29 | | #include <tools/degree.hxx> |
30 | | #include <i18nlangtag/lang.h> |
31 | | #include <vcl/fntstyle.hxx> |
32 | | #include <o3tl/cow_wrapper.hxx> |
33 | | |
34 | | class Size; |
35 | | class LanguageTag; |
36 | | class SvStream; |
37 | | |
38 | | class ImplFont; |
39 | | class FontAttributes; |
40 | | namespace vcl { class Font; } |
41 | | // need to first declare these outside the vcl namespace, or the friend declarations won't work right |
42 | | VCL_DLLPUBLIC SvStream& ReadFont( SvStream& rIStm, vcl::Font& ); |
43 | | VCL_DLLPUBLIC SvStream& WriteFont( SvStream& rOStm, const vcl::Font& ); |
44 | | |
45 | | namespace vcl { |
46 | | |
47 | | class SAL_WARN_UNUSED VCL_DLLPUBLIC Font |
48 | | { |
49 | | public: |
50 | | explicit Font(); |
51 | | Font( const Font& ); // TODO make me explicit |
52 | | Font( Font&& ) noexcept; |
53 | | explicit Font( const OUString& rFamilyName, const Size& ); |
54 | | explicit Font( const OUString& rFamilyName, const OUString& rStyleName, const Size& ); |
55 | | explicit Font( FontFamily eFamily, const Size& ); |
56 | | virtual ~Font(); |
57 | | |
58 | | const OUString& GetFamilyName() const; |
59 | | FontFamily GetFamilyTypeMaybeAskConfig(); |
60 | | FontFamily GetFamilyType() const; |
61 | | const OUString& GetStyleName() const; |
62 | | |
63 | | FontWeight GetWeightMaybeAskConfig(); |
64 | | FontWeight GetWeight() const; |
65 | | FontItalic GetItalicMaybeAskConfig(); |
66 | | FontItalic GetItalic() const; |
67 | | FontPitch GetPitchMaybeAskConfig(); |
68 | | FontPitch GetPitch() const; |
69 | | FontWidth GetWidthTypeMaybeAskConfig(); |
70 | | FontWidth GetWidthType() const; |
71 | | TextAlign GetAlignment() const; |
72 | | rtl_TextEncoding GetCharSet() const; |
73 | | FontEmphasisMark GetEmphasisMarkStyle() const; |
74 | | |
75 | | void SetFamilyName( const OUString& rFamilyName ); |
76 | | void SetStyleName( const OUString& rStyleName ); |
77 | | void SetFamily( FontFamily ); |
78 | | |
79 | | void SetPitch( FontPitch ePitch ); |
80 | | void SetItalic( FontItalic ); |
81 | | void SetWeight( FontWeight ); |
82 | | void SetWidthType( FontWidth ); |
83 | | void SetAlignment( TextAlign ); |
84 | | void SetCharSet( rtl_TextEncoding ); |
85 | | |
86 | | // Device dependent functions |
87 | | int GetQuality() const; |
88 | | |
89 | | void SetQuality(int); |
90 | | void IncreaseQualityBy(int); |
91 | | void DecreaseQualityBy(int); |
92 | | |
93 | | // setting the color on the font is obsolete, the only remaining |
94 | | // valid use is for keeping backward compatibility with old MetaFiles |
95 | | const Color& GetColor() const; |
96 | | const Color& GetFillColor() const; |
97 | | |
98 | | bool IsTransparent() const; |
99 | | |
100 | | void SetColor( const Color& ); |
101 | | void SetFillColor( const Color& ); |
102 | | |
103 | | void SetTransparent( bool bTransparent ); |
104 | | |
105 | | void SetFontSize( const Size& ); |
106 | | const Size& GetFontSize() const; |
107 | | void SetFontHeight( tools::Long nHeight ); |
108 | | tools::Long GetFontHeight() const; |
109 | | void SetAverageFontWidth( tools::Long nWidth ); |
110 | | tools::Long GetAverageFontWidth() const; |
111 | | SAL_DLLPRIVATE const Size& GetAverageFontSize() const; |
112 | | SAL_DLLPRIVATE const FontFamily& GetFontFamily() const; |
113 | | |
114 | | // tdf#127471 for corrections on EMF/WMF we need the AvgFontWidth in Windows-specific notation |
115 | | tools::Long GetOrCalculateAverageFontWidth() const; |
116 | | |
117 | | // Prefer LanguageTag over LanguageType |
118 | | SAL_DLLPRIVATE void SetLanguageTag( const LanguageTag & ); |
119 | | SAL_DLLPRIVATE const LanguageTag& GetLanguageTag() const; |
120 | | SAL_DLLPRIVATE void SetCJKContextLanguageTag( const LanguageTag& ); |
121 | | SAL_DLLPRIVATE const LanguageTag& GetCJKContextLanguageTag() const; |
122 | | void SetLanguage( LanguageType ); |
123 | | LanguageType GetLanguage() const; |
124 | | void SetCJKContextLanguage( LanguageType ); |
125 | | LanguageType GetCJKContextLanguage() const; |
126 | | |
127 | | void SetOrientation( Degree10 nLineOrientation ); |
128 | | Degree10 GetOrientation() const; |
129 | | void SetVertical( bool bVertical ); |
130 | | bool IsVertical() const; |
131 | | void SetKerning( FontKerning nKerning ); |
132 | | FontKerning GetKerning() const; |
133 | | bool IsKerning() const; |
134 | | void SetFixKerning(const short nSpacing); |
135 | | short GetFixKerning() const; |
136 | | bool IsFixKerning() const; |
137 | | |
138 | | void SetOutline( bool bOutline ); |
139 | | bool IsOutline() const; |
140 | | void SetShadow( bool bShadow ); |
141 | | bool IsShadow() const; |
142 | | void SetRelief( FontRelief ); |
143 | | FontRelief GetRelief() const; |
144 | | void SetUnderline( FontLineStyle ); |
145 | | FontLineStyle GetUnderline() const; |
146 | | void SetOverline( FontLineStyle ); |
147 | | FontLineStyle GetOverline() const; |
148 | | void SetStrikeout( FontStrikeout ); |
149 | | FontStrikeout GetStrikeout() const; |
150 | | void SetEmphasisMark( FontEmphasisMark ); |
151 | | FontEmphasisMark GetEmphasisMark() const; |
152 | | void SetWordLineMode( bool bWordLine ); |
153 | | bool IsWordLineMode() const; |
154 | | |
155 | | void Merge( const Font& rFont ); |
156 | | SAL_DLLPRIVATE void GetFontAttributes( FontAttributes& rAttrs ) const; |
157 | | |
158 | | Font& operator=( const Font& ); |
159 | | Font& operator=( Font&& ) noexcept; |
160 | | bool operator==( const Font& ) const; |
161 | | bool operator!=( const Font& rFont ) const |
162 | 3.80M | { return !(Font::operator==( rFont )); } |
163 | | bool IsSameInstance( const Font& ) const; |
164 | | SAL_DLLPRIVATE bool EqualIgnoreColor( const Font& ) const; |
165 | | |
166 | | // Compute value usable as hash. |
167 | | SAL_DLLPRIVATE size_t GetHashValueIgnoreColor() const; |
168 | | |
169 | | friend VCL_DLLPUBLIC SvStream& ::ReadFont( SvStream& rIStm, vcl::Font& ); |
170 | | friend VCL_DLLPUBLIC SvStream& ::WriteFont( SvStream& rOStm, const vcl::Font& ); |
171 | | |
172 | | static Font identifyFont( const void* pBuffer, sal_uInt32 nLen ); |
173 | | |
174 | | typedef o3tl::cow_wrapper< ImplFont > ImplType; |
175 | | |
176 | | inline bool IsUnderlineAbove() const; |
177 | | |
178 | | private: |
179 | | ImplType mpImplFont; |
180 | | }; |
181 | | |
182 | | inline bool Font::IsUnderlineAbove() const |
183 | 13.5k | { |
184 | 13.5k | if (!IsVertical()) |
185 | 9.16k | return false; |
186 | | // the underline is right for Japanese only |
187 | 4.34k | return (LANGUAGE_JAPANESE == GetLanguage()) || |
188 | 4.34k | (LANGUAGE_JAPANESE == GetCJKContextLanguage()); |
189 | 13.5k | } |
190 | | |
191 | | } |
192 | | |
193 | | #endif // _VCL_FONT_HXX |
194 | | |
195 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |