LibreOffice Module vcl (master)  1
fontattributes.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_INC_FONTATTRIBUTES_HXX
21 #define INCLUDED_VCL_INC_FONTATTRIBUTES_HXX
22 
23 #include <vcl/dllapi.h>
24 #include <rtl/ustring.hxx>
25 #include <sal/log.hxx>
26 #include <tools/fontenum.hxx>
27 
28 
29 /* The following class is extraordinarily similar to ImplFont. */
30 
32 {
33 public:
34  explicit FontAttributes();
35 
36  // device independent font functions
37  const OUString& GetFamilyName() const { return maFamilyName; }
38  FontFamily GetFamilyType() const { return meFamily; }
39  const OUString& GetStyleName() const { return maStyleName; }
40 
41  FontWeight GetWeight() const { return meWeight; }
42  FontItalic GetItalic() const { return meItalic; }
43  FontPitch GetPitch() const { return mePitch; }
44  FontWidth GetWidthType() const { return meWidthType; }
45  rtl_TextEncoding GetCharSet() const { return meCharSet; }
46 
47  bool IsSymbolFont() const { return mbSymbolFlag; }
48 
49  void SetFamilyName(const OUString& sFamilyName) { maFamilyName = sFamilyName; }
50  void SetStyleName( const OUString& sStyleName) { maStyleName = sStyleName; }
51  void SetFamilyType(const FontFamily eFontFamily) { meFamily = eFontFamily; }
52 
53  void SetPitch(const FontPitch ePitch ) { mePitch = ePitch; }
54  void SetItalic(const FontItalic eItalic ) { meItalic = eItalic; }
55  void SetWeight(const FontWeight eWeight ) { meWeight = eWeight; }
56  void SetWidthType(const FontWidth eWidthType) { meWidthType = eWidthType; }
57 
58  void SetSymbolFlag(const bool );
59 
60  bool CompareDeviceIndependentFontAttributes(const FontAttributes& rOther) const;
61 
62  // Device dependent functions
63  int GetQuality() const { return mnQuality; }
64  const OUString& GetMapNames() const { return maMapNames; }
65 
66 
67  void SetQuality( int nQuality ) { mnQuality = nQuality; }
68  void IncreaseQualityBy( int nQualityAmount ) { mnQuality += nQualityAmount; }
69  void AddMapName( OUString const& );
70 
71 private:
72  // device independent variables
73  OUString maFamilyName; // Font Family Name
74  OUString maStyleName; // Font Style Name
75  FontWeight meWeight; // Weight Type
76  FontFamily meFamily; // Family Type
77  FontPitch mePitch; // Pitch Type
78  FontWidth meWidthType; // Width Type
79  FontItalic meItalic; // Slant Type
80  rtl_TextEncoding meCharSet; // RTL_TEXTENCODING_SYMBOL or RTL_TEXTENCODING_UNICODE
81  bool mbSymbolFlag; // Is font a symbol?
82 
83  // device dependent variables
84  OUString maMapNames; // List of family name aliases separated with ';'
85  int mnQuality; // Quality (used when similar fonts compete)
86 
87 };
88 
89 inline void FontAttributes::SetSymbolFlag( const bool bSymbolFlag )
90 {
91  mbSymbolFlag = bSymbolFlag;
92  if ( bSymbolFlag )
93  {
94  meCharSet = RTL_TEXTENCODING_SYMBOL;
95  }
96  else
97  {
98  // if the symbol flag is unset, but it was a symbol font before then
99  // until the character set encoding is set via SetCharSet then we
100  // can't know what the characterset is!
101  if ( meCharSet == RTL_TEXTENCODING_SYMBOL )
102  {
103  meCharSet = RTL_TEXTENCODING_DONTKNOW;
104  }
105  }
106 }
107 
108 inline void FontAttributes::AddMapName( OUString const & aMapName )
109 {
110  if( maMapNames.getLength() > 0 )
111  {
112  maMapNames += ";";
113  }
114 
115  if (aMapName.getLength() == 0)
116  {
117  SAL_WARN("vcl.fonts", "New map name is empty");
118  return;
119  }
120 
121  maMapNames += aMapName;
122 }
123 
124 #endif // INCLUDED_VCL_INC_FONTATTRIBUTES_HXX
125 
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const OUString & GetStyleName() const
rtl_TextEncoding meCharSet
FontWidth
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
void SetWidthType(const FontWidth eWidthType)
void SetPitch(const FontPitch ePitch)
OUString maStyleName
FontFamily meFamily
FontWidth meWidthType
FontItalic meItalic
FontItalic GetItalic() const
rtl_TextEncoding GetCharSet() const
FontFamily GetFamilyType() const
void SetWeight(const FontWeight eWeight)
FontWeight GetWeight() const
void SetQuality(int nQuality)
void SetItalic(const FontItalic eItalic)
void SetFamilyName(const OUString &sFamilyName)
void SetSymbolFlag(const bool)
int GetQuality() const
FontPitch
const OUString & GetMapNames() const
FontWeight meWeight
FontFamily
FontWeight
void AddMapName(OUString const &)
OUString maFamilyName
void IncreaseQualityBy(int nQualityAmount)
void SetStyleName(const OUString &sStyleName)
FontWidth GetWidthType() const
#define SAL_WARN(area, stream)
bool IsSymbolFont() const
FontPitch GetPitch() const
const OUString & GetFamilyName() const
void SetFamilyType(const FontFamily eFontFamily)
FontItalic