xref: /trunk/main/unotools/source/misc/fontdefs.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_unotools.hxx"
30*cdf0e10cSrcweir #include <unotools/fontdefs.hxx>
31*cdf0e10cSrcweir #include <unotools/fontcfg.hxx>
32*cdf0e10cSrcweir #include <hash_map>
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir struct ImplLocalizedFontName
35*cdf0e10cSrcweir {
36*cdf0e10cSrcweir     const char*         mpEnglishName;
37*cdf0e10cSrcweir     const sal_Unicode*  mpLocalizedNames;
38*cdf0e10cSrcweir };
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir // TODO: where did the 0,0 delimiters come from? A single 0 should suffice...
41*cdf0e10cSrcweir static sal_Unicode const aBatang[] = { 0xBC14, 0xD0D5, 0, 0 };
42*cdf0e10cSrcweir static sal_Unicode const aBatangChe[] = { 0xBC14, 0xD0D5, 0xCCB4, 0, 0 };
43*cdf0e10cSrcweir static sal_Unicode const aGungsuh[] = { 0xAD81, 0xC11C, 0, 0 };
44*cdf0e10cSrcweir static sal_Unicode const aGungsuhChe[] = { 0xAD81, 0xC11C, 0xCCB4, 0, 0 };
45*cdf0e10cSrcweir static sal_Unicode const aGulim[] = { 0xAD74, 0xB9BC, 0, 0 };
46*cdf0e10cSrcweir static sal_Unicode const aGulimChe[] = { 0xAD74, 0xB9BC, 0xCCB4, 0, 0 };
47*cdf0e10cSrcweir static sal_Unicode const aDotum[] = { 0xB3CB, 0xC6C0, 0, 0 };
48*cdf0e10cSrcweir static sal_Unicode const aDotumChe[] = { 0xB3CB, 0xC6C0, 0xCCB4, 0, 0 };
49*cdf0e10cSrcweir static sal_Unicode const aSimSun[] = { 0x5B8B, 0x4F53, 0, 0 };
50*cdf0e10cSrcweir static sal_Unicode const aNSimSun[] = { 0x65B0, 0x5B8B, 0x4F53, 0, 0 };
51*cdf0e10cSrcweir static sal_Unicode const aSimHei[] = { 0x9ED1, 0x4F53, 0, 0 };
52*cdf0e10cSrcweir static sal_Unicode const aSimKai[] = { 0x6977, 0x4F53, 0, 0 };
53*cdf0e10cSrcweir static sal_Unicode const azycjkSun[] = { 0x4E2D, 0x6613, 0x5B8B, 0x4F53, 0, 0 };
54*cdf0e10cSrcweir static sal_Unicode const azycjkHei[] = { 0x4E2D, 0x6613, 0x9ED1, 0x4F53, 0, 0 };
55*cdf0e10cSrcweir static sal_Unicode const azycjkKai[] = { 0x4E2D, 0x6613, 0x6977, 0x4F53, 0, 0 };
56*cdf0e10cSrcweir static sal_Unicode const aFZHei[] = { 0x65B9, 0x6B63, 0x9ED1, 0x4F53, 0, 0 };
57*cdf0e10cSrcweir static sal_Unicode const aFZKai[] = { 0x65B9, 0x6B63, 0x6977, 0x4F53, 0, 0 };
58*cdf0e10cSrcweir static sal_Unicode const aFZSongYI[] = { 0x65B9, 0x6B63, 0x5B8B, 0x4E00, 0, 0 };
59*cdf0e10cSrcweir static sal_Unicode const aFZShuSong[] = { 0x65B9, 0x6B63, 0x4E66, 0x5B8B, 0, 0 };
60*cdf0e10cSrcweir static sal_Unicode const aFZFangSong[] = { 0x65B9, 0x6B63, 0x4EFF, 0x5B8B, 0, 0 };
61*cdf0e10cSrcweir // Attention: this fonts includes the wrong encoding vector - so we double the names with correct and wrong encoding
62*cdf0e10cSrcweir // First one is the GB-Encoding (we think the correct one), second is the big5 encoded name
63*cdf0e10cSrcweir static sal_Unicode const aMHei[] = { 'm', 0x7B80, 0x9ED1, 0, 'm', 0x6F60, 0x7AAA, 0, 0 };
64*cdf0e10cSrcweir static sal_Unicode const aMKai[] = { 'm', 0x7B80, 0x6977, 0x566C, 0, 'm', 0x6F60, 0x7FF1, 0x628E, 0, 0 };
65*cdf0e10cSrcweir static sal_Unicode const aMSong[] = { 'm', 0x7B80, 0x5B8B, 0, 'm', 0x6F60, 0x51BC, 0, 0 };
66*cdf0e10cSrcweir static sal_Unicode const aCFangSong[] = { 'm', 0x7B80, 0x592B, 0x5B8B, 0, 'm', 0x6F60, 0x6E98, 0x51BC, 0, 0 };
67*cdf0e10cSrcweir static sal_Unicode const aMingLiU[] = { 0x7D30, 0x660E, 0x9AD4, 0, 0 };
68*cdf0e10cSrcweir static sal_Unicode const aPMingLiU[] = { 0x65B0, 0x7D30, 0x660E, 0x9AD4, 0, 0 };
69*cdf0e10cSrcweir static sal_Unicode const aHei[] = { 0x6865, 0, 0 };
70*cdf0e10cSrcweir static sal_Unicode const aKai[] = { 0x6B61, 0, 0 };
71*cdf0e10cSrcweir static sal_Unicode const aMing[] = { 0x6D69, 0x6E67, 0, 0 };
72*cdf0e10cSrcweir static sal_Unicode const aMSGothic[] = { 'm','s',       0x30B4, 0x30B7, 0x30C3, 0x30AF, 0, 0 };
73*cdf0e10cSrcweir static sal_Unicode const aMSPGothic[] = { 'm','s','p',  0x30B4, 0x30B7, 0x30C3, 0x30AF, 0, 0 };
74*cdf0e10cSrcweir static sal_Unicode const aMSMincho[] = { 'm', 's',      0x660E, 0x671D, 0 };
75*cdf0e10cSrcweir static sal_Unicode const aMSPMincho[] = { 'm','s','p',  0x660E, 0x671D, 0 };
76*cdf0e10cSrcweir static sal_Unicode const aMSYaHei[] = { 0x5FAE, 0x8F6F, 0x96C5, 0x9ED1, 0 };
77*cdf0e10cSrcweir static sal_Unicode const aMSJhengHei[] = { 0x5FAE, 0x8EDF, 0x6B63, 0x9ED1, 0x9AD4, 0 };
78*cdf0e10cSrcweir static sal_Unicode const aMeiryo[]    = { 0x30e1, 0x30a4, 0x30ea, 0x30aa, 0 };
79*cdf0e10cSrcweir static sal_Unicode const aHGMinchoL[] = { 'h','g',      0x660E, 0x671D, 'l', 0, 0 };
80*cdf0e10cSrcweir static sal_Unicode const aHGGothicB[] = { 'h','g',      0x30B4, 0x30B7, 0x30C3, 0x30AF, 'b', 0 };
81*cdf0e10cSrcweir static sal_Unicode const aHGPMinchoL[] = { 'h','g','p', 0x660E, 0x671D, 'l', 0 };
82*cdf0e10cSrcweir static sal_Unicode const aHGPGothicB[] = { 'h','g','p', 0x30B4, 0x30B7, 0x30C3, 0x30AF, 'b', 0 };
83*cdf0e10cSrcweir static sal_Unicode const aHGMinchoLSun[] = { 'h','g',   0x660E, 0x671D, 'l', 's', 'u', 'n', 0 };
84*cdf0e10cSrcweir static sal_Unicode const aHGPMinchoLSun[] = { 'h','g','p', 0x660E, 0x671D, 'l', 's', 'u', 'n', 0 };
85*cdf0e10cSrcweir static sal_Unicode const aHGGothicBSun[] = { 'h', 'g', 0x30B4, 0x30B7, 0x30C3, 0x30AF, 'b', 's', 'u', 'n', 0 };
86*cdf0e10cSrcweir static sal_Unicode const aHGPGothicBSun[] = { 'h', 'g', 'p', 0x30B4, 0x30B7, 0x30C3, 0x30AF, 'b', 's', 'u', 'n', 0 };
87*cdf0e10cSrcweir static sal_Unicode const aHGHeiseiMin[] = { 'h', 'g', 0x5E73, 0x6210, 0x660E, 0x671D, 0x4F53, 0, 'h', 'g', 0x5E73, 0x6210, 0x660E, 0x671D, 0x4F53, 'w', '3', 'x', '1', '2', 0, 0 };
88*cdf0e10cSrcweir static sal_Unicode const aIPAMincho[] =  { 'i', 'p', 'a', 0x660E, 0x671D, 0 };
89*cdf0e10cSrcweir static sal_Unicode const aIPAPMincho[] = { 'i', 'p', 'a', 'p', 0x660E, 0x671D, 0 };
90*cdf0e10cSrcweir static sal_Unicode const aIPAGothic[] =  { 'i', 'p', 'a',  0x30B4, 0x30B7, 0x30C3, 0x30AF, 0 };
91*cdf0e10cSrcweir static sal_Unicode const aIPAPGothic[] =  { 'i', 'p', 'a', 'p', 0x30B4, 0x30B7, 0x30C3, 0x30AF, 0 };
92*cdf0e10cSrcweir static sal_Unicode const aIPAUIGothic[] =  { 'i', 'p', 'a', 'u', 'i', 0x30B4, 0x30B7, 0x30C3, 0x30AF, 0 };
93*cdf0e10cSrcweir static sal_Unicode const aSazanamiMincho[] = { 0x3055, 0x3056, 0x306A, 0x307F, 0x660E, 0x671D, 0, 0 };
94*cdf0e10cSrcweir static sal_Unicode const aSazanamiGothic[] = { 0x3055, 0x3056, 0x306A, 0x307F, 0x30B4, 0x30B7, 0x30C3, 0x30AF, 0, 0 };
95*cdf0e10cSrcweir static sal_Unicode const aKochiMincho[] = { 0x6771, 0x98A8, 0x660E, 0x671D, 0, 0 };
96*cdf0e10cSrcweir static sal_Unicode const aKochiGothic[] = { 0x6771, 0x98A8, 0x30B4, 0x30B7, 0x30C3, 0x30AF, 0, 0 };
97*cdf0e10cSrcweir static sal_Unicode const aSunDotum[] = { 0xC36C, 0xB3CB, 0xC6C0, 0, 0 };
98*cdf0e10cSrcweir static sal_Unicode const aSunGulim[] = { 0xC36C, 0xAD74, 0xB9BC, 0, 0 };
99*cdf0e10cSrcweir static sal_Unicode const aSunBatang[] = { 0xC36C, 0xBC14, 0xD0D5, 0, 0 };
100*cdf0e10cSrcweir static sal_Unicode const aBaekmukDotum[] = { 0xBC31, 0xBB35, 0xB3CB, 0xC6C0, 0, 0 };
101*cdf0e10cSrcweir static sal_Unicode const aBaekmukGulim[] = { 0xBC31, 0xBB35, 0xAD74, 0xB9BC, 0, 0 };
102*cdf0e10cSrcweir static sal_Unicode const aBaekmukBatang[] = { 0xBC31, 0xBB35, 0xBC14, 0xD0D5, 0, 0 };
103*cdf0e10cSrcweir static sal_Unicode const aFzMingTi[] = { 0x65B9, 0x6B63, 0x660E, 0x9AD4, 0, 0 };
104*cdf0e10cSrcweir static sal_Unicode const aFzHeiTiTW[]= { 0x65B9, 0x6B63, 0x9ED1, 0x9AD4, 0, 0 };
105*cdf0e10cSrcweir static sal_Unicode const aFzKaiTiTW[]= { 0x65B9, 0x6B63, 0x6977, 0x9AD4, 0, 0 };
106*cdf0e10cSrcweir static sal_Unicode const aFzHeiTiCN[]= { 0x65B9, 0x6B63, 0x9ED1, 0x4F53, 0, 0 };
107*cdf0e10cSrcweir static sal_Unicode const aFzKaiTiCN[]= { 0x65B9, 0x6B63, 0x6977, 0x4F53, 0, 0 };
108*cdf0e10cSrcweir static sal_Unicode const aFzSongTi[] = { 0x65B9, 0x6B63, 0x5B8B, 0x4F53, 0, 0 };
109*cdf0e10cSrcweir static sal_Unicode const aHYMyeongJoExtra[]         = { 'h', 'y', 0xACAC, 0xBA85, 0xC870, 0, 0 };
110*cdf0e10cSrcweir static sal_Unicode const aHYSinMyeongJoMedium[]     = { 'h', 'y', 0xC2E0, 0xBA85, 0xC870, 0, 0 };
111*cdf0e10cSrcweir static sal_Unicode const aHYGothicMedium[]          = { 'h', 'y', 0xC911, 0xACE0, 0xB515, 0, 0 };
112*cdf0e10cSrcweir static sal_Unicode const aHYGraphicMedium[]         = { 'h', 'y', 0xADF8, 0xB798, 0xD53D, 'm', 0, 0 };
113*cdf0e10cSrcweir static sal_Unicode const aHYGraphic[]               = { 'h', 'y', 0xADF8, 0xB798, 0xD53D, 0, 0 };
114*cdf0e10cSrcweir static sal_Unicode const aNewGulim[]                = { 0xC0C8, 0xAD74, 0xB9BC, 0, 0 };
115*cdf0e10cSrcweir static sal_Unicode const aSunGungseo[]              = { 0xC36C, 0xAD81, 0xC11C, 0, 0 };
116*cdf0e10cSrcweir static sal_Unicode const aHYGungSoBold[]            = { 'h','y', 0xAD81, 0xC11C, 'b', 0, 0 };
117*cdf0e10cSrcweir static sal_Unicode const aHYGungSo[]                 = { 'h','y', 0xAD81, 0xC11C, 0, 0 };
118*cdf0e10cSrcweir static sal_Unicode const aSunHeadLine[]             = { 0xC36C, 0xD5E4, 0xB4DC, 0xB77C, 0xC778, 0, 0 };
119*cdf0e10cSrcweir static sal_Unicode const aHYHeadLineMedium[]        = { 'h', 'y', 0xD5E4, 0xB4DC, 0xB77C, 0xC778, 'm', 0, 0 };
120*cdf0e10cSrcweir static sal_Unicode const aHYHeadLine[]              = { 'h', 'y', 0xD5E4, 0xB4DC, 0xB77C, 0xC778, 0, 0 };
121*cdf0e10cSrcweir static sal_Unicode const aYetR[]                    = { 0xD734, 0xBA3C, 0xC61B, 0xCCB4, 0, 0 };
122*cdf0e10cSrcweir static sal_Unicode const aHYGothicExtra[]           = { 'h', 'y', 0xACAC, 0xACE0, 0xB515, 0, 0 };
123*cdf0e10cSrcweir static sal_Unicode const aSunMokPan[]               = { 0xC36C, 0xBAA9, 0xD310, 0, 0 };
124*cdf0e10cSrcweir static sal_Unicode const aSunYeopseo[]              = { 0xC36C, 0xC5FD, 0xC11C, 0, 0 };
125*cdf0e10cSrcweir static sal_Unicode const aSunBaekSong[]              = { 0xC36C, 0xBC31, 0xC1A1, 0, 0 };
126*cdf0e10cSrcweir static sal_Unicode const aHYPostLight[]             = { 'h', 'y', 0xC5FD, 0xC11C, 'l', 0, 0 };
127*cdf0e10cSrcweir static sal_Unicode const aHYPost[]                  = { 'h', 'y', 0xC5FD, 0xC11C, 0, 0 };
128*cdf0e10cSrcweir static sal_Unicode const aMagicR[]                  = { 0xD734, 0xBA3C, 0xB9E4, 0xC9C1, 0xCCB4, 0, 0 };
129*cdf0e10cSrcweir static sal_Unicode const aSunCrystal[]              = { 0xC36C, 0xD06C, 0xB9AC, 0xC2A4, 0xD0C8, 0, 0 };
130*cdf0e10cSrcweir static sal_Unicode const aSunSaemmul[]              = { 0xC36C, 0xC0D8, 0xBB3C, 0, 0 };
131*cdf0e10cSrcweir static sal_Unicode const aHaansoftBatang[]          = { 0xD55C, 0xCEF4, 0xBC14, 0xD0D5, 0, 0 };
132*cdf0e10cSrcweir static sal_Unicode const aHaansoftDotum[]           = { 0xD55C, 0xCEF4, 0xB3CB, 0xC6C0, 0, 0 };
133*cdf0e10cSrcweir static sal_Unicode const aHyhaeseo[]                = { 0xD55C, 0xC591, 0xD574, 0xC11C, 0, 0 };
134*cdf0e10cSrcweir static sal_Unicode const aMDSol[]                   = { 'm', 'd', 0xC194, 0xCCB4, 0, 0 };
135*cdf0e10cSrcweir static sal_Unicode const aMDGaesung[]               = { 'm', 'd', 0xAC1C, 0xC131, 0xCCB4, 0, 0 };
136*cdf0e10cSrcweir static sal_Unicode const aMDArt[]                   = { 'm', 'd', 0xC544, 0xD2B8, 0xCCB4, 0, 0 };
137*cdf0e10cSrcweir static sal_Unicode const aMDAlong[]                 = { 'm', 'd', 0xC544, 0xB871, 0xCCB4, 0, 0 };
138*cdf0e10cSrcweir static sal_Unicode const aMDEasop[]                 = { 'm', 'd', 0xC774, 0xC19D, 0xCCB4, 0, 0 };
139*cdf0e10cSrcweir static sal_Unicode const aHYShortSamulMedium[]      = { 'h', 'y', 0xC595, 0xC740, 0xC0D8, 0xBB3C, 'm', 0 };
140*cdf0e10cSrcweir static sal_Unicode const aHYShortSamul[]            = { 'h', 'y', 0xC595, 0xC740, 0xC0D8, 0xBB3C, 0 };
141*cdf0e10cSrcweir static sal_Unicode const aHGGothicE[]               = { 'h','g', 0xFF7A, 0xFF9E, 0xFF7C, 0xFF6F, 0xFF78, 'e', 0 };
142*cdf0e10cSrcweir static sal_Unicode const aHGPGothicE[]              = { 'h','g','p', 0xFF7A, 0xFF9E, 0xFF7C, 0xFF6F, 0xFF78, 'e', 0 };
143*cdf0e10cSrcweir static sal_Unicode const aHGSGothicE[]              = { 'h','g','s', 0xFF7A, 0xFF9E, 0xFF7C, 0xFF6F, 0xFF78, 'e', 0 };
144*cdf0e10cSrcweir static sal_Unicode const aHGGothicM[]               = { 'h','g', 0xFF7A, 0xFF9E, 0xFF7C, 0xFF6F, 0xFF78, 'm', 0 };
145*cdf0e10cSrcweir static sal_Unicode const aHGPGothicM[]              = { 'h','g','p', 0xFF7A, 0xFF9E, 0xFF7C, 0xFF6F, 0xFF78, 'm', 0 };
146*cdf0e10cSrcweir static sal_Unicode const aHGSGothicM[]              = { 'h','g','s', 0xFF7A, 0xFF9E, 0xFF7C, 0xFF6F, 0xFF78, 'm', 0 };
147*cdf0e10cSrcweir static sal_Unicode const aHGGyoshotai[]             = { 'h','g', 0x884C, 0x66F8, 0x4F53, 0 };
148*cdf0e10cSrcweir static sal_Unicode const aHGPGyoshotai[]            = { 'h','g','p', 0x884C, 0x66F8, 0x4F53, 0 };
149*cdf0e10cSrcweir static sal_Unicode const aHGSGyoshotai[]            = { 'h','g','s', 0x884C, 0x66F8, 0x4F53, 0 };
150*cdf0e10cSrcweir static sal_Unicode const aHGKyokashotai[]           = { 'h','g', 0x6559, 0x79D1, 0x66F8, 0x4F53, 0 };
151*cdf0e10cSrcweir static sal_Unicode const aHGPKyokashotai[]          = { 'h','g','p', 0x6559, 0x79D1, 0x66F8, 0x4F53, 0 };
152*cdf0e10cSrcweir static sal_Unicode const aHGSKyokashotai[]          = { 'h','g','s', 0x6559, 0x79D1, 0x66F8, 0x4F53, 0 };
153*cdf0e10cSrcweir static sal_Unicode const aHGMinchoB[]               = { 'h','g', 0x660E, 0x671D, 'b', 0 };
154*cdf0e10cSrcweir static sal_Unicode const aHGPMinchoB[]              = { 'h','g','p', 0x660E, 0x671D, 'b', 0 };
155*cdf0e10cSrcweir static sal_Unicode const aHGSMinchoB[]              = { 'h','g','s', 0x660E, 0x671D, 'b', 0 };
156*cdf0e10cSrcweir static sal_Unicode const aHGMinchoE[]               = { 'h','g', 0x660E, 0x671D, 'e', 0 };
157*cdf0e10cSrcweir static sal_Unicode const aHGPMinchoE[]              = { 'h','g','p', 0x660E, 0x671D, 'e', 0 };
158*cdf0e10cSrcweir static sal_Unicode const aHGSMinchoE[]              = { 'h','g','s', 0x660E, 0x671D, 'e', 0 };
159*cdf0e10cSrcweir static sal_Unicode const aHGSoeiKakupoptai[]        = { 'h','g', 0x5275,0x82F1,0x89D2,0xFF8E,
160*cdf0e10cSrcweir                             0xFF9F,0xFF6F,0xFF8C,0xFF9F,0x4F53,0};
161*cdf0e10cSrcweir static sal_Unicode const aHGPSoeiKakupoptai[]       = { 'h','g', 'p', 0x5275,0x82F1,0x89D2,0xFF8E,
162*cdf0e10cSrcweir                             0xFF9F,0xFF6F,0xFF8C,0xFF9F,0x4F53,0};
163*cdf0e10cSrcweir static sal_Unicode const aHGSSoeiKakupoptai[]       = { 'h','g', 's', 0x5275,0x82F1,0x89D2,0xFF8E,
164*cdf0e10cSrcweir                             0xFF9F,0xFF6F,0xFF8C,0xFF9F,0x4F53,0};
165*cdf0e10cSrcweir static sal_Unicode const aHGSoeiPresenceEB[]        = { 'h','g', 0x5275,0x82F1,0xFF8C,0xFF9F,
166*cdf0e10cSrcweir                             0xFF9A,0xFF7E,0xFF9E,0xFF9D,0xFF7D, 'e','b',0};
167*cdf0e10cSrcweir static sal_Unicode const aHGPSoeiPresenceEB[]       = { 'h','g','p', 0x5275,0x82F1,0xFF8C,0xFF9F,
168*cdf0e10cSrcweir                             0xFF9A,0xFF7E,0xFF9E,0xFF9D,0xFF7D, 'e','b',0};
169*cdf0e10cSrcweir static sal_Unicode const aHGSSoeiPresenceEB[]       = { 'h','g','s', 0x5275,0x82F1,0xFF8C,0xFF9F,
170*cdf0e10cSrcweir                             0xFF9A,0xFF7E,0xFF9E,0xFF9D,0xFF7D, 'e','b',0};
171*cdf0e10cSrcweir static sal_Unicode const aHGSoeiKakugothicUB[]      = { 'h','g', 0x5275,0x82F1,0x89D2,0xFF7A,
172*cdf0e10cSrcweir                             0xFF9E,0xFF7C,0xFF6F,0xFF78,'u','b',0};
173*cdf0e10cSrcweir static sal_Unicode const aHGPSoeiKakugothicUB[]     = { 'h','g','p', 0x5275,0x82F1,0x89D2,0xFF7A,
174*cdf0e10cSrcweir                             0xFF9E,0xFF7C,0xFF6F,0xFF78,'u','b',0};
175*cdf0e10cSrcweir static sal_Unicode const aHGSSoeiKakugothicUB[]     = { 'h','g','s', 0x5275,0x82F1,0x89D2,0xFF7A,
176*cdf0e10cSrcweir                             0xFF9E,0xFF7C,0xFF6F,0xFF78,'u','b',0};
177*cdf0e10cSrcweir static sal_Unicode const aHGSeikaishotaiPRO[]       = { 'h','g', 0x6B63,0x6977,0x66F8,0x4F53, '-','p','r','o',0};
178*cdf0e10cSrcweir static sal_Unicode const aHGMaruGothicMPRO[]        = { 'h','g', 0x4E38,0xFF7A,0xFF9E,0xFF7C,0xFF6F,0xFF78, '-','p','r','o',0};
179*cdf0e10cSrcweir static sal_Unicode const aHiraginoMinchoPro[]       = { 0x30D2, 0x30E9, 0x30AE, 0x30CE, 0x660E, 0x671D, 'p','r','o',0};
180*cdf0e10cSrcweir static sal_Unicode const aHiraginoMinchoProN[]      = { 0x30D2, 0x30E9, 0x30AE, 0x30CE, 0x660E, 0x671D, 'p','r','o','n',0};
181*cdf0e10cSrcweir static sal_Unicode const aHiraginoKakuGothicPro[]   = { 0x30D2, 0x30E9, 0x30AE, 0x30CE, 0x89D2, 0x30B4, 'p','r','o',0};
182*cdf0e10cSrcweir static sal_Unicode const aHiraginoKakuGothicProN[]  = { 0x30D2, 0x30E9, 0x30AE, 0x30CE, 0x89D2, 0x30B4, 'p','r','o','n',0};
183*cdf0e10cSrcweir static sal_Unicode const aHiraginoMaruGothicPro[]   = { 0x30D2, 0x30E9, 0x30AE, 0x30CE, 0x4E38, 0x30B4, 'p','r','o',0};
184*cdf0e10cSrcweir static sal_Unicode const aHiraginoMaruGothicProN[]  = { 0x30D2, 0x30E9, 0x30AE, 0x30CE, 0x4E38, 0x30B4, 'p','r','o','n',0};
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir static ImplLocalizedFontName aImplLocalizedNamesList[] =
187*cdf0e10cSrcweir {
188*cdf0e10cSrcweir {   "batang",               aBatang },
189*cdf0e10cSrcweir {   "batangche",            aBatangChe },
190*cdf0e10cSrcweir {   "gungshu",              aGungsuh },
191*cdf0e10cSrcweir {   "gungshuche",           aGungsuhChe },
192*cdf0e10cSrcweir {   "gulim",                aGulim },
193*cdf0e10cSrcweir {   "gulimche",             aGulimChe },
194*cdf0e10cSrcweir {   "dotum",                aDotum },
195*cdf0e10cSrcweir {   "dotumche",             aDotumChe },
196*cdf0e10cSrcweir {   "simsun",               aSimSun },
197*cdf0e10cSrcweir {   "nsimsun",              aNSimSun },
198*cdf0e10cSrcweir {   "simhei",               aSimHei },
199*cdf0e10cSrcweir {   "simkai",               aSimKai },
200*cdf0e10cSrcweir {   "zycjksun",             azycjkSun },
201*cdf0e10cSrcweir {   "zycjkhei",             azycjkHei },
202*cdf0e10cSrcweir {   "zycjkkai",             azycjkKai },
203*cdf0e10cSrcweir {   "fzhei",                aFZHei },
204*cdf0e10cSrcweir {   "fzkai",                aFZKai },
205*cdf0e10cSrcweir {   "fzsong",               aFZSongYI },
206*cdf0e10cSrcweir {   "fzshusong",            aFZShuSong },
207*cdf0e10cSrcweir {   "fzfangsong",           aFZFangSong },
208*cdf0e10cSrcweir {   "mhei",                 aMHei },
209*cdf0e10cSrcweir {   "mkai",                 aMKai },
210*cdf0e10cSrcweir {   "msong",                aMSong },
211*cdf0e10cSrcweir {   "cfangsong",            aCFangSong },
212*cdf0e10cSrcweir {   "mingliu",              aMingLiU },
213*cdf0e10cSrcweir {   "pmingliu",             aPMingLiU },
214*cdf0e10cSrcweir {   "hei",                  aHei },
215*cdf0e10cSrcweir {   "kai",                  aKai },
216*cdf0e10cSrcweir {   "ming",                 aMing },
217*cdf0e10cSrcweir {   "msgothic",             aMSGothic },
218*cdf0e10cSrcweir {   "mspgothic",            aMSPGothic },
219*cdf0e10cSrcweir {   "msmincho",             aMSMincho },
220*cdf0e10cSrcweir {   "mspmincho",            aMSPMincho },
221*cdf0e10cSrcweir {   "microsoftjhenghei",    aMSJhengHei },
222*cdf0e10cSrcweir {   "microsoftyahei",       aMSYaHei },
223*cdf0e10cSrcweir {   "meiryo",               aMeiryo },
224*cdf0e10cSrcweir {   "hgminchol",            aHGMinchoL },
225*cdf0e10cSrcweir {   "hggothicb",            aHGGothicB },
226*cdf0e10cSrcweir {   "hgpminchol",           aHGPMinchoL },
227*cdf0e10cSrcweir {   "hgpgothicb",           aHGPGothicB },
228*cdf0e10cSrcweir {   "hgmincholsun",         aHGMinchoLSun },
229*cdf0e10cSrcweir {   "hggothicbsun",         aHGGothicBSun },
230*cdf0e10cSrcweir {   "hgpmincholsun",        aHGPMinchoLSun },
231*cdf0e10cSrcweir {   "hgpgothicbsun",        aHGPGothicBSun },
232*cdf0e10cSrcweir {   "hgheiseimin",          aHGHeiseiMin },
233*cdf0e10cSrcweir {   "ipamincho",            aIPAMincho },
234*cdf0e10cSrcweir {   "ipapmincho",           aIPAPMincho },
235*cdf0e10cSrcweir {   "ipagothic",            aIPAGothic },
236*cdf0e10cSrcweir {   "ipapgothic",           aIPAPGothic },
237*cdf0e10cSrcweir {   "ipauigothic",          aIPAUIGothic },
238*cdf0e10cSrcweir {   "sazanamimincho",       aSazanamiMincho },
239*cdf0e10cSrcweir {   "sazanamigothic",       aSazanamiGothic },
240*cdf0e10cSrcweir {   "kochimincho",          aKochiMincho },
241*cdf0e10cSrcweir {   "kochigothic",          aKochiGothic },
242*cdf0e10cSrcweir {   "sundotum",             aSunDotum },
243*cdf0e10cSrcweir {   "sungulim",             aSunGulim },
244*cdf0e10cSrcweir {   "sunbatang",            aSunBatang },
245*cdf0e10cSrcweir {   "baekmukdotum",         aBaekmukDotum },
246*cdf0e10cSrcweir {   "baekmukgulim",         aBaekmukGulim },
247*cdf0e10cSrcweir {   "baekmukbatang",        aBaekmukBatang },
248*cdf0e10cSrcweir {   "fzheiti",              aFzHeiTiCN },
249*cdf0e10cSrcweir {   "fzheiti",              aFzHeiTiTW },
250*cdf0e10cSrcweir {   "fzkaiti",              aFzKaiTiCN },
251*cdf0e10cSrcweir {   "fzkaitib",             aFzKaiTiTW },
252*cdf0e10cSrcweir {   "fzmingtib",            aFzMingTi },
253*cdf0e10cSrcweir {   "fzsongti",             aFzSongTi },
254*cdf0e10cSrcweir {   "hymyeongjoextra",      aHYMyeongJoExtra },
255*cdf0e10cSrcweir {   "hysinmyeongjomedium",  aHYSinMyeongJoMedium },
256*cdf0e10cSrcweir {   "hygothicmedium",       aHYGothicMedium },
257*cdf0e10cSrcweir {   "hygraphicmedium",      aHYGraphicMedium },
258*cdf0e10cSrcweir {   "hygraphic",            aHYGraphic },
259*cdf0e10cSrcweir {   "newgulim",             aNewGulim },
260*cdf0e10cSrcweir {   "sungungseo",           aSunGungseo },
261*cdf0e10cSrcweir {   "hygungsobold",         aHYGungSoBold },
262*cdf0e10cSrcweir {   "hygungso",             aHYGungSo },
263*cdf0e10cSrcweir {   "sunheadline",          aSunHeadLine },
264*cdf0e10cSrcweir {   "hyheadlinemedium",     aHYHeadLineMedium },
265*cdf0e10cSrcweir {   "hyheadline",           aHYHeadLine },
266*cdf0e10cSrcweir {   "yetr",                 aYetR },
267*cdf0e10cSrcweir {   "hygothicextra",        aHYGothicExtra },
268*cdf0e10cSrcweir {   "sunmokpan",            aSunMokPan },
269*cdf0e10cSrcweir {   "sunyeopseo",           aSunYeopseo },
270*cdf0e10cSrcweir {   "sunbaeksong",          aSunBaekSong },
271*cdf0e10cSrcweir {   "hypostlight",          aHYPostLight },
272*cdf0e10cSrcweir {   "hypost",               aHYPost },
273*cdf0e10cSrcweir {   "magicr",               aMagicR },
274*cdf0e10cSrcweir {   "suncrystal",           aSunCrystal },
275*cdf0e10cSrcweir {   "sunsaemmul",           aSunSaemmul },
276*cdf0e10cSrcweir {   "hyshortsamulmedium",   aHYShortSamulMedium },
277*cdf0e10cSrcweir {   "hyshortsamul",         aHYShortSamul },
278*cdf0e10cSrcweir {   "haansoftbatang",       aHaansoftBatang },
279*cdf0e10cSrcweir {   "haansoftdotum",        aHaansoftDotum },
280*cdf0e10cSrcweir {   "hyhaeseo",             aHyhaeseo },
281*cdf0e10cSrcweir {   "mdsol",                aMDSol },
282*cdf0e10cSrcweir {   "mdgaesung",            aMDGaesung },
283*cdf0e10cSrcweir {   "mdart",                aMDArt },
284*cdf0e10cSrcweir {   "mdalong",              aMDAlong },
285*cdf0e10cSrcweir {   "mdeasop",              aMDEasop },
286*cdf0e10cSrcweir {   "hggothice",            aHGGothicE },
287*cdf0e10cSrcweir {   "hgpgothice",           aHGPGothicE },
288*cdf0e10cSrcweir {   "hgpothice",            aHGSGothicE },
289*cdf0e10cSrcweir {   "hggothicm",            aHGGothicM },
290*cdf0e10cSrcweir {   "hgpgothicm",           aHGPGothicM },
291*cdf0e10cSrcweir {   "hgpgothicm",           aHGSGothicM },
292*cdf0e10cSrcweir {   "hggyoshotai",          aHGGyoshotai },
293*cdf0e10cSrcweir {   "hgpgyoshotai",         aHGPGyoshotai },
294*cdf0e10cSrcweir {   "hgsgyoshotai",         aHGSGyoshotai },
295*cdf0e10cSrcweir {   "hgkyokashotai",        aHGKyokashotai },
296*cdf0e10cSrcweir {   "hgpkyokashotai",       aHGPKyokashotai },
297*cdf0e10cSrcweir {   "hgskyokashotai",       aHGSKyokashotai },
298*cdf0e10cSrcweir {   "hgminchob",            aHGMinchoB },
299*cdf0e10cSrcweir {   "hgpminchob",           aHGPMinchoB },
300*cdf0e10cSrcweir {   "hgsminchob",           aHGSMinchoB },
301*cdf0e10cSrcweir {   "hgminchoe",            aHGMinchoE },
302*cdf0e10cSrcweir {   "hgpminchoe",           aHGPMinchoE },
303*cdf0e10cSrcweir {   "hgsminchoe",           aHGSMinchoE },
304*cdf0e10cSrcweir {   "hgsoeikakupoptai",     aHGSoeiKakupoptai },
305*cdf0e10cSrcweir {   "hgpsoeikakupopta",     aHGPSoeiKakupoptai },
306*cdf0e10cSrcweir {   "hgssoeikakupopta",     aHGSSoeiKakupoptai },
307*cdf0e10cSrcweir {   "hgsoeipresenceeb",     aHGSoeiPresenceEB },
308*cdf0e10cSrcweir {   "hgpsoeipresenceeb",    aHGPSoeiPresenceEB },
309*cdf0e10cSrcweir {   "hgssoeipresenceeb",    aHGSSoeiPresenceEB },
310*cdf0e10cSrcweir {   "hgsoeikakugothicub",   aHGSoeiKakugothicUB },
311*cdf0e10cSrcweir {   "hgpsoeikakugothicub",  aHGPSoeiKakugothicUB },
312*cdf0e10cSrcweir {   "hgssoeikakugothicub",  aHGSSoeiKakugothicUB },
313*cdf0e10cSrcweir {   "hgseikaishotaipro",    aHGSeikaishotaiPRO },
314*cdf0e10cSrcweir {   "hgmarugothicmpro",     aHGMaruGothicMPRO },
315*cdf0e10cSrcweir {   "hiraginominchopro",    aHiraginoMinchoPro },
316*cdf0e10cSrcweir {   "hiraginominchopron",   aHiraginoMinchoProN },
317*cdf0e10cSrcweir {   "hiraginokakugothicpro", aHiraginoKakuGothicPro },
318*cdf0e10cSrcweir {   "hiraginokakugothicpron", aHiraginoKakuGothicProN },
319*cdf0e10cSrcweir {   "hiraginomarugothicpro", aHiraginoMaruGothicPro },
320*cdf0e10cSrcweir {   "hiraginomarugothicpron", aHiraginoMaruGothicProN },
321*cdf0e10cSrcweir {   NULL,                   NULL },
322*cdf0e10cSrcweir };
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir // -----------------------------------------------------------------------
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir void GetEnglishSearchFontName( String& rName )
327*cdf0e10cSrcweir {
328*cdf0e10cSrcweir     bool        bNeedTranslation = false;
329*cdf0e10cSrcweir     xub_StrLen  nLen = rName.Len();
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir     // Remove trailing whitespaces
332*cdf0e10cSrcweir     xub_StrLen i = nLen;
333*cdf0e10cSrcweir     while ( i && (rName.GetChar( i-1 ) < 32) )
334*cdf0e10cSrcweir         i--;
335*cdf0e10cSrcweir     if ( i != nLen )
336*cdf0e10cSrcweir         rName.Erase( i );
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir     // Remove Script at the end
339*cdf0e10cSrcweir     // Scriptname must be the last part of the fontname and
340*cdf0e10cSrcweir     // looks like "fontname (scriptname)". So there can only be a
341*cdf0e10cSrcweir     // script name at the and of the fontname, when the last char is ')'
342*cdf0e10cSrcweir     if ( (nLen >= 3) && rName.GetChar( nLen-1 ) == ')' )
343*cdf0e10cSrcweir     {
344*cdf0e10cSrcweir         int nOpen = 1;
345*cdf0e10cSrcweir         xub_StrLen nTempLen = nLen-2;
346*cdf0e10cSrcweir         while ( nTempLen )
347*cdf0e10cSrcweir         {
348*cdf0e10cSrcweir             if ( rName.GetChar( nTempLen ) == '(' )
349*cdf0e10cSrcweir             {
350*cdf0e10cSrcweir                 nOpen--;
351*cdf0e10cSrcweir                 if ( !nOpen )
352*cdf0e10cSrcweir                 {
353*cdf0e10cSrcweir                     // Remove Space at the end
354*cdf0e10cSrcweir                     if ( nTempLen && (rName.GetChar( nTempLen-1 ) == ' ') )
355*cdf0e10cSrcweir                         nTempLen--;
356*cdf0e10cSrcweir                     rName.Erase( nTempLen );
357*cdf0e10cSrcweir                     nLen = nTempLen;
358*cdf0e10cSrcweir                     break;
359*cdf0e10cSrcweir                 }
360*cdf0e10cSrcweir             }
361*cdf0e10cSrcweir             if ( rName.GetChar( nTempLen ) == ')' )
362*cdf0e10cSrcweir                 nOpen++;
363*cdf0e10cSrcweir             nTempLen--;
364*cdf0e10cSrcweir         }
365*cdf0e10cSrcweir     }
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir     // remove all whitespaces and converts to lower case ASCII
368*cdf0e10cSrcweir     // TODO: better transliteration to ASCII e.g. all digits
369*cdf0e10cSrcweir     i = 0;
370*cdf0e10cSrcweir     while ( i < nLen )
371*cdf0e10cSrcweir     {
372*cdf0e10cSrcweir         sal_Unicode c = rName.GetChar( i );
373*cdf0e10cSrcweir         if ( c > 127 )
374*cdf0e10cSrcweir         {
375*cdf0e10cSrcweir             // Translate to Lowercase-ASCII
376*cdf0e10cSrcweir             // FullWidth-ASCII to half ASCII
377*cdf0e10cSrcweir             if ( (c >= 0xFF00) && (c <= 0xFF5E) )
378*cdf0e10cSrcweir             {
379*cdf0e10cSrcweir                 c -= 0xFF00-0x0020;
380*cdf0e10cSrcweir                 // Upper to Lower
381*cdf0e10cSrcweir                 if ( (c >= 'A') && (c <= 'Z') )
382*cdf0e10cSrcweir                     c += 'a' - 'A';
383*cdf0e10cSrcweir                 rName.SetChar( i, c );
384*cdf0e10cSrcweir             }
385*cdf0e10cSrcweir             else
386*cdf0e10cSrcweir             {
387*cdf0e10cSrcweir                 // Only Fontnames with None-Ascii-Characters must be translated
388*cdf0e10cSrcweir                 bNeedTranslation = true;
389*cdf0e10cSrcweir             }
390*cdf0e10cSrcweir         }
391*cdf0e10cSrcweir         // not lowercase Ascii
392*cdf0e10cSrcweir         else if ( !((c >= 'a') && (c <= 'z')) )
393*cdf0e10cSrcweir         {
394*cdf0e10cSrcweir             // To Lowercase-Ascii
395*cdf0e10cSrcweir             if ( (c >= 'A') && (c <= 'Z') )
396*cdf0e10cSrcweir             {
397*cdf0e10cSrcweir                 c += 'a' - 'A';
398*cdf0e10cSrcweir                 rName.SetChar( i, c );
399*cdf0e10cSrcweir             }
400*cdf0e10cSrcweir             else if( ((c < '0') || (c > '9')) && (c != ';') ) // not 0-9 or semicolon
401*cdf0e10cSrcweir             {
402*cdf0e10cSrcweir                 // Remove white spaces and special characters
403*cdf0e10cSrcweir                 rName.Erase( i, 1 );
404*cdf0e10cSrcweir                 nLen--;
405*cdf0e10cSrcweir                 continue;
406*cdf0e10cSrcweir             }
407*cdf0e10cSrcweir         }
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir         i++;
410*cdf0e10cSrcweir     }
411*cdf0e10cSrcweir 
412*cdf0e10cSrcweir     // translate normalized localized name to its normalized English ASCII name
413*cdf0e10cSrcweir     if( bNeedTranslation )
414*cdf0e10cSrcweir     {
415*cdf0e10cSrcweir         typedef std::hash_map<const String, const char*,FontNameHash> FontNameDictionary;
416*cdf0e10cSrcweir         static FontNameDictionary aDictionary( sizeof(aImplLocalizedNamesList) / sizeof(*aImplLocalizedNamesList) );
417*cdf0e10cSrcweir         // the font name dictionary needs to be intialized once
418*cdf0e10cSrcweir         if( aDictionary.empty() )
419*cdf0e10cSrcweir         {
420*cdf0e10cSrcweir             // TODO: check if all dictionary entries are already normalized?
421*cdf0e10cSrcweir             const ImplLocalizedFontName* pList = aImplLocalizedNamesList;
422*cdf0e10cSrcweir             for(; pList->mpEnglishName; ++pList )
423*cdf0e10cSrcweir                 aDictionary[ pList->mpLocalizedNames ] = pList->mpEnglishName;
424*cdf0e10cSrcweir         }
425*cdf0e10cSrcweir 
426*cdf0e10cSrcweir         FontNameDictionary::const_iterator it = aDictionary.find( rName );
427*cdf0e10cSrcweir         if( it != aDictionary.end() )
428*cdf0e10cSrcweir             rName.AssignAscii( it->second );
429*cdf0e10cSrcweir     }
430*cdf0e10cSrcweir }
431*cdf0e10cSrcweir 
432*cdf0e10cSrcweir // -----------------------------------------------------------------------
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir String GetNextFontToken( const String& rTokenStr, xub_StrLen& rIndex )
435*cdf0e10cSrcweir {
436*cdf0e10cSrcweir     // check for valid start index
437*cdf0e10cSrcweir     int nStringLen = rTokenStr.Len();
438*cdf0e10cSrcweir     if( rIndex >= nStringLen )
439*cdf0e10cSrcweir     {
440*cdf0e10cSrcweir         rIndex = STRING_NOTFOUND;
441*cdf0e10cSrcweir         return String();
442*cdf0e10cSrcweir     }
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir     // find the next token delimiter and return the token substring
445*cdf0e10cSrcweir     const sal_Unicode* pStr = rTokenStr.GetBuffer() + rIndex;
446*cdf0e10cSrcweir     const sal_Unicode* pEnd = rTokenStr.GetBuffer() + nStringLen;
447*cdf0e10cSrcweir     for(; pStr < pEnd; ++pStr )
448*cdf0e10cSrcweir         if( (*pStr == ';') || (*pStr == ',') )
449*cdf0e10cSrcweir             break;
450*cdf0e10cSrcweir 
451*cdf0e10cSrcweir     xub_StrLen nTokenStart = rIndex;
452*cdf0e10cSrcweir     xub_StrLen nTokenLen;
453*cdf0e10cSrcweir     if( pStr < pEnd )
454*cdf0e10cSrcweir     {
455*cdf0e10cSrcweir         rIndex = sal::static_int_cast<xub_StrLen>(pStr - rTokenStr.GetBuffer());
456*cdf0e10cSrcweir         nTokenLen = rIndex - nTokenStart;
457*cdf0e10cSrcweir         ++rIndex; // skip over token separator
458*cdf0e10cSrcweir     }
459*cdf0e10cSrcweir     else
460*cdf0e10cSrcweir     {
461*cdf0e10cSrcweir         // no token delimiter found => handle last token
462*cdf0e10cSrcweir         rIndex = STRING_NOTFOUND;
463*cdf0e10cSrcweir         nTokenLen = STRING_LEN;
464*cdf0e10cSrcweir 
465*cdf0e10cSrcweir         // optimize if the token string consists of just one token
466*cdf0e10cSrcweir         if( !nTokenStart )
467*cdf0e10cSrcweir             return rTokenStr;
468*cdf0e10cSrcweir     }
469*cdf0e10cSrcweir 
470*cdf0e10cSrcweir     return String( rTokenStr, nTokenStart, nTokenLen );
471*cdf0e10cSrcweir }
472*cdf0e10cSrcweir 
473*cdf0e10cSrcweir // TODO: get rid of this in another incompatible build with SW project.
474*cdf0e10cSrcweir // SW's WW8 and RTF filters still use this (from fontcvt.hxx)
475*cdf0e10cSrcweir String GetFontToken( const String& rTokenStr, xub_StrLen nToken, xub_StrLen& rIndex )
476*cdf0e10cSrcweir {
477*cdf0e10cSrcweir     // skip nToken Tokens
478*cdf0e10cSrcweir     for( xub_StrLen i = 0; (i < nToken) && (rIndex != STRING_NOTFOUND); ++i )
479*cdf0e10cSrcweir         GetNextFontToken( rTokenStr, rIndex );
480*cdf0e10cSrcweir 
481*cdf0e10cSrcweir     return GetNextFontToken( rTokenStr, rIndex );
482*cdf0e10cSrcweir }
483*cdf0e10cSrcweir 
484*cdf0e10cSrcweir // =======================================================================
485*cdf0e10cSrcweir 
486*cdf0e10cSrcweir static bool ImplIsFontToken( const String& rName, const String& rToken )
487*cdf0e10cSrcweir {
488*cdf0e10cSrcweir     String      aTempName;
489*cdf0e10cSrcweir     xub_StrLen  nIndex = 0;
490*cdf0e10cSrcweir     do
491*cdf0e10cSrcweir     {
492*cdf0e10cSrcweir         aTempName = GetNextFontToken( rName, nIndex );
493*cdf0e10cSrcweir         if ( rToken == aTempName )
494*cdf0e10cSrcweir             return true;
495*cdf0e10cSrcweir     }
496*cdf0e10cSrcweir     while ( nIndex != STRING_NOTFOUND );
497*cdf0e10cSrcweir 
498*cdf0e10cSrcweir     return false;
499*cdf0e10cSrcweir }
500*cdf0e10cSrcweir 
501*cdf0e10cSrcweir // -----------------------------------------------------------------------
502*cdf0e10cSrcweir 
503*cdf0e10cSrcweir static void ImplAppendFontToken( String& rName, const String& rNewToken )
504*cdf0e10cSrcweir {
505*cdf0e10cSrcweir     if ( rName.Len() )
506*cdf0e10cSrcweir     {
507*cdf0e10cSrcweir         rName.Append( ';' );
508*cdf0e10cSrcweir         rName.Append( rNewToken );
509*cdf0e10cSrcweir     }
510*cdf0e10cSrcweir     else
511*cdf0e10cSrcweir         rName = rNewToken;
512*cdf0e10cSrcweir }
513*cdf0e10cSrcweir 
514*cdf0e10cSrcweir void AddTokenFontName( String& rName, const String& rNewToken )
515*cdf0e10cSrcweir {
516*cdf0e10cSrcweir     if ( !ImplIsFontToken( rName, rNewToken ) )
517*cdf0e10cSrcweir         ImplAppendFontToken( rName, rNewToken );
518*cdf0e10cSrcweir }
519*cdf0e10cSrcweir 
520*cdf0e10cSrcweir // =======================================================================
521*cdf0e10cSrcweir 
522*cdf0e10cSrcweir String GetSubsFontName( const String& rName, sal_uLong nFlags )
523*cdf0e10cSrcweir {
524*cdf0e10cSrcweir     String aName;
525*cdf0e10cSrcweir 
526*cdf0e10cSrcweir     xub_StrLen nIndex = 0;
527*cdf0e10cSrcweir     String aOrgName = GetNextFontToken( rName, nIndex );
528*cdf0e10cSrcweir     GetEnglishSearchFontName( aOrgName );
529*cdf0e10cSrcweir 
530*cdf0e10cSrcweir     // #93662# do not try to replace StarSymbol with MS only font
531*cdf0e10cSrcweir     if( nFlags == (SUBSFONT_MS|SUBSFONT_ONLYONE)
532*cdf0e10cSrcweir     &&  ( aOrgName.EqualsAscii( "starsymbol" )
533*cdf0e10cSrcweir       ||  aOrgName.EqualsAscii( "opensymbol" ) ) )
534*cdf0e10cSrcweir         return aName;
535*cdf0e10cSrcweir 
536*cdf0e10cSrcweir     const utl::FontNameAttr* pAttr = utl::FontSubstConfiguration::get()->getSubstInfo( aOrgName );
537*cdf0e10cSrcweir     if ( pAttr )
538*cdf0e10cSrcweir     {
539*cdf0e10cSrcweir         for( int i = 0; i < 3; i++ )
540*cdf0e10cSrcweir         {
541*cdf0e10cSrcweir             const ::std::vector< String >* pVector = NULL;
542*cdf0e10cSrcweir             switch( i )
543*cdf0e10cSrcweir             {
544*cdf0e10cSrcweir                 case 0:
545*cdf0e10cSrcweir                     if( nFlags & SUBSFONT_MS  &&  pAttr->MSSubstitutions.size() )
546*cdf0e10cSrcweir                         pVector = &pAttr->MSSubstitutions;
547*cdf0e10cSrcweir                     break;
548*cdf0e10cSrcweir                 case 1:
549*cdf0e10cSrcweir                     if( nFlags & SUBSFONT_PS  &&  pAttr->PSSubstitutions.size() )
550*cdf0e10cSrcweir                         pVector = &pAttr->PSSubstitutions;
551*cdf0e10cSrcweir                     break;
552*cdf0e10cSrcweir                 case 2:
553*cdf0e10cSrcweir                     if( nFlags & SUBSFONT_HTML  &&  pAttr->HTMLSubstitutions.size() )
554*cdf0e10cSrcweir                         pVector = &pAttr->HTMLSubstitutions;
555*cdf0e10cSrcweir                     break;
556*cdf0e10cSrcweir             }
557*cdf0e10cSrcweir             if( ! pVector )
558*cdf0e10cSrcweir                 continue;
559*cdf0e10cSrcweir             for( ::std::vector< String >::const_iterator it = pVector->begin(); it != pVector->end(); ++it )
560*cdf0e10cSrcweir                 if( ! ImplIsFontToken( rName, *it ) )
561*cdf0e10cSrcweir                 {
562*cdf0e10cSrcweir                     ImplAppendFontToken( aName, *it );
563*cdf0e10cSrcweir                     if( nFlags & SUBSFONT_ONLYONE )
564*cdf0e10cSrcweir                     {
565*cdf0e10cSrcweir                         i = 4;
566*cdf0e10cSrcweir                         break;
567*cdf0e10cSrcweir                     }
568*cdf0e10cSrcweir                 }
569*cdf0e10cSrcweir         }
570*cdf0e10cSrcweir     }
571*cdf0e10cSrcweir 
572*cdf0e10cSrcweir     return aName;
573*cdf0e10cSrcweir }
574*cdf0e10cSrcweir 
575*cdf0e10cSrcweir // -----------------------------------------------------------------------
576*cdf0e10cSrcweir 
577*cdf0e10cSrcweir // TODO: use a more generic String hash
578*cdf0e10cSrcweir int FontNameHash::operator()( const String& rStr ) const
579*cdf0e10cSrcweir {
580*cdf0e10cSrcweir     // this simple hash just has to be good enough for font names
581*cdf0e10cSrcweir     int nHash = 0;
582*cdf0e10cSrcweir     const int nLen = rStr.Len();
583*cdf0e10cSrcweir     const sal_Unicode* p = rStr.GetBuffer();
584*cdf0e10cSrcweir     switch( nLen )
585*cdf0e10cSrcweir     {
586*cdf0e10cSrcweir         default: nHash = (p[0]<<16) - (p[1]<<8) + p[2];
587*cdf0e10cSrcweir                  nHash += nLen;
588*cdf0e10cSrcweir                  p += nLen - 3;
589*cdf0e10cSrcweir                  // fall through
590*cdf0e10cSrcweir         case 3:  nHash += (p[2]<<16);   // fall through
591*cdf0e10cSrcweir         case 2:  nHash += (p[1]<<8);    // fall through
592*cdf0e10cSrcweir         case 1:  nHash += p[0];         // fall through
593*cdf0e10cSrcweir         case 0:  break;
594*cdf0e10cSrcweir     };
595*cdf0e10cSrcweir 
596*cdf0e10cSrcweir     return nHash;
597*cdf0e10cSrcweir }
598*cdf0e10cSrcweir 
599