File indexing completed on 2024-04-28 15:24:34

0001 /*
0002    Copyright (C) 2007 Eric Seidel <eric@webkit.org>
0003    Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
0004    Copyright (C) 2008 Eric Seidel <eric@webkit.org>
0005 
0006    This library is free software; you can redistribute it and/or
0007    modify it under the terms of the GNU Library General Public
0008    License as published by the Free Software Foundation; either
0009    version 2 of the License, or (at your option) any later version.
0010 
0011    This library is distributed in the hope that it will be useful,
0012    but WITHOUT ANY WARRANTY; without even the implied warranty of
0013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014    Library General Public License for more details.
0015 
0016    You should have received a copy of the GNU Library General Public License
0017    along with this library; see the file COPYING.LIB.  If not, write to
0018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019    Boston, MA 02110-1301, USA.
0020 */
0021 
0022 #include "wtf/Platform.h"
0023 
0024 #if ENABLE(SVG_FONTS)
0025 #include "SVGHKernElement.h"
0026 
0027 #include "SVGFontElement.h"
0028 //FIXME khtml #include "SVGFontFaceElement.h"
0029 #include "SVGFontData.h"
0030 #include "SVGNames.h"
0031 #include "SVGParserUtilities.h"
0032 //FIXME khtml #include "SimpleFontData.h"
0033 
0034 namespace WebCore
0035 {
0036 
0037 using namespace SVGNames;
0038 
0039 SVGHKernElement::SVGHKernElement(const QualifiedName &tagName, Document *doc)
0040     : SVGElement(tagName, doc)
0041 {
0042 }
0043 
0044 SVGHKernElement::~SVGHKernElement()
0045 {
0046 }
0047 
0048 void SVGHKernElement::insertedIntoDocument()
0049 {
0050     Node *fontNode = parentNode();
0051     if (fontNode && fontNode->hasTagName(fontTag)) {
0052         if (SVGFontElement *element = static_cast<SVGFontElement *>(fontNode)) {
0053             element->invalidateGlyphCache();
0054         }
0055     }
0056 }
0057 
0058 void SVGHKernElement::removedFromDocument()
0059 {
0060     Node *fontNode = parentNode();
0061     if (fontNode && fontNode->hasTagName(fontTag)) {
0062         if (SVGFontElement *element = static_cast<SVGFontElement *>(fontNode)) {
0063             element->invalidateGlyphCache();
0064         }
0065     }
0066 }
0067 
0068 SVGHorizontalKerningPair SVGHKernElement::buildHorizontalKerningPair() const
0069 {
0070     SVGHorizontalKerningPair kerningPair;
0071 
0072     kerningPair.unicode1 = getAttribute(u1Attr);
0073     kerningPair.glyphName1 = getAttribute(g1Attr);
0074     kerningPair.unicode2 = getAttribute(u2Attr);
0075     kerningPair.glyphName2 = getAttribute(g2Attr);
0076     kerningPair.kerning = getAttribute(kAttr).string().toDouble();
0077 
0078     return kerningPair;
0079 }
0080 
0081 }
0082 
0083 #endif // ENABLE(SVG_FONTS)