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_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 <i18nlangtag/lang.h>
29 #include <vcl/fntstyle.hxx>
30 #include <o3tl/cow_wrapper.hxx>
35 #define FontAlign TextAlign
39 namespace vcl
{ class Font
; }
40 // need to first declare these outside the vcl namespace, or the friend declarations won't work right
41 VCL_DLLPUBLIC SvStream
& ReadFont( SvStream
& rIStm
, vcl::Font
& );
42 VCL_DLLPUBLIC SvStream
& WriteFont( SvStream
& rOStm
, const vcl::Font
& );
46 class VCL_DLLPUBLIC Font
50 Font( const Font
& ); // TODO make me explicit
51 Font( Font
&& ) noexcept
;
52 explicit Font( const OUString
& rFamilyName
, const Size
& );
53 explicit Font( const OUString
& rFamilyName
, const OUString
& rStyleName
, const Size
& );
54 explicit Font( FontFamily eFamily
, const Size
& );
57 const OUString
& GetFamilyName() const;
58 FontFamily
GetFamilyType();
59 FontFamily
GetFamilyType() const;
60 const OUString
& GetStyleName() const;
62 FontWeight
GetWeight();
63 FontWeight
GetWeight() const;
64 FontItalic
GetItalic();
65 FontItalic
GetItalic() const;
67 FontPitch
GetPitch() const;
68 FontWidth
GetWidthType();
69 FontWidth
GetWidthType() const;
70 FontAlign
GetAlignment() const;
71 rtl_TextEncoding
GetCharSet() const;
73 bool IsSymbolFont() const;
75 void SetFamilyName( const OUString
& rFamilyName
);
76 void SetStyleName( const OUString
& rStyleName
);
77 void SetFamily( FontFamily
);
79 void SetPitch( FontPitch ePitch
);
80 void SetItalic( FontItalic
);
81 void SetWeight( FontWeight
);
82 void SetWidthType( FontWidth
);
83 void SetAlignment( FontAlign
);
84 void SetCharSet( rtl_TextEncoding
);
86 void SetSymbolFlag( bool );
88 // Device dependent functions
89 int GetQuality() const;
92 void IncreaseQualityBy(int);
93 void DecreaseQualityBy(int);
95 // setting the color on the font is obsolete, the only remaining
96 // valid use is for keeping backward compatibility with old MetaFiles
97 const Color
& GetColor() const;
98 const Color
& GetFillColor() const;
100 bool IsTransparent() const;
102 void SetColor( const Color
& );
103 void SetFillColor( const Color
& );
105 void SetTransparent( bool bTransparent
);
107 void SetFontSize( const Size
& );
108 const Size
& GetFontSize() const;
109 void SetFontHeight( long nHeight
);
110 long GetFontHeight() const;
111 void SetAverageFontWidth( long nWidth
);
112 long GetAverageFontWidth() const;
114 // Prefer LanguageTag over LanguageType
115 void SetLanguageTag( const LanguageTag
& );
116 const LanguageTag
& GetLanguageTag() const;
117 void SetCJKContextLanguageTag( const LanguageTag
& );
118 const LanguageTag
& GetCJKContextLanguageTag() const;
119 void SetLanguage( LanguageType
);
120 LanguageType
GetLanguage() const;
121 void SetCJKContextLanguage( LanguageType
);
122 LanguageType
GetCJKContextLanguage() const;
124 void SetOrientation( short nLineOrientation
);
125 short GetOrientation() const;
126 void SetVertical( bool bVertical
);
127 bool IsVertical() const;
128 void SetKerning( FontKerning nKerning
);
129 FontKerning
GetKerning() const;
130 bool IsKerning() const;
132 void SetOutline( bool bOutline
);
133 bool IsOutline() const;
134 void SetShadow( bool bShadow
);
135 bool IsShadow() const;
136 void SetRelief( FontRelief
);
137 FontRelief
GetRelief() const;
138 void SetUnderline( FontLineStyle
);
139 FontLineStyle
GetUnderline() const;
140 void SetOverline( FontLineStyle
);
141 FontLineStyle
GetOverline() const;
142 void SetStrikeout( FontStrikeout
);
143 FontStrikeout
GetStrikeout() const;
144 void SetEmphasisMark( FontEmphasisMark
);
145 FontEmphasisMark
GetEmphasisMark() const;
146 void SetWordLineMode( bool bWordLine
);
147 bool IsWordLineMode() const;
149 void Merge( const Font
& rFont
);
150 void GetFontAttributes( FontAttributes
& rAttrs
) const;
152 Font
& operator=( const Font
& );
153 Font
& operator=( Font
&& ) noexcept
;
154 bool operator==( const Font
& ) const;
155 bool operator!=( const Font
& rFont
) const
156 { return !(Font::operator==( rFont
)); }
157 bool IsSameInstance( const Font
& ) const;
159 friend VCL_DLLPUBLIC SvStream
& ::ReadFont( SvStream
& rIStm
, vcl::Font
& );
160 friend VCL_DLLPUBLIC SvStream
& ::WriteFont( SvStream
& rOStm
, const vcl::Font
& );
162 static Font
identifyFont( const void* pBuffer
, sal_uInt32 nLen
);
164 typedef o3tl::cow_wrapper
< ImplFont
> ImplType
;
166 inline bool IsUnderlineAbove() const;
172 inline bool Font::IsUnderlineAbove() const
176 // the underline is right for Japanese only
177 return (LANGUAGE_JAPANESE
== GetLanguage()) ||
178 (LANGUAGE_JAPANESE
== GetCJKContextLanguage());
183 #endif // _VCL_FONT_HXX
185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */