1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef _SV_IMPFONT_HXX
30 #define _SV_IMPFONT_HXX
32 #include <tools/gen.hxx>
33 #include <tools/string.hxx>
34 #include <i18npool/lang.h>
35 #include <tools/color.hxx>
36 #include <vcl/dllapi.h>
37 #include <vcl/vclenum.hxx>
38 #include <vcl/fntstyle.hxx>
48 Impl_Font( const Impl_Font
& );
50 bool operator==( const Impl_Font
& ) const;
52 FontPitch
GetPitch() { if(mePitch
==PITCH_DONTKNOW
) AskConfig(); return mePitch
; }
53 FontFamily
GetFamily() { if(meFamily
==FAMILY_DONTKNOW
) AskConfig(); return meFamily
; }
54 FontItalic
GetItalic() { if(meItalic
==ITALIC_DONTKNOW
) AskConfig(); return meItalic
; }
55 FontWeight
GetWeight() { if(meWeight
==WEIGHT_DONTKNOW
) AskConfig(); return meWeight
; }
56 FontWidth
GetWidthType() { if(meWidthType
==WIDTH_DONTKNOW
)AskConfig(); return meWidthType
; }
66 Color maColor
; // compatibility, now on output device
67 Color maFillColor
; // compatibility, now on output device
68 rtl_TextEncoding meCharSet
;
69 LanguageType meLanguage
;
70 LanguageType meCJKLanguage
;
75 FontWidth meWidthType
;
77 FontUnderline meUnderline
;
78 FontUnderline meOverline
;
79 FontStrikeout meStrikeout
;
81 FontEmphasisMark meEmphasisMark
;
82 FontType meType
; // used by metrics only
84 FontKerning mnKerning
;
85 sal_Bool mbWordLine
:1,
87 mbConfigLookup
:1, // there was a config lookup
90 mbTransparent
:1; // compatibility, now on output device
92 friend SvStream
& operator>>( SvStream
& rIStm
, Impl_Font
& );
93 friend SvStream
& operator<<( SvStream
& rOStm
, const Impl_Font
& );
102 friend class OutputDevice
;
105 long mnAscent
; // Ascent
106 long mnDescent
; // Descent
107 long mnIntLeading
; // Internal Leading
108 long mnExtLeading
; // External Leading
109 long mnLineHeight
; // Ascent+Descent+EmphasisMark
110 long mnSlant
; // Slant
111 sal_uInt16 mnMiscFlags
; // Misc Flags
112 sal_uInt32 mnRefCount
; // Reference Counter
114 enum { DEVICE_FLAG
=1, SCALABLE_FLAG
=2, LATIN_FLAG
=4, CJK_FLAG
=8, CTL_FLAG
=16 };
121 long GetAscent() const { return mnAscent
; }
122 long GetDescent() const { return mnDescent
; }
123 long GetIntLeading() const { return mnIntLeading
; }
124 long GetExtLeading() const { return mnExtLeading
; }
125 long GetLineHeight() const { return mnLineHeight
; }
126 long GetSlant() const { return mnSlant
; }
128 bool IsDeviceFont() const { return ((mnMiscFlags
& DEVICE_FLAG
) != 0); }
129 bool IsScalable() const { return ((mnMiscFlags
& SCALABLE_FLAG
) != 0); }
130 bool SupportsLatin() const { return ((mnMiscFlags
& LATIN_FLAG
) != 0); }
131 bool SupportsCJK() const { return ((mnMiscFlags
& CJK_FLAG
) != 0); }
132 bool SupportsCTL() const { return ((mnMiscFlags
& CTL_FLAG
) != 0); }
134 bool operator==( const ImplFontMetric
& ) const;
137 // ------------------
138 // - ImplFontOptions -
139 // ------------------
141 class ImplFontOptions
144 FontEmbeddedBitmap meEmbeddedBitmap
; // whether the embedded bitmaps should be used
145 FontAntiAlias meAntiAlias
; // whether the font should be antialiased
146 FontAutoHint meAutoHint
; // whether the font should be autohinted
147 FontHinting meHinting
; // whether the font should be hinted
148 FontHintStyle meHintStyle
; // type of font hinting to be used
151 meEmbeddedBitmap(EMBEDDEDBITMAP_DONTKNOW
),
152 meAntiAlias(ANTIALIAS_DONTKNOW
),
153 meAutoHint(AUTOHINT_DONTKNOW
),
154 meHinting(HINTING_DONTKNOW
),
155 meHintStyle(HINT_SLIGHT
)
157 virtual ~ImplFontOptions()
159 FontAutoHint
GetUseAutoHint() const
160 { return meAutoHint
; }
161 FontHintStyle
GetHintStyle() const
162 { return meHintStyle
; }
163 bool DontUseEmbeddedBitmaps() const
164 { return meEmbeddedBitmap
== EMBEDDEDBITMAP_FALSE
; }
165 bool DontUseAntiAlias() const
166 { return meAntiAlias
== ANTIALIAS_FALSE
; }
167 bool DontUseHinting() const
168 { return (meHinting
== HINTING_FALSE
) || (GetHintStyle() == HINT_NONE
); }
169 virtual void *GetPattern(void * /*pFace*/, bool /*bEmbolden*/, bool /*bVerticalMetrics*/) const
173 // -------------------
174 // - ImplFontCharMap -
175 // -------------------
179 class VCL_PLUGIN_PUBLIC ImplFontCharMap
182 explicit ImplFontCharMap( const CmapResult
& );
183 virtual ~ImplFontCharMap();
185 static ImplFontCharMap
* GetDefaultMap( bool bSymbols
=false);
187 bool IsDefaultMap() const;
188 bool HasChar( sal_uInt32
) const;
189 int CountCharsInRange( sal_uInt32 cMin
, sal_uInt32 cMax
) const;
190 int GetCharCount() const;
192 sal_uInt32
GetFirstChar() const;
193 sal_uInt32
GetLastChar() const;
195 sal_uInt32
GetNextChar( sal_uInt32
) const;
196 sal_uInt32
GetPrevChar( sal_uInt32
) const;
198 int GetIndexFromChar( sal_uInt32
) const;
199 sal_uInt32
GetCharFromIndex( int ) const;
201 void AddReference() const;
202 void DeReference() const;
204 int GetGlyphIndex( sal_uInt32
) const;
207 int ImplFindRangeIndex( sal_uInt32
) const;
209 // prevent assignment and copy construction
210 explicit ImplFontCharMap( const ImplFontCharMap
& );
211 void operator=( const ImplFontCharMap
& );
214 const sal_uInt32
* mpRangeCodes
; // pairs of StartCode/(EndCode+1)
215 const int* mpStartGlyphs
; // range-specific mapper to glyphs
216 const sal_uInt16
* mpGlyphIds
; // individual glyphid mappings
218 int mnCharCount
; // covered codepoints
219 mutable int mnRefCount
;
222 // CmapResult is a normalized version of the many CMAP formats
223 class VCL_PLUGIN_PUBLIC CmapResult
226 explicit CmapResult( bool bSymbolic
= false,
227 const sal_uInt32
* pRangeCodes
= NULL
, int nRangeCount
= 0,
228 const int* pStartGlyphs
= 0, const sal_uInt16
* pGlyphIds
= NULL
);
230 const sal_uInt32
* mpRangeCodes
;
231 const int* mpStartGlyphs
;
232 const sal_uInt16
* mpGlyphIds
;
238 bool ParseCMAP( const unsigned char* pRawData
, int nRawLength
, CmapResult
& );
240 #endif // _SV_IMPFONT_HXX
242 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */