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