LibreOffice Module vcl (master)  1
font.hxx
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 #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 <i18nlangtag/lang.h>
29 #include <vcl/fntstyle.hxx>
30 #include <o3tl/cow_wrapper.hxx>
31 
32 class Size;
33 class LanguageTag;
34 class SvStream;
35 #define FontAlign TextAlign
36 
37 class ImplFont;
38 class FontAttributes;
39 namespace vcl { class Font; }
40 // need to first declare these outside the vcl namespace, or the friend declarations won't work right
43 
44 namespace vcl {
45 
47 {
48 public:
49  explicit 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& );
55  virtual ~Font();
56 
57  const OUString& GetFamilyName() const;
58  FontFamily GetFamilyType();
59  FontFamily GetFamilyType() const;
60  const OUString& GetStyleName() const;
61 
62  FontWeight GetWeight();
63  FontWeight GetWeight() const;
64  FontItalic GetItalic();
65  FontItalic GetItalic() const;
66  FontPitch GetPitch();
67  FontPitch GetPitch() const;
68  FontWidth GetWidthType();
69  FontWidth GetWidthType() const;
70  FontAlign GetAlignment() const;
71  rtl_TextEncoding GetCharSet() const;
72 
73  bool IsSymbolFont() 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( FontAlign );
84  void SetCharSet( rtl_TextEncoding );
85 
86  void SetSymbolFlag( bool );
87 
88  // Device dependent functions
89  int GetQuality() const;
90 
91  void SetQuality(int);
92  void IncreaseQualityBy(int);
93  void DecreaseQualityBy(int);
94 
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;
99 
100  bool IsTransparent() const;
101 
102  void SetColor( const Color& );
103  void SetFillColor( const Color& );
104 
105  void SetTransparent( bool bTransparent );
106 
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;
113 
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;
123 
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;
131 
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;
148 
149  void Merge( const Font& rFont );
150  void GetFontAttributes( FontAttributes& rAttrs ) const;
151 
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;
158 
159  friend VCL_DLLPUBLIC SvStream& ::ReadFont( SvStream& rIStm, vcl::Font& );
160  friend VCL_DLLPUBLIC SvStream& ::WriteFont( SvStream& rOStm, const vcl::Font& );
161 
162  static Font identifyFont( const void* pBuffer, sal_uInt32 nLen );
163 
165 
166  inline bool IsUnderlineAbove() const;
167 
168 private:
169  ImplType mpImplFont;
170 };
171 
172 inline bool Font::IsUnderlineAbove() const
173 {
174  if (!IsVertical())
175  return false;
176  // the underline is right for Japanese only
177  return (LANGUAGE_JAPANESE == GetLanguage()) ||
179 }
180 
181 }
182 
183 #endif // _VCL_FONT_HXX
184 
185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define FontAlign
Definition: font.hxx:35
FontWidth
LanguageType GetCJKContextLanguage() const
Definition: font/font.cxx:683
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
FontEmphasisMark
VCL_DLLPUBLIC SvStream & ReadFont(SvStream &rIStm, vcl::Font &)
Definition: font/font.cxx:445
LanguageType GetLanguage() const
Definition: font/font.cxx:682
bool IsVertical() const
Definition: font/font.cxx:686
bool operator!=(const Font &rFont) const
Definition: font.hxx:155
VCL_DLLPUBLIC SvStream & WriteFont(SvStream &rOStm, const vcl::Font &)
Definition: font/font.cxx:450
FontKerning
Definition: fntstyle.hxx:28
o3tl::cow_wrapper< ImplFont > ImplType
Definition: font.hxx:164
bool operator==(const ItalicMatrix &a, const ItalicMatrix &b)
Definition: vclenum.hxx:203
LanguageType GetLanguage(SwWrtShell &rSh, sal_uInt16 nLangWhichId)
FontPitch
bool IsUnderlineAbove() const
Definition: font.hxx:172
FontFamily
FontWeight
size_t GetFontHeight()
bool operator==(const Font &) const
Definition: font/font.cxx:293
ImplType mpImplFont
Definition: font.hxx:169
void SetLanguage(SwWrtShell &rWrtSh, const OUString &rLangText, bool bIsForSelection, SfxItemSet &rCoreSet)
FontLineStyle
#define LANGUAGE_JAPANESE
FontStrikeout
FontRelief
Definition: fntstyle.hxx:26
FontItalic