Line data Source code
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 _SV_IMPFONT_HXX
21 : #define _SV_IMPFONT_HXX
22 :
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>
31 :
32 : // ------------
33 : // - Impl_Font -
34 : // ------------
35 :
36 : typedef sal_uInt32 FontRefCount;
37 :
38 2730773 : class Impl_Font
39 : {
40 : public:
41 : Impl_Font();
42 : Impl_Font( const Impl_Font& );
43 :
44 : bool operator==( const Impl_Font& ) const;
45 :
46 32085 : FontPitch GetPitch() { if(mePitch==PITCH_DONTKNOW) AskConfig(); return mePitch; }
47 22108 : FontFamily GetFamily() { if(meFamily==FAMILY_DONTKNOW) AskConfig(); return meFamily; }
48 1480517 : FontItalic GetItalic() { if(meItalic==ITALIC_DONTKNOW) AskConfig(); return meItalic; }
49 305725 : FontWeight GetWeight() { if(meWeight==WEIGHT_DONTKNOW) AskConfig(); return meWeight; }
50 3745 : FontWidth GetWidthType() { if(meWidthType==WIDTH_DONTKNOW)AskConfig(); return meWidthType; }
51 :
52 : private:
53 : friend class Font;
54 : void AskConfig();
55 :
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
84 :
85 : friend SvStream& operator>>( SvStream& rIStm, Impl_Font& );
86 : friend SvStream& operator<<( SvStream& rOStm, const Impl_Font& );
87 : };
88 :
89 : // ------------------
90 : // - ImplFontMetric -
91 : // ------------------
92 :
93 : class ImplFontMetric
94 : {
95 : friend class OutputDevice;
96 :
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
106 :
107 : enum { DEVICE_FLAG=1, SCALABLE_FLAG=2, LATIN_FLAG=4, CJK_FLAG=8, CTL_FLAG=16 };
108 :
109 : public:
110 : ImplFontMetric();
111 : void AddReference();
112 : void DeReference();
113 :
114 543005 : long GetAscent() const { return mnAscent; }
115 516448 : long GetDescent() const { return mnDescent; }
116 378799 : long GetIntLeading() const { return mnIntLeading; }
117 2709 : long GetExtLeading() const { return mnExtLeading; }
118 0 : long GetLineHeight() const { return mnLineHeight; }
119 0 : long GetSlant() const { return mnSlant; }
120 :
121 : bool IsDeviceFont() const { return ((mnMiscFlags & DEVICE_FLAG) != 0); }
122 110700 : 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); }
126 :
127 : bool operator==( const ImplFontMetric& ) const;
128 : };
129 :
130 : // ------------------
131 : // - ImplFontOptions -
132 : // ------------------
133 :
134 : class ImplFontOptions
135 : {
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 0 : ImplFontOptions() :
144 : meEmbeddedBitmap(EMBEDDEDBITMAP_DONTKNOW),
145 : meAntiAlias(ANTIALIAS_DONTKNOW),
146 : meAutoHint(AUTOHINT_DONTKNOW),
147 : meHinting(HINTING_DONTKNOW),
148 0 : meHintStyle(HINT_SLIGHT)
149 0 : {}
150 0 : virtual ~ImplFontOptions()
151 0 : {}
152 0 : FontAutoHint GetUseAutoHint() const
153 0 : { return meAutoHint; }
154 0 : FontHintStyle GetHintStyle() const
155 0 : { return meHintStyle; }
156 0 : bool DontUseEmbeddedBitmaps() const
157 0 : { return meEmbeddedBitmap == EMBEDDEDBITMAP_FALSE; }
158 0 : bool DontUseAntiAlias() const
159 0 : { return meAntiAlias == ANTIALIAS_FALSE; }
160 0 : bool DontUseHinting() const
161 0 : { return (meHinting == HINTING_FALSE) || (GetHintStyle() == HINT_NONE); }
162 0 : virtual void *GetPattern(void * /*pFace*/, bool /*bEmbolden*/, bool /*bVerticalMetrics*/) const
163 0 : { return NULL; }
164 : };
165 :
166 : // -------------------
167 : // - ImplFontCharMap -
168 : // -------------------
169 :
170 : class CmapResult;
171 :
172 : class VCL_PLUGIN_PUBLIC ImplFontCharMap
173 : {
174 : public:
175 : explicit ImplFontCharMap( const CmapResult& );
176 : virtual ~ImplFontCharMap();
177 :
178 : static ImplFontCharMap* GetDefaultMap( bool bSymbols=false);
179 :
180 : bool IsDefaultMap() const;
181 : bool HasChar( sal_uInt32 ) const;
182 : int CountCharsInRange( sal_uInt32 cMin, sal_uInt32 cMax ) const;
183 : int GetCharCount() const;
184 :
185 : sal_uInt32 GetFirstChar() const;
186 : sal_uInt32 GetLastChar() const;
187 :
188 : sal_uInt32 GetNextChar( sal_uInt32 ) const;
189 : sal_uInt32 GetPrevChar( sal_uInt32 ) const;
190 :
191 : int GetIndexFromChar( sal_uInt32 ) const;
192 : sal_uInt32 GetCharFromIndex( int ) const;
193 :
194 : void AddReference() const;
195 : void DeReference() const;
196 :
197 : int GetGlyphIndex( sal_uInt32 ) const;
198 :
199 : private:
200 : int ImplFindRangeIndex( sal_uInt32 ) const;
201 :
202 : // prevent assignment and copy construction
203 : explicit ImplFontCharMap( const ImplFontCharMap& );
204 : void operator=( const ImplFontCharMap& );
205 :
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;
213 : };
214 :
215 : // CmapResult is a normalized version of the many CMAP formats
216 : class VCL_PLUGIN_PUBLIC CmapResult
217 : {
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 );
222 :
223 : const sal_uInt32* mpRangeCodes;
224 : const int* mpStartGlyphs;
225 : const sal_uInt16* mpGlyphIds;
226 : int mnRangeCount;
227 : bool mbSymbolic;
228 : bool mbRecoded;
229 : };
230 :
231 : bool ParseCMAP( const unsigned char* pRawData, int nRawLength, CmapResult& );
232 :
233 : void UpdateAttributesFromPSName( const String& rPSName, ImplDevFontAttributes& );
234 :
235 : #endif // _SV_IMPFONT_HXX
236 :
237 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|