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