LibreOffice Module vcl (master)  1
impfont.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 #pragma once
21 
22 #include <sal/config.h>
23 
24 #include <rtl/ustring.hxx>
25 #include <tools/color.hxx>
26 #include <tools/fontenum.hxx>
27 #include <tools/gen.hxx>
29 #include <vcl/fntstyle.hxx>
30 
31 /* The following class is extraordinarily similar to FontAttributes. */
32 
33 class ImplFont
34 {
35 public:
36  explicit ImplFont();
37  explicit ImplFont( const ImplFont& );
38 
39  // device independent font functions
40  const OUString& GetFamilyName() const { return maFamilyName; }
42  const OUString& GetStyleName() const { return maStyleName; }
43 
48  TextAlign GetAlignment() const { return meAlign; }
49  rtl_TextEncoding GetCharSet() const { return meCharSet; }
50  const Size& GetFontSize() const { return maAverageFontSize; }
51 
52  bool IsSymbolFont() const { return mbSymbolFlag; }
53 
54  void SetFamilyName( const OUString& sFamilyName ) { maFamilyName = sFamilyName; }
55  void SetStyleName( const OUString& sStyleName ) { maStyleName = sStyleName; }
56  void SetFamilyType( const FontFamily eFontFamily ) { meFamily = eFontFamily; }
57 
58  void SetPitch( const FontPitch ePitch ) { mePitch = ePitch; }
59  void SetItalic( const FontItalic eItalic ) { meItalic = eItalic; }
60  void SetWeight( const FontWeight eWeight ) { meWeight = eWeight; }
61  void SetWidthType( const FontWidth eWidthType ) { meWidthType = eWidthType; }
62  void SetAlignment( const TextAlign eAlignment ) { meAlign = eAlignment; }
63  void SetCharSet( const rtl_TextEncoding eCharSet ) { meCharSet = eCharSet; }
64  void SetFontSize( const Size& rSize )
65  {
66  if(rSize.Height() != maAverageFontSize.Height())
67  {
68  // reset evtl. buffered calculated AverageFontSize, it depends
69  // on Font::Height
71  }
72  maAverageFontSize = rSize;
73  }
74 
75  void SetSymbolFlag( const bool bSymbolFlag ) { mbSymbolFlag = bSymbolFlag; }
76 
77  // straight properties, no getting them from AskConfig()
79  FontWeight GetWeightNoAsk() const { return meWeight; }
80  FontItalic GetItalicNoAsk() const { return meItalic; }
81  FontPitch GetPitchNoAsk() const { return mePitch; }
83 
84  // device dependent functions
85  int GetQuality() const { return mnQuality; }
86 
87  void SetQuality( int nQuality ) { mnQuality = nQuality; }
88  void IncreaseQualityBy( int nQualityAmount ) { mnQuality += nQualityAmount; }
89  void DecreaseQualityBy( int nQualityAmount ) { mnQuality -= nQualityAmount; }
90 
93 
94  bool operator==( const ImplFont& ) const;
95  bool EqualIgnoreColor( const ImplFont& ) const;
96 
97  size_t GetHashValue() const;
98  size_t GetHashValueIgnoreColor() const;
99 
100 private:
101  friend class vcl::Font;
102  friend SvStream& ReadImplFont( SvStream& rIStm, ImplFont&, tools::Long& );
103  friend SvStream& WriteImplFont( SvStream& rOStm, const ImplFont&, tools::Long );
104 
105  void AskConfig();
106 
107  // Device independent variables
108  OUString maFamilyName;
109  OUString maStyleName;
123  rtl_TextEncoding meCharSet;
124 
127 
128  // Flags - device independent
129  bool mbSymbolFlag:1,
130  mbOutline:1,
131  mbConfigLookup:1, // config lookup should only be done once
132  mbShadow:1,
133  mbVertical:1,
134  mbTransparent:1; // compatibility, now on output device
135 
136  // deprecated variables - device independent
137  Color maColor; // compatibility, now on output device
138  Color maFillColor; // compatibility, now on output device
139 
140  // Device dependent variables
141  bool mbWordLine:1;
142 
143  // TODO: metric data, should be migrated to ImplFontMetric
145 
147 
149 };
150 
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
tools::Long GetCalculatedAverageFontWidth() const
Definition: impfont.hxx:91
rtl_TextEncoding GetCharSet() const
Definition: impfont.hxx:49
FontKerning meKerning
Definition: impfont.hxx:121
void SetAlignment(const TextAlign eAlignment)
Definition: impfont.hxx:62
FontStrikeout meStrikeout
Definition: impfont.hxx:118
int GetQuality() const
Definition: impfont.hxx:85
FontItalic meItalic
Definition: impfont.hxx:114
FontLineStyle meOverline
Definition: impfont.hxx:117
void SetCharSet(const rtl_TextEncoding eCharSet)
Definition: impfont.hxx:63
FontWidth meWidthType
Definition: impfont.hxx:113
TextAlign meAlign
Definition: impfont.hxx:115
FontWeight meWeight
Definition: impfont.hxx:110
const OUString & GetStyleName() const
Definition: impfont.hxx:42
tools::Long mnCalculatedAverageFontWidth
Definition: impfont.hxx:148
Color maFillColor
Definition: impfont.hxx:138
FontWidth
FontItalic GetItalic()
Definition: impfont.hxx:45
const Size & GetFontSize() const
Definition: impfont.hxx:50
long Long
void SetQuality(int nQuality)
Definition: impfont.hxx:87
FAMILY_DONTKNOW
FontEmphasisMark
FontRelief meRelief
Definition: impfont.hxx:119
FontWeight GetWeightNoAsk() const
Definition: impfont.hxx:79
FontFamily meFamily
Definition: impfont.hxx:111
bool mbVertical
Definition: impfont.hxx:129
int mnQuality
Definition: impfont.hxx:146
const OUString & GetFamilyName() const
Definition: impfont.hxx:40
void SetFontSize(const Size &rSize)
Definition: impfont.hxx:64
void SetWidthType(const FontWidth eWidthType)
Definition: impfont.hxx:61
FontWidth GetWidthTypeNoAsk() const
Definition: impfont.hxx:82
void SetWeight(const FontWeight eWeight)
Definition: impfont.hxx:60
Size maAverageFontSize
Definition: impfont.hxx:122
void AskConfig()
Definition: font/font.cxx:1083
bool IsSymbolFont() const
Definition: impfont.hxx:52
FontPitch GetPitchNoAsk() const
Definition: impfont.hxx:81
friend SvStream & ReadImplFont(SvStream &rIStm, ImplFont &, tools::Long &)
Definition: font/font.cxx:456
void IncreaseQualityBy(int nQualityAmount)
Definition: impfont.hxx:88
void SetPitch(const FontPitch ePitch)
Definition: impfont.hxx:58
LanguageTag maCJKLanguageTag
Definition: impfont.hxx:126
friend SvStream & WriteImplFont(SvStream &rOStm, const ImplFont &, tools::Long)
Definition: font/font.cxx:523
FontKerning
Definition: fntstyle.hxx:28
bool mbSymbolFlag
Definition: impfont.hxx:129
OUString maStyleName
Definition: impfont.hxx:109
FontFamily GetFamilyTypeNoAsk() const
Definition: impfont.hxx:78
void SetCalculatedAverageFontWidth(tools::Long nNew)
Definition: impfont.hxx:92
FontWidth GetWidthType()
Definition: impfont.hxx:47
WEIGHT_DONTKNOW
void SetFamilyName(const OUString &sFamilyName)
Definition: impfont.hxx:54
void DecreaseQualityBy(int nQualityAmount)
Definition: impfont.hxx:89
bool operator==(const ImplFont &) const
Definition: font/font.cxx:989
Degree10 mnOrientation
Definition: impfont.hxx:144
FontEmphasisMark meEmphasisMark
Definition: impfont.hxx:120
rtl_TextEncoding meCharSet
Definition: impfont.hxx:123
LanguageTag maLanguageTag
Definition: impfont.hxx:125
bool mbConfigLookup
Definition: impfont.hxx:129
void SetSymbolFlag(const bool bSymbolFlag)
Definition: impfont.hxx:75
FontItalic GetItalicNoAsk() const
Definition: impfont.hxx:80
Color maColor
Definition: impfont.hxx:137
PITCH_DONTKNOW
TextAlign GetAlignment() const
Definition: impfont.hxx:48
FontPitch
bool EqualIgnoreColor(const ImplFont &) const
Definition: font/font.cxx:1001
TextAlign
FontWeight GetWeight()
Definition: impfont.hxx:44
bool mbShadow
Definition: impfont.hxx:129
FontFamily
FontPitch GetPitch()
Definition: impfont.hxx:46
FontPitch mePitch
Definition: impfont.hxx:112
FontWeight
void SetStyleName(const OUString &sStyleName)
Definition: impfont.hxx:55
size_t GetHashValueIgnoreColor() const
Definition: font/font.cxx:1048
constexpr tools::Long Height() const
WIDTH_DONTKNOW
bool mbTransparent
Definition: impfont.hxx:129
ITALIC_DONTKNOW
size_t GetHashValue() const
Definition: font/font.cxx:1040
void SetFamilyType(const FontFamily eFontFamily)
Definition: impfont.hxx:56
FontFamily GetFamilyType()
Definition: impfont.hxx:41
bool mbWordLine
Definition: impfont.hxx:141
OUString maFamilyName
Definition: impfont.hxx:108
void SetItalic(const FontItalic eItalic)
Definition: impfont.hxx:59
FontLineStyle
bool mbOutline
Definition: impfont.hxx:129
FontStrikeout
FontLineStyle meUnderline
Definition: impfont.hxx:116
FontRelief
Definition: fntstyle.hxx:26
FontItalic