Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / hwpfilter / source / fontmap.cxx
blobde891c7a3864ad9d7543f389e77c5380fdba8cdd
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <stdio.h>
30 #ifdef SOLARIS
31 #include <strings.h>
32 #else
33 #include <string.h>
34 #endif
36 // #i42367# prevent MS compiler from using system locale for parsing
37 #ifdef _MSC_VER
38 #pragma setlocale("C")
39 #endif
42 struct FontEntry
44 const char *familyname;
45 int key;
46 double ratio;
48 /**
49 * ratio\xb4\xc2 \xc7\xd1\xb1\xdb 70%, \xbc\xfd\xc0\xda 10% \xbf\xb5\xb9\xae 20%\xc0\xc7 \xba\xf1\xc0\xb2\xb7\xce \xb1\xb8\xbc\xba\xb5\xc7\xbe\xfa\xb4\xd9\xb4\xc2 \xb0\xa1\xc1\xa4\xc7\xcf\xbf\xa1 \xc1\xa4\xc7\xd8\xc1\xf8\xb4\xd9.
51 const struct FontEntry FontMapTab[] =
53 {"\xb8\xed\xc1\xb6",0, 0.97},
54 {"\xb0\xed\xb5\xf1",1, 0.97},
55 {"\xbb\xf9\xb9\xb0",1, 0.97},
56 {"\xc7\xca\xb1\xe2",0, 0.97},
57 {"\xbd\xc3\xbd\xba\xc5\xdb",1, 0.84},
58 {"\xbd\xc3\xbd\xba\xc5\xdb \xbe\xe0\xc0\xda",1, 0.84},
59 {"\xbd\xc3\xbd\xba\xc5\xdb \xb0\xa3\xc0\xda",1, 0.84},
60 {"HY\xb5\xd5\xb1\xd9 \xb0\xed\xb5\xf1",2, 0.97},
61 {"\xbf\xbe\xc7\xd1\xb1\xdb",0, 0.97},
62 {"\xb0\xa1\xb4\xc2\xb0\xf8\xc7\xd1",0, 0.72},
63 {"\xc1\xdf\xb0\xa3\xb0\xf8\xc7\xd1",0, 0.72},
64 {"\xb1\xbd\xc0\xba\xb0\xf8\xc7\xd1",0, 0.72},
65 {"\xb0\xa1\xb4\xc2\xc7\xd1",0, 0.72},
66 {"\xc1\xdf\xb0\xa3\xc7\xd1",0, 0.72},
67 {"\xb1\xbd\xc0\xba\xc7\xd1",0, 0.72},
68 {"\xc8\xde\xb8\xd5\xb8\xed\xc1\xb6",0, 0.97},
69 {"\xc8\xde\xb8\xd5\xb0\xed\xb5\xf1",1, 0.97},
70 {"\xb0\xa1\xb4\xc2\xbe\xc8\xbb\xf3\xbc\xf6\xc3\xbc",0, 0.55},
71 {"\xc1\xdf\xb0\xa3\xbe\xc8\xbb\xf3\xbc\xf6\xc3\xbc",0, 0.637},
72 {"\xb1\xbd\xc0\xba\xbe\xc8\xbb\xf3\xbc\xf6\xc3\xbc",0, 0.63},
73 {"\xc8\xde\xb8\xd5\xb0\xa1\xb4\xc2\xbb\xf9\xc3\xbc",0, 0.666},
74 {"\xc8\xde\xb8\xd5\xc1\xdf\xb0\xa3\xbb\xf9\xc3\xbc",0, 0.685},
75 {"\xc8\xde\xb8\xd5\xb1\xbd\xc0\xba\xbb\xf9\xc3\xbc",0, 0.727},
76 {"\xc8\xde\xb8\xd5\xb0\xa1\xb4\xc2\xc6\xd4\xc3\xbc",0, 0.666},
77 {"\xc8\xde\xb8\xd5\xc1\xdf\xb0\xa3\xc6\xd4\xc3\xbc",0, 0.685},
78 {"\xc8\xde\xb8\xd5\xb1\xbd\xc0\xba\xc6\xd4\xc3\xbc",0, 0.727},
79 {"\xc8\xde\xb8\xd5\xbf\xbe\xc3\xbc",3, 0.97},
80 {"\xc7\xd1\xbe\xe7\xbd\xc5\xb8\xed\xc1\xb6",0, 0.97},
81 {"\xc7\xd1\xbe\xe7\xb0\xdf\xb8\xed\xc1\xb6",1, 0.97},
82 {"\xc7\xd1\xbe\xe7\xc1\xdf\xb0\xed\xb5\xf1",1, 0.97},
83 {"\xc7\xd1\xbe\xe7\xb0\xdf\xb0\xed\xb5\xf1",1, 0.97},
84 {"\xc7\xd1\xbe\xe7\xb1\xd7\xb7\xa1\xc7\xc8",0, 0.97},
85 {"\xc7\xd1\xbe\xe7\xb1\xc3\xbc\xad",3, 0.97},
86 {"\xb9\xae\xc8\xad\xb9\xd9\xc5\xc1",0, 0.97},
87 {"\xb9\xae\xc8\xad\xb9\xd9\xc5\xc1\xc1\xa6\xb8\xf1",1, 0.97},
88 {"\xb9\xae\xc8\xad\xb5\xb8\xbf\xf2",1, 0.97},
89 {"\xb9\xae\xc8\xad\xb5\xb8\xbf\xf2\xc1\xa6\xb8\xf1",0, 0.97},
90 {"\xb9\xae\xc8\xad\xbe\xb2\xb1\xe2",0, 0.97},
91 {"\xb9\xae\xc8\xad\xbe\xb2\xb1\xe2\xc8\xea\xb8\xb2",0, 0.97},
92 {"\xc6\xe6\xc8\xea\xb8\xb2",0, 0.97},
93 {"\xba\xb9\xbc\xfe\xbe\xc6",0, 0.827},
94 {"\xbf\xc1\xbc\xf6\xbc\xf6",0, 0.97},
95 {"\xbf\xc0\xc0\xcc",0, 0.97},
96 {"\xb0\xa1\xc1\xf6",0, 0.97},
97 {"\xb0\xad\xb3\xb6\xc4\xe1",2, 0.97},
98 {"\xb5\xfe\xb1\xe2",3, 0.97},
99 {"\xc5\xb8\xc0\xcc\xc7\xc1",0, 0.987},
100 {"\xc5\xc2 \xb3\xaa\xb9\xab",1, 0.97},
101 {"\xc5\xc2 \xc7\xec\xb5\xe5\xb6\xf3\xc0\xce",0, 0.97},
102 {"\xc5\xc2 \xb0\xa1\xb4\xc2 \xc7\xec\xb5\xe5\xb6\xf3\xc0\xce",0, 0.97},
103 {"\xc5\xc2 \xc7\xec\xb5\xe5\xb6\xf3\xc0\xceT",0, 0.97},
104 {"\xc5\xc2 \xb0\xa1\xb4\xc2 \xc7\xec\xb5\xe5\xb6\xf3\xc0\xceT",0, 0.97},
105 {"\xbe\xe7\xc0\xe7 \xb4\xd9\xbf\xee\xb8\xed\xc1\xb6M",0, 0.97},
106 {"\xbe\xe7\xc0\xe7 \xba\xbb\xb8\xf1\xb0\xa2M",0, 0.97},
107 {"\xbe\xe7\xc0\xe7 \xbc\xd2\xbd\xbd",1, 0.97},
108 {"\xbe\xe7\xc0\xe7 \xb8\xc5\xc8\xad",1, 0.987},
109 {"\xbe\xe7\xc0\xe7 \xc6\xb0\xc6\xb0",0, 0.97},
110 {"\xbe\xe7\xc0\xe7 \xc2\xfc\xbd\xa1",1, 0.97},
111 {"\xbe\xe7\xc0\xe7 \xb5\xd1\xb1\xe2",0, 0.97},
112 {"\xbe\xe7\xc0\xe7 \xbb\xfe\xb3\xda",1, 0.97},
113 {"\xbe\xe7\xc0\xe7 \xbf\xcd\xb4\xe7",1, 0.97},
114 {"\xbd\xc5\xb8\xed \xbc\xbc\xb8\xed\xc1\xb6",0, 0.97},
115 {"\xbd\xc5\xb8\xed \xbd\xc5\xb8\xed\xc1\xb6",0, 0.97},
116 {"\xbd\xc5\xb8\xed \xbd\xc5\xbd\xc5\xb8\xed\xc1\xb6",0, 0.97},
117 {"\xbd\xc5\xb8\xed \xc1\xdf\xb8\xed\xc1\xb6",0, 0.97},
118 {"\xbd\xc5\xb8\xed \xc5\xc2\xb8\xed\xc1\xb6",0, 0.97},
119 {"\xbd\xc5\xb8\xed \xb0\xdf\xb8\xed\xc1\xb6",0, 0.97},
120 {"\xbd\xc5\xb8\xed \xbd\xc5\xb9\xae\xb8\xed\xc1\xb6",0, 0.97},
121 {"\xbd\xc5\xb8\xed \xbc\xf8\xb8\xed\xc1\xb6",0, 0.97},
122 {"\xbd\xc5\xb8\xed \xbc\xbc\xb0\xed\xb5\xf1",1, 0.97},
123 {"\xbd\xc5\xb8\xed \xc1\xdf\xb0\xed\xb5\xf1",1, 0.97},
124 {"\xbd\xc5\xb8\xed \xc5\xc2\xb0\xed\xb5\xf1",1, 0.97},
125 {"\xbd\xc5\xb8\xed \xb0\xdf\xb0\xed\xb5\xf1",1, 0.97},
126 {"\xbd\xc5\xb8\xed \xbc\xbc\xb3\xaa\xb7\xe7",2, 0.97},
127 {"\xbd\xc5\xb8\xed \xb5\xf0\xb3\xaa\xb7\xe7",2, 0.97},
128 {"\xbd\xc5\xb8\xed \xbd\xc5\xb1\xd7\xb7\xa1\xc7\xc8",2, 0.97},
129 {"\xbd\xc5\xb8\xed \xc5\xc2\xb1\xd7\xb7\xa1\xc7\xc8",2, 0.97},
130 {"\xbd\xc5\xb8\xed \xb1\xc3\xbc\xad",3, 0.97}
133 #define FONTCOUNT 4
134 #ifndef WIN32
135 #if defined(LINUX)
136 const char* RepFontTab[] =
138 "\xb9\xe9\xb9\xac \xb9\xd9\xc5\xc1", /* 0 */
139 "\xb9\xe9\xb9\xac \xb5\xb8\xbf\xf2", /* 1 */
140 "\xb9\xe9\xb9\xac \xb1\xbc\xb8\xb2", /* 2 */
141 "\xb9\xe9\xb9\xac \xc7\xec\xb5\xe5\xb6\xf3\xc0\xce" /* 3 */
143 #else
144 const char* RepFontTab[] =
146 "Batang", /* 0 */
147 "Dotum", /* 1 */
148 "Gulim", /* 2 */
149 "Gungso" /* 3 */
151 #endif
152 #else
153 const char* RepFontTab[] =
155 "\xb9\xd9\xc5\xc1", /* 0 */
156 "\xb5\xb8\xbf\xf2", /* 1 */
157 "\xb1\xbc\xb8\xb2", /* 2 */
158 "\xb1\xc3\xbc\xad" /* 3 */
160 #endif
162 int getRepFamilyName(const char* orig, char *buf, double &ratio)
164 int i;
165 int size = sizeof(FontMapTab)/sizeof(FontEntry);
166 for( i = 0 ; i < size ; i++)
168 if( !strcmp(orig, FontMapTab[i].familyname) ){
169 ratio = FontMapTab[i].ratio;
170 return strlen( strcpy(buf,RepFontTab[FontMapTab[i].key]) );
173 ratio = FontMapTab[0].ratio;
174 return strlen( strcpy(buf, RepFontTab[0] ) );
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */