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