1 /*
2 * Copyright (C) 2007-2009 Torch Mobile Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 *
19 */
20
21 #include "config.h"
22 #include "GlyphPageTreeNode.h"
23
24 #include "Font.h"
25 #include "FontCache.h"
26 #include "FontData.h"
27 #include "SimpleFontData.h"
28
29 namespace WebCore {
30
31 DWORD getKnownFontCodePages(const wchar_t* family);
32
33 typedef unsigned (*funcGetCharCodePages)(unsigned short c, unsigned& lastPos);
34 funcGetCharCodePages getCharCodePages = 0;
35
fill(unsigned offset,unsigned length,UChar * buffer,unsigned bufferLength,const SimpleFontData * fontData)36 bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData)
37 {
38 if (length != bufferLength)
39 return false;
40
41 if (fontData->platformData().hfont()) {
42 DWORD fontCodePages = fontData->platformData().codePages();
43 if (fontCodePages) {
44 if (getCharCodePages) {
45 unsigned lastPos = 0;
46 for (unsigned i = 0; i < bufferLength; ++i) {
47 DWORD actualCodePages = getCharCodePages(buffer[i], lastPos);
48 if (!actualCodePages || (actualCodePages & fontCodePages))
49 setGlyphDataForIndex(offset + i, buffer[i], fontData);
50 else
51 setGlyphDataForIndex(offset + i, buffer[i], 0);
52 }
53 return true;
54 #if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
55 } else if (IMLangFontLink2* langFontLink = fontCache()->getFontLinkInterface()) {
56 #else
57 } else if (IMLangFontLink* langFontLink = fontCache()->getFontLinkInterface()) {
58 #endif
59 for (unsigned i = 0; i < bufferLength; ++i) {
60 DWORD actualCodePages;
61 langFontLink->GetCharCodePages(buffer[i], &actualCodePages);
62 if (!actualCodePages || (actualCodePages & fontCodePages))
63 setGlyphDataForIndex(offset + i, buffer[i], fontData);
64 else
65 setGlyphDataForIndex(offset + i, buffer[i], 0);
66 }
67 return true;
68 }
69 }
70 }
71
72 for (unsigned i = 0; i < length; ++i)
73 setGlyphDataForIndex(offset + i, buffer[i], fontData);
74
75 return true;
76 }
77
78 } // namespace WebCore
79