vcl: 'horizontically'
[LibreOffice.git] / include / vcl / font.hxx
blob2d437c5b3da06590060358e01df87e8dc90140e8
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;
37 #define FontAlign TextAlign
39 class ImplFont;
40 class FontAttributes;
41 namespace vcl { class Font; }
42 // need to first declare these outside the vcl namespace, or the friend declarations won't work right
43 VCL_DLLPUBLIC SvStream& ReadFont( SvStream& rIStm, vcl::Font& );
44 VCL_DLLPUBLIC SvStream& WriteFont( SvStream& rOStm, const vcl::Font& );
46 namespace vcl {
48 class SAL_WARN_UNUSED VCL_DLLPUBLIC Font
50 public:
51 explicit Font();
52 Font( const Font& ); // TODO make me explicit
53 Font( Font&& ) noexcept;
54 explicit Font( const OUString& rFamilyName, const Size& );
55 explicit Font( const OUString& rFamilyName, const OUString& rStyleName, const Size& );
56 explicit Font( FontFamily eFamily, const Size& );
57 virtual ~Font();
59 const OUString& GetFamilyName() const;
60 FontFamily GetFamilyType();
61 FontFamily GetFamilyType() const;
62 const OUString& GetStyleName() const;
64 FontWeight GetWeight();
65 FontWeight GetWeight() const;
66 FontItalic GetItalic();
67 FontItalic GetItalic() const;
68 FontPitch GetPitch();
69 FontPitch GetPitch() const;
70 FontWidth GetWidthType();
71 FontWidth GetWidthType() const;
72 FontAlign GetAlignment() const;
73 rtl_TextEncoding GetCharSet() const;
75 bool IsSymbolFont() const;
77 void SetFamilyName( const OUString& rFamilyName );
78 void SetStyleName( const OUString& rStyleName );
79 void SetFamily( FontFamily );
81 void SetPitch( FontPitch ePitch );
82 void SetItalic( FontItalic );
83 void SetWeight( FontWeight );
84 void SetWidthType( FontWidth );
85 void SetAlignment( FontAlign );
86 void SetCharSet( rtl_TextEncoding );
88 void SetSymbolFlag( bool );
90 // Device dependent functions
91 int GetQuality() const;
93 void SetQuality(int);
94 void IncreaseQualityBy(int);
95 void DecreaseQualityBy(int);
97 // setting the color on the font is obsolete, the only remaining
98 // valid use is for keeping backward compatibility with old MetaFiles
99 const Color& GetColor() const;
100 const Color& GetFillColor() const;
102 bool IsTransparent() const;
104 void SetColor( const Color& );
105 void SetFillColor( const Color& );
107 void SetTransparent( bool bTransparent );
109 void SetFontSize( const Size& );
110 const Size& GetFontSize() const;
111 void SetFontHeight( tools::Long nHeight );
112 tools::Long GetFontHeight() const;
113 void SetAverageFontWidth( tools::Long nWidth );
114 tools::Long GetAverageFontWidth() const;
116 // Prefer LanguageTag over LanguageType
117 void SetLanguageTag( const LanguageTag & );
118 const LanguageTag& GetLanguageTag() const;
119 void SetCJKContextLanguageTag( const LanguageTag& );
120 const LanguageTag& GetCJKContextLanguageTag() const;
121 void SetLanguage( LanguageType );
122 LanguageType GetLanguage() const;
123 void SetCJKContextLanguage( LanguageType );
124 LanguageType GetCJKContextLanguage() const;
126 void SetOrientation( Degree10 nLineOrientation );
127 Degree10 GetOrientation() const;
128 void SetVertical( bool bVertical );
129 bool IsVertical() const;
130 void SetKerning( FontKerning nKerning );
131 FontKerning GetKerning() const;
132 bool IsKerning() const;
134 void SetOutline( bool bOutline );
135 bool IsOutline() const;
136 void SetShadow( bool bShadow );
137 bool IsShadow() const;
138 void SetRelief( FontRelief );
139 FontRelief GetRelief() const;
140 void SetUnderline( FontLineStyle );
141 FontLineStyle GetUnderline() const;
142 void SetOverline( FontLineStyle );
143 FontLineStyle GetOverline() const;
144 void SetStrikeout( FontStrikeout );
145 FontStrikeout GetStrikeout() const;
146 void SetEmphasisMark( FontEmphasisMark );
147 FontEmphasisMark GetEmphasisMark() const;
148 void SetWordLineMode( bool bWordLine );
149 bool IsWordLineMode() const;
151 void Merge( const Font& rFont );
152 void GetFontAttributes( FontAttributes& rAttrs ) const;
154 Font& operator=( const Font& );
155 Font& operator=( Font&& ) noexcept;
156 bool operator==( const Font& ) const;
157 bool operator!=( const Font& rFont ) const
158 { return !(Font::operator==( rFont )); }
159 bool IsSameInstance( const Font& ) const;
161 friend VCL_DLLPUBLIC SvStream& ::ReadFont( SvStream& rIStm, vcl::Font& );
162 friend VCL_DLLPUBLIC SvStream& ::WriteFont( SvStream& rOStm, const vcl::Font& );
164 static Font identifyFont( const void* pBuffer, sal_uInt32 nLen );
166 typedef o3tl::cow_wrapper< ImplFont > ImplType;
168 inline bool IsUnderlineAbove() const;
170 private:
171 ImplType mpImplFont;
174 inline bool Font::IsUnderlineAbove() const
176 if (!IsVertical())
177 return false;
178 // the underline is right for Japanese only
179 return (LANGUAGE_JAPANESE == GetLanguage()) ||
180 (LANGUAGE_JAPANESE == GetCJKContextLanguage());
185 #endif // _VCL_FONT_HXX
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */