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 INCLUDED_VCL_INC_IMPFONT_HXX
21 #define INCLUDED_VCL_INC_IMPFONT_HXX
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>
34 typedef sal_uInt32 FontRefCount
;
40 Impl_Font( const Impl_Font
& );
42 bool operator==( const Impl_Font
& ) const;
44 FontPitch
GetPitch() { if(mePitch
==PITCH_DONTKNOW
) AskConfig(); return mePitch
; }
45 FontFamily
GetFamily() { if(meFamily
==FAMILY_DONTKNOW
) AskConfig(); return meFamily
; }
46 FontItalic
GetItalic() { if(meItalic
==ITALIC_DONTKNOW
) AskConfig(); return meItalic
; }
47 FontWeight
GetWeight() { if(meWeight
==WEIGHT_DONTKNOW
) AskConfig(); return meWeight
; }
48 FontWidth
GetWidthType() { if(meWidthType
==WIDTH_DONTKNOW
)AskConfig(); return meWidthType
; }
54 FontRefCount mnRefCount
;
55 OUString maFamilyName
;
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
;
67 FontWidth meWidthType
;
69 FontUnderline meUnderline
;
70 FontUnderline meOverline
;
71 FontStrikeout meStrikeout
;
73 FontEmphasisMark meEmphasisMark
;
75 FontKerning mnKerning
;
78 mbConfigLookup
:1, // there was a config lookup
81 mbTransparent
:1; // compatibility, now on output device
83 friend SvStream
& ReadImpl_Font( SvStream
& rIStm
, Impl_Font
& );
84 friend SvStream
& WriteImpl_Font( SvStream
& rOStm
, const Impl_Font
& );
91 friend class OutputDevice
;
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
103 enum { DEVICE_FLAG
=1, SCALABLE_FLAG
=2, LATIN_FLAG
=4, CJK_FLAG
=8, CTL_FLAG
=16 };
110 long GetAscent() const { return mnAscent
; }
111 long GetDescent() const { return mnDescent
; }
112 long GetIntLeading() const { return mnIntLeading
; }
113 long GetExtLeading() const { return mnExtLeading
; }
114 long GetLineHeight() const { return mnLineHeight
; }
115 long GetSlant() const { return mnSlant
; }
117 bool IsDeviceFont() const { return ((mnMiscFlags
& DEVICE_FLAG
) != 0); }
118 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); }
123 bool operator==( const ImplFontMetric
& ) const;
126 // - ImplFontOptions -
128 class ImplFontOptions
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
138 meEmbeddedBitmap(EMBEDDEDBITMAP_DONTKNOW
),
139 meAntiAlias(ANTIALIAS_DONTKNOW
),
140 meAutoHint(AUTOHINT_DONTKNOW
),
141 meHinting(HINTING_DONTKNOW
),
142 meHintStyle(HINT_SLIGHT
)
144 virtual ~ImplFontOptions()
146 FontAutoHint
GetUseAutoHint() const
147 { return meAutoHint
; }
148 FontHintStyle
GetHintStyle() const
149 { return meHintStyle
; }
150 bool DontUseEmbeddedBitmaps() const
151 { return meEmbeddedBitmap
== EMBEDDEDBITMAP_FALSE
; }
152 bool DontUseAntiAlias() const
153 { return meAntiAlias
== ANTIALIAS_FALSE
; }
154 bool DontUseHinting() const
155 { return (meHinting
== HINTING_FALSE
) || (GetHintStyle() == HINT_NONE
); }
156 virtual void *GetPattern(void * /*pFace*/, bool /*bEmbolden*/, bool /*bVerticalMetrics*/) const
160 // - ImplFontCharMap -
164 class VCL_PLUGIN_PUBLIC ImplFontCharMap
167 explicit ImplFontCharMap( const CmapResult
& );
168 virtual ~ImplFontCharMap();
170 static ImplFontCharMap
* GetDefaultMap( bool bSymbols
=false);
172 bool IsDefaultMap() const;
173 bool HasChar( sal_uInt32
) const;
174 int CountCharsInRange( sal_uInt32 cMin
, sal_uInt32 cMax
) const;
175 int GetCharCount() const;
177 sal_uInt32
GetFirstChar() const;
178 sal_uInt32
GetLastChar() const;
180 sal_uInt32
GetNextChar( sal_uInt32
) const;
181 sal_uInt32
GetPrevChar( sal_uInt32
) const;
183 int GetIndexFromChar( sal_uInt32
) const;
184 sal_uInt32
GetCharFromIndex( int ) const;
186 void AddReference() const;
187 void DeReference() const;
189 int GetGlyphIndex( sal_uInt32
) const;
192 int ImplFindRangeIndex( sal_uInt32
) const;
194 // prevent assignment and copy construction
195 explicit ImplFontCharMap( const ImplFontCharMap
& );
196 void operator=( const ImplFontCharMap
& );
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
203 int mnCharCount
; // covered codepoints
204 mutable FontRefCount mnRefCount
;
207 // CmapResult is a normalized version of the many CMAP formats
208 class VCL_PLUGIN_PUBLIC CmapResult
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
);
215 const sal_uInt32
* mpRangeCodes
;
216 const int* mpStartGlyphs
;
217 const sal_uInt16
* mpGlyphIds
;
223 bool ParseCMAP( const unsigned char* pRawData
, int nRawLength
, CmapResult
& );
225 void UpdateAttributesFromPSName( const OUString
& rPSName
, ImplDevFontAttributes
& );
227 #endif // INCLUDED_VCL_INC_IMPFONT_HXX
229 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */