bump product version to 4.1.6.2
[LibreOffice.git] / vcl / inc / impfont.hxx
blob26a9dd41aed9b7b9a6c68f831fc9f0b2854e8743
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 _SV_IMPFONT_HXX
21 #define _SV_IMPFONT_HXX
23 #include <tools/gen.hxx>
24 #include <tools/string.hxx>
25 #include <i18nlangtag/lang.h>
26 #include <tools/color.hxx>
27 #include <vcl/dllapi.h>
28 #include <vcl/vclenum.hxx>
29 #include <vcl/fntstyle.hxx>
30 #include <outfont.hxx>
32 // ------------
33 // - Impl_Font -
34 // ------------
36 typedef sal_uInt32 FontRefCount;
38 class Impl_Font
40 public:
41 Impl_Font();
42 Impl_Font( const Impl_Font& );
44 bool operator==( const Impl_Font& ) const;
46 FontPitch GetPitch() { if(mePitch==PITCH_DONTKNOW) AskConfig(); return mePitch; }
47 FontFamily GetFamily() { if(meFamily==FAMILY_DONTKNOW) AskConfig(); return meFamily; }
48 FontItalic GetItalic() { if(meItalic==ITALIC_DONTKNOW) AskConfig(); return meItalic; }
49 FontWeight GetWeight() { if(meWeight==WEIGHT_DONTKNOW) AskConfig(); return meWeight; }
50 FontWidth GetWidthType() { if(meWidthType==WIDTH_DONTKNOW)AskConfig(); return meWidthType; }
52 private:
53 friend class Font;
54 void AskConfig();
56 FontRefCount mnRefCount;
57 String maFamilyName;
58 String maStyleName;
59 Size maSize;
60 Color maColor; // compatibility, now on output device
61 Color maFillColor; // compatibility, now on output device
62 rtl_TextEncoding meCharSet;
63 LanguageType meLanguage;
64 LanguageType meCJKLanguage;
65 FontFamily meFamily;
66 FontPitch mePitch;
67 TextAlign meAlign;
68 FontWeight meWeight;
69 FontWidth meWidthType;
70 FontItalic meItalic;
71 FontUnderline meUnderline;
72 FontUnderline meOverline;
73 FontStrikeout meStrikeout;
74 FontRelief meRelief;
75 FontEmphasisMark meEmphasisMark;
76 short mnOrientation;
77 FontKerning mnKerning;
78 sal_Bool mbWordLine:1,
79 mbOutline:1,
80 mbConfigLookup:1, // there was a config lookup
81 mbShadow:1,
82 mbVertical:1,
83 mbTransparent:1; // compatibility, now on output device
85 friend SvStream& operator>>( SvStream& rIStm, Impl_Font& );
86 friend SvStream& operator<<( SvStream& rOStm, const Impl_Font& );
89 // ------------------
90 // - ImplFontMetric -
91 // ------------------
93 class ImplFontMetric
95 friend class OutputDevice;
97 private:
98 long mnAscent; // Ascent
99 long mnDescent; // Descent
100 long mnIntLeading; // Internal Leading
101 long mnExtLeading; // External Leading
102 long mnLineHeight; // Ascent+Descent+EmphasisMark
103 long mnSlant; // Slant
104 sal_uInt16 mnMiscFlags; // Misc Flags
105 FontRefCount mnRefCount; // Reference Counter
107 enum { DEVICE_FLAG=1, SCALABLE_FLAG=2, LATIN_FLAG=4, CJK_FLAG=8, CTL_FLAG=16 };
109 public:
110 ImplFontMetric();
111 void AddReference();
112 void DeReference();
114 long GetAscent() const { return mnAscent; }
115 long GetDescent() const { return mnDescent; }
116 long GetIntLeading() const { return mnIntLeading; }
117 long GetExtLeading() const { return mnExtLeading; }
118 long GetLineHeight() const { return mnLineHeight; }
119 long GetSlant() const { return mnSlant; }
121 bool IsDeviceFont() const { return ((mnMiscFlags & DEVICE_FLAG) != 0); }
122 bool IsScalable() const { return ((mnMiscFlags & SCALABLE_FLAG) != 0); }
123 bool SupportsLatin() const { return ((mnMiscFlags & LATIN_FLAG) != 0); }
124 bool SupportsCJK() const { return ((mnMiscFlags & CJK_FLAG) != 0); }
125 bool SupportsCTL() const { return ((mnMiscFlags & CTL_FLAG) != 0); }
127 bool operator==( const ImplFontMetric& ) const;
130 // ------------------
131 // - ImplFontOptions -
132 // ------------------
134 class ImplFontOptions
136 public:
137 FontEmbeddedBitmap meEmbeddedBitmap; // whether the embedded bitmaps should be used
138 FontAntiAlias meAntiAlias; // whether the font should be antialiased
139 FontAutoHint meAutoHint; // whether the font should be autohinted
140 FontHinting meHinting; // whether the font should be hinted
141 FontHintStyle meHintStyle; // type of font hinting to be used
142 public:
143 ImplFontOptions() :
144 meEmbeddedBitmap(EMBEDDEDBITMAP_DONTKNOW),
145 meAntiAlias(ANTIALIAS_DONTKNOW),
146 meAutoHint(AUTOHINT_DONTKNOW),
147 meHinting(HINTING_DONTKNOW),
148 meHintStyle(HINT_SLIGHT)
150 virtual ~ImplFontOptions()
152 FontAutoHint GetUseAutoHint() const
153 { return meAutoHint; }
154 FontHintStyle GetHintStyle() const
155 { return meHintStyle; }
156 bool DontUseEmbeddedBitmaps() const
157 { return meEmbeddedBitmap == EMBEDDEDBITMAP_FALSE; }
158 bool DontUseAntiAlias() const
159 { return meAntiAlias == ANTIALIAS_FALSE; }
160 bool DontUseHinting() const
161 { return (meHinting == HINTING_FALSE) || (GetHintStyle() == HINT_NONE); }
162 virtual void *GetPattern(void * /*pFace*/, bool /*bEmbolden*/, bool /*bVerticalMetrics*/) const
163 { return NULL; }
166 // -------------------
167 // - ImplFontCharMap -
168 // -------------------
170 class CmapResult;
172 class VCL_PLUGIN_PUBLIC ImplFontCharMap
174 public:
175 explicit ImplFontCharMap( const CmapResult& );
176 virtual ~ImplFontCharMap();
178 static ImplFontCharMap* GetDefaultMap( bool bSymbols=false);
180 bool IsDefaultMap() const;
181 bool HasChar( sal_uInt32 ) const;
182 int CountCharsInRange( sal_uInt32 cMin, sal_uInt32 cMax ) const;
183 int GetCharCount() const;
185 sal_uInt32 GetFirstChar() const;
186 sal_uInt32 GetLastChar() const;
188 sal_uInt32 GetNextChar( sal_uInt32 ) const;
189 sal_uInt32 GetPrevChar( sal_uInt32 ) const;
191 int GetIndexFromChar( sal_uInt32 ) const;
192 sal_uInt32 GetCharFromIndex( int ) const;
194 void AddReference() const;
195 void DeReference() const;
197 int GetGlyphIndex( sal_uInt32 ) const;
199 private:
200 int ImplFindRangeIndex( sal_uInt32 ) const;
202 // prevent assignment and copy construction
203 explicit ImplFontCharMap( const ImplFontCharMap& );
204 void operator=( const ImplFontCharMap& );
206 private:
207 const sal_uInt32* mpRangeCodes; // pairs of StartCode/(EndCode+1)
208 const int* mpStartGlyphs; // range-specific mapper to glyphs
209 const sal_uInt16* mpGlyphIds; // individual glyphid mappings
210 int mnRangeCount;
211 int mnCharCount; // covered codepoints
212 mutable FontRefCount mnRefCount;
215 // CmapResult is a normalized version of the many CMAP formats
216 class VCL_PLUGIN_PUBLIC CmapResult
218 public:
219 explicit CmapResult( bool bSymbolic = false,
220 const sal_uInt32* pRangeCodes = NULL, int nRangeCount = 0,
221 const int* pStartGlyphs = 0, const sal_uInt16* pGlyphIds = NULL );
223 const sal_uInt32* mpRangeCodes;
224 const int* mpStartGlyphs;
225 const sal_uInt16* mpGlyphIds;
226 int mnRangeCount;
227 bool mbSymbolic;
228 bool mbRecoded;
231 bool ParseCMAP( const unsigned char* pRawData, int nRawLength, CmapResult& );
233 void UpdateAttributesFromPSName( const String& rPSName, ImplDevFontAttributes& );
235 #endif // _SV_IMPFONT_HXX
237 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */