Basic Collection class unit test
[LibreOffice.git] / include / vcl / font.hxx
blobddc98c0223b9bd171753afe97577e485d0488c06
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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_FONT_HXX
21 #define INCLUDED_VCL_FONT_HXX
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>
34 class Size;
35 class LanguageTag;
36 class SvStream;
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& );
45 namespace vcl {
47 class SAL_WARN_UNUSED VCL_DLLPUBLIC Font
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();
58 const OUString& GetFamilyName() const;
59 FontFamily GetFamilyType();
60 FontFamily GetFamilyType() const;
61 const OUString& GetStyleName() const;
63 FontWeight GetWeight();
64 FontWeight GetWeight() const;
65 FontItalic GetItalic();
66 FontItalic GetItalic() const;
67 FontPitch GetPitch();
68 FontPitch GetPitch() const;
69 FontWidth GetWidthType();
70 FontWidth GetWidthType() const;
71 TextAlign GetAlignment() const;
72 rtl_TextEncoding GetCharSet() const;
74 bool IsSymbolFont() const;
76 void SetFamilyName( const OUString& rFamilyName );
77 void SetStyleName( const OUString& rStyleName );
78 void SetFamily( FontFamily );
80 void SetPitch( FontPitch ePitch );
81 void SetItalic( FontItalic );
82 void SetWeight( FontWeight );
83 void SetWidthType( FontWidth );
84 void SetAlignment( TextAlign );
85 void SetCharSet( rtl_TextEncoding );
87 void SetSymbolFlag( bool );
89 // Device dependent functions
90 int GetQuality() const;
92 void SetQuality(int);
93 void IncreaseQualityBy(int);
94 void DecreaseQualityBy(int);
96 // setting the color on the font is obsolete, the only remaining
97 // valid use is for keeping backward compatibility with old MetaFiles
98 const Color& GetColor() const;
99 const Color& GetFillColor() const;
101 bool IsTransparent() const;
103 void SetColor( const Color& );
104 void SetFillColor( const Color& );
106 void SetTransparent( bool bTransparent );
108 void SetFontSize( const Size& );
109 const Size& GetFontSize() const;
110 void SetFontHeight( tools::Long nHeight );
111 tools::Long GetFontHeight() const;
112 void SetAverageFontWidth( tools::Long nWidth );
113 tools::Long GetAverageFontWidth() const;
115 // tdf#127471 for corrections on EMF/WMF we need the AvgFontWidth in Windows-specific notation
116 tools::Long GetOrCalculateAverageFontWidth() const;
118 // Prefer LanguageTag over LanguageType
119 void SetLanguageTag( const LanguageTag & );
120 const LanguageTag& GetLanguageTag() const;
121 void SetCJKContextLanguageTag( const LanguageTag& );
122 const LanguageTag& GetCJKContextLanguageTag() const;
123 void SetLanguage( LanguageType );
124 LanguageType GetLanguage() const;
125 void SetCJKContextLanguage( LanguageType );
126 LanguageType GetCJKContextLanguage() const;
128 void SetOrientation( Degree10 nLineOrientation );
129 Degree10 GetOrientation() const;
130 void SetVertical( bool bVertical );
131 bool IsVertical() const;
132 void SetKerning( FontKerning nKerning );
133 FontKerning GetKerning() const;
134 bool IsKerning() const;
136 void SetOutline( bool bOutline );
137 bool IsOutline() const;
138 void SetShadow( bool bShadow );
139 bool IsShadow() const;
140 void SetRelief( FontRelief );
141 FontRelief GetRelief() const;
142 void SetUnderline( FontLineStyle );
143 FontLineStyle GetUnderline() const;
144 void SetOverline( FontLineStyle );
145 FontLineStyle GetOverline() const;
146 void SetStrikeout( FontStrikeout );
147 FontStrikeout GetStrikeout() const;
148 void SetEmphasisMark( FontEmphasisMark );
149 FontEmphasisMark GetEmphasisMark() const;
150 void SetWordLineMode( bool bWordLine );
151 bool IsWordLineMode() const;
153 void Merge( const Font& rFont );
154 void GetFontAttributes( FontAttributes& rAttrs ) const;
156 Font& operator=( const Font& );
157 Font& operator=( Font&& ) noexcept;
158 bool operator==( const Font& ) const;
159 bool operator!=( const Font& rFont ) const
160 { return !(Font::operator==( rFont )); }
161 bool IsSameInstance( const Font& ) const;
163 friend VCL_DLLPUBLIC SvStream& ::ReadFont( SvStream& rIStm, vcl::Font& );
164 friend VCL_DLLPUBLIC SvStream& ::WriteFont( SvStream& rOStm, const vcl::Font& );
166 static Font identifyFont( const void* pBuffer, sal_uInt32 nLen );
168 typedef o3tl::cow_wrapper< ImplFont > ImplType;
170 inline bool IsUnderlineAbove() const;
172 private:
173 ImplType mpImplFont;
176 inline bool Font::IsUnderlineAbove() const
178 if (!IsVertical())
179 return false;
180 // the underline is right for Japanese only
181 return (LANGUAGE_JAPANESE == GetLanguage()) ||
182 (LANGUAGE_JAPANESE == GetCJKContextLanguage());
187 #endif // _VCL_FONT_HXX
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */