Home | History | Annotate | Download | only in qt
      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 
     24 #include "config.h"
     25 #include "SimpleFontData.h"
     26 
     27 #include <QFontMetrics>
     28 
     29 namespace WebCore {
     30 
     31 void SimpleFontData::determinePitch()
     32 {
     33     m_treatAsFixedPitch = m_platformData.font().fixedPitch();
     34 }
     35 
     36 bool SimpleFontData::containsCharacters(const UChar*, int) const
     37 {
     38     return true;
     39 }
     40 
     41 void SimpleFontData::platformInit()
     42 {
     43     QFontMetrics fm(m_platformData.font());
     44 
     45     m_ascent = fm.ascent();
     46     m_descent = fm.descent();
     47     m_lineSpacing = fm.lineSpacing();
     48     m_xHeight = fm.xHeight();
     49     m_spaceWidth = fm.width(QLatin1Char(' '));
     50     m_lineGap = fm.leading();
     51 }
     52 
     53 void SimpleFontData::platformGlyphInit()
     54 {
     55     m_spaceGlyph = 0;
     56     m_adjustedSpaceWidth = m_spaceWidth;
     57     determinePitch();
     58     m_missingGlyphData.fontData = this;
     59     m_missingGlyphData.glyph = 0;
     60 }
     61 
     62 void SimpleFontData::platformCharWidthInit()
     63 {
     64     QFontMetrics fm(m_platformData.font());
     65     m_avgCharWidth = fm.averageCharWidth();
     66     m_maxCharWidth = fm.maxWidth();
     67 }
     68 
     69 void SimpleFontData::platformDestroy()
     70 {
     71 }
     72 
     73 }
     74