1 /*
2     Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
3     Copyright (C) 2008 Holger Hans Peter Freyther
4 
5     This library is free software; you can redistribute it and/or
6     modify it under the terms of the GNU Library General Public
7     License as published by the Free Software Foundation; either
8     version 2 of the License, or (at your option) any later version.
9 
10     This library is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13     Library General Public License for more details.
14 
15     You should have received a copy of the GNU Library General Public License
16     along with this library; see the file COPYING.LIB.  If not, write to
17     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18     Boston, MA 02110-1301, USA.
19 
20     This class provides all functionality needed for loading images, style sheets and html
21     pages from the web. It has a memory cache for these objects.
22 */
23 #include "config.h"
24 #include "GlyphPageTreeNode.h"
25 
26 #if HAVE(QRAWFONT)
27 #include "SimpleFontData.h"
28 #include <QFontMetricsF>
29 #include <QTextLayout>
30 #endif
31 
32 namespace WebCore {
33 
34 #if HAVE(QRAWFONT)
fill(unsigned offset,unsigned length,UChar * buffer,unsigned bufferLength,const SimpleFontData * fontData)35 bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData)
36 {
37     QRawFont rawFont = fontData->platformData().rawFont();
38     QString qstring = QString::fromRawData(reinterpret_cast<const QChar*>(buffer), static_cast<int>(bufferLength));
39     QVector<quint32> indexes = rawFont.glyphIndexesForString(qstring);
40 
41     bool haveGlyphs = false;
42 
43     for (unsigned i = 0; i < length; ++i) {
44         Glyph glyph = (i < indexes.size()) ? indexes.at(i) : 0;
45         if (!glyph)
46             setGlyphDataForIndex(offset + i, 0, 0);
47         else {
48             haveGlyphs = true;
49             setGlyphDataForIndex(offset + i, glyph, fontData);
50         }
51     }
52     return haveGlyphs;
53 }
54 #else
55 
56 void GlyphPageTreeNode::pruneTreeCustomFontData(const FontData*)
57 {
58 }
59 
60 void GlyphPageTreeNode::pruneTreeFontData(const WebCore::SimpleFontData*)
61 {
62 }
63 #endif // HAVE(QRAWFONT)
64 
65 }
66