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