Ignore:
Timestamp:
2013-06-11T01:01:28+02:00 (11 years ago)
Author:
Don-vip
Message:

fix #8742 - update svgsalamander to release 0.1.18+patch (fix bug SVGSALAMANDER-26) -> allow to open more SVG files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/com/kitfox/svg/FontFace.java

    r4256 r6002  
    11/*
    2  * Font.java
    3  *
    4  *
    5  *  The Salamander Project - 2D and 3D graphics libraries in Java
    6  *  Copyright (C) 2004 Mark McKay
    7  *
    8  *  This library is free software; you can redistribute it and/or
    9  *  modify it under the terms of the GNU Lesser General Public
    10  *  License as published by the Free Software Foundation; either
    11  *  version 2.1 of the License, or (at your option) any later version.
    12  *
    13  *  This library is distributed in the hope that it will be useful,
    14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    16  *  Lesser General Public License for more details.
    17  *
    18  *  You should have received a copy of the GNU Lesser General Public
    19  *  License along with this library; if not, write to the Free Software
    20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    21  *
    22  *  Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
    23  *  projects can be found at http://www.kitfox.com
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
     5 *
     6 * Redistribution and use in source and binary forms, with or
     7 * without modification, are permitted provided that the following
     8 * conditions are met:
     9 *
     10 *   - Redistributions of source code must retain the above
     11 *     copyright notice, this list of conditions and the following
     12 *     disclaimer.
     13 *   - Redistributions in binary form must reproduce the above
     14 *     copyright notice, this list of conditions and the following
     15 *     disclaimer in the documentation and/or other materials
     16 *     provided with the distribution.
     17 *
     18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     29 * OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
     31 * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
     32 * projects can be found at http://www.kitfox.com
    2433 *
    2534 * Created on February 20, 2004, 10:00 PM
    2635 */
    27 
    2836package com.kitfox.svg;
    2937
    3038import com.kitfox.svg.xml.StyleAttribute;
    31 import com.kitfox.svg.xml.*;
    32 import org.xml.sax.*;
    33 
    34 import java.awt.geom.*;
    35 import java.awt.*;
    36 
    3739
    3840/**
     
    4648public class FontFace extends SVGElement
    4749{
     50
     51    public static final String TAG_NAME = "fontface";
    4852    String fontFamily;
    49 
    50     /** Em size of coordinate system font is defined in */
     53    /**
     54     * Em size of coordinate system font is defined in
     55     */
    5156    int unitsPerEm = 1000;
    52 
    5357    int ascent = -1;
    5458    int descent = -1;
    5559    int accentHeight = -1;
    56 
    5760    int underlinePosition = -1;
    5861    int underlineThickness = -1;
     
    6265    int overlineThickness = -1;
    6366
    64     /** Creates a new instance of Font */
     67    /**
     68     * Creates a new instance of Font
     69     */
    6570    public FontFace()
    6671    {
    6772    }
    68 /*
    69     public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent)
    70     {
    71                 //Load style string
    72         super.loaderStartElement(helper, attrs, parent);
    73 
    74         fontFamily = attrs.getValue("font-family");
    75 
    76         String unitsPerEm = attrs.getValue("units-per-em");
    77         String ascent = attrs.getValue("ascent");
    78         String descent = attrs.getValue("descent");
    79         String accentHeight = attrs.getValue("accent-height");
    80 
    81         String underlinePosition = attrs.getValue("underline-position");
    82         String underlineThickness = attrs.getValue("underline-thickness");
    83         String strikethroughPosition = attrs.getValue("strikethrough-position");
    84         String strikethroughThickness = attrs.getValue("strikethrough-thickness");
    85         String overlinePosition = attrs.getValue("overline-position");
    86         String overlineThickness = attrs.getValue("overline-thickness");
    87 
    88 
    89         if (unitsPerEm != null) this.unitsPerEm = XMLParseUtil.parseInt(unitsPerEm);
    90         if (ascent != null) this.ascent = XMLParseUtil.parseInt(ascent);
    91         if (descent != null) this.descent = XMLParseUtil.parseInt(descent);
    92         if (accentHeight != null) this.accentHeight = XMLParseUtil.parseInt(accentHeight);
    93 
    94         if (underlinePosition != null) this.underlinePosition = XMLParseUtil.parseInt(underlinePosition);
    95         if (underlineThickness != null) this.underlineThickness = XMLParseUtil.parseInt(underlineThickness);
    96         if (strikethroughPosition != null) this.strikethroughPosition = XMLParseUtil.parseInt(strikethroughPosition);
    97         if (strikethroughThickness != null) this.strikethroughThickness = XMLParseUtil.parseInt(strikethroughThickness);
    98         if (overlinePosition != null) this.overlinePosition = XMLParseUtil.parseInt(overlinePosition);
    99         if (overlineThickness != null) this.overlineThickness = XMLParseUtil.parseInt(overlineThickness);
    100 
    101 //        unitFontXform.setToScale(1.0 / (double)unitsPerEm, 1.0 / (double)unitsPerEm);
    102     }
    103   */ 
    104     /*
    105     public void loaderEndElement(SVGLoaderHelper helper)
    106     {
    107         super.loaderEndElement(helper);
    108 
    109         build();
    110        
    111 //        unitFontXform.setToScale(1.0 / (double)unitsPerEm, 1.0 / (double)unitsPerEm);
    112     }
    113      */
    114    
     73
     74    public String getTagName()
     75    {
     76        return TAG_NAME;
     77    }
     78
    11579    protected void build() throws SVGException
    11680    {
    11781        super.build();
    118        
     82
    11983        StyleAttribute sty = new StyleAttribute();
    120        
    121         if (getPres(sty.setName("font-family"))) fontFamily = sty.getStringValue();
    122        
    123         if (getPres(sty.setName("units-per-em"))) unitsPerEm = sty.getIntValue();
    124         if (getPres(sty.setName("ascent"))) ascent = sty.getIntValue();
    125         if (getPres(sty.setName("descent"))) descent = sty.getIntValue();
    126         if (getPres(sty.setName("accent-height"))) accentHeight = sty.getIntValue();
    127 
    128         if (getPres(sty.setName("underline-position"))) underlinePosition = sty.getIntValue();
    129         if (getPres(sty.setName("underline-thickness"))) underlineThickness = sty.getIntValue();
    130         if (getPres(sty.setName("strikethrough-position"))) strikethroughPosition = sty.getIntValue();
    131         if (getPres(sty.setName("strikethrough-thickenss"))) strikethroughThickness = sty.getIntValue();
    132         if (getPres(sty.setName("overline-position"))) overlinePosition = sty.getIntValue();
    133         if (getPres(sty.setName("overline-thickness"))) overlineThickness = sty.getIntValue();
    134     }
    135 
    136 
    137     public String getFontFamily() { return fontFamily; }
    138 
    139     public int getUnitsPerEm() { return unitsPerEm; }
     84
     85        if (getPres(sty.setName("font-family")))
     86        {
     87            fontFamily = sty.getStringValue();
     88        }
     89
     90        if (getPres(sty.setName("units-per-em")))
     91        {
     92            unitsPerEm = sty.getIntValue();
     93        }
     94        if (getPres(sty.setName("ascent")))
     95        {
     96            ascent = sty.getIntValue();
     97        }
     98        if (getPres(sty.setName("descent")))
     99        {
     100            descent = sty.getIntValue();
     101        }
     102        if (getPres(sty.setName("accent-height")))
     103        {
     104            accentHeight = sty.getIntValue();
     105        }
     106
     107        if (getPres(sty.setName("underline-position")))
     108        {
     109            underlinePosition = sty.getIntValue();
     110        }
     111        if (getPres(sty.setName("underline-thickness")))
     112        {
     113            underlineThickness = sty.getIntValue();
     114        }
     115        if (getPres(sty.setName("strikethrough-position")))
     116        {
     117            strikethroughPosition = sty.getIntValue();
     118        }
     119        if (getPres(sty.setName("strikethrough-thickenss")))
     120        {
     121            strikethroughThickness = sty.getIntValue();
     122        }
     123        if (getPres(sty.setName("overline-position")))
     124        {
     125            overlinePosition = sty.getIntValue();
     126        }
     127        if (getPres(sty.setName("overline-thickness")))
     128        {
     129            overlineThickness = sty.getIntValue();
     130        }
     131    }
     132
     133    public String getFontFamily()
     134    {
     135        return fontFamily;
     136    }
     137
     138    public int getUnitsPerEm()
     139    {
     140        return unitsPerEm;
     141    }
    140142
    141143    public int getAscent()
    142144    {
    143145        if (ascent == -1)
    144             ascent = unitsPerEm - ((Font)parent).getVertOriginY();
     146        {
     147            ascent = unitsPerEm - ((Font) parent).getVertOriginY();
     148        }
    145149        return ascent;
    146150    }
     
    149153    {
    150154        if (descent == -1)
    151             descent = ((Font)parent).getVertOriginY();
     155        {
     156            descent = ((Font) parent).getVertOriginY();
     157        }
    152158        return descent;
    153159    }
     
    156162    {
    157163        if (accentHeight == -1)
     164        {
    158165            accentHeight = getAscent();
     166        }
    159167        return accentHeight;
    160168    }
     
    163171    {
    164172        if (underlinePosition == -1)
     173        {
    165174            underlinePosition = unitsPerEm * 5 / 6;
     175        }
    166176        return underlinePosition;
    167177    }
     
    170180    {
    171181        if (underlineThickness == -1)
     182        {
    172183            underlineThickness = unitsPerEm / 20;
     184        }
    173185        return underlineThickness;
    174186    }
     
    177189    {
    178190        if (strikethroughPosition == -1)
     191        {
    179192            strikethroughPosition = unitsPerEm * 3 / 6;
     193        }
    180194        return strikethroughPosition;
    181195    }
     
    184198    {
    185199        if (strikethroughThickness == -1)
     200        {
    186201            strikethroughThickness = unitsPerEm / 20;
     202        }
    187203        return strikethroughThickness;
    188204    }
     
    191207    {
    192208        if (overlinePosition == -1)
     209        {
    193210            overlinePosition = unitsPerEm * 5 / 6;
     211        }
    194212        return overlinePosition;
    195213    }
     
    198216    {
    199217        if (overlineThickness == -1)
     218        {
    200219            overlineThickness = unitsPerEm / 20;
     220        }
    201221        return overlineThickness;
    202222    }
    203    
     223
    204224    /**
    205      * Updates all attributes in this diagram associated with a time event.
    206      * Ie, all attributes with track information.
     225     * Updates all attributes in this diagram associated with a time event. Ie,
     226     * all attributes with track information.
     227     *
    207228     * @return - true if this node has changed state as a result of the time
    208229     * update
Note: See TracChangeset for help on using the changeset viewer.