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 9038446 : 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 105896 : FontPitch GetPitch() { if(mePitch==PITCH_DONTKNOW) AskConfig(); return mePitch; }
48 85548 : FontFamily GetFamily() { if(meFamily==FAMILY_DONTKNOW) AskConfig(); return meFamily; }
49 8417477 : FontItalic GetItalic() { if(meItalic==ITALIC_DONTKNOW) AskConfig(); return meItalic; }
50 1652947 : FontWeight GetWeight() { if(meWeight==WEIGHT_DONTKNOW) AskConfig(); return meWeight; }
51 6929 : 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 534054 : long GetAscent() const { return mnAscent; }
114 447225 : long GetDescent() const { return mnDescent; }
115 733821 : long GetIntLeading() const { return mnIntLeading; }
116 47949 : 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 327828 : 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 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 : virtual ~ImplFontOptions() {}
147 :
148 0 : FontAutoHint GetUseAutoHint() const { return meAutoHint; }
149 0 : FontHintStyle GetHintStyle() const { return meHintStyle; }
150 0 : bool DontUseEmbeddedBitmaps() const { return meEmbeddedBitmap == EMBEDDEDBITMAP_FALSE; }
151 0 : bool DontUseAntiAlias() const { return meAntiAlias == ANTIALIAS_FALSE; }
152 0 : 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 : // prevent assignment and copy construction
172 : explicit ImplFontCharMap( const ImplFontCharMap& );
173 : void operator=( const ImplFontCharMap& );
174 :
175 : static ImplFontCharMapPtr getDefaultMap( bool bSymbols=false);
176 : bool isDefaultMap() const;
177 :
178 : private:
179 : const sal_uInt32* mpRangeCodes; // pairs of StartCode/(EndCode+1)
180 : const int* mpStartGlyphs; // range-specific mapper to glyphs
181 : const sal_uInt16* mpGlyphIds; // individual glyphid mappings
182 : int mnRangeCount;
183 : int mnCharCount; // covered codepoints
184 : mutable sal_uInt32 mnRefCount;
185 : };
186 :
187 22980 : inline void intrusive_ptr_add_ref(ImplFontCharMap* pImplFontCharMap)
188 : {
189 22980 : ++pImplFontCharMap->mnRefCount;
190 22980 : }
191 :
192 22980 : inline void intrusive_ptr_release(ImplFontCharMap* pImplFontCharMap)
193 : {
194 22980 : if (--pImplFontCharMap->mnRefCount == 0)
195 11490 : delete pImplFontCharMap;
196 22980 : }
197 :
198 : // CmapResult is a normalized version of the many CMAP formats
199 : class VCL_PLUGIN_PUBLIC CmapResult
200 : {
201 : public:
202 : explicit CmapResult( bool bSymbolic = false,
203 : const sal_uInt32* pRangeCodes = NULL, int nRangeCount = 0,
204 : const int* pStartGlyphs = 0, const sal_uInt16* pGlyphIds = NULL );
205 :
206 : const sal_uInt32* mpRangeCodes;
207 : const int* mpStartGlyphs;
208 : const sal_uInt16* mpGlyphIds;
209 : int mnRangeCount;
210 : bool mbSymbolic;
211 : bool mbRecoded;
212 : };
213 :
214 : bool ParseCMAP( const unsigned char* pRawData, int nRawLength, CmapResult& );
215 :
216 : void UpdateAttributesFromPSName( const OUString& rPSName, ImplDevFontAttributes& );
217 :
218 : #endif // INCLUDED_VCL_INC_IMPFONT_HXX
219 :
220 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|