xref: /aoo42x/main/vcl/inc/impfont.hxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _SV_IMPFONT_HXX
29*cdf0e10cSrcweir #define _SV_IMPFONT_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <tools/gen.hxx>
32*cdf0e10cSrcweir #include <tools/string.hxx>
33*cdf0e10cSrcweir #include <i18npool/lang.h>
34*cdf0e10cSrcweir #include <tools/color.hxx>
35*cdf0e10cSrcweir #include <vcl/dllapi.h>
36*cdf0e10cSrcweir #include <vcl/vclenum.hxx>
37*cdf0e10cSrcweir #include <vcl/fntstyle.hxx>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir // ------------
40*cdf0e10cSrcweir // - Impl_Font -
41*cdf0e10cSrcweir // ------------
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir class Impl_Font
44*cdf0e10cSrcweir {
45*cdf0e10cSrcweir public:
46*cdf0e10cSrcweir              Impl_Font();
47*cdf0e10cSrcweir              Impl_Font( const Impl_Font& );
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir     bool     operator==( const Impl_Font& ) const;
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir     FontPitch           GetPitch()      { if(mePitch==PITCH_DONTKNOW)    AskConfig(); return mePitch; }
52*cdf0e10cSrcweir     FontFamily          GetFamily()     { if(meFamily==FAMILY_DONTKNOW)  AskConfig(); return meFamily; }
53*cdf0e10cSrcweir     FontItalic          GetItalic()     { if(meItalic==ITALIC_DONTKNOW)  AskConfig(); return meItalic; }
54*cdf0e10cSrcweir     FontWeight          GetWeight()     { if(meWeight==WEIGHT_DONTKNOW)  AskConfig(); return meWeight; }
55*cdf0e10cSrcweir     FontWidth           GetWidthType()  { if(meWidthType==WIDTH_DONTKNOW)AskConfig(); return meWidthType; }
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir private:
58*cdf0e10cSrcweir     friend class Font;
59*cdf0e10cSrcweir     void                AskConfig();
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir 	int					mnRefCount;
62*cdf0e10cSrcweir 	String				maFamilyName;
63*cdf0e10cSrcweir 	String				maStyleName;
64*cdf0e10cSrcweir 	Size				maSize;
65*cdf0e10cSrcweir 	Color				maColor;		// compatibility, now on output device
66*cdf0e10cSrcweir 	Color				maFillColor;	// compatibility, now on output device
67*cdf0e10cSrcweir 	rtl_TextEncoding	meCharSet;
68*cdf0e10cSrcweir 	LanguageType		meLanguage;
69*cdf0e10cSrcweir 	LanguageType		meCJKLanguage;
70*cdf0e10cSrcweir 	FontFamily			meFamily;
71*cdf0e10cSrcweir 	FontPitch			mePitch;
72*cdf0e10cSrcweir 	TextAlign			meAlign;
73*cdf0e10cSrcweir 	FontWeight			meWeight;
74*cdf0e10cSrcweir 	FontWidth			meWidthType;
75*cdf0e10cSrcweir 	FontItalic			meItalic;
76*cdf0e10cSrcweir 	FontUnderline		meUnderline;
77*cdf0e10cSrcweir 	FontUnderline		meOverline;
78*cdf0e10cSrcweir 	FontStrikeout		meStrikeout;
79*cdf0e10cSrcweir 	FontRelief			meRelief;
80*cdf0e10cSrcweir 	FontEmphasisMark	meEmphasisMark;
81*cdf0e10cSrcweir 	FontType			meType;			// used by metrics only
82*cdf0e10cSrcweir 	short				mnOrientation;
83*cdf0e10cSrcweir 	FontKerning 		mnKerning;
84*cdf0e10cSrcweir 	sal_Bool				mbWordLine:1,
85*cdf0e10cSrcweir                         mbOutline:1,
86*cdf0e10cSrcweir                         mbConfigLookup:1,   // there was a config lookup
87*cdf0e10cSrcweir 						mbShadow:1,
88*cdf0e10cSrcweir 						mbVertical:1,
89*cdf0e10cSrcweir 						mbTransparent:1;	// compatibility, now on output device
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir 	friend SvStream&	operator>>( SvStream& rIStm, Impl_Font& );
92*cdf0e10cSrcweir 	friend SvStream&	operator<<( SvStream& rOStm, const Impl_Font& );
93*cdf0e10cSrcweir };
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir // ------------------
96*cdf0e10cSrcweir // - ImplFontMetric -
97*cdf0e10cSrcweir // ------------------
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir class ImplFontMetric
100*cdf0e10cSrcweir {
101*cdf0e10cSrcweir     friend class OutputDevice;
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir private:
104*cdf0e10cSrcweir     long    mnAscent;      // Ascent
105*cdf0e10cSrcweir     long    mnDescent;     // Descent
106*cdf0e10cSrcweir     long    mnIntLeading;  // Internal Leading
107*cdf0e10cSrcweir     long    mnExtLeading;  // External Leading
108*cdf0e10cSrcweir     long    mnLineHeight;  // Ascent+Descent+EmphasisMark
109*cdf0e10cSrcweir     long    mnSlant;       // Slant
110*cdf0e10cSrcweir     sal_uInt16  mnMiscFlags;   // Misc Flags
111*cdf0e10cSrcweir     sal_uInt32  mnRefCount;    // Reference Counter
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir     enum { DEVICE_FLAG=1, SCALABLE_FLAG=2, LATIN_FLAG=4, CJK_FLAG=8, CTL_FLAG=16 };
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir public:
116*cdf0e10cSrcweir             ImplFontMetric();
117*cdf0e10cSrcweir     void    AddReference();
118*cdf0e10cSrcweir     void    DeReference();
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir     long    GetAscent() const       { return mnAscent; }
121*cdf0e10cSrcweir     long    GetDescent() const      { return mnDescent; }
122*cdf0e10cSrcweir     long    GetIntLeading() const   { return mnIntLeading; }
123*cdf0e10cSrcweir     long    GetExtLeading() const   { return mnExtLeading; }
124*cdf0e10cSrcweir     long    GetLineHeight() const   { return mnLineHeight; }
125*cdf0e10cSrcweir     long    GetSlant() const        { return mnSlant; }
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir     bool    IsDeviceFont() const    { return ((mnMiscFlags & DEVICE_FLAG) != 0); }
128*cdf0e10cSrcweir     bool    IsScalable() const      { return ((mnMiscFlags & SCALABLE_FLAG) != 0); }
129*cdf0e10cSrcweir     bool    SupportsLatin() const   { return ((mnMiscFlags & LATIN_FLAG) != 0); }
130*cdf0e10cSrcweir     bool    SupportsCJK() const     { return ((mnMiscFlags & CJK_FLAG) != 0); }
131*cdf0e10cSrcweir     bool    SupportsCTL() const     { return ((mnMiscFlags & CTL_FLAG) != 0); }
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir     bool    operator==( const ImplFontMetric& ) const;
134*cdf0e10cSrcweir };
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir // ------------------
137*cdf0e10cSrcweir // - ImplFontHints -
138*cdf0e10cSrcweir // ------------------
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir class ImplFontOptions
141*cdf0e10cSrcweir {
142*cdf0e10cSrcweir public:
143*cdf0e10cSrcweir     FontEmbeddedBitmap meEmbeddedBitmap; // whether the embedded bitmaps should be used
144*cdf0e10cSrcweir     FontAntiAlias      meAntiAlias;      // whether the font should be antialiased
145*cdf0e10cSrcweir     FontAutoHint       meAutoHint;       // whether the font should be autohinted
146*cdf0e10cSrcweir     FontHinting        meHinting;        // whether the font should be hinted
147*cdf0e10cSrcweir     FontHintStyle      meHintStyle;      // type of font hinting to be used
148*cdf0e10cSrcweir public:
149*cdf0e10cSrcweir     ImplFontOptions() :
150*cdf0e10cSrcweir         meEmbeddedBitmap(EMBEDDEDBITMAP_DONTKNOW),
151*cdf0e10cSrcweir         meAntiAlias(ANTIALIAS_DONTKNOW),
152*cdf0e10cSrcweir         meAutoHint(AUTOHINT_DONTKNOW),
153*cdf0e10cSrcweir         meHinting(HINTING_DONTKNOW),
154*cdf0e10cSrcweir         meHintStyle(HINT_SLIGHT)
155*cdf0e10cSrcweir     {}
156*cdf0e10cSrcweir     ImplFontOptions( FontEmbeddedBitmap eEmbeddedBitmap, FontAntiAlias eAntiAlias,
157*cdf0e10cSrcweir         FontAutoHint eAutoHint, FontHinting eHinting, FontHintStyle eHintStyle) :
158*cdf0e10cSrcweir         meEmbeddedBitmap(eEmbeddedBitmap),
159*cdf0e10cSrcweir         meAntiAlias(eAntiAlias),
160*cdf0e10cSrcweir         meAutoHint(eAutoHint),
161*cdf0e10cSrcweir         meHinting(eHinting),
162*cdf0e10cSrcweir         meHintStyle(eHintStyle)
163*cdf0e10cSrcweir     {}
164*cdf0e10cSrcweir     FontAutoHint GetUseAutoHint() const { return meAutoHint; }
165*cdf0e10cSrcweir     FontHintStyle GetHintStyle() const { return meHintStyle; }
166*cdf0e10cSrcweir     bool DontUseEmbeddedBitmaps() const { return meEmbeddedBitmap == EMBEDDEDBITMAP_FALSE; }
167*cdf0e10cSrcweir     bool DontUseAntiAlias() const { return meAntiAlias == ANTIALIAS_FALSE; }
168*cdf0e10cSrcweir     bool DontUseHinting() const { return (meHinting == HINTING_FALSE) || (GetHintStyle() == HINT_NONE); }
169*cdf0e10cSrcweir };
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir // -------------------
172*cdf0e10cSrcweir // - ImplFontCharMap -
173*cdf0e10cSrcweir // -------------------
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir class CmapResult;
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir class VCL_PLUGIN_PUBLIC ImplFontCharMap
178*cdf0e10cSrcweir {
179*cdf0e10cSrcweir public:
180*cdf0e10cSrcweir     explicit             ImplFontCharMap( const CmapResult& );
181*cdf0e10cSrcweir     virtual              ~ImplFontCharMap();
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir 	static ImplFontCharMap* GetDefaultMap( bool bSymbols=false);
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir     bool                IsDefaultMap() const;
186*cdf0e10cSrcweir     bool                HasChar( sal_uInt32 ) const;
187*cdf0e10cSrcweir     int                 CountCharsInRange( sal_uInt32 cMin, sal_uInt32 cMax ) const;
188*cdf0e10cSrcweir     int                 GetCharCount() const;
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir     sal_uInt32          GetFirstChar() const;
191*cdf0e10cSrcweir     sal_uInt32          GetLastChar() const;
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir     sal_uInt32          GetNextChar( sal_uInt32 ) const;
194*cdf0e10cSrcweir     sal_uInt32          GetPrevChar( sal_uInt32 ) const;
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir     int                 GetIndexFromChar( sal_uInt32 ) const;
197*cdf0e10cSrcweir     sal_uInt32          GetCharFromIndex( int ) const;
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir     void                AddReference() const;
200*cdf0e10cSrcweir     void                DeReference() const;
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir     int                 GetGlyphIndex( sal_uInt32 ) const;
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir private:
205*cdf0e10cSrcweir     int                 ImplFindRangeIndex( sal_uInt32 ) const;
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir     // prevent assignment and copy construction
208*cdf0e10cSrcweir     explicit            ImplFontCharMap( const ImplFontCharMap& );
209*cdf0e10cSrcweir     void                operator=( const ImplFontCharMap& );
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir private:
212*cdf0e10cSrcweir     const sal_uInt32*   mpRangeCodes;     // pairs of StartCode/(EndCode+1)
213*cdf0e10cSrcweir     const int*          mpStartGlyphs;    // range-specific mapper to glyphs
214*cdf0e10cSrcweir     const sal_uInt16*       mpGlyphIds;       // individual glyphid mappings
215*cdf0e10cSrcweir     int                 mnRangeCount;
216*cdf0e10cSrcweir     int                 mnCharCount;      // covered codepoints
217*cdf0e10cSrcweir     mutable int         mnRefCount;
218*cdf0e10cSrcweir };
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir // CmapResult is a normalized version of the many CMAP formats
221*cdf0e10cSrcweir class VCL_PLUGIN_PUBLIC CmapResult
222*cdf0e10cSrcweir {
223*cdf0e10cSrcweir public:
224*cdf0e10cSrcweir 	explicit	CmapResult( bool bSymbolic = false,
225*cdf0e10cSrcweir 					const sal_uInt32* pRangeCodes = NULL, int nRangeCount = 0,
226*cdf0e10cSrcweir 					const int* pStartGlyphs = 0, const sal_uInt16* pGlyphIds = NULL );
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir 	const sal_uInt32* mpRangeCodes;
229*cdf0e10cSrcweir 	const int*        mpStartGlyphs;
230*cdf0e10cSrcweir 	const sal_uInt16*     mpGlyphIds;
231*cdf0e10cSrcweir 	int			      mnRangeCount;
232*cdf0e10cSrcweir 	bool		      mbSymbolic;
233*cdf0e10cSrcweir 	bool			  mbRecoded;
234*cdf0e10cSrcweir };
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir bool ParseCMAP( const unsigned char* pRawData, int nRawLength, CmapResult& );
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir #endif // _SV_IMPFONT_HXX
239*cdf0e10cSrcweir 
240