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/vclenum.hxx>
25 #include <tools/ref.hxx>
28 class ImplFontCharMap
;
32 typedef tools::SvRef
<ImplFontCharMap
> ImplFontCharMapRef
;
33 typedef tools::SvRef
<FontCharMap
> FontCharMapRef
;
35 class VCL_DLLPUBLIC FontCharMap final
: public SvRefBase
38 /** A new FontCharMap is created based on a "default" map, which includes
39 all codepoints in the Unicode BMP range, including surrogates.
43 /** A new FontCharMap is created based on passed arguments.
45 FontCharMap(bool bMicrosoftSymbolMap
, std::vector
<sal_UCS4
> aRangeCodes
);
47 virtual ~FontCharMap() override
;
49 /** Get the default font character map
51 @returns the default font character map.
53 static FontCharMapRef
GetDefaultMap(bool bMicrosoftSymbolMap
);
55 /** Determines if the font character map is the "default". The default map
56 includes all codepoints in the Unicode BMP range, including surrogates.
58 @returns true if default map, false if not default map.
60 bool IsDefaultMap() const;
62 /** Does the font character map include the UCS4 character?
64 @returns true if character exists in font character map, false is not.
66 bool HasChar( sal_UCS4
) const;
68 /** Returns the number of chars supported by the font, which
69 are inside the unicode range from cMin to cMax (inclusive).
71 @param cMin Lowest codepoint in range to be counted
72 @param cMax Highest codepoint in range to be counted
74 @returns number of characters in the font charmap between the two
77 int CountCharsInRange( sal_UCS4 cMin
, sal_UCS4 cMax
) const;
79 /** Get the number of characters in the font character map.
81 @returns number of characters in the font character map.
83 int GetCharCount() const;
85 /** Get the first character in the font character map.
87 @returns first character in the font character map.
89 sal_UCS4
GetFirstChar() const;
91 /** Get the last character in the font character map.
93 @returns last character in the font character map.
95 sal_UCS4
GetLastChar() const;
97 /** Get the next character in the font character map. This is important
98 because character maps (e.g. the default map which holds the characters
99 in the BMP plane) can have discontiguous ranges.
101 @param cChar Character from which to find next character
103 @returns next character in the font character map.
105 sal_UCS4
GetNextChar( sal_UCS4 cChar
) const;
107 /** Get the previous character in the font character map. This is important
108 because character maps (e.g. the default map which holds the characters
109 in the BMP plane) can have discontiguous ranges.
111 @param cChar Character from which to find previous character
113 @returns previous character in the font character map.
115 sal_UCS4
GetPrevChar( sal_UCS4 cChar
) const;
117 /** Get the index of a particular character in the font character map. The
118 index is different from the codepoint, because font character maps can
122 @param cChar Character used to find index number
124 @returns Index of character in font character map.
126 int GetIndexFromChar( sal_UCS4 cChar
) const;
128 /** Get the character at a particular index in the font character map. The
129 index is different from the codepoint, because font character maps can
131 determine the character.
133 @param nCharIndex Index used to find the character
135 @returns Character in font character map.
137 sal_UCS4
GetCharFromIndex( int nCharIndex
) const;
139 bool isMicrosoftSymbolMap() const;
142 ImplFontCharMapRef mpImplFontCharMap
;
144 friend class ::OutputDevice
;
146 int findRangeIndex( sal_UCS4
) const;
148 FontCharMap( ImplFontCharMapRef pIFCMap
);
150 // prevent assignment and copy construction
151 FontCharMap( const FontCharMap
& ) = delete;
152 void operator=( const FontCharMap
& ) = delete;
155 #endif // INCLUDED_FONTCHARMAP_HXX
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */