Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / vcl / inc / outfont.hxx
blob2fa0862f20348c3a10a22f766139a508054ce372
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_INC_OUTFONT_HXX
21 #define INCLUDED_VCL_INC_OUTFONT_HXX
23 #include <rtl/ustring.hxx>
24 #include <sal/types.h>
25 #include <i18nlangtag/lang.h>
26 #include <tools/solar.h>
27 #include <vcl/dllapi.h>
28 #include <unotools/fontdefs.hxx>
29 #include <vcl/vclenum.hxx>
31 #include <boost/unordered_map.hpp>
33 class PhysicalFontFace;
34 class PhysicalFontFamily;
35 class ImplGetDevFontList;
36 class ImplGetDevSizeList;
37 class ImplFontEntry;
38 class ImplPreMatchFontSubstitution;
39 class ImplGlyphFallbackFontSubstitution;
40 class FontSelectPattern;
41 class Font;
42 class ConvertChar;
43 struct FontMatchStatus;
44 class OutputDevice;
45 class Size;
47 namespace com { namespace sun { namespace star { namespace lang { struct Locale; }}}}
49 // - ImplFontAttributes -
51 // device independent font properties
53 class ImplFontAttributes
55 public: // TODO: create matching interface class
56 const OUString& GetFamilyName() const { return maName; }
57 const OUString& GetStyleName() const { return maStyleName; }
58 FontWeight GetWeight() const { return meWeight; }
59 FontItalic GetSlant() const { return meItalic; }
60 FontFamily GetFamilyType() const { return meFamily; }
61 FontPitch GetPitch() const { return mePitch; }
62 FontWidth GetWidthType() const { return meWidthType; }
63 bool IsSymbolFont() const { return mbSymbolFlag; }
64 void SetFamilyName(const OUString& sFamilyName) { maName = sFamilyName; }
65 void SetStyleName( const OUString& sStyleName) { maStyleName = sStyleName; }
66 void SetFamilyType(const FontFamily eFontFamily) { meFamily = eFontFamily; }
67 void SetPitch(const FontPitch ePitch ) { mePitch = ePitch; }
68 void SetItalic(const FontItalic eItalic ) { meItalic = eItalic; }
69 void SetWeight(const FontWeight eWeight ) { meWeight = eWeight; }
70 void SetWidthType(const FontWidth eWidthType) { meWidthType = eWidthType; }
71 void SetSymbolFlag(const bool bSymbolFlag ) { mbSymbolFlag = bSymbolFlag; }
72 bool operator==(const ImplFontAttributes& rOther) const;
73 bool operator!=(const ImplFontAttributes& rOther) const
75 return !(*this == rOther);
78 private:
79 OUString maName; // Font Family Name
80 OUString maStyleName; // Font Style Name
81 FontWeight meWeight; // Weight Type
82 FontItalic meItalic; // Slant Type
83 FontFamily meFamily; // Family Type
84 FontPitch mePitch; // Pitch Type
85 FontWidth meWidthType; // Width Type
86 bool mbSymbolFlag;
89 // - ImplDevFontAttributes -
91 // device dependent font properties
93 class ImplDevFontAttributes : public ImplFontAttributes
95 public: // TODO: create matching interface class
96 const OUString& GetAliasNames() const { return maMapNames; }
97 int GetQuality() const { return mnQuality; }
98 bool IsRotatable() const { return mbOrientation; }
99 bool IsDeviceFont() const { return mbDevice; }
100 bool IsEmbeddable() const { return mbEmbeddable; }
101 bool IsSubsettable() const { return mbSubsettable; }
103 public: // TODO: hide members behind accessor methods
104 OUString maMapNames; // List of family name aliases separated with ';'
105 int mnQuality; // Quality (used when similar fonts compete)
106 bool mbOrientation; // true: physical font can be rotated
107 bool mbDevice; // true: built in font
108 bool mbSubsettable; // true: a subset of the font can be created
109 bool mbEmbeddable; // true: the font can be embedded
112 class FontSelectPatternAttributes : public ImplFontAttributes
114 public:
115 FontSelectPatternAttributes( const Font&, const OUString& rSearchName,
116 const Size&, float fExactHeight );
117 #ifdef WNT
118 FontSelectPatternAttributes( const PhysicalFontFace&, const Size&,
119 float fExactHeight, int nOrientation, bool bVertical );
120 #endif
122 size_t hashCode() const;
123 bool operator==(const FontSelectPatternAttributes& rOther) const;
124 bool operator!=(const FontSelectPatternAttributes& rOther) const
126 return !(*this == rOther);
129 public:
130 OUString maTargetName; // name of the font name token that is chosen
131 OUString maSearchName; // name of the font that matches best
132 int mnWidth; // width of font in pixel units
133 int mnHeight; // height of font in pixel units
134 float mfExactHeight; // requested height (in pixels with subpixel details)
135 int mnOrientation; // text orientation in 3600 system
136 LanguageType meLanguage; // text language
137 bool mbVertical; // vertical mode of requested font
138 bool mbNonAntialiased; // true if antialiasing is disabled
140 bool mbEmbolden; // Force emboldening
141 ItalicMatrix maItalicMatrix; // Force matrix for slant
144 class FontSelectPattern : public FontSelectPatternAttributes
146 public:
147 FontSelectPattern( const Font&, const OUString& rSearchName,
148 const Size&, float fExactHeight );
149 #ifdef WNT
150 // ifdeffed to prevent it going into unusedcode.easy
151 FontSelectPattern( const PhysicalFontFace&, const Size&,
152 float fExactHeight, int nOrientation, bool bVertical );
153 #endif
155 public: // TODO: change to private
156 const PhysicalFontFace* mpFontData; // a matching PhysicalFontFace object
157 ImplFontEntry* mpFontEntry; // pointer to the resulting FontCache entry
158 void copyAttributes(const FontSelectPatternAttributes &rAttributes);
161 // - ImplFontMetricData -
163 class ImplFontMetricData : public ImplFontAttributes
165 public:
166 explicit ImplFontMetricData( const FontSelectPattern& );
167 void ImplInitTextLineSize( const OutputDevice* pDev );
168 void ImplInitAboveTextLineSize();
170 public: // TODO: hide members behind accessor methods
171 // font instance attributes from the font request
172 long mnWidth; // Reference Width
173 short mnOrientation; // Rotation in 1/10 degrees
175 // font metrics measured for the font instance
176 long mnAscent; // Ascent
177 long mnDescent; // Descent
178 long mnIntLeading; // Internal Leading
179 long mnExtLeading; // External Leading
180 int mnSlant; // Slant (Italic/Oblique)
181 long mnMinKashida; // Minimal width of kashida (Arabic)
183 // font attributes queried from the font instance
184 int meFamilyType; // Font Family Type
185 bool mbDevice; // Flag for Device Fonts
186 bool mbScalableFont;
187 bool mbKernableFont;
189 // font metrics that are usually derived from the measurements
190 long mnUnderlineSize; // Lineheight of Underline
191 long mnUnderlineOffset; // Offset from Underline to Baseline
192 long mnBUnderlineSize; // Height of bold underline
193 long mnBUnderlineOffset; // Offset from bold underline to baseline
194 long mnDUnderlineSize; // Height of double underline
195 long mnDUnderlineOffset1; // Offset from double underline to baseline
196 long mnDUnderlineOffset2; // Offset from double underline to baseline
197 long mnWUnderlineSize; // Height of WaveLine underline
198 long mnWUnderlineOffset; // Offset from WaveLine underline to baseline, but centrered to WaveLine
199 long mnAboveUnderlineSize; // Height of single underline (for Vertical Right)
200 long mnAboveUnderlineOffset; // Offset from single underline to baseline (for Vertical Right)
201 long mnAboveBUnderlineSize; // Height of bold underline (for Vertical Right)
202 long mnAboveBUnderlineOffset; // Offset from bold underline to baseline (for Vertical Right)
203 long mnAboveDUnderlineSize; // Height of double underline (for Vertical Right)
204 long mnAboveDUnderlineOffset1; // Offset from double underline to baseline (for Vertical Right)
205 long mnAboveDUnderlineOffset2; // Offset from double underline to baseline (for Vertical Right)
206 long mnAboveWUnderlineSize; // Height of WaveLine-strike-out (for Vertical Right)
207 long mnAboveWUnderlineOffset; // Offset from WaveLine-strike-out to baseline, but centrered to to WaveLine (for Vertical Right)
208 long mnStrikeoutSize; // Height of single strike-out
209 long mnStrikeoutOffset; // Offset from single strike-out to baseline
210 long mnBStrikeoutSize; // Height of bold strike-out
211 long mnBStrikeoutOffset; // Offset of bold strike-out to baseline
212 long mnDStrikeoutSize; // Height of double strike-out
213 long mnDStrikeoutOffset1; // Offset of double strike-out to baseline
214 long mnDStrikeoutOffset2; // Offset of double strike-out to baseline
217 // - ImplFontEntry -
219 // TODO: rename ImplFontEntry to LogicalFontInstance
220 // TODO: allow sharing of metrics for related fonts
222 class VCL_PLUGIN_PUBLIC ImplFontEntry
224 public:
225 explicit ImplFontEntry( const FontSelectPattern& );
226 virtual ~ImplFontEntry();
228 public: // TODO: make data members private
229 FontSelectPattern maFontSelData; // FontSelectionData
230 ImplFontMetricData maMetric; // Font Metric
231 const ConvertChar* mpConversion; // used e.g. for StarBats->StarSymbol
232 long mnLineHeight;
233 sal_uLong mnRefCount;
234 sal_uInt16 mnSetFontFlags; // Flags returned by SalGraphics::SetFont()
235 short mnOwnOrientation; // text angle if lower layers don't rotate text themselves
236 short mnOrientation; // text angle in 3600 system
237 bool mbInit; // true if maMetric member is valid
239 void AddFallbackForUnicode( sal_UCS4, FontWeight eWeight, const OUString& rFontName );
240 bool GetFallbackForUnicode( sal_UCS4, FontWeight eWeight, OUString* pFontName ) const;
241 void IgnoreFallbackForUnicode( sal_UCS4, FontWeight eWeight, const OUString& rFontName );
243 private:
244 // cache of Unicode characters and replacement font names
245 // TODO: a fallback map can be shared with many other ImplFontEntries
246 // TODO: at least the ones which just differ in orientation, stretching or height
247 typedef ::std::pair<sal_UCS4,FontWeight> GFBCacheKey;
248 struct GFBCacheKey_Hash{ size_t operator()( const GFBCacheKey& ) const; };
249 typedef ::boost::unordered_map<GFBCacheKey,OUString,GFBCacheKey_Hash> UnicodeFallbackList;
250 UnicodeFallbackList* mpUnicodeFallbackList;
253 class ImplTextLineInfo
255 private:
256 long mnWidth;
257 sal_Int32 mnIndex;
258 sal_Int32 mnLen;
260 public:
261 ImplTextLineInfo( long nWidth, sal_Int32 nIndex, sal_Int32 nLen )
263 if(nIndex == -1 || nIndex == 0x0FFFF || nLen == -1 || nLen == 0x0FFFF)
265 SAL_INFO("sal.rtl.xub",
266 "ImplTextLine Info Suspicious arguments nIndex:" << nIndex << " nLen:" << nLen);
268 mnWidth = nWidth;
269 mnIndex = nIndex;
270 mnLen = nLen;
273 long GetWidth() const { return mnWidth; }
274 sal_Int32 GetIndex() const { return mnIndex; }
275 sal_Int32 GetLen() const { return mnLen; }
278 #define MULTITEXTLINEINFO_RESIZE 16
279 typedef ImplTextLineInfo* PImplTextLineInfo;
281 class ImplMultiTextLineInfo
283 private:
284 PImplTextLineInfo* mpLines;
285 sal_Int32 mnLines;
286 sal_Int32 mnSize;
288 public:
289 ImplMultiTextLineInfo();
290 ~ImplMultiTextLineInfo();
292 void AddLine( ImplTextLineInfo* pLine );
293 void Clear();
295 ImplTextLineInfo* GetLine( sal_uInt16 nLine ) const
296 { return mpLines[nLine]; }
297 sal_Int32 Count() const { return mnLines; }
299 private:
300 ImplMultiTextLineInfo( const ImplMultiTextLineInfo& );
301 ImplMultiTextLineInfo& operator=( const ImplMultiTextLineInfo& );
304 #endif // INCLUDED_VCL_INC_OUTFONT_HXX
306 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */