Updating the changelog in the VERSION file, and version_sync.
[shapes.git] / source / glyphlist.h
blob9ce4871550155cfabd63a9dac2dbc6d4bd48070e
1 /* This file is part of Shapes.
3 * Shapes is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * any later version.
8 * Shapes is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright 2008 Henrik Tidefelt
19 #pragma once
21 #include "ptrowner.h"
22 #include "charptrless.h"
24 #include <vector>
25 #include <map>
26 #include <iostream>
28 // This may not be the appropriate namespace...
29 namespace FontMetrics
32 class GlyphList
34 public:
35 // This shall be encoded as iconv's Helpers::theUCS4EncodingName.
36 // Please refer to charconverters.h for the exact meaning of this.
37 typedef uint32_t UnicodeType;
38 private:
39 // This is only a memory, with no particular order of its items.
40 PtrOwner_back_Access< std::vector< const char * > > nameMem_;
42 // This is idexed by size_t and maps to a name or a null pointer.
43 static const size_t TABLE_SIZE = 65536;
44 std::vector< const char * > namePtrs_;
45 std::map< UnicodeType, const char * > namePtrsWide_;
47 // This is the reverse map.
48 std::map< const char *, UnicodeType, charPtrLess > nameMap_;
50 public:
51 GlyphList( std::istream & iFile );
52 ~GlyphList( );
54 // Returns true on success.
55 bool UCS4_to_name( UnicodeType code, const char ** dst ) const;
56 bool UTF8_to_name( const char * code, const char ** dst ) const;
58 // Returns true on success.
59 bool name_to_UCS4( const char * name, UnicodeType * dst ) const;
61 size_t size( ) const;
63 private:
64 void readfile( std::istream & iFile );