1 /*
2 Copyright (C) 2008 Holger Hans Peter Freyther
3 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
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 */
21
22 #include "config.h"
23 #include "FontPlatformData.h"
24
25 #include "PlatformString.h"
26
27 namespace WebCore {
28
FontPlatformData(const FontDescription & description,int wordSpacing,int letterSpacing)29 FontPlatformData::FontPlatformData(const FontDescription& description, int wordSpacing, int letterSpacing)
30 : m_size(0.0f)
31 , m_bold(false)
32 , m_oblique(false)
33 {
34 QString familyName;
35 const FontFamily* family = &description.family();
36 while (family) {
37 familyName += family->family();
38 family = family->next();
39 if (family)
40 familyName += QLatin1Char(',');
41 }
42
43 m_font.setFamily(familyName);
44 m_font.setPixelSize(qRound(description.computedSize()));
45 m_font.setItalic(description.italic());
46
47 m_font.setWeight(toQFontWeight(description.weight()));
48 m_bold = m_font.bold();
49
50 bool smallCaps = description.smallCaps();
51 m_font.setCapitalization(smallCaps ? QFont::SmallCaps : QFont::MixedCase);
52 m_font.setWordSpacing(wordSpacing);
53 m_font.setLetterSpacing(QFont::AbsoluteSpacing, letterSpacing);
54 m_size = m_font.pointSize();
55 }
56
FontPlatformData(const QFont & font,bool bold)57 FontPlatformData::FontPlatformData(const QFont& font, bool bold)
58 : m_size(font.pointSize())
59 , m_bold(bold)
60 , m_oblique(false)
61 , m_font(font)
62 {
63 }
64
65 #if ENABLE(SVG_FONTS)
FontPlatformData(float size,bool bold,bool oblique)66 FontPlatformData::FontPlatformData(float size, bool bold, bool oblique)
67 : m_size(size)
68 , m_bold(bold)
69 , m_oblique(oblique)
70 {
71 }
72 #endif
73
FontPlatformData()74 FontPlatformData::FontPlatformData()
75 : m_size(0.0f)
76 , m_bold(false)
77 , m_oblique(false)
78 {
79 }
80
81 #ifndef NDEBUG
description() const82 String FontPlatformData::description() const
83 {
84 return String();
85 }
86 #endif
87
88 }
89