Fixes parts of: http://bugzilla.opendarwin.org/show_bug.cgi?id=10467
WebKit should have Qt platform support
* platform/qt/FontCacheQt.cpp: Added.
(WebCore::FontCache::platformInit):
(WebCore::FontCache::getFontDataForCharacters):
(WebCore::FontCache::getSimilarFontPlatformData):
(WebCore::FontCache::getLastResortFallbackFont):
(WebCore::FontCache::createFontPlatformData):
* platform/qt/FontDataQt.cpp: Added.
(WebCore::FontData::platformInit):
(WebCore::FontData::platformDestroy):
(WebCore::FontData::smallCapsFontData):
(WebCore::FontData::containsCharacters):
(WebCore::FontData::determinePitch):
(WebCore::FontData::platformWidthForGlyph):
* platform/qt/FontPlatformData.h: Added.
* platform/qt/FontPlatformDataQt.cpp: Added.
(WebCore::FontPlatformData::FontPlatformData):
(WebCore::FontPlatformData::operator=):
(WebCore::FontPlatformData::~FontPlatformData):
(WebCore::FontPlatformData::isFixedPitch):
(WebCore::FontPlatformData::setFont):
(WebCore::FontPlatformData::font):
(WebCore::FontPlatformData::hash):
(WebCore::FontPlatformData::operator==):
* platform/qt/FontQt.cpp: Added.
(WebCore::Font::operator QFont):
(WebCore::Font::drawGlyphs):
(WebCore::Font::drawComplexText):
(WebCore::Font::floatWidthForComplexText):
* platform/qt/GlyphMapQt.cpp: Added.
(WebCore::GlyphMap::fillPage):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16012
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-08-24 Nikolas Zimmermann <zimmermann@kde.org>
+
+ Reviewed by ap.
+
+ Fixes parts of: http://bugzilla.opendarwin.org/show_bug.cgi?id=10467
+ WebKit should have Qt platform support
+
+ * platform/qt/FontCacheQt.cpp: Added.
+ (WebCore::FontCache::platformInit):
+ (WebCore::FontCache::getFontDataForCharacters):
+ (WebCore::FontCache::getSimilarFontPlatformData):
+ (WebCore::FontCache::getLastResortFallbackFont):
+ (WebCore::FontCache::createFontPlatformData):
+ * platform/qt/FontDataQt.cpp: Added.
+ (WebCore::FontData::platformInit):
+ (WebCore::FontData::platformDestroy):
+ (WebCore::FontData::smallCapsFontData):
+ (WebCore::FontData::containsCharacters):
+ (WebCore::FontData::determinePitch):
+ (WebCore::FontData::platformWidthForGlyph):
+ * platform/qt/FontPlatformData.h: Added.
+ * platform/qt/FontPlatformDataQt.cpp: Added.
+ (WebCore::FontPlatformData::FontPlatformData):
+ (WebCore::FontPlatformData::operator=):
+ (WebCore::FontPlatformData::~FontPlatformData):
+ (WebCore::FontPlatformData::isFixedPitch):
+ (WebCore::FontPlatformData::setFont):
+ (WebCore::FontPlatformData::font):
+ (WebCore::FontPlatformData::hash):
+ (WebCore::FontPlatformData::operator==):
+ * platform/qt/FontQt.cpp: Added.
+ (WebCore::Font::operator QFont):
+ (WebCore::Font::drawGlyphs):
+ (WebCore::Font::drawComplexText):
+ (WebCore::Font::floatWidthForComplexText):
+ * platform/qt/GlyphMapQt.cpp: Added.
+ (WebCore::GlyphMap::fillPage):
+
2006-08-24 David Harrison <harrison@apple.com>
Reinstate r15966 because layout test changes are correct.
--- /dev/null
+/*
+ * Copyright (C) 2006 Dirk Mueller <mueller@kde.org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "FontCache.h"
+
+#include "Font.h"
+#include "FontPlatformData.h"
+
+namespace WebCore {
+
+void FontCache::platformInit()
+{
+ // no-op
+}
+
+const FontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
+{
+ return new FontData(FontPlatformData(font.fontDescription(), font.family().family()));
+}
+
+FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font)
+{
+ return new FontPlatformData(font.fontDescription(), font.family().family());
+}
+
+FontPlatformData* FontCache::getLastResortFallbackFont(const Font& font)
+{
+ // FIXME: Would be even better to somehow get the user's default font here.
+ // For now we'll pick the default that the user would get without changing any prefs.
+ static AtomicString s_timesStr("Times New Roman");
+ return getCachedFontPlatformData(font.fontDescription(), s_timesStr);
+}
+
+FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
+{
+ return 0;
+}
+
+}
+
+// vim: ts=4 sw=4 et
--- /dev/null
+/*
+ * Copyright (C) 2006 Dirk Mueller <mueller@kde.org>
+ * Copyright (C) 2006 Simon Hausmann <hausmann@kde.org>
+ * Copyright (C) 2006 George Staikos <staikos@kde.org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "FontData.h"
+
+#include "Font.h"
+#include "FloatRect.h"
+#include "FontCache.h"
+#include "GlyphBuffer.h"
+#include "FontDescription.h"
+
+#include <QFontMetrics>
+
+namespace WebCore {
+
+void FontData::platformInit()
+{
+ QFontMetrics metrics(m_font.font());
+ m_ascent = metrics.ascent();
+ m_descent = metrics.descent();
+ m_lineSpacing = metrics.lineSpacing();
+ m_lineGap = metrics.leading();
+ m_xHeight = metrics.xHeight();
+ m_lineSpacing = m_ascent + m_descent + m_lineGap;
+}
+
+void FontData::platformDestroy()
+{
+}
+
+FontData* FontData::smallCapsFontData(const FontDescription& fontDescription) const
+{
+ return 0;
+}
+
+bool FontData::containsCharacters(const UChar* characters, int length) const
+{
+ return true;
+}
+
+void FontData::determinePitch()
+{
+}
+
+float FontData::platformWidthForGlyph(Glyph glyph) const
+{
+ return QFontMetricsF(m_font.font()).width(QChar(ushort(glyph)));
+}
+
+}
+
+// vim: ts=4 sw=4 et
--- /dev/null
+/*
+ * This file is part of the internal font implementation. It should not be included by anyone other than
+ * FontMac.cpp, FontWin.cpp and Font.cpp.
+ *
+ * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006 Zack Rusin <zack@kde.org>
+ * Copyright (C) 2006 Dirk Mueller <mueller@kde.org>
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef FontPlatformData_H
+#define FontPlatformData_H
+
+#include "GlyphBuffer.h"
+#include "FontDescription.h"
+
+#include <QFont>
+#include <QString>
+
+namespace WebCore {
+
+class FontPlatformData {
+public:
+ FontPlatformData(const FontPlatformData& other);
+ FontPlatformData& operator=(const FontPlatformData& other);
+
+ class Deleted { };
+ FontPlatformData(Deleted);
+
+ FontPlatformData();
+ FontPlatformData(const FontDescription&, const AtomicString& family);
+ ~FontPlatformData();
+
+ bool isFixedPitch();
+
+ void setFont(const QFont&);
+ QFont font() const;
+
+ unsigned hash() const;
+
+ bool operator==(const FontPlatformData& other) const;
+
+private:
+ QFont m_font;
+};
+
+}
+
+#endif
+
+// vim: ts=4 sw=4 et
--- /dev/null
+/*
+ * This file is part of the internal font implementation. It should not be included by anyone other than
+ * FontMac.cpp, FontWin.cpp and Font.cpp.
+ *
+ * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006 George Staikos <staikos@kde.org>
+ * Copyright (C) 2006 Dirk Mueller <mueller@kde.org>
+ * Copyright (C) 2006 Zack Rusin <zack@kde.org>
+ * Copyright (C) 2006 Simon Hausmann <hausmann@kde.org>
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+#include "FontPlatformData.h"
+
+#include "DeprecatedString.h"
+#include "FontDescription.h"
+
+#include <QDebug>
+#include <QFontInfo>
+
+namespace WebCore {
+
+FontPlatformData::FontPlatformData()
+{
+}
+
+FontPlatformData::FontPlatformData(Deleted)
+{
+}
+
+FontPlatformData::FontPlatformData(const FontDescription& fontDescription, const AtomicString& familyName)
+{
+ QFont font("Times New Roman", 12);
+ font.setFamily(familyName.domString());
+ font.setPixelSize(fontDescription.computedSize());
+ font.setItalic(fontDescription.italic());
+ font.setWeight(fontDescription.weight());
+ setFont(font);
+}
+
+FontPlatformData::FontPlatformData(const FontPlatformData& other)
+ : m_font(other.m_font)
+{
+}
+
+FontPlatformData& FontPlatformData::operator=(const FontPlatformData& other)
+{
+ m_font = other.m_font;
+ return *this;
+}
+
+FontPlatformData::~FontPlatformData()
+{
+}
+
+bool FontPlatformData::isFixedPitch()
+{
+ return QFontInfo(m_font).fixedPitch();
+}
+
+void FontPlatformData::setFont(const QFont& other)
+{
+ m_font = other;
+}
+
+QFont FontPlatformData::font() const
+{
+ return m_font;
+}
+
+unsigned FontPlatformData::hash() const
+{
+ return qHash(&m_font);
+}
+
+bool FontPlatformData::operator==(const FontPlatformData& other) const
+{
+ return (other.m_font == m_font);
+}
+
+}
+
+// vim: ts=4 sw=4 et
--- /dev/null
+/*
+ * Copyright (C) 2006 Dirk Mueller <mueller@kde.org>
+ * Copyright (C) 2006 Zack Rusin <zack@kde.org>
+ * Copyright (C) 2006 Simon Hausmann <hausmann@kde.org>
+ * Copyright (C) 2006 Allan Sandfeld Jensen <sandfeld@kde.org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "Font.h"
+
+#include "FontData.h"
+#include "GraphicsContext.h"
+
+#include <QPainter>
+#include <QDebug>
+
+namespace WebCore {
+
+Font::operator QFont() const
+{
+ Q_ASSERT(primaryFont() != 0);
+ return primaryFont()->platformData().font();
+}
+
+void Font::drawGlyphs(GraphicsContext* graphicsContext, const FontData* font, const GlyphBuffer& glyphBuffer,
+ int from, int numGlyphs, const FloatPoint& point) const
+{
+ QPainter& p = *graphicsContext->platformContext();
+
+ Color color = graphicsContext->pen().color();
+ p.setPen(QColor(color.red(), color.green(), color.blue()));
+ p.setFont(font->platformData().font());
+
+ QChar* buffer = reinterpret_cast<QChar*>(glyphBuffer.glyphs(from));
+ QString str = QString::fromRawData(buffer, numGlyphs);
+
+ p.drawText(QPointF(point.x(),point.y()), str);
+}
+
+void Font::drawComplexText(GraphicsContext* ctx, const TextRun& run, const TextStyle&, const FloatPoint& point) const
+{
+ // ### style, run.from()/length() cut-off
+ ctx->platformContext()->drawText(point.x(),
+ point.y(),
+ QString::fromRawData(reinterpret_cast<const QChar*>(run.characters() + run.from()), run.length()));
+}
+
+float Font::floatWidthForComplexText(const TextRun& run, const TextStyle&) const
+{
+ // ### style
+ QFontMetricsF metrics(primaryFont()->m_font.font());
+ return metrics.width(QString::fromRawData(reinterpret_cast<const QChar*>(run.characters() + run.from()), run.length()));
+}
+
+}
+
+// vim: ts=4 sw=4 et
--- /dev/null
+/*
+ * Copyright (C) 2006 George Staikos <staikos@kde.org>
+ * Copyright (C) 2006 Dirk Mueller <mueller@kde.org>
+ * Copyright (C) 2006 Zack Rusin <zack@kde.org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "GlyphMap.h"
+
+#include "FontData.h"
+
+namespace WebCore {
+
+bool GlyphMap::fillPage(GlyphPage* page, UChar* buffer, unsigned bufferLength, const FontData* fontData)
+{
+ for (unsigned i = 0; i < bufferLength; i++) {
+ page->setGlyphDataForIndex(i, buffer[i], fontData);
+ }
+
+ return true;
+}
+
+}
+
+// vim: ts=4 sw=4 et