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_METRIC_HXX
21 #define INCLUDED_VCL_METRIC_HXX
23 #include <vcl/dllapi.h>
24 #include <vcl/font.hxx>
25 #include <vcl/outdev.hxx>
27 #include <boost/intrusive_ptr.hpp>
30 class ImplFontCharMap
;
33 typedef sal_uInt32 sal_UCS4
;
34 typedef boost::intrusive_ptr
< ImplFontCharMap
> ImplFontCharMapPtr
;
35 typedef boost::intrusive_ptr
< FontCharMap
> FontCharMapPtr
;
39 // avoid problems where poppler's FontInfo is picked up
40 class VCL_DLLPUBLIC FontInfo
: public vcl::Font
42 friend class ::OutputDevice
;
45 ImplFontMetric
* mpImplMetric
; // Implementation
49 FontInfo( const FontInfo
& );
52 FontType
GetType() const;
54 FontInfo
& operator=( const FontInfo
& );
55 bool operator==( const FontInfo
& ) const;
56 bool operator!=( const FontInfo
& rInfo
) const
57 { return !operator==( rInfo
); }
62 class VCL_DLLPUBLIC FontMetric
: public vcl::FontInfo
66 FontMetric( const FontMetric
& );
69 long GetAscent() const;
70 long GetDescent() const;
71 long GetIntLeading() const;
72 long GetExtLeading() const;
73 long GetLineHeight() const;
74 long GetSlant() const;
75 bool IsFullstopCentered() const;
77 FontMetric
& operator=( const FontMetric
& rMetric
);
78 bool operator==( const FontMetric
& rMetric
) const;
79 bool operator!=( const FontMetric
& rMetric
) const
80 { return !operator==( rMetric
); }
83 template< typename charT
, typename traits
>
84 inline std::basic_ostream
<charT
, traits
> & operator <<(
85 std::basic_ostream
<charT
, traits
> & stream
, const FontMetric
& rMetric
)
88 << "name=" << "\"" << rMetric
.GetName() << "\""
89 << ",size=(" << rMetric
.GetSize().Width() << "," << rMetric
.GetSize().Height() << ")"
90 << ",ascent=" << rMetric
.GetAscent()
91 << ",descent=" << rMetric
.GetDescent()
92 << ",intLeading=" << rMetric
.GetIntLeading()
93 << ",extLeading=" << rMetric
.GetExtLeading()
94 << ",lineHeight=" << rMetric
.GetLineHeight()
95 << ",slant=" << rMetric
.GetSlant()
100 class VCL_DLLPUBLIC FontCharMap
103 /** A new FontCharMap is created based on a "default" map, which includes
104 all codepoints in the Unicode BMP range, including surrogates.
107 FontCharMap( const CmapResult
& rCR
);
110 /** Get the default font character map
112 @returns the default font character map.
114 static FontCharMapPtr
GetDefaultMap( bool bSymbols
=false );
116 /** Determines if the font character map is the "default". The default map
117 includes all codepoints in the Unicode BMP range, including surrogates.
119 @returns true if default map, false if not default map.
121 bool IsDefaultMap() const;
123 /** Does the font character map include the UCS4 character?
125 @returns true if character exists in font character map, false is not.
127 bool HasChar( sal_UCS4
) const;
129 /** Returns the number of chars supported by the font, which
130 are inside the unicode range from cMin to cMax (inclusive).
132 @param cMin Lowest codepoint in range to be counted
133 @param cMax Highest codepoitn in range to be counted
135 @returns number of characters in the font charmap between the two
138 int CountCharsInRange( sal_UCS4 cMin
, sal_UCS4 cMax
) const;
140 /** Get the number of characters in the font character map.
142 @returns number of characters in the font character map.
144 int GetCharCount() const;
146 /** Get the first character in the font character map.
148 @returns first character in the font character map.
150 sal_UCS4
GetFirstChar() const;
152 /** Get the last character in the font character map.
154 @returns last character in the font character map.
156 sal_UCS4
GetLastChar() const;
158 /** Get the next character in the font character map. This is important
159 because character maps (e.g. the default map which holds the characters
160 in the BMP plane) can have discontiguous ranges.
162 @param cChar Character from which to find next character
164 @returns next character in the font character map.
166 sal_UCS4
GetNextChar( sal_UCS4 cChar
) const;
168 /** Get the previous character in the font character map. This is important
169 because character maps (e.g. the default map which holds the characters
170 in the BMP plane) can have discontiguous ranges.
172 @param cChar Character from which to find previous character
174 @returns previous character in the font character map.
176 sal_UCS4
GetPrevChar( sal_UCS4 cChar
) const;
178 /** Get the index of a particular character in the font character map. The
179 index is different from the codepoint, because font character maps can
183 @param cChar Character used to find index number
185 @returns Index of character in font character map.
187 int GetIndexFromChar( sal_UCS4 cChar
) const;
189 /** Get the character at a particular index in the font character map. The
190 index is different from the codepoint, because font character maps can
192 determine the character.
194 @param nCharIndex Index used to find the character
196 @returns Character in font character map.
198 sal_UCS4
GetCharFromIndex( int nCharIndex
) const;
200 int GetGlyphIndex( sal_UCS4
) const;
203 ImplFontCharMapPtr mpImplFontCharMap
;
205 friend class ::OutputDevice
;
206 friend void intrusive_ptr_release(FontCharMap
* pFontCharMap
);
207 friend void intrusive_ptr_add_ref(FontCharMap
* pFontCharMap
);
209 int findRangeIndex( sal_uInt32
) const;
211 FontCharMap( ImplFontCharMapPtr pIFCMap
);
213 sal_uInt32 mnRefCount
;
215 // prevent assignment and copy construction
216 FontCharMap( const FontCharMap
& ) SAL_DELETED_FUNCTION
;
217 void operator=( const FontCharMap
& ) SAL_DELETED_FUNCTION
;
220 inline void intrusive_ptr_add_ref(FontCharMap
* pFontCharMap
)
222 ++pFontCharMap
->mnRefCount
;
225 inline void intrusive_ptr_release(FontCharMap
* pFontCharMap
)
227 if (--pFontCharMap
->mnRefCount
== 0)
231 class VCL_DLLPUBLIC TextRectInfo
233 friend class ::OutputDevice
;
237 sal_uInt16 mnLineCount
;
243 sal_uInt16
GetLineCount() const { return mnLineCount
; }
244 long GetMaxLineWidth() const { return mnMaxWidth
; }
245 bool IsEllipses() const { return mbEllipsis
; }
247 bool operator ==( const TextRectInfo
& rInfo
) const
248 { return ((mnMaxWidth
== rInfo
.mnMaxWidth
) &&
249 (mnLineCount
== rInfo
.mnLineCount
) &&
250 (mbEllipsis
== rInfo
.mbEllipsis
)); }
251 bool operator !=( const TextRectInfo
& rInfo
) const
252 { return !(TextRectInfo::operator==( rInfo
)); }
255 inline TextRectInfo::TextRectInfo()
262 #endif // INCLUDED_VCL_METRIC_HXX
264 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */