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 INCLUDED_VCL_INC_IMPFONT_HXX
21 : #define INCLUDED_VCL_INC_IMPFONT_HXX
22 :
23 : #include <rtl/ustring.hxx>
24 : #include <tools/gen.hxx>
25 : #include <i18nlangtag/languagetag.hxx>
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 : #include <boost/intrusive_ptr.hpp>
33 :
34 : class ImplFontCharMap;
35 : typedef boost::intrusive_ptr< ImplFontCharMap > ImplFontCharMapPtr;
36 :
37 : // - Impl_Font -
38 :
39 7338116 : class Impl_Font
40 : {
41 : public:
42 : Impl_Font();
43 : Impl_Font( const Impl_Font& );
44 :
45 : bool operator==( const Impl_Font& ) const;
46 :
47 80205 : FontPitch GetPitch() { if(mePitch==PITCH_DONTKNOW) AskConfig(); return mePitch; }
48 57284 : FontFamily GetFamily() { if(meFamily==FAMILY_DONTKNOW) AskConfig(); return meFamily; }
49 7321516 : FontItalic GetItalic() { if(meItalic==ITALIC_DONTKNOW) AskConfig(); return meItalic; }
50 1501876 : FontWeight GetWeight() { if(meWeight==WEIGHT_DONTKNOW) AskConfig(); return meWeight; }
51 2304 : FontWidth GetWidthType() { if(meWidthType==WIDTH_DONTKNOW)AskConfig(); return meWidthType; }
52 :
53 : private:
54 : friend class vcl::Font;
55 : void AskConfig();
56 :
57 : sal_uInt32 mnRefCount;
58 : OUString maFamilyName;
59 : OUString maStyleName;
60 : Size maSize;
61 : Color maColor; // compatibility, now on output device
62 : Color maFillColor; // compatibility, now on output device
63 : rtl_TextEncoding meCharSet;
64 : LanguageTag maLanguageTag;
65 : LanguageTag maCJKLanguageTag;
66 : FontFamily meFamily;
67 : FontPitch mePitch;
68 : TextAlign meAlign;
69 : FontWeight meWeight;
70 : FontWidth meWidthType;
71 : FontItalic meItalic;
72 : FontUnderline meUnderline;
73 : FontUnderline meOverline;
74 : FontStrikeout meStrikeout;
75 : FontRelief meRelief;
76 : FontEmphasisMark meEmphasisMark;
77 : short mnOrientation;
78 : FontKerning mnKerning;
79 : bool mbWordLine:1,
80 : mbOutline:1,
81 : mbConfigLookup:1, // there was a config lookup
82 : mbShadow:1,
83 : mbVertical:1,
84 : mbTransparent:1; // compatibility, now on output device
85 :
86 : friend SvStream& ReadImpl_Font( SvStream& rIStm, Impl_Font& );
87 : friend SvStream& WriteImpl_Font( SvStream& rOStm, const Impl_Font& );
88 : };
89 :
90 : // - ImplFontMetric -
91 :
92 : class ImplFontMetric
93 : {
94 : friend class ::OutputDevice;
95 :
96 : private:
97 : long mnAscent; // Ascent
98 : long mnDescent; // Descent
99 : long mnIntLeading; // Internal Leading
100 : long mnExtLeading; // External Leading
101 : long mnLineHeight; // Ascent+Descent+EmphasisMark
102 : long mnSlant; // Slant
103 : sal_uInt16 mnMiscFlags; // Misc Flags
104 : sal_uInt32 mnRefCount; // Reference Counter
105 :
106 : enum { DEVICE_FLAG=1, SCALABLE_FLAG=2, LATIN_FLAG=4, CJK_FLAG=8, CTL_FLAG=16 };
107 :
108 : public:
109 : ImplFontMetric();
110 : void AddReference();
111 : void DeReference();
112 :
113 553865 : long GetAscent() const { return mnAscent; }
114 504365 : long GetDescent() const { return mnDescent; }
115 779662 : long GetIntLeading() const { return mnIntLeading; }
116 26734 : long GetExtLeading() const { return mnExtLeading; }
117 0 : long GetLineHeight() const { return mnLineHeight; }
118 0 : long GetSlant() const { return mnSlant; }
119 :
120 : bool IsDeviceFont() const { return ((mnMiscFlags & DEVICE_FLAG) != 0); }
121 319117 : bool IsScalable() const { return ((mnMiscFlags & SCALABLE_FLAG) != 0); }
122 : bool SupportsLatin() const { return ((mnMiscFlags & LATIN_FLAG) != 0); }
123 : bool SupportsCJK() const { return ((mnMiscFlags & CJK_FLAG) != 0); }
124 : bool SupportsCTL() const { return ((mnMiscFlags & CTL_FLAG) != 0); }
125 :
126 : bool operator==( const ImplFontMetric& ) const;
127 : };
128 :
129 : // - ImplFontOptions -
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 37 : ImplFontOptions() :
141 : meEmbeddedBitmap(EMBEDDEDBITMAP_DONTKNOW),
142 : meAntiAlias(ANTIALIAS_DONTKNOW),
143 : meAutoHint(AUTOHINT_DONTKNOW),
144 : meHinting(HINTING_DONTKNOW),
145 37 : meHintStyle(HINT_SLIGHT) {}
146 19 : virtual ~ImplFontOptions() {}
147 :
148 102 : FontAutoHint GetUseAutoHint() const { return meAutoHint; }
149 204 : FontHintStyle GetHintStyle() const { return meHintStyle; }
150 102 : bool DontUseEmbeddedBitmaps() const { return meEmbeddedBitmap == EMBEDDEDBITMAP_FALSE; }
151 102 : bool DontUseAntiAlias() const { return meAntiAlias == ANTIALIAS_FALSE; }
152 102 : bool DontUseHinting() const { return (meHinting == HINTING_FALSE) || (GetHintStyle() == HINT_NONE); }
153 0 : virtual void* GetPattern(void * /*pFace*/, bool /*bEmbolden*/, bool /*bVerticalMetrics*/) const { return NULL; }
154 : };
155 :
156 : // - ImplFontCharMap -
157 :
158 : class CmapResult;
159 :
160 : class VCL_PLUGIN_PUBLIC ImplFontCharMap
161 : {
162 : public:
163 : explicit ImplFontCharMap( const CmapResult& );
164 : virtual ~ImplFontCharMap();
165 :
166 : private:
167 : friend class FontCharMap;
168 : friend void intrusive_ptr_add_ref(ImplFontCharMap* pImplFontCharMap);
169 : friend void intrusive_ptr_release(ImplFontCharMap* pImplFontCharMap);
170 :
171 : ImplFontCharMap( const ImplFontCharMap& ) SAL_DELETED_FUNCTION;
172 : void operator=( const ImplFontCharMap& ) SAL_DELETED_FUNCTION;
173 :
174 : static ImplFontCharMapPtr getDefaultMap( bool bSymbols=false);
175 : bool isDefaultMap() const;
176 :
177 : private:
178 : const sal_uInt32* mpRangeCodes; // pairs of StartCode/(EndCode+1)
179 : const int* mpStartGlyphs; // range-specific mapper to glyphs
180 : const sal_uInt16* mpGlyphIds; // individual glyphid mappings
181 : int mnRangeCount;
182 : int mnCharCount; // covered codepoints
183 : mutable sal_uInt32 mnRefCount;
184 : };
185 :
186 17044 : inline void intrusive_ptr_add_ref(ImplFontCharMap* pImplFontCharMap)
187 : {
188 17044 : ++pImplFontCharMap->mnRefCount;
189 17044 : }
190 :
191 17044 : inline void intrusive_ptr_release(ImplFontCharMap* pImplFontCharMap)
192 : {
193 17044 : if (--pImplFontCharMap->mnRefCount == 0)
194 8522 : delete pImplFontCharMap;
195 17044 : }
196 :
197 : // CmapResult is a normalized version of the many CMAP formats
198 : class VCL_PLUGIN_PUBLIC CmapResult
199 : {
200 : public:
201 : explicit CmapResult( bool bSymbolic = false,
202 : const sal_uInt32* pRangeCodes = NULL, int nRangeCount = 0,
203 : const int* pStartGlyphs = 0, const sal_uInt16* pGlyphIds = NULL );
204 :
205 : const sal_uInt32* mpRangeCodes;
206 : const int* mpStartGlyphs;
207 : const sal_uInt16* mpGlyphIds;
208 : int mnRangeCount;
209 : bool mbSymbolic;
210 : bool mbRecoded;
211 : };
212 :
213 : bool ParseCMAP( const unsigned char* pRawData, int nRawLength, CmapResult& );
214 :
215 : void UpdateAttributesFromPSName( const OUString& rPSName, ImplDevFontAttributes& );
216 :
217 : #endif // INCLUDED_VCL_INC_IMPFONT_HXX
218 :
219 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|