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_FONTCHARMAP_HXX
21 #define INCLUDED_FONTCHARMAP_HXX
23 #include <vcl/dllapi.h>
24 #include <vcl/font.hxx>
25 #include <vcl/outdev.hxx>
27 class ImplFontCharMap
;
30 typedef sal_uInt32 sal_UCS4
;
31 typedef tools::SvRef
<ImplFontCharMap
> ImplFontCharMapRef
;
32 typedef tools::SvRef
<FontCharMap
> FontCharMapRef
;
34 class VCL_DLLPUBLIC FontCharMap
: public SvRefBase
37 /** A new FontCharMap is created based on a "default" map, which includes
38 all codepoints in the Unicode BMP range, including surrogates.
41 FontCharMap( const CmapResult
& rCR
);
42 virtual ~FontCharMap() override
;
44 /** Get the default font character map
46 @returns the default font character map.
48 static FontCharMapRef
GetDefaultMap( bool bSymbols
);
50 /** Determines if the font character map is the "default". The default map
51 includes all codepoints in the Unicode BMP range, including surrogates.
53 @returns true if default map, false if not default map.
55 bool IsDefaultMap() const;
57 /** Does the font character map include the UCS4 character?
59 @returns true if character exists in font character map, false is not.
61 bool HasChar( sal_UCS4
) const;
63 /** Returns the number of chars supported by the font, which
64 are inside the unicode range from cMin to cMax (inclusive).
66 @param cMin Lowest codepoint in range to be counted
67 @param cMax Highest codepoint in range to be counted
69 @returns number of characters in the font charmap between the two
72 int CountCharsInRange( sal_UCS4 cMin
, sal_UCS4 cMax
) const;
74 /** Get the number of characters in the font character map.
76 @returns number of characters in the font character map.
78 int GetCharCount() const;
80 /** Get the first character in the font character map.
82 @returns first character in the font character map.
84 sal_UCS4
GetFirstChar() const;
86 /** Get the last character in the font character map.
88 @returns last character in the font character map.
90 sal_UCS4
GetLastChar() const;
92 /** Get the next character in the font character map. This is important
93 because character maps (e.g. the default map which holds the characters
94 in the BMP plane) can have discontiguous ranges.
96 @param cChar Character from which to find next character
98 @returns next character in the font character map.
100 sal_UCS4
GetNextChar( sal_UCS4 cChar
) const;
102 /** Get the previous character in the font character map. This is important
103 because character maps (e.g. the default map which holds the characters
104 in the BMP plane) can have discontiguous ranges.
106 @param cChar Character from which to find previous character
108 @returns previous character in the font character map.
110 sal_UCS4
GetPrevChar( sal_UCS4 cChar
) const;
112 /** Get the index of a particular character in the font character map. The
113 index is different from the codepoint, because font character maps can
117 @param cChar Character used to find index number
119 @returns Index of character in font character map.
121 int GetIndexFromChar( sal_UCS4 cChar
) const;
123 /** Get the character at a particular index in the font character map. The
124 index is different from the codepoint, because font character maps can
126 determine the character.
128 @param nCharIndex Index used to find the character
130 @returns Character in font character map.
132 sal_UCS4
GetCharFromIndex( int nCharIndex
) const;
134 int GetGlyphIndex( sal_UCS4
) const;
137 ImplFontCharMapRef mpImplFontCharMap
;
139 friend class ::OutputDevice
;
141 int findRangeIndex( sal_uInt32
) const;
143 FontCharMap( ImplFontCharMapRef
const & pIFCMap
);
145 // prevent assignment and copy construction
146 FontCharMap( const FontCharMap
& ) = delete;
147 void operator=( const FontCharMap
& ) = delete;
150 // CmapResult is a normalized version of the many CMAP formats
151 class VCL_PLUGIN_PUBLIC CmapResult
154 explicit CmapResult( bool bSymbolic
= false,
155 const sal_uInt32
* pRangeCodes
= nullptr, int nRangeCount
= 0 );
157 const sal_uInt32
* mpRangeCodes
;
158 const int* mpStartGlyphs
;
159 const sal_uInt16
* mpGlyphIds
;
165 #endif // INCLUDED_FONTCHARMAP_HXX
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */