Coverage Report

Created: 2026-03-12 06:42

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libmwaw/src/lib/MWAWFontConverter.cxx
Line
Count
Source
1
/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2
3
/* libmwaw
4
* Version: MPL 2.0 / LGPLv2+
5
*
6
* The contents of this file are subject to the Mozilla Public License Version
7
* 2.0 (the "License"); you may not use this file except in compliance with
8
* the License or as specified alternatively below. You may obtain a copy of
9
* the License at http://www.mozilla.org/MPL/
10
*
11
* Software distributed under the License is distributed on an "AS IS" basis,
12
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13
* for the specific language governing rights and limitations under the
14
* License.
15
*
16
* Major Contributor(s):
17
* Copyright (C) 2002 William Lachance (wrlach@gmail.com)
18
* Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19
* Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20
* Copyright (C) 2006, 2007 Andrew Ziem
21
* Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
22
*
23
*
24
* All Rights Reserved.
25
*
26
* For minor contributions see the git repository.
27
*
28
* Alternatively, the contents of this file may be used under the terms of
29
* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
30
* in which case the provisions of the LGPLv2+ are applicable
31
* instead of those above.
32
*/
33
34
#include <iostream>
35
36
#include "libmwaw_internal.hxx"
37
38
#include "MWAWFontConverter.hxx"
39
#include "MWAWFontSJISConverter.hxx"
40
41
42
//! Internal namespace used to store the data used by MWAWFontConverterInternal
43
namespace MWAWFontConverterInternal
44
{
45
//! Internal and low level: tools to convert Macintosh characters
46
namespace Data
47
{
48
//! Internal and low level: a class to store a conversion map for character, ...
49
struct ConversionData {
50
  //! constructor
51
  explicit ConversionData(std::map<unsigned char, unsigned long> &map,
52
                          char const *odtName="", int delta=0)
53
49.8M
    : m_encoding(MWAWFontConverter::E_DEFAULT)
54
49.8M
    , m_conversion(map)
55
49.8M
    , m_name(odtName)
56
49.8M
    , m_deltaSize(delta)
57
49.8M
  {
58
49.8M
  }
59
  //! constructor for different encoding
60
  ConversionData(std::map<unsigned char, unsigned long> &map, MWAWFontConverter::Encoding encoding, char const *odtName="", int delta=0)
61
1.99M
    : m_encoding(encoding)
62
1.99M
    , m_conversion(map)
63
1.99M
    , m_name(odtName)
64
1.99M
    , m_deltaSize(delta)
65
1.99M
  {
66
1.99M
  }
67
68
  //! the character encoding
69
  MWAWFontConverter::Encoding m_encoding;
70
  //! the conversion map character -> unicode
71
  std::map<unsigned char, unsigned long> &m_conversion;
72
  //! the odt font name (if empty used the name)
73
  std::string m_name;
74
  //! the size delta: odtSize = fSize + deltaSize
75
  int m_deltaSize;
76
};
77
78
// Courtesy of unicode.org: http://unicode.org/Public/MAPPINGS/VENDORS/APPLE/ROMAN.TXT
79
//! Internal and Low level: vector ( char, unicode) for roman font
80
static int const s_romanUnicode [] = {
81
  0x20,0x0020,  0x21,0x0021,  0x22,0x0022,  0x23,0x0023,  0x24,0x0024,
82
  0x25,0x0025,  0x26,0x0026,  0x27,0x0027,  0x28,0x0028,  0x29,0x0029,
83
  0x2A,0x002A,  0x2B,0x002B,  0x2C,0x002C,  0x2D,0x002D,  0x2E,0x002E,
84
  0x2F,0x002F,  0x30,0x0030,  0x31,0x0031,  0x32,0x0032,  0x33,0x0033,
85
  0x34,0x0034,  0x35,0x0035,  0x36,0x0036,  0x37,0x0037,  0x38,0x0038,
86
  0x39,0x0039,  0x3A,0x003A,  0x3B,0x003B,  0x3C,0x003C,  0x3D,0x003D,
87
  0x3E,0x003E,  0x3F,0x003F,  0x40,0x0040,  0x41,0x0041,  0x42,0x0042,
88
  0x43,0x0043,  0x44,0x0044,  0x45,0x0045,  0x46,0x0046,  0x47,0x0047,
89
  0x48,0x0048,  0x49,0x0049,  0x4A,0x004A,  0x4B,0x004B,  0x4C,0x004C,
90
  0x4D,0x004D,  0x4E,0x004E,  0x4F,0x004F,  0x50,0x0050,  0x51,0x0051,
91
  0x52,0x0052,  0x53,0x0053,  0x54,0x0054,  0x55,0x0055,  0x56,0x0056,
92
  0x57,0x0057,  0x58,0x0058,  0x59,0x0059,  0x5A,0x005A,  0x5B,0x005B,
93
// in icelandic : 5f='|o'
94
// in czech : 5f='s' (final 's' or begin word letter 'z')
95
  0x5C,0x005C,  0x5D,0x005D,  0x5E,0x005E,  0x5F,0x005F,  0x60,0x0060,
96
  0x61,0x0061,  0x62,0x0062,  0x63,0x0063,  0x64,0x0064,  0x65,0x0065,
97
  0x66,0x0066,  0x67,0x0067,  0x68,0x0068,  0x69,0x0069,  0x6A,0x006A,
98
  0x6B,0x006B,  0x6C,0x006C,  0x6D,0x006D,  0x6E,0x006E,  0x6F,0x006F,
99
  0x70,0x0070,  0x71,0x0071,  0x72,0x0072,  0x73,0x0073,  0x74,0x0074,
100
  0x75,0x0075,  0x76,0x0076,  0x77,0x0077,  0x78,0x0078,  0x79,0x0079,
101
  0x7A,0x007A,  0x7B,0x007B,  0x7C,0x007C,  0x7D,0x007D,  0x7E,0x007E,
102
  0x7F,0x007F,  0x80,0x00C4,  0x81,0x00C5,  0x82,0x00C7,  0x83,0x00C9,
103
  0x84,0x00D1,  0x85,0x00D6,  0x86,0x00DC,  0x87,0x00E1,  0x88,0x00E0,
104
  0x89,0x00E2,  0x8A,0x00E4,  0x8B,0x00E3,  0x8C,0x00E5,  0x8D,0x00E7,
105
  0x8E,0x00E9,  0x8F,0x00E8,  0x90,0x00EA,  0x91,0x00EB,  0x92,0x00ED,
106
  0x93,0x00EC,  0x94,0x00EE,  0x95,0x00EF,  0x96,0x00F1,  0x97,0x00F3,
107
  0x98,0x00F2,  0x99,0x00F4,  0x9A,0x00F6,  0x9B,0x00F5,  0x9C,0x00FA,
108
  0x9D,0x00F9,  0x9E,0x00FB,  0x9F,0x00FC,  0xA0,0x2020,  0xA1,0x00B0,
109
  0xA2,0x00A2,  0xA3,0x00A3,  0xA4,0x00A7,  0xA5,0x2022,  0xA6,0x00B6,
110
  0xA7,0x00DF,  0xA8,0x00AE,  0xA9,0x00A9,  0xAA,0x2122,  0xAB,0x00B4,
111
  0xAC,0x00A8,  0xAD,0x2260,  0xAE,0x00C6,  0xAF,0x00D8,  0xB0,0x221E,
112
  0xB1,0x00B1,  0xB2,0x2264,  0xB3,0x2265,  0xB4,0x00A5,  0xB5,0x00B5,
113
  0xB6,0x2202,  0xB7,0x2211,  0xB8,0x220F,  0xB9,0x03C0,  0xBA,0x222B,
114
  0xBB,0x00AA,  0xBC,0x00BA,  0xBD,0x03A9,  0xBE,0x00E6,  0xBF,0x00F8,
115
  0xC0,0x00BF,  0xC1,0x00A1,  0xC2,0x00AC,  0xC3,0x221A,  0xC4,0x0192,
116
  0xC5,0x2248,  0xC6,0x2206,  0xC7,0x00AB,  0xC8,0x00BB,  0xC9,0x2026,
117
  0xCA,0x00A0,  0xCB,0x00C0,  0xCC,0x00C3,  0xCD,0x00D5,  0xCE,0x0152,
118
  0xCF,0x0153,  0xD0,0x2013,  0xD1,0x2014,  0xD2,0x201C,  0xD3,0x201D,
119
  0xD4,0x2018,  0xD5,0x2019,  0xD6,0x00F7,  0xD7,0x25CA,  0xD8,0x00FF,
120
  0xD9,0x0178,  0xDA,0x2044,  0xDB,0x20AC,  0xDC,0x2039,  0xDD,0x203A,
121
  0xDE,0xFB01,  0xDF,0xFB02,  0xE0,0x2021,  0xE1,0x00B7,  0xE2,0x201A,
122
// E6 = non breaking space (instead of 0x00CA) ?
123
  0xE3,0x201E,  0xE4,0x2030,  0xE5,0x00C2,  0xE6,0x00CA,  0xE7,0x00C1,
124
  0xE8,0x00CB,  0xE9,0x00C8,  0xEA,0x00CD,  0xEB,0x00CE,  0xEC,0x00CF,
125
  0xED,0x00CC,  0xEE,0x00D3,  0xEF,0x00D4,  0xF0,0xF8FF,  0xF1,0x00D2,
126
  0xF2,0x00DA,  0xF3,0x00DB,  0xF4,0x00D9,  0xF5,0x0131,  0xF6,0x02C6,
127
  0xF7,0x02DC,  0xF8,0x00AF,  0xF9,0x02D8,  0xFA,0x02D9,  0xFB,0x02DA,
128
  0xFC,0x00B8,  0xFD,0x02DD,  0xFE,0x02DB,  0xFF,0x02C7
129
};
130
131
// Courtesy of unicode.org: http://unicode.org/Public/MAPPINGS/VENDORS/APPLE/CENTEURO.TXT
132
//! Internal and Low level: vector (char, unicode) for Central european font
133
static int const s_centralEuroUnicode[] = {
134
  0x20,0x0020, 0x21,0x0021, 0x22,0x0022, 0x23,0x0023, 0x24,0x0024, 0x25,0x0025, 0x26,0x0026, 0x27,0x0027,
135
  0x28,0x0028, 0x29,0x0029, 0x2A,0x002A, 0x2B,0x002B, 0x2C,0x002C, 0x2D,0x002D, 0x2E,0x002E, 0x2F,0x002F,
136
  0x30,0x0030, 0x31,0x0031, 0x32,0x0032, 0x33,0x0033, 0x34,0x0034, 0x35,0x0035, 0x36,0x0036, 0x37,0x0037,
137
  0x38,0x0038, 0x39,0x0039, 0x3A,0x003A, 0x3B,0x003B, 0x3C,0x003C, 0x3D,0x003D, 0x3E,0x003E, 0x3F,0x003F,
138
  0x40,0x0040, 0x41,0x0041, 0x42,0x0042, 0x43,0x0043, 0x44,0x0044, 0x45,0x0045, 0x46,0x0046, 0x47,0x0047,
139
  0x48,0x0048, 0x49,0x0049, 0x4A,0x004A, 0x4B,0x004B, 0x4C,0x004C, 0x4D,0x004D, 0x4E,0x004E, 0x4F,0x004F,
140
  0x50,0x0050, 0x51,0x0051, 0x52,0x0052, 0x53,0x0053, 0x54,0x0054, 0x55,0x0055, 0x56,0x0056, 0x57,0x0057,
141
  0x58,0x0058, 0x59,0x0059, 0x5A,0x005A, 0x5B,0x005B, 0x5C,0x005C, 0x5D,0x005D, 0x5E,0x005E, 0x5F,0x005F,
142
  0x60,0x0060, 0x61,0x0061, 0x62,0x0062, 0x63,0x0063, 0x64,0x0064, 0x65,0x0065, 0x66,0x0066, 0x67,0x0067,
143
  0x68,0x0068, 0x69,0x0069, 0x6A,0x006A, 0x6B,0x006B, 0x6C,0x006C, 0x6D,0x006D, 0x6E,0x006E, 0x6F,0x006F,
144
  0x70,0x0070, 0x71,0x0071, 0x72,0x0072, 0x73,0x0073, 0x74,0x0074, 0x75,0x0075, 0x76,0x0076, 0x77,0x0077,
145
  0x78,0x0078, 0x79,0x0079, 0x7A,0x007A, 0x7B,0x007B, 0x7C,0x007C, 0x7D,0x007D, 0x7E,0x007E,
146
  0x80,0x00C4, 0x81,0x0100, 0x82,0x0101, 0x83,0x00C9, 0x84,0x0104, 0x85,0x00D6, 0x86,0x00DC, 0x87,0x00E1,
147
  0x88,0x0105, 0x89,0x010C, 0x8A,0x00E4, 0x8B,0x010D, 0x8C,0x0106, 0x8D,0x0107, 0x8E,0x00E9, 0x8F,0x0179,
148
  0x90,0x017A, 0x91,0x010E, 0x92,0x00ED, 0x93,0x010F, 0x94,0x0112, 0x95,0x0113, 0x96,0x0116, 0x97,0x00F3,
149
  0x98,0x0117, 0x99,0x00F4, 0x9A,0x00F6, 0x9B,0x00F5, 0x9C,0x00FA, 0x9D,0x011A, 0x9E,0x011B, 0x9F,0x00FC,
150
  0xA0,0x2020, 0xA1,0x00B0, 0xA2,0x0118, 0xA3,0x00A3, 0xA4,0x00A7, 0xA5,0x2022, 0xA6,0x00B6, 0xA7,0x00DF,
151
  0xA8,0x00AE, 0xA9,0x00A9, 0xAA,0x2122, 0xAB,0x0119, 0xAC,0x00A8, 0xAD,0x2260, 0xAE,0x0123, 0xAF,0x012E,
152
  0xB0,0x012F, 0xB1,0x012A, 0xB2,0x2264, 0xB3,0x2265, 0xB4,0x012B, 0xB5,0x0136, 0xB6,0x2202, 0xB7,0x2211,
153
  0xB8,0x0142, 0xB9,0x013B, 0xBA,0x013C, 0xBB,0x013D, 0xBC,0x013E, 0xBD,0x0139, 0xBE,0x013A, 0xBF,0x0145,
154
  0xC0,0x0146, 0xC1,0x0143, 0xC2,0x00AC, 0xC3,0x221A, 0xC4,0x0144, 0xC5,0x0147, 0xC6,0x2206, 0xC7,0x00AB,
155
  0xC8,0x00BB, 0xC9,0x2026, 0xCA,0x00A0, 0xCB,0x0148, 0xCC,0x0150, 0xCD,0x00D5, 0xCE,0x0151, 0xCF,0x014C,
156
  0xD0,0x2013, 0xD1,0x2014, 0xD2,0x201C, 0xD3,0x201D, 0xD4,0x2018, 0xD5,0x2019, 0xD6,0x00F7, 0xD7,0x25CA,
157
  0xD8,0x014D, 0xD9,0x0154, 0xDA,0x0155, 0xDB,0x0158, 0xDC,0x2039, 0xDD,0x203A, 0xDE,0x0159, 0xDF,0x0156,
158
  0xE0,0x0157, 0xE1,0x0160, 0xE2,0x201A, 0xE3,0x201E, 0xE4,0x0161, 0xE5,0x015A, 0xE6,0x015B, 0xE7,0x00C1,
159
  0xE8,0x0164, 0xE9,0x0165, 0xEA,0x00CD, 0xEB,0x017D, 0xEC,0x017E, 0xED,0x016A, 0xEE,0x00D3, 0xEF,0x00D4,
160
  0xF0,0x016B, 0xF1,0x016E, 0xF2,0x00DA, 0xF3,0x016F, 0xF4,0x0170, 0xF5,0x0171, 0xF6,0x0172, 0xF7,0x0173,
161
  0xF8,0x00DD, 0xF9,0x00FD, 0xFA,0x0137, 0xFB,0x017B, 0xFC,0x0141, 0xFD,0x017C, 0xFE,0x0122, 0xFF,0x02C7,
162
};
163
164
// Courtesy of unicode.org: http://unicode.org/Public/MAPPINGS/VENDORS/APPLE/CYRILLIC.TXT
165
//! Internal and Low level: vector (char, unicode) for Cyrillic font
166
static int const s_cyrillicUnicode[] = {
167
  0x20,0x0020, 0x21,0x0021, 0x22,0x0022, 0x23,0x0023, 0x24,0x0024, 0x25,0x0025, 0x26,0x0026, 0x27,0x0027,
168
  0x28,0x0028, 0x29,0x0029, 0x2A,0x002A, 0x2B,0x002B, 0x2C,0x002C, 0x2D,0x002D, 0x2E,0x002E, 0x2F,0x002F,
169
  0x30,0x0030, 0x31,0x0031, 0x32,0x0032, 0x33,0x0033, 0x34,0x0034, 0x35,0x0035, 0x36,0x0036, 0x37,0x0037,
170
  0x38,0x0038, 0x39,0x0039, 0x3A,0x003A, 0x3B,0x003B, 0x3C,0x003C, 0x3D,0x003D, 0x3E,0x003E, 0x3F,0x003F,
171
  0x40,0x0040, 0x41,0x0041, 0x42,0x0042, 0x43,0x0043, 0x44,0x0044, 0x45,0x0045, 0x46,0x0046, 0x47,0x0047,
172
  0x48,0x0048, 0x49,0x0049, 0x4A,0x004A, 0x4B,0x004B, 0x4C,0x004C, 0x4D,0x004D, 0x4E,0x004E, 0x4F,0x004F,
173
  0x50,0x0050, 0x51,0x0051, 0x52,0x0052, 0x53,0x0053, 0x54,0x0054, 0x55,0x0055, 0x56,0x0056, 0x57,0x0057,
174
  0x58,0x0058, 0x59,0x0059, 0x5A,0x005A, 0x5B,0x005B, 0x5C,0x005C, 0x5D,0x005D, 0x5E,0x005E, 0x5F,0x005F,
175
  0x60,0x0060, 0x61,0x0061, 0x62,0x0062, 0x63,0x0063, 0x64,0x0064, 0x65,0x0065, 0x66,0x0066, 0x67,0x0067,
176
  0x68,0x0068, 0x69,0x0069, 0x6A,0x006A, 0x6B,0x006B, 0x6C,0x006C, 0x6D,0x006D, 0x6E,0x006E, 0x6F,0x006F,
177
  0x70,0x0070, 0x71,0x0071, 0x72,0x0072, 0x73,0x0073, 0x74,0x0074, 0x75,0x0075, 0x76,0x0076, 0x77,0x0077,
178
  0x78,0x0078, 0x79,0x0079, 0x7A,0x007A, 0x7B,0x007B, 0x7C,0x007C, 0x7D,0x007D, 0x7E,0x007E,
179
  0x80,0x0410, 0x81,0x0411, 0x82,0x0412, 0x83,0x0413, 0x84,0x0414, 0x85,0x0415, 0x86,0x0416, 0x87,0x0417,
180
  0x88,0x0418, 0x89,0x0419, 0x8A,0x041A, 0x8B,0x041B, 0x8C,0x041C, 0x8D,0x041D, 0x8E,0x041E, 0x8F,0x041F,
181
  0x90,0x0420, 0x91,0x0421, 0x92,0x0422, 0x93,0x0423, 0x94,0x0424, 0x95,0x0425, 0x96,0x0426, 0x97,0x0427,
182
  0x98,0x0428, 0x99,0x0429, 0x9A,0x042A, 0x9B,0x042B, 0x9C,0x042C, 0x9D,0x042D, 0x9E,0x042E, 0x9F,0x042F,
183
  0xA0,0x2020, 0xA1,0x00B0, 0xA2,0x0490, 0xA3,0x00A3, 0xA4,0x00A7, 0xA5,0x2022, 0xA6,0x00B6, 0xA7,0x0406,
184
  0xA8,0x00AE, 0xA9,0x00A9, 0xAA,0x2122, 0xAB,0x0402, 0xAC,0x0452, 0xAD,0x2260, 0xAE,0x0403, 0xAF,0x0453,
185
  0xB0,0x221E, 0xB1,0x00B1, 0xB2,0x2264, 0xB3,0x2265, 0xB4,0x0456, 0xB5,0x00B5, 0xB6,0x0491, 0xB7,0x0408,
186
  0xB8,0x0404, 0xB9,0x0454, 0xBA,0x0407, 0xBB,0x0457, 0xBC,0x0409, 0xBD,0x0459, 0xBE,0x040A, 0xBF,0x045A,
187
  0xC0,0x0458, 0xC1,0x0405, 0xC2,0x00AC, 0xC3,0x221A, 0xC4,0x0192, 0xC5,0x2248, 0xC6,0x2206, 0xC7,0x00AB,
188
  0xC8,0x00BB, 0xC9,0x2026, 0xCA,0x00A0, 0xCB,0x040B, 0xCC,0x045B, 0xCD,0x040C, 0xCE,0x045C, 0xCF,0x0455,
189
  0xD0,0x2013, 0xD1,0x2014, 0xD2,0x201C, 0xD3,0x201D, 0xD4,0x2018, 0xD5,0x2019, 0xD6,0x00F7, 0xD7,0x201E,
190
  0xD8,0x040E, 0xD9,0x045E, 0xDA,0x040F, 0xDB,0x045F, 0xDC,0x2116, 0xDD,0x0401, 0xDE,0x0451, 0xDF,0x044F,
191
  0xE0,0x0430, 0xE1,0x0431, 0xE2,0x0432, 0xE3,0x0433, 0xE4,0x0434, 0xE5,0x0435, 0xE6,0x0436, 0xE7,0x0437,
192
  0xE8,0x0438, 0xE9,0x0439, 0xEA,0x043A, 0xEB,0x043B, 0xEC,0x043C, 0xED,0x043D, 0xEE,0x043E, 0xEF,0x043F,
193
  0xF0,0x0440, 0xF1,0x0441, 0xF2,0x0442, 0xF3,0x0443, 0xF4,0x0444, 0xF5,0x0445, 0xF6,0x0446, 0xF7,0x0447,
194
  0xF8,0x0448, 0xF9,0x0449, 0xFA,0x044A, 0xFB,0x044B, 0xFC,0x044C, 0xFD,0x044D, 0xFE,0x044E, 0xFF,0x20AC,
195
};
196
197
// Courtesy of unicode.org: http://unicode.org/Public/MAPPINGS/VENDORS/APPLE/TURKISH.TXT
198
//! Internal and Low level: vector (char, unicode) for Turkish font ( diff to mac roman)
199
static int const s_turkishUnicode[] = {
200
  0xda,0x11e, 0xdb,0x11f, 0xdc,0x130, 0xdd,0x131, 0xde,0x15e, 0xdf,0x15f, 0xf5,0xf8a0
201
};
202
203
// Courtesy of unicode.org: http://unicode.org/Public/MAPPINGS/VENDORS/APPLE/SYMBOL.TXT
204
//! Internal and Low level: vector (char, unicode) for symbol font
205
static int const s_symbolUnicode[] = {
206
  0x20,0x0020,  0x21,0x0021,  0x22,0x2200,  0x23,0x0023,  0x24,0x2203,
207
  0x25,0x0025,  0x26,0x0026,  0x27,0x220D,  0x28,0x0028,  0x29,0x0029,
208
  0x2A,0x2217,  0x2B,0x002B,  0x2C,0x002C,  0x2D,0x2212,  0x2E,0x002E,
209
  0x2F,0x002F,  0x30,0x0030,  0x31,0x0031,  0x32,0x0032,  0x33,0x0033,
210
  0x34,0x0034,  0x35,0x0035,  0x36,0x0036,  0x37,0x0037,  0x38,0x0038,
211
  0x39,0x0039,  0x3A,0x003A,  0x3B,0x003B,  0x3C,0x003C,  0x3D,0x003D,
212
  0x3E,0x003E,  0x3F,0x003F,  0x40,0x2245,  0x41,0x0391,  0x42,0x0392,
213
  0x43,0x03A7,  0x44,0x0394,  0x45,0x0395,  0x46,0x03A6,  0x47,0x0393,
214
  0x48,0x0397,  0x49,0x0399,  0x4A,0x03D1,  0x4B,0x039A,  0x4C,0x039B,
215
  0x4D,0x039C,  0x4E,0x039D,  0x4F,0x039F,  0x50,0x03A0,  0x51,0x0398,
216
  0x52,0x03A1,  0x53,0x03A3,  0x54,0x03A4,  0x55,0x03A5,  0x56,0x03C2,
217
  0x57,0x03A9,  0x58,0x039E,  0x59,0x03A8,  0x5A,0x0396,  0x5B,0x005B,
218
  0x5C,0x2234,  0x5D,0x005D,  0x5E,0x22A5,  0x5F,0x005F,  0x60,0xF8E5,
219
  0x61,0x03B1,  0x62,0x03B2,  0x63,0x03C7,  0x64,0x03B4,  0x65,0x03B5,
220
  0x66,0x03C6,  0x67,0x03B3,  0x68,0x03B7,  0x69,0x03B9,  0x6A,0x03D5,
221
  0x6B,0x03BA,  0x6C,0x03BB,  0x6D,0x03BC,  0x6E,0x03BD,  0x6F,0x03BF,
222
  0x70,0x03C0,  0x71,0x03B8,  0x72,0x03C1,  0x73,0x03C3,  0x74,0x03C4,
223
  0x75,0x03C5,  0x76,0x03D6,  0x77,0x03C9,  0x78,0x03BE,  0x79,0x03C8,
224
  0x7A,0x03B6,  0x7B,0x007B,  0x7C,0x007C,  0x7D,0x007D,  0x7E,0x223C,
225
  0xA0,0x20AC,  0xA1,0x03D2,  0xA2,0x2032,  0xA3,0x2264,  0xA4,0x2044,
226
  0xA5,0x221E,  0xA6,0x0192,  0xA7,0x2663,  0xA8,0x2666,  0xA9,0x2665,
227
  0xAA,0x2660,  0xAB,0x2194,  0xAC,0x2190,  0xAD,0x2191,  0xAE,0x2192,
228
  0xAF,0x2193,  0xB0,0x00B0,  0xB1,0x00B1,  0xB2,0x2033,  0xB3,0x2265,
229
  0xB4,0x00D7,  0xB5,0x221D,  0xB6,0x2202,  0xB7,0x2022,  0xB8,0x00F7,
230
  0xB9,0x2260,  0xBA,0x2261,  0xBB,0x2248,  0xBC,0x2026,  0xBD,0x23D0,
231
  0xBE,0x23AF,  0xBF,0x21B5,  0xC0,0x2135,  0xC1,0x2111,  0xC2,0x211C,
232
  0xC3,0x2118,  0xC4,0x2297,  0xC5,0x2295,  0xC6,0x2205,  0xC7,0x2229,
233
  0xC8,0x222A,  0xC9,0x2283,  0xCA,0x2287,  0xCB,0x2284,  0xCC,0x2282,
234
  0xCD,0x2286,  0xCE,0x2208,  0xCF,0x2209,  0xD0,0x2220,  0xD1,0x2207,
235
  0xD2,0x00AE,  0xD3,0x00A9,  0xD4,0x2122,  0xD5,0x220F,  0xD6,0x221A,
236
  0xD7,0x22C5,  0xD8,0x00AC,  0xD9,0x2227,  0xDA,0x2228,  0xDB,0x21D4,
237
  0xDC,0x21D0,  0xDD,0x21D1,  0xDE,0x21D2,  0xDF,0x21D3,  0xE0,0x25CA,
238
  0xE1,0x3008,  0xE2,0x00AE,  0xE3,0x00A9,  0xE4,0x2122,  0xE5,0x2211,
239
  0xE6,0x239B,  0xE7,0x239C,  0xE8,0x239D,  0xE9,0x23A1,  0xEA,0x23A2,
240
  0xEB,0x23A3,  0xEC,0x23A7,  0xED,0x23A8,  0xEE,0x23A9,  0xEF,0x23AA,
241
  0xF0,0xF8FF,  0xF1,0x3009,  0xF2,0x222B,  0xF3,0x2320,  0xF4,0x23AE,
242
  0xF5,0x2321,  0xF6,0x239E,  0xF7,0x239F,  0xF8,0x23A0,  0xF9,0x23A4,
243
  0xFA,0x23A5,  0xFB,0x23A6,  0xFC,0x23AB,  0xFD,0x23AC,  0xFE,0x23AD
244
};
245
246
// Courtesy of unicode.org: http://unicode.org/Public/MAPPINGS/VENDORS/APPLE/DINGBATS.TXT
247
//! Internal and Low level: vector (char, unicode) for dingbats font
248
static int const s_dingbatsUnicode[] = {
249
  0x20,0x0020,  0x21,0x2701,  0x22,0x2702,  0x23,0x2703,  0x24,0x2704,
250
  0x25,0x260E,  0x26,0x2706,  0x27,0x2707,  0x28,0x2708,  0x29,0x2709,
251
  0x2A,0x261B,  0x2B,0x261E,  0x2C,0x270C,  0x2D,0x270D,  0x2E,0x270E,
252
  0x2F,0x270F,  0x30,0x2710,  0x31,0x2711,  0x32,0x2712,  0x33,0x2713,
253
  0x34,0x2714,  0x35,0x2715,  0x36,0x2716,  0x37,0x2717,  0x38,0x2718,
254
  0x39,0x2719,  0x3A,0x271A,  0x3B,0x271B,  0x3C,0x271C,  0x3D,0x271D,
255
  0x3E,0x271E,  0x3F,0x271F,  0x40,0x2720,  0x41,0x2721,  0x42,0x2722,
256
  0x43,0x2723,  0x44,0x2724,  0x45,0x2725,  0x46,0x2726,  0x47,0x2727,
257
  0x48,0x2605,  0x49,0x2729,  0x4A,0x272A,  0x4B,0x272B,  0x4C,0x272C,
258
  0x4D,0x272D,  0x4E,0x272E,  0x4F,0x272F,  0x50,0x2730,  0x51,0x2731,
259
  0x52,0x2732,  0x53,0x2733,  0x54,0x2734,  0x55,0x2735,  0x56,0x2736,
260
  0x57,0x2737,  0x58,0x2738,  0x59,0x2739,  0x5A,0x273A,  0x5B,0x273B,
261
  0x5C,0x273C,  0x5D,0x273D,  0x5E,0x273E,  0x5F,0x273F,  0x60,0x2740,
262
  0x61,0x2741,  0x62,0x2742,  0x63,0x2743,  0x64,0x2744,  0x65,0x2745,
263
  0x66,0x2746,  0x67,0x2747,  0x68,0x2748,  0x69,0x2749,  0x6A,0x274A,
264
  0x6B,0x274B,  0x6C,0x25CF,  0x6D,0x274D,  0x6E,0x25A0,  0x6F,0x274F,
265
  0x70,0x2750,  0x71,0x2751,  0x72,0x2752,  0x73,0x25B2,  0x74,0x25BC,
266
  0x75,0x25C6,  0x76,0x2756,  0x77,0x25D7,  0x78,0x2758,  0x79,0x2759,
267
  0x7A,0x275A,  0x7B,0x275B,  0x7C,0x275C,  0x7D,0x275D,  0x7E,0x275E,
268
  0x80,0x2768,  0x81,0x2769,  0x82,0x276A,  0x83,0x276B,  0x84,0x276C,
269
  0x85,0x276D,  0x86,0x276E,  0x87,0x276F,  0x88,0x2770,  0x89,0x2771,
270
  0x8A,0x2772,  0x8B,0x2773,  0x8C,0x2774,  0x8D,0x2775,  0xA1,0x2761,
271
  0xA2,0x2762,  0xA3,0x2763,  0xA4,0x2764,  0xA5,0x2765,  0xA6,0x2766,
272
  0xA7,0x2767,  0xA8,0x2663,  0xA9,0x2666,  0xAA,0x2665,  0xAB,0x2660,
273
  0xAC,0x2460,  0xAD,0x2461,  0xAE,0x2462,  0xAF,0x2463,  0xB0,0x2464,
274
  0xB1,0x2465,  0xB2,0x2466,  0xB3,0x2467,  0xB4,0x2468,  0xB5,0x2469,
275
  0xB6,0x2776,  0xB7,0x2777,  0xB8,0x2778,  0xB9,0x2779,  0xBA,0x277A,
276
  0xBB,0x277B,  0xBC,0x277C,  0xBD,0x277D,  0xBE,0x277E,  0xBF,0x277F,
277
  0xC0,0x2780,  0xC1,0x2781,  0xC2,0x2782,  0xC3,0x2783,  0xC4,0x2784,
278
  0xC5,0x2785,  0xC6,0x2786,  0xC7,0x2787,  0xC8,0x2788,  0xC9,0x2789,
279
  0xCA,0x278A,  0xCB,0x278B,  0xCC,0x278C,  0xCD,0x278D,  0xCE,0x278E,
280
  0xCF,0x278F,  0xD0,0x2790,  0xD1,0x2791,  0xD2,0x2792,  0xD3,0x2793,
281
  0xD4,0x2794,  0xD5,0x2192,  0xD6,0x2194,  0xD7,0x2195,  0xD8,0x2798,
282
  0xD9,0x2799,  0xDA,0x279A,  0xDB,0x279B,  0xDC,0x279C,  0xDD,0x279D,
283
  0xDE,0x279E,  0xDF,0x279F,  0xE0,0x27A0,  0xE1,0x27A1,  0xE2,0x27A2,
284
  0xE3,0x27A3,  0xE4,0x27A4,  0xE5,0x27A5,  0xE6,0x27A6,  0xE7,0x27A7,
285
  0xE8,0x27A8,  0xE9,0x27A9,  0xEA,0x27AA,  0xEB,0x27AB,  0xEC,0x27AC,
286
  0xED,0x27AD,  0xEE,0x27AE,  0xEF,0x27AF,  0xF1,0x27B1,  0xF2,0x27B2,
287
  0xF3,0x27B3,  0xF4,0x27B4,  0xF5,0x27B5,  0xF6,0x27B6,  0xF7,0x27B7,
288
  0xF8,0x27B8,  0xF9,0x27B9,  0xFA,0x27BA,  0xFB,0x27BB,  0xFC,0x27BC,
289
  0xFD,0x27BD,  0xFE,0x27BE
290
};
291
292
//! Internal and Low level: vector (char, unicode) for Monotype Sorts font
293
static int const s_monotypeSortsUnicode[] = {
294
  0x20,0x20, 0x21,0x2701, 0x22,0x2700, 0x23,0x2703,
295
  0x24,0x2704, 0x25,0x260, 0x26,0x2706, 0x27,0x2622,
296
  0x28,0x2708, 0x29,0x2709, 0x2a,0x261b, 0x2b,0x261e,
297
  0x2c,0x270c, 0x2d,0x270d, 0x2e,0x270e, 0x2f,0x270f,
298
  0x30,0x2710, 0x31,0x2711, 0x32,0x2712, 0x33,0x2713,
299
  0x34,0x2714, 0x35,0x2715, 0x36,0x2716, 0x37,0x2717,
300
  0x38,0x2718, 0x39,0x2719, 0x3a,0x271a, 0x3b,0x271b,
301
  0x3c,0x271c, 0x3d,0x271d, 0x3e,0x271e, 0x3f,0x271f,
302
  0x40,0x2720, 0x41,0x2721, 0x42,0x2722, 0x43,0x2723,
303
  0x44,0x2724, 0x45,0x2725, 0x46,0x2726, 0x47,0x2727,
304
  0x48,0x2605, 0x49,0x2729, 0x4a,0x272a, 0x4b,0x272b,
305
  0x4c,0x272c, 0x4d,0x272d, 0x4e,0x272e, 0x4f,0x272f,
306
  0x50,0x2730, 0x51,0x2736, 0x52,0x2732, 0x53,0x2731,
307
  0x54,0x2731, 0x55,0x2735, 0x56,0x2736, 0x57,0x2737,
308
  0x58,0x2738, 0x59,0x2739, 0x5a,0x273a, 0x5b,0x273b,
309
  0x5c,0x273c, 0x5d,0x273d, 0x5e,0x273e, 0x5f,0x273f,
310
  0x60,0x2740, 0x61,0x2741, 0x62,0x2742, 0x63,0x2743,
311
  0x64,0x2744, 0x65,0x2745, 0x66,0x2746, 0x67,0x2747,
312
  0x68,0x2748, 0x69,0x2749, 0x6a,0x274a, 0x6b,0x274b,
313
  0x6c,0x25cf, 0x6d,0x25ef, 0x6e,0x2b1b, 0x6f,0x274f,
314
  0x70,0x2750, 0x71,0x2751, 0x72,0x2752, 0x73,0x25b2,
315
  0x74,0x25bc, 0x75,0x25c6, 0x76,0x2756, 0x77,0x25d7,
316
  0x78,0x2758, 0x79,0x2759, 0x7a,0x275a, 0x7b,0x275b,
317
  0x7c,0x275c, 0x7d,0x275d, 0x7e,0x275e,
318
  0x80,0x2768, 0x81,0x2769, 0x82,0x28, 0x83,0x29,
319
  0x84,0x2329, 0x85,0x232a, 0x86,0x27e8, 0x87,0x27e9,
320
  0x88,0x2770, 0x89,0x2771, 0x8a,0x5b, 0x8b,0x5d,
321
  0x8c,0x7b, 0x8d,0x7d,
322
  0xa1,0x2761, 0xa2,0x2762, 0xa3,0x2763,
323
  0xa4,0x2764, 0xa5,0x2765, 0xa6,0x2766, 0xa7,0x2767,
324
  0xa8,0x2663, 0xa9,0x2666, 0xaa,0x2665, 0xab,0x2660,
325
  0xac,0x2460, 0xad,0x2461, 0xae,0x2462, 0xaf,0x2463,
326
  0xb0,0x2464, 0xb1,0x2465, 0xb2,0x2466, 0xb3,0x2467,
327
  0xb4,0x2468, 0xb5,0x2469, 0xb6,0x2776, 0xb7,0x2777,
328
  0xb8,0x2778, 0xb9,0x2779, 0xba,0x277a, 0xbb,0x277b,
329
  0xbc,0x277c, 0xbd,0x277d, 0xbe,0x277e, 0xbf,0x277f,
330
  0xc0,0x2780, 0xc1,0x2781, 0xc2,0x2782, 0xc3,0x2783,
331
  0xc4,0x2784, 0xc5,0x2785, 0xc6,0x2786, 0xc7,0x2787,
332
  0xc8,0x2788, 0xc9,0x2789, 0xca,0x2776, 0xcb,0x2777,
333
  0xcc,0x2778, 0xcd,0x2779, 0xce,0x277a, 0xcf,0x277b,
334
  0xd0,0x277c, 0xd1,0x277d, 0xd2,0x277e, 0xd3,0x277f,
335
  0xd4,0x279c, 0xd5,0x2192, 0xd6,0x2194, 0xd7,0x2195,
336
  0xd8,0x2798, 0xd9,0x2799, 0xda,0x279a, 0xdb,0x279b,
337
  0xdc,0x279c, 0xdd,0x279d, 0xde,0x279e, 0xdf,0x279f,
338
  0xe0,0x27a0, 0xe1,0x27a1, 0xe2,0x27a2, 0xe3,0x27a3,
339
  0xe4,0x27a4, 0xe5,0x27a5, 0xe6,0x27a6, 0xe7,0x27a7,
340
  0xe8,0x27a8, 0xe9,0x27a9, 0xea,0x27aa, 0xeb,0x27ab,
341
  0xec,0x27ac, 0xed,0x27ad, 0xee,0x27ae, 0xef,0x27af,
342
  0xf1,0x27b1, 0xf2,0x27b2, 0xf3,0x27b3,
343
  0xf4,0x27b4, 0xf5,0x27b5, 0xf6,0x27b6, 0xf7,0x27b7,
344
  0xf8,0x27bc, 0xf9,0x27b9, 0xfa,0x27ba, 0xfb,0x27bb,
345
  0xfc,0x27bc, 0xfd,0x27bd, 0xfe,0x27be
346
};
347
348
// Courtesy of unicode.org: http://www.alanwood.net/demos/wingdings.html
349
//! Internal and Low level: vector (char, unicode) for wingdings font
350
static int const s_wingdingsUnicode[] = {
351
  0x20,0x0020,  0x21,0x270f,  0x22,0x2702,  0x23,0x2701,  0x24,0x1F453,
352
  0x25,0x1F514, 0x26,0x1F514, 0x27,0x2710/*candle*/, 0x28,0x260E, 0x29,0x2706,
353
  0x2A,0x2709,  0x2B,0x260E,  0x2C,0x1f4ea, 0x2D,0x1f4eb, 0x2E,0x1f4ec,
354
  0x2F,0x1f4ed, 0x30,0x1f4c1, 0x31,0x1f4c2, 0x32,0x1f4c4, 0x33,0x1f4c4,
355
  0x34,0x1f4c4, 0x35,0x25AF,  0x36,0x231B,  0x37,0x2328,  0x38,0x1F42F/*mouse*/,
356
  0x39,0x2328/*trackpad*/, 0x3A,0x1F4BB, 0x3B,0x2328/*harddisk*/, 0x3C,0x1F4BE,  0x3D,0x1F4BE,
357
  0x3E,0x2707,  0x3F,0x270D,  0x40,0x270D,  0x41,0x270c,  0x42,0x1F44C,
358
  0x43,0x1F44D, 0x44,0x1F44E, 0x45,0x261C,  0x46,0x261E,  0x47,0x261D,
359
  0x48,0x261F,  0x49,0x270B,  0x4A,0x263A,  0x4B,0x1F610, 0x4C,0x2639,
360
  0x4D,0x1F4A3, 0x4E,0x2620,  0x4F,0x2690,  0x50,0x1F6A9, 0x51,0x2708,
361
  0x52,0x263C,  0x53,0x1F4A7, 0x54,0x2744,  0x55,0x271E,  0x56,0x271E,
362
  0x57,0x271D,  0x58,0x2720,  0x59,0x2721,  0x5A,0x262a,  0x5B,0x262f,
363
  0x5C,0x0950,  0x5D,0x2638,  0x5E,0x2648,  0x5F,0x2649,  0x60,0x264a,
364
  0x61,0x264b,  0x62,0x264c,  0x63,0x264d,  0x64,0x264e,  0x65,0x264f,
365
  0x66,0x2650,  0x67,0x2651,  0x68,0x2652,  0x69,0x2653,  0x6A,0x0026,
366
  0x6B,0x0026,  0x6C,0x25CF,  0x6D,0x274D,  0x6E,0x25A0,  0x6F,0x27A1,
367
  0x70,0x2751,  0x71,0x2751,  0x72,0x2752,  0x73,0x2B27,  0x74,0x29EB,
368
  0x75,0x25C6,  0x76,0x2756,  0x77,0x2B25,  0x78,0x2327,  0x79,0x2353,
369
  0x7A,0x2318,  0x7B,0x2740,  0x7C,0x273F,  0x7D,0x275D,  0x7E,0x275E,
370
  0x7F,0x25AF,  0x80,0x24EA,  0x81,0x2460,  0x82,0x2461,  0x83,0x2462,
371
  0x84,0x2463,  0x85,0x2464,  0x86,0x2465,  0x87,0x2466,  0x88,0x2467,
372
  0x89,0x2468,  0x8A,0x2469,  0x8B,0x24FF,  0x8C,0x2776,  0x8D,0x2777,
373
  0x8E,0x2778,  0x8F,0x2779,  0x90,0x277A,  0x91,0x277B,  0x92,0x277C,
374
  0x93,0x277D,  0x94,0x277E,  0x95,0x277F,
375
  0x96,0x269B,  0x97,0x269B,  0x98,0x269B,  0x99,0x269B,
376
  0x9a,0x269B,  0x9b,0x269B,  0x9c,0x269B,  0x9d,0x269B,  // bud and vine leaf
377
  0x9E,0x00B7,  0x9F,0x277F,  0xA0,0x25AA,  0xA1,0x25CB,  0xA2,0x2B55,
378
  0xA3,0x2B55,  0xA4,0x25C9,  0xA5,0x25CE,  0xA6,0x25CB,
379
  0xA7,0x25AA,  0xA8,0x25FB,  0xA9,0x2726,  0xAA,0x2726,  0xAB,0x2605,
380
  0xAC,0x2736,  0xAD,0x2734,  0xAE,0x2739,  0xAF,0x2735,  0xB0,0x2316,
381
  0xB1,0x2316,  0xB2,0x27E1,  0xB3,0x2311,  0xB4,0x27E1,  0xB5,0x25CB,/*clock*/
382
  0xB6,0x2730,  0xB7,0x1F550, 0xB8,0x1F551, 0xB9,0x1F552, 0xBA,0x1F553,
383
  0xBB,0x1F554, 0xBC,0x1F555, 0xBD,0x1F556, 0xBE,0x1F557, 0xBF,0x1F558,
384
  0xC0,0x1F559, 0xC1,0x1F55A, 0xC2,0x1F55B, 0xC3,0x21B5,  0xC4,0x21B3,
385
  0xC5,0x21B0,  0xC6,0x21B1,  0xC7,0x21BB,  0xC8,0x21BA,  0xC9,0x21BA,
386
  0xCA,0x21BB,  0xCB,0x2722,  0xCC,0x2722,
387
  0xCD,0x2743,  0xCE,0x2743,  0xCF,0x2743,  0xD0,0x2743,
388
  0xD1,0x2743,  0xD2,0x2743,  0xD3,0x2743,  0xD4,0x2743,  /* normally leaf...*/
389
  0xD5,0x232B,  0xD6,0x2326,  0xD7,0x21E6,  0xD8,0x27A2,
390
  0xD9,0x21E7,  0xDA,0x21E9,  0xDB,0x21E6,  0xDC,0x27B2,  0xDD,0x21E7,
391
  0xDE,0x21E9,  0xDF,0x21E6,  0xE0,0x21E8,  0xE1,0x21E7,  0xE2,0x21E9,
392
  0xE3,0x2B00,  0xE4,0x2B01,  0xE5,0x2B03,  0xE6,0x2B02,  0xE7,0x21E6,
393
  0xE8,0x2794,  0xE9,0x21E7,  0xEA,0x21E9,  0xEB,0x2B00,  0xEC,0x2B01,
394
  0xED,0x2B03,  0xEE,0x2B02,  0xEF,0x21E6,  0xF0,0x27E8,  0xF1,0x27E7,
395
  0xF2,0x21E9,
396
  0xF3,0x2B04,  0xF4,0x21F3,  0xF5,0x2B00,  0xF6,0x2B01,  0xF7,0x2B03,
397
  0xF8,0x2B02,  0xF9,0x25AD,  0xFA,0x25AB,  0xFB,0x2717,  0xFC,0x2713,
398
  0xFD,0x2612,  0xFE,0x2611
399
};
400
401
//
402
// For the next one, we stored only the "known" differences between roman and font
403
//
404
/** Internal and Low level: vector (char, unicode) for cursive font
405
406
\note only characters which differs from roman*/
407
static int const s_cursiveIncompleteUnicode[] = {
408
  0xa2,0xBC, 0xa3,0x2153, 0xa4,0x2159, 0xaa,0xBD, 0xc1,0x2154
409
  // 0x40, 0xB0: some number,
410
};
411
412
/** Internal and Low level: vector (char, unicode) for math font
413
414
\note only characters which differs from roman */
415
static int const s_mathIncompleteUnicode[] = {
416
  0x22,0x222A, 0x27,0x222A,  0x28,0x2229, 0x2b,0x2260, 0x31,0x2282,
417
  0x33,0x2227, 0x36,0x2A2F,  0x39,0x2282, 0x43,0x2102, 0x44,0x216E,
418
  0x47,0x0393, 0x49,0x2160,  0x4e,0x2115, 0x52,0x211D, 0x5a,0x2124,
419
  0x63,0x0255, 0x64,0x03B4,  0x65,0x212F, 0x68,0x210E, 0x70,0x01BF,
420
  0x76,0x2174
421
};
422
423
/** Internal and Low level: vector (char, unicode) for scientific font
424
425
\note only characters which differs from roman*/
426
static int const s_scientificIncompleteUnicode[] = {
427
  0x23,0x0394, 0x40,0x221A,  0x49,0x2160, 0x56,0x2164, 0x5c,0x007C,
428
  0x5b,0x2192, 0x5d,0x2192,  0x90,0x211D, 0x91,0x2192, 0xa7,0x03C3,
429
  0xa9,0x03B3, 0xab,0x03F5,  0xad,0x2260, 0xc3,0x03C8, 0xcf,0x03B8,
430
  0xd1,0x223C, 0xd4,0x2192,  0xe3,0x2009, 0xe8,0x00a0, 0xec,0x2303,
431
  0xee,0x2227, 0xef,0x0305,  0xf2,0x2192
432
};
433
434
// other fonts with unknown names :
435
/** Internal and Low level: vector (char, unicode) for font 107
436
437
\note only characters which differs from roman */
438
static int const s_unknown107IncompleteUnicode[] = {
439
  0x76,0x221a
440
};
441
/** Internal and Low level: vector (char, unicode) for font 128
442
443
\note only characters which differs from roman*/
444
static int const s_unknown128IncompleteUnicode[] = {
445
  0x43,0x2102, 0x4e,0x2115, 0x52,0x211D, 0x61,0xFE3F, 0x76,0x2192
446
};
447
/** Internal and Low level: vector (char, unicode) for font 200
448
449
\note only characters which differs from roman */
450
static int const s_unknown200IncompleteUnicode[] = {
451
  0x76,0x2192, 0x77,0x2192, 0x61,0xFE3F
452
};
453
454
//! Internal and Low level: vector (char, unicode) for SJIS font (see MWAWFontSJISConverter )
455
static int const s_SJISSimplifiedUnicode[]= {
456
  0x20,0x0020, 0x21,0x0021, 0x22,0x0022, 0x23,0x0023, 0x24,0x0024, 0x25,0x0025, 0x26,0x0026, 0x27,0x0027,
457
  0x28,0x0028, 0x29,0x0029, 0x2A,0x002A, 0x2B,0x002B, 0x2C,0x002C, 0x2D,0x002D, 0x2E,0x002E, 0x2F,0x002F,
458
  0x30,0x0030, 0x31,0x0031, 0x32,0x0032, 0x33,0x0033, 0x34,0x0034, 0x35,0x0035, 0x36,0x0036, 0x37,0x0037,
459
  0x38,0x0038, 0x39,0x0039, 0x3A,0x003A, 0x3B,0x003B, 0x3C,0x003C, 0x3D,0x003D, 0x3E,0x003E, 0x3F,0x003F,
460
  0x40,0x0040, 0x41,0x0041, 0x42,0x0042, 0x43,0x0043, 0x44,0x0044, 0x45,0x0045, 0x46,0x0046, 0x47,0x0047,
461
  0x48,0x0048, 0x49,0x0049, 0x4A,0x004A, 0x4B,0x004B, 0x4C,0x004C, 0x4D,0x004D, 0x4E,0x004E, 0x4F,0x004F,
462
  0x50,0x0050, 0x51,0x0051, 0x52,0x0052, 0x53,0x0053, 0x54,0x0054, 0x55,0x0055, 0x56,0x0056, 0x57,0x0057,
463
  0x58,0x0058, 0x59,0x0059, 0x5A,0x005A, 0x5B,0x005B, 0x5C,0x00A5, 0x5D,0x005D, 0x5E,0x005E, 0x5F,0x005F,
464
  0x60,0x0060, 0x61,0x0061, 0x62,0x0062, 0x63,0x0063, 0x64,0x0064, 0x65,0x0065, 0x66,0x0066, 0x67,0x0067,
465
  0x68,0x0068, 0x69,0x0069, 0x6A,0x006A, 0x6B,0x006B, 0x6C,0x006C, 0x6D,0x006D, 0x6E,0x006E, 0x6F,0x006F,
466
  0x70,0x0070, 0x71,0x0071, 0x72,0x0072, 0x73,0x0073, 0x74,0x0074, 0x75,0x0075, 0x76,0x0076, 0x77,0x0077,
467
  0x78,0x0078, 0x79,0x0079, 0x7A,0x007A, 0x7B,0x007B, 0x7C,0x007C, 0x7D,0x007D, 0x7E,0x203E, 0x7F,0x007F,
468
  0xA1,0xFF61, 0xA2,0xFF62, 0xA3,0xFF63, 0xA4,0xFF64, 0xA5,0xFF65, 0xA6,0xFF66, 0xA7,0xFF67, 0xA8,0xFF68,
469
  0xA9,0xFF69, 0xAA,0xFF6A, 0xAB,0xFF6B, 0xAC,0xFF6C, 0xAD,0xFF6D, 0xAE,0xFF6E, 0xAF,0xFF6F, 0xB0,0xFF70,
470
  0xB1,0xFF71, 0xB2,0xFF72, 0xB3,0xFF73, 0xB4,0xFF74, 0xB5,0xFF75, 0xB6,0xFF76, 0xB7,0xFF77, 0xB8,0xFF78,
471
  0xB9,0xFF79, 0xBA,0xFF7A, 0xBB,0xFF7B, 0xBC,0xFF7C, 0xBD,0xFF7D, 0xBE,0xFF7E, 0xBF,0xFF7F, 0xC0,0xFF80,
472
  0xC1,0xFF81, 0xC2,0xFF82, 0xC3,0xFF83, 0xC4,0xFF84, 0xC5,0xFF85, 0xC6,0xFF86, 0xC7,0xFF87, 0xC8,0xFF88,
473
  0xC9,0xFF89, 0xCA,0xFF8A, 0xCB,0xFF8B, 0xCC,0xFF8C, 0xCD,0xFF8D, 0xCE,0xFF8E, 0xCF,0xFF8F, 0xD0,0xFF90,
474
  0xD1,0xFF91, 0xD2,0xFF92, 0xD3,0xFF93, 0xD4,0xFF94, 0xD5,0xFF95, 0xD6,0xFF96, 0xD7,0xFF97, 0xD8,0xFF98,
475
  0xD9,0xFF99, 0xDA,0xFF9A, 0xDB,0xFF9B, 0xDC,0xFF9C, 0xDD,0xFF9D, 0xDE,0xFF9E, 0xDF,0xFF9F
476
};
477
478
//
479
// some pc encoding
480
//
481
482
//! Internal and Low Level: the Windows CP1250 encoding
483
static int const s_windowsCP1250Unicode[] = {
484
  0x80,0x20ac,0x82,0x201a,0x84,0x201e,0x85,0x2026,0x86,0x2020,0x87,0x2021,
485
  0x89,0x2030,0x8a,0x160,0x8b,0x2039,0x8c,0x15a,0x8d,0x164,0x8e,0x17d,0x8f,0x179,
486
  0x91,0x2018,0x92,0x2019,0x93,0x201c,0x94,0x201d,0x95,0x2022,0x96,0x2013,0x97,0x2014,
487
  0x99,0x2122,0x9a,0x161,0x9b,0x203a,0x9c,0x15b,0x9d,0x165,0x9e,0x17e,0x9f,0x17a,
488
  0xa1,0x2c7,0xa2,0x2d8,0xa3,0x141,0xa5,0x104,
489
  0xaa,0x15e,0xaf,0x17b,
490
  0xb2,0x2db,0xb3,0x142,
491
  0xb9,0x105,0xba,0x15f,0xbc,0x13d,0xbd,0x2dd,0xbe,0x13e,0xbf,0x17c,
492
  0xc0,0x154,0xc3,0x102,0xc5,0x139,0xc6,0x106,
493
  0xc8,0x10c,0xca,0x118,0xcc,0x11a,0xcf,0x10e,
494
  0xd0,0x110,0xd1,0x143,0xd2,0x147,0xd5,0x150,
495
  0xd8,0x158,0xd9,0x16e,0xdb,0x170,0xde,0x162,
496
  0xe0,0x155,0xe3,0x103,0xe5,0x13a,0xe6,0x107,
497
  0xe8,0x10d,0xea,0x119,0xec,0x11b,0xef,0x10f,
498
  0xf0,0x111,0xf1,0x144,0xf2,0x148,0xf5,0x151,
499
  0xf8,0x159,0xf9,0x16f,0xfb,0x171,0xfe,0x163,0xff,0x2d9
500
};
501
502
//! Internal and Low Level: the Windows CP1251 encoding
503
static int const s_windowsCP1251Unicode[] = {
504
  0x80,0x402, 0x81,0x403, 0x82,0x201a, 0x83,0x453, 0x84,0x201e, 0x85,0x2026, 0x86,0x2020, 0x87,0x2021,
505
  0x88,0x20ac, 0x89,0x2030, 0x8a,0x409, 0x8b,0x2039, 0x8c,0x40a, 0x8d,0x40c, 0x8e,0x40b, 0x8f,0x40f,
506
  0x90,0x452, 0x91,0x2018, 0x92,0x2019, 0x93,0x201c, 0x94,0x201d, 0x95,0x2022, 0x96,0x2013, 0x97,0x2014,
507
  0x99,0x2122, 0x9a,0x459, 0x9b,0x203a, 0x9c,0x45a, 0x9d,0x45c, 0x9e,0x45b, 0x9f,0x45f,
508
  0xa1,0x40e, 0xa2,0x45e, 0xa3,0x408, 0xa5,0x490,
509
  0xa8,0x401, 0xaa,0x404, 0xaf,0x407,
510
  0xb2,0x406, 0xb3,0x456, 0xb4,0x491,
511
  0xb8,0x451, 0xb9,0x2116, 0xba,0x454, 0xbc,0x458, 0xbd,0x405, 0xbe,0x455, 0xbf,0x457,
512
  0xc0,0x410, 0xc1,0x411, 0xc2,0x412, 0xc3,0x413, 0xc4,0x414, 0xc5,0x415, 0xc6,0x416, 0xc7,0x417,
513
  0xc8,0x418, 0xc9,0x419, 0xca,0x41a, 0xcb,0x41b, 0xcc,0x41c, 0xcd,0x41d, 0xce,0x41e, 0xcf,0x41f,
514
  0xd0,0x420, 0xd1,0x421, 0xd2,0x422, 0xd3,0x423, 0xd4,0x424, 0xd5,0x425, 0xd6,0x426, 0xd7,0x427,
515
  0xd8,0x428, 0xd9,0x429, 0xda,0x42a, 0xdb,0x42b, 0xdc,0x42c, 0xdd,0x42d, 0xde,0x42e, 0xdf,0x42f,
516
  0xe0,0x430, 0xe1,0x431, 0xe2,0x432, 0xe3,0x433, 0xe4,0x434, 0xe5,0x435, 0xe6,0x436, 0xe7,0x437,
517
  0xe8,0x438, 0xe9,0x439, 0xea,0x43a, 0xeb,0x43b, 0xec,0x43c, 0xed,0x43d, 0xee,0x43e, 0xef,0x43f,
518
  0xf0,0x440, 0xf1,0x441, 0xf2,0x442, 0xf3,0x443, 0xf4,0x444, 0xf5,0x445, 0xf6,0x446, 0xf7,0x447,
519
  0xf8,0x448, 0xf9,0x449, 0xfa,0x44a, 0xfb,0x44b, 0xfc,0x44c, 0xfd,0x44d, 0xfe,0x44e, 0xff,0x44f
520
};
521
522
//! Internal and Low Level: the Windows CP1252 encoding
523
static int const s_windowsCP1252Unicode[] = {
524
  0x80,0x20ac, 0x82,0x201a, 0x83,0x0192, 0x84,0x201e, 0x85,0x2026, 0x86,0x2020, 0x87,0x2021,
525
  0x88,0x02c6, 0x89,0x2030, 0x8a,0x0160, 0x8b,0x2039, 0x8c,0x0152, 0x8e,0x017d,
526
  0x91,0x2018, 0x92,0x2019, 0x93,0x201c, 0x94,0x201d, 0x95,0x2022, 0x96,0x2013, 0x97,0x2014,
527
  0x98,0x02dc, 0x99,0x2122, 0x9a,0x0161, 0x9b,0x203a, 0x9c,0x0153, 0x9e,0x017e, 0x9f,0x0178
528
};
529
530
//! Internal and Low Level: the Windows CP1253 encoding
531
static int const s_windowsCP1253Unicode[] = {
532
  0x80,0x20ac, 0x82,0x201a, 0x83,0x192, 0x84,0x201e, 0x85,0x2026, 0x86,0x2020, 0x87,0x2021,
533
  0x89,0x2030, 0x8b,0x2039,
534
  0x91,0x2018, 0x92,0x2019, 0x93,0x201c, 0x94,0x201d, 0x95,0x2022, 0x96,0x2013, 0x97,0x2014,
535
  0x99,0x2122, 0x9b,0x203a,
536
  0xa1,0x385, 0xa2,0x386,
537
  0xaf,0x2015,
538
  0xb4,0x384,
539
  0xb8,0x388, 0xb9,0x389, 0xba,0x38a, 0xbc,0x38c, 0xbe,0x38e, 0xbf,0x38f,
540
  0xc0,0x390, 0xc1,0x391, 0xc2,0x392, 0xc3,0x393, 0xc4,0x394, 0xc5,0x395, 0xc6,0x396, 0xc7,0x397,
541
  0xc8,0x398, 0xc9,0x399, 0xca,0x39a, 0xcb,0x39b, 0xcc,0x39c, 0xcd,0x39d, 0xce,0x39e, 0xcf,0x39f,
542
  0xd0,0x3a0, 0xd1,0x3a1, 0xd3,0x3a3, 0xd4,0x3a4, 0xd5,0x3a5, 0xd6,0x3a6, 0xd7,0x3a7,
543
  0xd8,0x3a8, 0xd9,0x3a9, 0xda,0x3aa, 0xdb,0x3ab, 0xdc,0x3ac, 0xdd,0x3ad, 0xde,0x3ae, 0xdf,0x3af,
544
  0xe0,0x3b0, 0xe1,0x3b1, 0xe2,0x3b2, 0xe3,0x3b3, 0xe4,0x3b4, 0xe5,0x3b5, 0xe6,0x3b6, 0xe7,0x3b7,
545
  0xe8,0x3b8, 0xe9,0x3b9, 0xea,0x3ba, 0xeb,0x3bb, 0xec,0x3bc, 0xed,0x3bd, 0xee,0x3be, 0xef,0x3bf,
546
  0xf0,0x3c0, 0xf1,0x3c1, 0xf2,0x3c2, 0xf3,0x3c3, 0xf4,0x3c4, 0xf5,0x3c5, 0xf6,0x3c6, 0xf7,0x3c7,
547
  0xf8,0x3c8, 0xf9,0x3c9, 0xfa,0x3ca, 0xfb,0x3cb, 0xfc,0x3cc, 0xfd,0x3cd, 0xfe,0x3ce
548
};
549
550
551
//! Internal and Low Level: the Windows CP1254 encoding
552
static int const s_windowsCP1254Unicode[] = {
553
  0x80,0x20ac, 0x82,0x201a, 0x83,0x192, 0x84,0x201e, 0x85,0x2026, 0x86,0x2020, 0x87,0x2021,
554
  0x88,0x2c6, 0x89,0x2030, 0x8a,0x160, 0x8b,0x2039, 0x8c,0x152,
555
  0x91,0x2018, 0x92,0x2019, 0x93,0x201c, 0x94,0x201d, 0x95,0x2022, 0x96,0x2013, 0x97,0x2014,
556
  0x98,0x2dc, 0x99,0x2122, 0x9a,0x161, 0x9b,0x203a, 0x9c,0x153, 0x9f,0x178,
557
  0xd0,0x11e,
558
  0xdd,0x130, 0xde,0x15e,
559
  0xf0,0x11f,
560
  0xfd,0x131, 0xfe,0x15f
561
};
562
563
//! Internal and Low Level: the Windows CP1255 encoding
564
static int const s_windowsCP1255Unicode[] = {
565
  0x80,0x20ac, 0x82,0x201a, 0x83,0x192, 0x84,0x201e, 0x85,0x2026, 0x86,0x2020, 0x87,0x2021,
566
  0x88,0x2c6, 0x89,0x2030, 0x8b,0x2039,
567
  0x91,0x2018, 0x92,0x2019, 0x93,0x201c, 0x94,0x201d, 0x95,0x2022, 0x96,0x2013, 0x97,0x2014,
568
  0x98,0x2dc, 0x99,0x2122, 0x9b,0x203a,
569
  0xa4,0x20aa,
570
  0xaa,0xd7,
571
  0xba,0xf7,
572
  0xc0,0x5b0, 0xc1,0x5b1, 0xc2,0x5b2, 0xc3,0x5b3, 0xc4,0x5b4, 0xc5,0x5b5, 0xc6,0x5b6, 0xc7,0x5b7,
573
  0xc8,0x5b8, 0xc9,0x5b9, 0xcb,0x5bb, 0xcc,0x5bc, 0xcd,0x5bd, 0xce,0x5be, 0xcf,0x5bf,
574
  0xd0,0x5c0, 0xd1,0x5c1, 0xd2,0x5c2, 0xd3,0x5c3, 0xd4,0x5f0, 0xd5,0x5f1, 0xd6,0x5f2, 0xd7,0x5f3,
575
  0xd8,0x5f4,
576
  0xe0,0x5d0, 0xe1,0x5d1, 0xe2,0x5d2, 0xe3,0x5d3, 0xe4,0x5d4, 0xe5,0x5d5, 0xe6,0x5d6, 0xe7,0x5d7,
577
  0xe8,0x5d8, 0xe9,0x5d9, 0xea,0x5da, 0xeb,0x5db, 0xec,0x5dc, 0xed,0x5dd, 0xee,0x5de, 0xef,0x5df,
578
  0xf0,0x5e0, 0xf1,0x5e1, 0xf2,0x5e2, 0xf3,0x5e3, 0xf4,0x5e4, 0xf5,0x5e5, 0xf6,0x5e6, 0xf7,0x5e7,
579
  0xf8,0x5e8, 0xf9,0x5e9, 0xfa,0x5ea, 0xfd,0x200e, 0xfe,0x200f
580
};
581
582
//! Internal and Low Level: the Windows CP1256 encoding
583
static int const s_windowsCP1256Unicode[] = {
584
  0x80,0x20ac, 0x81,0x67e, 0x82,0x201a, 0x83,0x192, 0x84,0x201e, 0x85,0x2026, 0x86,0x2020, 0x87,0x2021,
585
  0x88,0x2c6, 0x89,0x2030, 0x8a,0x679, 0x8b,0x2039, 0x8c,0x152, 0x8d,0x686, 0x8e,0x698, 0x8f,0x688,
586
  0x90,0x6af, 0x91,0x2018, 0x92,0x2019, 0x93,0x201c, 0x94,0x201d, 0x95,0x2022, 0x96,0x2013, 0x97,0x2014,
587
  0x98,0x6a9, 0x99,0x2122, 0x9a,0x691, 0x9b,0x203a, 0x9c,0x153, 0x9d,0x200c, 0x9e,0x200d, 0x9f,0x6ba,
588
  0xa1,0x60c,
589
  0xaa,0x6be,
590
  0xba,0x61b, 0xbf,0x61f,
591
  0xc0,0x6c1, 0xc1,0x621, 0xc2,0x622, 0xc3,0x623, 0xc4,0x624, 0xc5,0x625, 0xc6,0x626, 0xc7,0x627,
592
  0xc8,0x628, 0xc9,0x629, 0xca,0x62a, 0xcb,0x62b, 0xcc,0x62c, 0xcd,0x62d, 0xce,0x62e, 0xcf,0x62f,
593
  0xd0,0x630, 0xd1,0x631, 0xd2,0x632, 0xd3,0x633, 0xd4,0x634, 0xd5,0x635, 0xd6,0x636,
594
  0xd8,0x637, 0xd9,0x638, 0xda,0x639, 0xdb,0x63a, 0xdc,0x640, 0xdd,0x641, 0xde,0x642, 0xdf,0x643,
595
  0xe1,0x644, 0xe3,0x645, 0xe4,0x646, 0xe5,0x647, 0xe6,0x648,
596
  0xec,0x649, 0xed,0x64a,
597
  0xf0,0x64b, 0xf1,0x64c, 0xf2,0x64d, 0xf3,0x64e, 0xf5,0x64f, 0xf6,0x650,
598
  0xf8,0x651, 0xfa,0x652, 0xfd,0x200e, 0xfe,0x200f, 0xff,0x6d2
599
};
600
601
//! Internal and Low Level: the Windows CP1257 encoding
602
static int const s_windowsCP1257Unicode[] = {
603
  0x80,0x20ac, 0x82,0x201a, 0x84,0x201e, 0x85,0x2026, 0x86,0x2020, 0x87,0x2021,
604
  0x89,0x2030, 0x8b,0x2039, 0x8d,0xa8, 0x8e,0x2c7, 0x8f,0xb8,
605
  0x91,0x2018, 0x92,0x2019, 0x93,0x201c, 0x94,0x201d, 0x95,0x2022, 0x96,0x2013, 0x97,0x2014,
606
  0x99,0x2122, 0x9b,0x203a, 0x9d,0xaf, 0x9e,0x2db,
607
  0xa8,0xd8, 0xaa,0x156, 0xaf,0xc6,
608
  0xb8,0xf8, 0xba,0x157, 0xbf,0xe6,
609
  0xc0,0x104, 0xc1,0x12e, 0xc2,0x100, 0xc3,0x106, 0xc6,0x118, 0xc7,0x112,
610
  0xc8,0x10c, 0xca,0x179, 0xcb,0x116, 0xcc,0x122, 0xcd,0x136, 0xce,0x12a, 0xcf,0x13b,
611
  0xd0,0x160, 0xd1,0x143, 0xd2,0x145, 0xd4,0x14c,
612
  0xd8,0x172, 0xd9,0x141, 0xda,0x15a, 0xdb,0x16a, 0xdd,0x17b, 0xde,0x17d,
613
  0xe0,0x105, 0xe1,0x12f, 0xe2,0x101, 0xe3,0x107, 0xe6,0x119, 0xe7,0x113,
614
  0xe8,0x10d, 0xea,0x17a, 0xeb,0x117, 0xec,0x123, 0xed,0x137, 0xee,0x12b, 0xef,0x13c,
615
  0xf0,0x161, 0xf1,0x144, 0xf2,0x146, 0xf4,0x14d,
616
  0xf8,0x173, 0xf9,0x142, 0xfa,0x15b, 0xfb,0x16b, 0xfd,0x17c, 0xfe,0x17e, 0xff,0x2d9
617
};
618
619
//! Internal and Low Level: the Windows CP1258 encoding
620
static int const s_windowsCP1258Unicode[] = {
621
  0x80,0x20ac, 0x82,0x201a, 0x83,0x192, 0x84,0x201e, 0x85,0x2026, 0x86,0x2020, 0x87,0x2021,
622
  0x88,0x2c6, 0x89,0x2030, 0x8b,0x2039, 0x8c,0x152,
623
  0x91,0x2018, 0x92,0x2019, 0x93,0x201c, 0x94,0x201d, 0x95,0x2022, 0x96,0x2013, 0x97,0x2014,
624
  0x98,0x2dc, 0x99,0x2122, 0x9b,0x203a, 0x9c,0x153, 0x9f,0x178,
625
  0xc3,0x102,
626
  0xcc,0x300,
627
  0xd0,0x110, 0xd2,0x309, 0xd5,0x1a0,
628
  0xdd,0x1af, 0xde,0x303,
629
  0xe3,0x103,
630
  0xec,0x301,
631
  0xf0,0x111, 0xf2,0x323, 0xf5,0x1a1,
632
  0xfd,0x1b0, 0xfe,0x20ab
633
};
634
635
class KnownConversion
636
{
637
public:
638
  //! constructor
639
  KnownConversion()
640
1.99M
    : m_convertMap()
641
1.99M
    , m_familyMap()
642
1.99M
    , m_romanMap()
643
1.99M
    , m_centralEuroMap()
644
1.99M
    , m_cyrillicMap()
645
1.99M
    , m_turkishMap()
646
1.99M
    , m_symbolMap()
647
1.99M
    , m_dingbatsMap()
648
1.99M
    , m_cursiveMap()
649
1.99M
    , m_mathMap()
650
1.99M
    , m_monotypeSortsMap()
651
1.99M
    , m_scientificMap()
652
1.99M
    , m_wingdingsMap()
653
1.99M
    , m_SJISMap()
654
1.99M
    , m_unknown107Map()
655
1.99M
    , m_unknown128Map()
656
1.99M
    , m_unknown200Map()
657
1.99M
    , m_windowsCP1250Map()
658
1.99M
    , m_windowsCP1251Map()
659
1.99M
    , m_windowsCP1252Map()
660
1.99M
    , m_windowsCP1253Map()
661
1.99M
    , m_windowsCP1254Map()
662
1.99M
    , m_windowsCP1255Map()
663
1.99M
    , m_windowsCP1256Map()
664
1.99M
    , m_windowsCP1257Map()
665
1.99M
    , m_windowsCP1258Map()
666
667
1.99M
    , m_defaultConv(m_romanMap)
668
1.99M
    , m_centralEuroConv(m_centralEuroMap)
669
1.99M
    , m_cyrillicConv(m_cyrillicMap)
670
1.99M
    , m_turkishConv(m_turkishMap)
671
1.99M
    , m_timeConv(m_romanMap,"Times New Roman")
672
1.99M
    , m_zapfChanceryConv(m_romanMap,"Apple Chancery", -2)
673
1.99M
    , m_symbolConv(m_symbolMap)
674
1.99M
    , m_dingbatsConv(m_dingbatsMap)
675
1.99M
    , m_cursiveConv(m_cursiveMap,"Apple Chancery")
676
1.99M
    , m_mathConv(m_mathMap)
677
1.99M
    , m_monotypeSortsConv(m_monotypeSortsMap, "Monotype Sorts")
678
1.99M
    , m_scientificConv(m_scientificMap)
679
1.99M
    , m_wingdingsConv(m_wingdingsMap)
680
1.99M
    , m_SJISConv(m_SJISMap, MWAWFontConverter::E_SJIS)
681
1.99M
    , m_unknown107Conv(m_unknown107Map)
682
1.99M
    , m_unknown128Conv(m_unknown128Map)
683
1.99M
    , m_unknown200Conv(m_unknown200Map)
684
1.99M
    , m_windowsCP1250Conv(m_windowsCP1250Map)
685
1.99M
    , m_windowsCP1251Conv(m_windowsCP1251Map)
686
1.99M
    , m_windowsCP1252Conv(m_windowsCP1252Map)
687
1.99M
    , m_windowsCP1253Conv(m_windowsCP1253Map)
688
1.99M
    , m_windowsCP1254Conv(m_windowsCP1254Map)
689
1.99M
    , m_windowsCP1255Conv(m_windowsCP1255Map)
690
1.99M
    , m_windowsCP1256Conv(m_windowsCP1256Map)
691
1.99M
    , m_windowsCP1257Conv(m_windowsCP1257Map)
692
1.99M
    , m_windowsCP1258Conv(m_windowsCP1258Map)
693
1.99M
  {
694
1.99M
    initMaps();
695
1.99M
  }
696
  //! returns the conversion map which corresponds to a name, or the default map
697
  Data::ConversionData const &getConversionMaps(std::string fName);
698
699
  //! set a family correspondance
700
  void setFamily(std::string const &fName, std::string const &family)
701
59.3k
  {
702
59.3k
    if (fName.length() && family.length())
703
59.3k
      m_familyMap[fName]=family;
704
59.3k
  }
705
  //! return the default converter
706
  ConversionData const &getDefault() const
707
0
  {
708
0
    return m_defaultConv;
709
0
  }
710
protected:
711
  //! Internal and Low level: initializes all the conversion maps
712
  void initMaps();
713
714
  //! Internal and Low level: initializes a map with a vector of \a numElt elements (char, unicode)
715
  static void initAMap(int const *arr, size_t numElt, std::map<unsigned char, unsigned long> &map)
716
45.8M
  {
717
4.22G
    for (size_t i = 0; i < numElt; i++) {
718
4.17G
      auto c = static_cast<unsigned char>(arr[2*i]);
719
4.17G
      auto unicode = static_cast<unsigned long>(arr[2*i+1]);
720
4.17G
      map[c] = unicode;
721
4.17G
    }
722
45.8M
  }
723
724
  /** the conversiont map fName -> ConversionData */
725
  std::map<std::string, ConversionData const *> m_convertMap;
726
727
  //! Internal and Low level: map font name -> family font name
728
  std::map<std::string, std::string> m_familyMap;
729
730
  //! Internal and Low level: map char -> unicode for roman font
731
  std::map<unsigned char, unsigned long> m_romanMap;
732
  //! Internal and Low level: map char -> unicode for central european font
733
  std::map<unsigned char, unsigned long> m_centralEuroMap;
734
  //! Internal and Low level: map char -> unicode for cyrillic font
735
  std::map<unsigned char, unsigned long> m_cyrillicMap;
736
  //! Internal and Low level: map char -> unicode for turkish font
737
  std::map<unsigned char, unsigned long> m_turkishMap;
738
739
  //! Internal and Low level: map char -> unicode for symbol font
740
  std::map<unsigned char, unsigned long> m_symbolMap;
741
  //! Internal and Low level: map char -> unicode for dingbats font
742
  std::map<unsigned char, unsigned long> m_dingbatsMap;
743
  //! Internal and Low level: map char -> unicode for cursive font
744
  std::map<unsigned char, unsigned long> m_cursiveMap;
745
  //! Internal and Low level: map char -> unicode for math font
746
  std::map<unsigned char, unsigned long> m_mathMap;
747
  //! Internal and Low level: map char -> unicode for monotypeSorts font
748
  std::map<unsigned char, unsigned long> m_monotypeSortsMap;
749
  //! Internal and Low level: map char -> unicode for scientific font
750
  std::map<unsigned char, unsigned long> m_scientificMap;
751
  //! Internal and Low level: map char -> unicode for wingdings font
752
  std::map<unsigned char, unsigned long> m_wingdingsMap;
753
  //! Internal and Low level: simplified map char -> unicode for SJIS font
754
  std::map<unsigned char, unsigned long> m_SJISMap;
755
  //! Internal and Low level: map char -> unicode for font 107
756
  std::map<unsigned char, unsigned long> m_unknown107Map;
757
  //! Internal and Low level: map char -> unicode for font 128
758
  std::map<unsigned char, unsigned long> m_unknown128Map;
759
  //! Internal and Low level: map char -> unicode for font 200
760
  std::map<unsigned char, unsigned long> m_unknown200Map;
761
  //! Internal and Low level: map char -> unicode for Windows CP1250
762
  std::map<unsigned char, unsigned long> m_windowsCP1250Map;
763
  //! Internal and Low level: map char -> unicode for Windows CP1251
764
  std::map<unsigned char, unsigned long> m_windowsCP1251Map;
765
  //! Internal and Low level: map char -> unicode for Windows CP1252
766
  std::map<unsigned char, unsigned long> m_windowsCP1252Map;
767
  //! Internal and Low level: map char -> unicode for Windows CP1253
768
  std::map<unsigned char, unsigned long> m_windowsCP1253Map;
769
  //! Internal and Low level: map char -> unicode for Windows CP1254
770
  std::map<unsigned char, unsigned long> m_windowsCP1254Map;
771
  //! Internal and Low level: map char -> unicode for Windows CP1255
772
  std::map<unsigned char, unsigned long> m_windowsCP1255Map;
773
  //! Internal and Low level: map char -> unicode for Windows CP1256
774
  std::map<unsigned char, unsigned long> m_windowsCP1256Map;
775
  //! Internal and Low level: map char -> unicode for Windows CP1257
776
  std::map<unsigned char, unsigned long> m_windowsCP1257Map;
777
  //! Internal and Low level: map char -> unicode for Windows CP1258
778
  std::map<unsigned char, unsigned long> m_windowsCP1258Map;
779
780
  //! Internal and Low level: the default converter: roman
781
  ConversionData m_defaultConv;
782
  //! Internal and Low level: the default converter: central european
783
  ConversionData m_centralEuroConv;
784
  //! Internal and Low level: the default converter: cyrillic
785
  ConversionData m_cyrillicConv;
786
  //! Internal and Low level: the default converter: turkish
787
  ConversionData m_turkishConv;
788
789
  //! Internal and Low level: the converter for times font
790
  ConversionData m_timeConv;
791
  //! Internal and Low level: the converter for zapfChancery font
792
  ConversionData m_zapfChanceryConv;
793
  //! Internal and Low level: the converter for symbol font
794
  ConversionData m_symbolConv;
795
  //! Internal and Low level: the converter for dingbats font
796
  ConversionData m_dingbatsConv;
797
  //! Internal and Low level: the converter for cursive font
798
  ConversionData m_cursiveConv;
799
  //! Internal and Low level: the converter for math font
800
  ConversionData m_mathConv;
801
  //! Internal and Low level: the converter for monotypeSorts font
802
  ConversionData m_monotypeSortsConv;
803
  //! Internal and Low level: the converter for scientific font
804
  ConversionData m_scientificConv;
805
  //! Internal and Low level: the converter for wingdings font
806
  ConversionData m_wingdingsConv;
807
  //! Internal and Low level: the converter for SJIS font
808
  ConversionData m_SJISConv;
809
  //! Internal and Low level: the converter for font 107
810
  ConversionData m_unknown107Conv;
811
  //! Internal and Low level: the converter for font 128
812
  ConversionData m_unknown128Conv;
813
  //! Internal and Low level: the converter for font 200
814
  ConversionData m_unknown200Conv;
815
816
  //! Internal and Low level: the converter for Windows CP1250
817
  ConversionData m_windowsCP1250Conv;
818
  //! Internal and Low level: the converter for Windows CP1251
819
  ConversionData m_windowsCP1251Conv;
820
  //! Internal and Low level: the converter for Windows CP1252
821
  ConversionData m_windowsCP1252Conv;
822
  //! Internal and Low level: the converter for Windows CP1253
823
  ConversionData m_windowsCP1253Conv;
824
  //! Internal and Low level: the converter for Windows CP1254
825
  ConversionData m_windowsCP1254Conv;
826
  //! Internal and Low level: the converter for Windows CP1255
827
  ConversionData m_windowsCP1255Conv;
828
  //! Internal and Low level: the converter for Windows CP1256
829
  ConversionData m_windowsCP1256Conv;
830
  //! Internal and Low level: the converter for Windows CP1257
831
  ConversionData m_windowsCP1257Conv;
832
  //! Internal and Low level: the converter for Windows CP1258
833
  ConversionData m_windowsCP1258Conv;
834
};
835
836
837
//! Internal and Low level: initializes all the conversion maps
838
void KnownConversion::initMaps()
839
1.99M
{
840
1.99M
  size_t numRoman = sizeof(s_romanUnicode)/(2*sizeof(int));
841
448M
  for (size_t i = 0; i < numRoman; i++) {
842
446M
    auto c = static_cast<unsigned char>(s_romanUnicode[2*i]);
843
446M
    auto unicode = static_cast<unsigned long>(s_romanUnicode[2*i+1]);
844
446M
    m_romanMap[c] = m_turkishMap[c] = unicode;
845
446M
    m_cursiveMap[c] = m_mathMap[c] = m_scientificMap[c] = unicode;
846
446M
    m_unknown107Map[c] = m_unknown128Map[c] = m_unknown200Map[c] = unicode;
847
446M
  }
848
448M
  for (unsigned long c=0x20; c<=0xff; ++c)
849
446M
    m_windowsCP1250Map[static_cast<unsigned char>(c)]=m_windowsCP1251Map[static_cast<unsigned char>(c)]=
850
446M
          m_windowsCP1252Map[static_cast<unsigned char>(c)]=m_windowsCP1253Map[static_cast<unsigned char>(c)]=
851
446M
                m_windowsCP1254Map[static_cast<unsigned char>(c)]=m_windowsCP1255Map[static_cast<unsigned char>(c)]=
852
446M
                      m_windowsCP1256Map[static_cast<unsigned char>(c)]=m_windowsCP1257Map[static_cast<unsigned char>(c)]=
853
446M
                            m_windowsCP1258Map[static_cast<unsigned char>(c)]=c;
854
1.99M
  initAMap(s_centralEuroUnicode, sizeof(s_centralEuroUnicode)/(2*sizeof(int)), m_centralEuroMap);
855
1.99M
  initAMap(s_cyrillicUnicode, sizeof(s_cyrillicUnicode)/(2*sizeof(int)), m_cyrillicMap);
856
1.99M
  initAMap(s_turkishUnicode, sizeof(s_turkishUnicode)/(2*sizeof(int)), m_turkishMap);
857
858
1.99M
  initAMap(s_symbolUnicode, sizeof(s_symbolUnicode)/(2*sizeof(int)), m_symbolMap);
859
1.99M
  initAMap(s_dingbatsUnicode, sizeof(s_dingbatsUnicode)/(2*sizeof(int)), m_dingbatsMap);
860
1.99M
  initAMap(s_cursiveIncompleteUnicode, sizeof(s_cursiveIncompleteUnicode)/(2*sizeof(int)), m_cursiveMap);
861
1.99M
  initAMap(s_mathIncompleteUnicode, sizeof(s_mathIncompleteUnicode)/(2*sizeof(int)), m_mathMap);
862
1.99M
  initAMap(s_monotypeSortsUnicode, sizeof(s_monotypeSortsUnicode)/(2*sizeof(int)), m_monotypeSortsMap);
863
1.99M
  initAMap(s_scientificIncompleteUnicode, sizeof(s_scientificIncompleteUnicode)/(2*sizeof(int)),m_scientificMap);
864
1.99M
  initAMap(s_wingdingsUnicode, sizeof(s_wingdingsUnicode)/(2*sizeof(int)), m_wingdingsMap);
865
1.99M
  initAMap(s_SJISSimplifiedUnicode, sizeof(s_SJISSimplifiedUnicode)/(2*sizeof(int)), m_SJISMap);
866
1.99M
  initAMap(s_unknown107IncompleteUnicode, sizeof(s_unknown107IncompleteUnicode)/(2*sizeof(int)),m_unknown107Map);
867
1.99M
  initAMap(s_unknown128IncompleteUnicode, sizeof(s_unknown128IncompleteUnicode)/(2*sizeof(int)),m_unknown128Map);
868
1.99M
  initAMap(s_unknown200IncompleteUnicode, sizeof(s_unknown200IncompleteUnicode)/(2*sizeof(int)),m_unknown200Map);
869
1.99M
  initAMap(s_windowsCP1250Unicode, sizeof(s_windowsCP1250Unicode)/(2*sizeof(int)),m_windowsCP1250Map);
870
1.99M
  initAMap(s_windowsCP1251Unicode, sizeof(s_windowsCP1251Unicode)/(2*sizeof(int)),m_windowsCP1251Map);
871
1.99M
  initAMap(s_windowsCP1252Unicode, sizeof(s_windowsCP1252Unicode)/(2*sizeof(int)),m_windowsCP1252Map);
872
1.99M
  initAMap(s_windowsCP1253Unicode, sizeof(s_windowsCP1253Unicode)/(2*sizeof(int)),m_windowsCP1253Map);
873
1.99M
  initAMap(s_windowsCP1254Unicode, sizeof(s_windowsCP1254Unicode)/(2*sizeof(int)),m_windowsCP1254Map);
874
1.99M
  initAMap(s_windowsCP1255Unicode, sizeof(s_windowsCP1255Unicode)/(2*sizeof(int)),m_windowsCP1255Map);
875
1.99M
  initAMap(s_windowsCP1256Unicode, sizeof(s_windowsCP1256Unicode)/(2*sizeof(int)),m_windowsCP1256Map);
876
1.99M
  initAMap(s_windowsCP1257Unicode, sizeof(s_windowsCP1257Unicode)/(2*sizeof(int)),m_windowsCP1257Map);
877
1.99M
  initAMap(s_windowsCP1258Unicode, sizeof(s_windowsCP1258Unicode)/(2*sizeof(int)),m_windowsCP1258Map);
878
879
  // init convertMap
880
1.99M
  m_convertMap[std::string("Default")] = &m_defaultConv;
881
1.99M
  m_convertMap[std::string("Times")] = &m_timeConv;
882
1.99M
  m_convertMap[std::string("Zapf Chancery")] = &m_zapfChanceryConv;
883
1.99M
  m_convertMap[std::string("Symbol")] = &m_symbolConv;
884
1.99M
  m_convertMap[std::string("Zapf Dingbats")] = &m_dingbatsConv;
885
1.99M
  m_convertMap[std::string("Cursive")] = &m_cursiveConv;
886
1.99M
  m_convertMap[std::string("Math")] = &m_mathConv;
887
1.99M
  m_convertMap[std::string("Monotype Sorts")] = &m_monotypeSortsConv;
888
1.99M
  m_convertMap[std::string("scientific")] = &m_scientificConv;
889
1.99M
  m_convertMap[std::string("Wingdings")] = &m_wingdingsConv;
890
1.99M
  m_convertMap[std::string("Osaka")] = &m_SJISConv;
891
1.99M
  m_convertMap[std::string("Unknown107")] = &m_unknown107Conv;
892
1.99M
  m_convertMap[std::string("Unknown128")] = &m_unknown128Conv;
893
1.99M
  m_convertMap[std::string("Unknown200")] = &m_unknown200Conv;
894
895
1.99M
  m_convertMap[std::string("CP1250")] = &m_windowsCP1250Conv;
896
1.99M
  m_convertMap[std::string("CP1251")] = &m_windowsCP1251Conv;
897
1.99M
  m_convertMap[std::string("CP1252")] = &m_windowsCP1252Conv;
898
1.99M
  m_convertMap[std::string("CP1253")] = &m_windowsCP1253Conv;
899
1.99M
  m_convertMap[std::string("CP1254")] = &m_windowsCP1254Conv;
900
1.99M
  m_convertMap[std::string("CP1255")] = &m_windowsCP1255Conv;
901
1.99M
  m_convertMap[std::string("CP1256")] = &m_windowsCP1256Conv;
902
1.99M
  m_convertMap[std::string("CP1257")] = &m_windowsCP1257Conv;
903
1.99M
  m_convertMap[std::string("CP1258")] = &m_windowsCP1258Conv;
904
905
1.99M
  m_convertMap[std::string("APC Courier")] = & m_cyrillicConv;
906
1.99M
  m_convertMap[std::string("Baston CYR")] = & m_cyrillicConv; // similar to Helvetica
907
1.99M
  m_convertMap[std::string("Latinskij")] = & m_cyrillicConv;  // similar to Times
908
1.99M
  m_convertMap[std::string("Priamoj")] = & m_cyrillicConv;  // similar to Monaco
909
1.99M
  m_convertMap[std::string("Priamoj Prop")] = & m_cyrillicConv; // similar to Geneva
910
1.99M
  m_convertMap[std::string("Sistemnyj")] = & m_cyrillicConv; // similar to Chicago
911
912
1.99M
  m_familyMap["Osaka Tohaba"]="Osaka";
913
1.99M
  m_familyMap["Hei"]="Osaka"; // checkme
914
1.99M
  m_familyMap["Heisei Mincho"]="Osaka";
915
1.99M
  m_familyMap["Heisei KakuGothic"]="Osaka";
916
1.99M
  m_familyMap["Heiti SC Light"]="Osaka"; // checkme
917
1.99M
  m_familyMap["Heiti SC Medium"]="Osaka"; // checkme
918
1.99M
  m_familyMap["Hiragino KakuGothic ProN W3"]="Osaka";
919
1.99M
  m_familyMap["Hiragino MaruGo W3"]="Osaka";
920
1.99M
  m_familyMap["Hiragino MaruGo W4"]="Osaka";
921
1.99M
  m_familyMap["Hiragino MaruGo W6"]="Osaka";
922
1.99M
  m_familyMap["Hiragino Kakugo W3"]="Osaka";
923
1.99M
  m_familyMap["Hiragino Kakugo W6"]="Osaka";
924
1.99M
  m_familyMap["Hiragino Kakugo W8"]="Osaka";
925
1.99M
  m_familyMap["Hiragino San GB W3"]="Osaka"; // checkme
926
1.99M
  m_familyMap["Hiragino San GB W6"]="Osaka"; // checkme
927
1.99M
}
928
929
ConversionData const &KnownConversion::getConversionMaps(std::string fName)
930
44.7M
{
931
44.7M
  if (fName.empty()) return m_defaultConv;
932
26.0M
  auto it= m_convertMap.find(fName);
933
26.0M
  if (it != m_convertMap.end()) return *(it->second);
934
935
  // look for a family map
936
13.8M
  auto famIt= m_familyMap.find(fName);
937
13.8M
  if (famIt == m_familyMap.end()) {
938
    // checkme maybe ok for pre-OS7, ... but not for WorldScript
939
13.6M
    size_t len=fName.length();
940
13.6M
    if (len > 4 && fName.substr(len-4,4)==" CYR")
941
7.45k
      return m_cyrillicConv;
942
13.6M
    if (len > 3 && fName[len-3]==' ') {
943
31.9k
      if (fName.substr(len-3,3)==" CE")
944
3.05k
        return m_centralEuroConv;
945
28.9k
      if (fName.substr(len-3,3)==" CY")
946
4.35k
        return m_cyrillicConv;
947
24.5k
      if (fName.substr(len-3,3)==" TC")
948
1.41k
        return m_turkishConv;
949
24.5k
    }
950
13.6M
    return m_defaultConv;
951
13.6M
  }
952
241k
  fName = famIt->second;
953
241k
  it= m_convertMap.find(fName);
954
241k
  if (it != m_convertMap.end()) return *(it->second);
955
0
  return  m_defaultConv;
956
241k
}
957
958
}
959
960
//------------------------------------------------------------
961
//
962
// Font convertor imlementation
963
//
964
//------------------------------------------------------------
965
//! the default font converter
966
class State
967
{
968
public:
969
  //! the constructor
970
  State()
971
1.99M
    : m_knownConversion()
972
1.99M
    , m_idNameMap()
973
1.99M
    , m_nameIdMap()
974
1.99M
    , m_nameTranslatedNameMap()
975
1.99M
    , m_nameIdCounter(0)
976
1.99M
    , m_uniqueId(768)
977
1.99M
    , m_sjisConverter()
978
1.99M
    , m_unicodeCache()
979
1.99M
  {
980
1.99M
    initMaps();
981
1.99M
  }
982
983
  /** returns an unused id */
984
  int getUnusedId()
985
578k
  {
986
1.14M
    while (m_idNameMap.find(m_uniqueId)!=m_idNameMap.end())
987
562k
      m_uniqueId++;
988
578k
    return m_uniqueId;
989
578k
  }
990
991
  /** returns the identificator for a name,
992
  if not set creates one */
993
  int getId(std::string const &name, std::string const &family="")
994
1.38M
  {
995
1.38M
    if (name.empty()) return -1;
996
1.37M
    auto it=m_nameIdMap.find(name);
997
1.37M
    if (it != m_nameIdMap.end()) return it->second;
998
578k
    int newId=getUnusedId();
999
578k
    setCorrespondance(newId, name, family);
1000
578k
    return newId;
1001
1.37M
  }
1002
1003
  //! returns the name corresponding to an id or return std::string("")
1004
  std::string getName(int macId)
1005
84.1M
  {
1006
84.1M
    auto it=m_idNameMap.find(macId);
1007
84.1M
    if (it==m_idNameMap.end()) return "";
1008
29.7M
    return it->second;
1009
84.1M
  }
1010
1011
  /* converts a character in unicode
1012
     \return -1 if the character is not transformed */
1013
  int unicode(int macId, unsigned char c);
1014
  /* converts a character in unicode, if needed can read the next input caracter
1015
     \return -1 if the character is not transformed */
1016
  int unicode(int macId, unsigned char c, MWAWInputStreamPtr &input);
1017
1018
  /** converts a character in unicode, if needed can read the next input caracter in str
1019
      \return -1 if the character is not transformed */
1020
  int unicode(int macId, unsigned char c, unsigned char const *(&str), int len);
1021
  /** final font name and a delta which can be used to change the size
1022
  if no name is found, return "Times New Roman" */
1023
  void getOdtInfo(int macId, std::string &nm, int &deltaSize);
1024
1025
  //! fixes the name corresponding to an id
1026
  void setCorrespondance(int macId, std::string const &name, std::string const &family="")
1027
1.22M
  {
1028
1.22M
    m_idNameMap[macId] = name;
1029
1.22M
    m_nameIdMap[name] = macId;
1030
1.22M
    m_nameIdCounter++;
1031
1.22M
    if (family.length())
1032
59.3k
      m_knownConversion.setFamily(name,family);
1033
1.22M
  }
1034
1035
  /** check if a string is valid, if not, convert it to a valid string */
1036
  std::string getValidName(std::string const &name) const
1037
2.02M
  {
1038
2.02M
    if (m_nameTranslatedNameMap.count(name))
1039
0
      return m_nameTranslatedNameMap.find(name)->second;
1040
1041
2.02M
    std::string fName;
1042
2.02M
    static bool first = true;
1043
87.1M
    for (auto c : name) {
1044
87.1M
      auto ch = static_cast<unsigned char>(c);
1045
87.1M
      if (ch > 0x1f && ch < 0x80) {
1046
30.0M
        fName+=c;
1047
30.0M
        continue;
1048
30.0M
      }
1049
57.1M
      if (first) {
1050
37
        MWAW_DEBUG_MSG(("MWAWFontConverterInternal::State::getValidName: fontName contains bad character\n"));
1051
37
        first = false;
1052
37
      }
1053
57.1M
      fName += 'X';
1054
57.1M
    }
1055
2.02M
    return fName;
1056
2.02M
  }
1057
1058
protected:
1059
  //! initializes the map
1060
  void initMaps();
1061
  //! try to update the cache
1062
  bool updateCache(int macId);
1063
1064
  //! the basic conversion map
1065
  MWAWFontConverterInternal::Data::KnownConversion m_knownConversion;
1066
  //! map sysid -> font name
1067
  std::map<int, std::string> m_idNameMap;
1068
  //! map font name -> sysid
1069
  std::map<std::string, int> m_nameIdMap;
1070
  //! map font name (in original language) -> latin name
1071
  std::map<std::string, std::string> m_nameTranslatedNameMap;
1072
1073
  //!Internal: a counter modified when a new correspondance name<->id is found
1074
  long m_nameIdCounter;
1075
1076
  //! a int used to create new id for a name
1077
  int m_uniqueId;
1078
1079
  //! a SJIS convertor to convert Shit-JIS font
1080
  std::shared_ptr<MWAWFontSJISConverter> m_sjisConverter;
1081
1082
  //! small structure to speedup unicode
1083
  struct UnicodeCache {
1084
    //! constructor
1085
    UnicodeCache()
1086
1.99M
      : m_nameIdCounter(-1)
1087
1.99M
      , m_macId(-1)
1088
1.99M
      , m_conv(nullptr)
1089
1.99M
    {
1090
1.99M
    }
1091
    //! actual counter
1092
    long m_nameIdCounter;
1093
    //! actual macId
1094
    int m_macId;
1095
    //! actual convertor
1096
    MWAWFontConverterInternal::Data::ConversionData const *m_conv;
1097
  } m_unicodeCache;
1098
1099
};
1100
1101
// initializes the default conversion map
1102
void State::initMaps()
1103
1.99M
{
1104
  // mac cyrillic encoding => mac roman encoding
1105
1.99M
  m_nameTranslatedNameMap["\x81\xe0\xf1\xf2\xe8\xee\xed"]="Baston CYR";
1106
1.99M
  m_nameTranslatedNameMap["\x8b\xe0\xf2\xe8\xed\xf1\xea\xe8\xe9"]="Latinskij";
1107
1.99M
  m_nameTranslatedNameMap["\x8f\xf0\xdf\xec\xee\xe9"]="Priamoj";
1108
1.99M
  m_nameTranslatedNameMap["\x8f\xf0\xdf\xec\xee\xe9\x20\x8f\xf0\xee\xef"]="Priamoj Prop";
1109
1.99M
  m_nameTranslatedNameMap["\x91\xe8\xf1\xf2\xe5\xec\xed\xfb\xe9"]="Sistemnyj";
1110
1.99M
  m_nameTranslatedNameMap["\x80\x90\x91\x8a\xf3\xf0\xfc\xe5\xf0"]="APC Courier";
1111
1112
  // see http://developer.apple.com/documentation/mac/Text/Text-277.html
1113
  // or Apple II Technical Notes #41 (  http://www.umich.edu/~archive/apple2/technotes/tn/iigs/TN.IIGS.041 )
1114
  // 0 system fonts, 1 appli fonts
1115
1.99M
  m_idNameMap[2] = "NewYork";
1116
1.99M
  m_idNameMap[3] = "Geneva";
1117
1.99M
  m_idNameMap[4] = "Monaco";
1118
1.99M
  m_idNameMap[5] = "Venice";
1119
1.99M
  m_idNameMap[6] = "London";
1120
1.99M
  m_idNameMap[7] = "Athens";
1121
1.99M
  m_idNameMap[8] = "SanFran";
1122
1.99M
  m_idNameMap[9] = "Toronto";
1123
1124
1.99M
  m_idNameMap[11] = "Cairo";
1125
1.99M
  m_idNameMap[12] = "LosAngeles";
1126
1.99M
  m_idNameMap[13] = "Zapf Dingbats";
1127
1.99M
  m_idNameMap[14] = "Bookman";
1128
1.99M
  m_idNameMap[16] = "Palatino";
1129
1.99M
  m_idNameMap[18] = "Zapf Chancery";
1130
1.99M
  m_idNameMap[20] = "Times";
1131
1.99M
  m_idNameMap[21] = "Helvetica";
1132
1.99M
  m_idNameMap[22] = "Courier";
1133
1.99M
  m_idNameMap[23] = "Symbol";
1134
1.99M
  m_idNameMap[24] = "Mobile"; // or Taliesin: apple 2
1135
1136
  // ------- Apple II Technical Notes #41
1137
1.99M
  m_idNameMap[33] = "Avant Garde";
1138
1.99M
  m_idNameMap[34] = "New Century Schoolbook";
1139
1140
  // ------- Osnola: from a personal computer
1141
1.99M
  m_idNameMap[150] = "scientific";
1142
1.99M
  m_idNameMap[157] = "Cursive";
1143
1.99M
  m_idNameMap[201] = "Math";
1144
1145
  // ------- Osnola: unknown name
1146
1.99M
  m_idNameMap[107] = "Unknown107";
1147
1.99M
  m_idNameMap[128] = "Unknown128";
1148
1.99M
  m_idNameMap[200] = "Unknown200";
1149
1150
  // ------- fixme: find encoding
1151
1.99M
  m_idNameMap[174] = "Futura";
1152
1.99M
  m_idNameMap[258] = "ProFont";
1153
1.99M
  m_idNameMap[513] = "ISO Latin Nr 1";
1154
1.99M
  m_idNameMap[514] = "PCFont 437";
1155
1.99M
  m_idNameMap[515] = "PCFont 850";
1156
1.99M
  m_idNameMap[1029] = "VT80 Graphics";
1157
1.99M
  m_idNameMap[1030] = "3270 Graphics";
1158
1.99M
  m_idNameMap[1109] = "Trebuchet MS";
1159
1.99M
  m_idNameMap[1345] = "ProFont";
1160
1.99M
  m_idNameMap[1895] = "Nu Sans Regular";
1161
1.99M
  m_idNameMap[2001] = "Arial";
1162
1.99M
  m_idNameMap[2002] = "Charcoal";
1163
1.99M
  m_idNameMap[2004] = "Sand";
1164
1.99M
  m_idNameMap[2005] = "Courier New";
1165
1.99M
  m_idNameMap[2006] = "Techno";
1166
1.99M
  m_idNameMap[2010] = "Times New Roman";
1167
1.99M
  m_idNameMap[2011] = "Wingdings";
1168
1.99M
  m_idNameMap[2013] = "Hoefler Text";
1169
1.99M
  m_idNameMap[2018] = "Hoefler Text Ornaments";
1170
1.99M
  m_idNameMap[2039] = "Impact";
1171
1.99M
  m_idNameMap[2041] = "Mistral";
1172
1.99M
  m_idNameMap[2305] = "Textile";
1173
1.99M
  m_idNameMap[2307] = "Gadget";
1174
1.99M
  m_idNameMap[2311] = "Apple Chancery";
1175
1.99M
  m_idNameMap[2515] = "MT Extra";
1176
1.99M
  m_idNameMap[4513] = "Comic Sans MS";
1177
1.99M
  m_idNameMap[7092] = "Monotype.com";
1178
1.99M
  m_idNameMap[7102] = "Andale Mono";
1179
1.99M
  m_idNameMap[7203] = "Verdenal";
1180
1.99M
  m_idNameMap[9728] = "Espi Sans";
1181
1.99M
  m_idNameMap[9729] = "Charcoal";
1182
1.99M
  m_idNameMap[9840] = "Espy Sans/Copland";
1183
1.99M
  m_idNameMap[9841] = "Espy Sans/Bold";
1184
1.99M
  m_idNameMap[9842] = "Espy Sans Bold/Copland";
1185
1.99M
  m_idNameMap[10840] = "Klang MT";
1186
1.99M
  m_idNameMap[10890] = "Script MT Bold";
1187
1.99M
  m_idNameMap[10897] = "Old English Text MT";
1188
1.99M
  m_idNameMap[10909] = "New Berolina MT";
1189
1.99M
  m_idNameMap[10957] = "Bodoni MT Ultra Bold";
1190
1.99M
  m_idNameMap[10967] = "Arial MT Condensed Light";
1191
1.99M
  m_idNameMap[11103] = "Lydian MT";
1192
1193
  // japanese font ( check me )
1194
1.99M
  m_idNameMap[16384] = "Osaka";
1195
1.99M
  m_idNameMap[16436] = "Osaka Tohaba";
1196
1.99M
  m_idNameMap[16700] = "Heisei Mincho";
1197
1.99M
  m_idNameMap[16701] = "Heisei KakuGothic";
1198
1.99M
  m_idNameMap[16800] = "Hiragino KakuGothic ProN W3";
1199
1.99M
  m_idNameMap[28930] = "Hei";
1200
1.99M
  m_idNameMap[35934] = "Hiragino MaruGo W4";
1201
1.99M
  m_idNameMap[39129] = "Heiti SC Medium";
1202
1.99M
  m_idNameMap[48166] = "Hiragino Kakugo W3";
1203
1.99M
  m_idNameMap[48169] = "Hiragino Kakugo W6";
1204
1.99M
  m_idNameMap[54024] = "Hiragino Kakugo W8";
1205
1.99M
  m_idNameMap[55129] = "Hiragino San GB W6";
1206
1.99M
  m_idNameMap[55225] = "Hiragino San GB W3";
1207
1.99M
  m_idNameMap[62905] = "Heiti SC Light";
1208
1.99M
  m_idNameMap[64640] = "Hiragino MaruGo W3";
1209
1.99M
  m_idNameMap[64643] = "Hiragino MaruGo W6";
1210
1211
  // cyrillic font
1212
1.99M
  m_idNameMap[19456] = "Sistemnyj";
1213
1.99M
  m_idNameMap[19459] = "Priamoj Prop";
1214
1.99M
  m_idNameMap[19460] = "Priamoj";
1215
1.99M
  m_idNameMap[19473] = "APC Courier";
1216
1.99M
  m_idNameMap[19491] = "Baston CYR";
1217
1.99M
  m_idNameMap[19540] = "Latinskij";
1218
  // Windows
1219
1.99M
  m_idNameMap[101250] = "CP1250";
1220
1.99M
  m_idNameMap[101251] = "CP1251";
1221
1.99M
  m_idNameMap[101252] = "CP1252";
1222
1.99M
  m_idNameMap[101253] = "CP1253";
1223
1.99M
  m_idNameMap[101254] = "CP1254";
1224
1.99M
  m_idNameMap[101255] = "CP1255";
1225
1.99M
  m_idNameMap[101256] = "CP1256";
1226
1.99M
  m_idNameMap[101257] = "CP1257";
1227
1.99M
  m_idNameMap[101258] = "CP1258";
1228
1229
1.99M
  for (auto const &it : m_idNameMap)
1230
197M
    m_nameIdMap[it.second] = it.first;
1231
1.99M
}
1232
1233
// try to find the good converter
1234
bool State::updateCache(int macId)
1235
1.35G
{
1236
1.35G
  if (!m_unicodeCache.m_conv || m_unicodeCache.m_macId != macId ||  m_unicodeCache.m_nameIdCounter != m_nameIdCounter) {
1237
4.14M
    m_unicodeCache.m_macId = macId;
1238
4.14M
    m_unicodeCache.m_nameIdCounter = m_nameIdCounter;
1239
4.14M
    m_unicodeCache.m_conv = &m_knownConversion.getConversionMaps(getName(macId));
1240
4.14M
  }
1241
1.35G
  if (!m_unicodeCache.m_conv) {
1242
0
    MWAW_DEBUG_MSG(("unicode Error: can not find a convertor\n"));
1243
0
    return false;
1244
0
  }
1245
1.35G
  return true;
1246
1.35G
}
1247
1248
// returns an unicode caracter
1249
int State::unicode(int macId, unsigned char c)
1250
1.10G
{
1251
1.10G
  if (!updateCache(macId))
1252
0
    return -1;
1253
1.10G
  auto it = m_unicodeCache.m_conv->m_conversion.find(c);
1254
1.10G
  if (it == m_unicodeCache.m_conv->m_conversion.end()) return -1;
1255
1.10G
  return static_cast<int>(it->second);
1256
1.10G
}
1257
1258
// returns an unicode caracter
1259
int State::unicode(int macId, unsigned char c, MWAWInputStreamPtr &input)
1260
242M
{
1261
242M
  if (!updateCache(macId))
1262
0
    return -1;
1263
242M
  if (m_unicodeCache.m_conv->m_encoding==MWAWFontConverter::E_SJIS) {
1264
2.52M
    if (!m_sjisConverter)
1265
3.16k
      m_sjisConverter.reset(new MWAWFontSJISConverter);
1266
2.52M
    return m_sjisConverter->unicode(c,input);
1267
2.52M
  }
1268
1269
240M
  auto it = m_unicodeCache.m_conv->m_conversion.find(c);
1270
240M
  if (it == m_unicodeCache.m_conv->m_conversion.end()) return -1;
1271
239M
  return static_cast<int>(it->second);
1272
240M
}
1273
1274
int State::unicode(int macId, unsigned char c, unsigned char const *(&str), int len)
1275
1.89k
{
1276
1.89k
  if (!updateCache(macId))
1277
0
    return -1;
1278
1.89k
  if (m_unicodeCache.m_conv->m_encoding==MWAWFontConverter::E_SJIS) {
1279
0
    if (!m_sjisConverter)
1280
0
      m_sjisConverter.reset(new MWAWFontSJISConverter);
1281
0
    return m_sjisConverter->unicode(c,str,len);
1282
0
  }
1283
1284
1.89k
  auto it = m_unicodeCache.m_conv->m_conversion.find(c);
1285
1.89k
  if (it == m_unicodeCache.m_conv->m_conversion.end()) return -1;
1286
1.89k
  return static_cast<int>(it->second);
1287
1.89k
}
1288
1289
void State::getOdtInfo(int macId, std::string &nm, int &deltaSize)
1290
40.6M
{
1291
40.6M
  std::string nam = getName(macId);
1292
40.6M
  auto const *conv = &m_knownConversion.getConversionMaps(nam);
1293
1294
40.6M
  nm = conv->m_name;
1295
40.6M
  deltaSize = conv->m_deltaSize;
1296
1297
40.6M
  if (!nm.empty() && nm[0]=='_') nm=nm.substr(1); // special case for pc font
1298
40.6M
  if (!nm.empty()) return;
1299
29.7M
  if (!nam.empty() && nam[0]=='_') nam=nam.substr(1); // special case for pc font
1300
29.7M
  if (!nam.empty()) {
1301
13.7M
    nm = nam;
1302
13.7M
    return;
1303
13.7M
  }
1304
#ifdef DEBUG
1305
  static int lastUnknownId = -1;
1306
  if (macId != lastUnknownId) {
1307
    lastUnknownId = macId;
1308
    MWAW_DEBUG_MSG(("MWAWFontConverterInternal::State::getOdtInfo: Unknown font with id=%d\n",macId));
1309
  }
1310
#endif
1311
16.0M
  nm = "Times New Roman";
1312
16.0M
}
1313
1314
}
1315
1316
MWAWFontConverter::MWAWFontConverter()
1317
1.99M
  : m_manager(new MWAWFontConverterInternal::State)
1318
1.99M
{
1319
1.99M
}
1320
MWAWFontConverter::~MWAWFontConverter()
1321
1.99M
{
1322
1.99M
}
1323
1324
void MWAWFontConverter::setCorrespondance(int macId, std::string const &name, std::string family)
1325
645k
{
1326
645k
  m_manager->setCorrespondance(macId, m_manager->getValidName(name), family);
1327
645k
}
1328
1329
int MWAWFontConverter::getId(std::string const &name, std::string family)  const
1330
1.38M
{
1331
1.38M
  return m_manager->getId(m_manager->getValidName(name), family);
1332
1.38M
}
1333
1334
std::string MWAWFontConverter::getName(int macId) const
1335
39.4M
{
1336
39.4M
  return m_manager->getName(macId);
1337
39.4M
}
1338
1339
void MWAWFontConverter::getOdtInfo(int macId, std::string &nm, int &deltaSize) const
1340
40.6M
{
1341
40.6M
  m_manager->getOdtInfo(macId, nm, deltaSize);
1342
40.6M
}
1343
1344
int MWAWFontConverter::unicode(int macId, unsigned char c) const
1345
2.48G
{
1346
2.48G
  if (c < 0x20) return -1;
1347
1.10G
  return m_manager->unicode(macId, c);
1348
2.48G
}
1349
1350
int MWAWFontConverter::unicode(int macId, unsigned char c, MWAWInputStreamPtr &input) const
1351
345M
{
1352
345M
  if (c < 0x20) return -1;
1353
242M
  return m_manager->unicode(macId,c,input);
1354
345M
}
1355
1356
int MWAWFontConverter::unicode(int macId, unsigned char c, unsigned char const *(&str), int len) const
1357
2.21k
{
1358
2.21k
  if (c < 0x20) return -1;
1359
1.89k
  return m_manager->unicode(macId,c,str,len);
1360
2.21k
}
1361
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: