1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef _SV_IMPFONT_HXX
21 #define _SV_IMPFONT_HXX
23 #include <tools/gen.hxx>
24 #include <tools/string.hxx>
25 #include <i18nlangtag/lang.h>
26 #include <tools/color.hxx>
27 #include <vcl/dllapi.h>
28 #include <vcl/vclenum.hxx>
29 #include <vcl/fntstyle.hxx>
30 #include <outfont.hxx>
36 typedef sal_uInt32 FontRefCount
;
42 Impl_Font( const Impl_Font
& );
44 bool operator==( const Impl_Font
& ) const;
46 FontPitch
GetPitch() { if(mePitch
==PITCH_DONTKNOW
) AskConfig(); return mePitch
; }
47 FontFamily
GetFamily() { if(meFamily
==FAMILY_DONTKNOW
) AskConfig(); return meFamily
; }
48 FontItalic
GetItalic() { if(meItalic
==ITALIC_DONTKNOW
) AskConfig(); return meItalic
; }
49 FontWeight
GetWeight() { if(meWeight
==WEIGHT_DONTKNOW
) AskConfig(); return meWeight
; }
50 FontWidth
GetWidthType() { if(meWidthType
==WIDTH_DONTKNOW
)AskConfig(); return meWidthType
; }
56 FontRefCount mnRefCount
;
60 Color maColor
; // compatibility, now on output device
61 Color maFillColor
; // compatibility, now on output device
62 rtl_TextEncoding meCharSet
;
63 LanguageType meLanguage
;
64 LanguageType meCJKLanguage
;
69 FontWidth meWidthType
;
71 FontUnderline meUnderline
;
72 FontUnderline meOverline
;
73 FontStrikeout meStrikeout
;
75 FontEmphasisMark meEmphasisMark
;
77 FontKerning mnKerning
;
78 sal_Bool mbWordLine
:1,
80 mbConfigLookup
:1, // there was a config lookup
83 mbTransparent
:1; // compatibility, now on output device
85 friend SvStream
& operator>>( SvStream
& rIStm
, Impl_Font
& );
86 friend SvStream
& operator<<( SvStream
& rOStm
, const Impl_Font
& );
95 friend class OutputDevice
;
98 long mnAscent
; // Ascent
99 long mnDescent
; // Descent
100 long mnIntLeading
; // Internal Leading
101 long mnExtLeading
; // External Leading
102 long mnLineHeight
; // Ascent+Descent+EmphasisMark
103 long mnSlant
; // Slant
104 sal_uInt16 mnMiscFlags
; // Misc Flags
105 FontRefCount mnRefCount
; // Reference Counter
107 enum { DEVICE_FLAG
=1, SCALABLE_FLAG
=2, LATIN_FLAG
=4, CJK_FLAG
=8, CTL_FLAG
=16 };
114 long GetAscent() const { return mnAscent
; }
115 long GetDescent() const { return mnDescent
; }
116 long GetIntLeading() const { return mnIntLeading
; }
117 long GetExtLeading() const { return mnExtLeading
; }
118 long GetLineHeight() const { return mnLineHeight
; }
119 long GetSlant() const { return mnSlant
; }
121 bool IsDeviceFont() const { return ((mnMiscFlags
& DEVICE_FLAG
) != 0); }
122 bool IsScalable() const { return ((mnMiscFlags
& SCALABLE_FLAG
) != 0); }
123 bool SupportsLatin() const { return ((mnMiscFlags
& LATIN_FLAG
) != 0); }
124 bool SupportsCJK() const { return ((mnMiscFlags
& CJK_FLAG
) != 0); }
125 bool SupportsCTL() const { return ((mnMiscFlags
& CTL_FLAG
) != 0); }
127 bool operator==( const ImplFontMetric
& ) const;
130 // ------------------
131 // - ImplFontOptions -
132 // ------------------
134 class ImplFontOptions
137 FontEmbeddedBitmap meEmbeddedBitmap
; // whether the embedded bitmaps should be used
138 FontAntiAlias meAntiAlias
; // whether the font should be antialiased
139 FontAutoHint meAutoHint
; // whether the font should be autohinted
140 FontHinting meHinting
; // whether the font should be hinted
141 FontHintStyle meHintStyle
; // type of font hinting to be used
144 meEmbeddedBitmap(EMBEDDEDBITMAP_DONTKNOW
),
145 meAntiAlias(ANTIALIAS_DONTKNOW
),
146 meAutoHint(AUTOHINT_DONTKNOW
),
147 meHinting(HINTING_DONTKNOW
),
148 meHintStyle(HINT_SLIGHT
)
150 virtual ~ImplFontOptions()
152 FontAutoHint
GetUseAutoHint() const
153 { return meAutoHint
; }
154 FontHintStyle
GetHintStyle() const
155 { return meHintStyle
; }
156 bool DontUseEmbeddedBitmaps() const
157 { return meEmbeddedBitmap
== EMBEDDEDBITMAP_FALSE
; }
158 bool DontUseAntiAlias() const
159 { return meAntiAlias
== ANTIALIAS_FALSE
; }
160 bool DontUseHinting() const
161 { return (meHinting
== HINTING_FALSE
) || (GetHintStyle() == HINT_NONE
); }
162 virtual void *GetPattern(void * /*pFace*/, bool /*bEmbolden*/, bool /*bVerticalMetrics*/) const
166 // -------------------
167 // - ImplFontCharMap -
168 // -------------------
172 class VCL_PLUGIN_PUBLIC ImplFontCharMap
175 explicit ImplFontCharMap( const CmapResult
& );
176 virtual ~ImplFontCharMap();
178 static ImplFontCharMap
* GetDefaultMap( bool bSymbols
=false);
180 bool IsDefaultMap() const;
181 bool HasChar( sal_uInt32
) const;
182 int CountCharsInRange( sal_uInt32 cMin
, sal_uInt32 cMax
) const;
183 int GetCharCount() const;
185 sal_uInt32
GetFirstChar() const;
186 sal_uInt32
GetLastChar() const;
188 sal_uInt32
GetNextChar( sal_uInt32
) const;
189 sal_uInt32
GetPrevChar( sal_uInt32
) const;
191 int GetIndexFromChar( sal_uInt32
) const;
192 sal_uInt32
GetCharFromIndex( int ) const;
194 void AddReference() const;
195 void DeReference() const;
197 int GetGlyphIndex( sal_uInt32
) const;
200 int ImplFindRangeIndex( sal_uInt32
) const;
202 // prevent assignment and copy construction
203 explicit ImplFontCharMap( const ImplFontCharMap
& );
204 void operator=( const ImplFontCharMap
& );
207 const sal_uInt32
* mpRangeCodes
; // pairs of StartCode/(EndCode+1)
208 const int* mpStartGlyphs
; // range-specific mapper to glyphs
209 const sal_uInt16
* mpGlyphIds
; // individual glyphid mappings
211 int mnCharCount
; // covered codepoints
212 mutable FontRefCount mnRefCount
;
215 // CmapResult is a normalized version of the many CMAP formats
216 class VCL_PLUGIN_PUBLIC CmapResult
219 explicit CmapResult( bool bSymbolic
= false,
220 const sal_uInt32
* pRangeCodes
= NULL
, int nRangeCount
= 0,
221 const int* pStartGlyphs
= 0, const sal_uInt16
* pGlyphIds
= NULL
);
223 const sal_uInt32
* mpRangeCodes
;
224 const int* mpStartGlyphs
;
225 const sal_uInt16
* mpGlyphIds
;
231 bool ParseCMAP( const unsigned char* pRawData
, int nRawLength
, CmapResult
& );
233 void UpdateAttributesFromPSName( const String
& rPSName
, ImplDevFontAttributes
& );
235 #endif // _SV_IMPFONT_HXX
237 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */