All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jpedal.fonts.glyph.T1Glyph Maven / Gradle / Ivy

There is a newer version: 20151002
Show newest version
/*
 * ===========================================
 * Java Pdf Extraction Decoding Access Library
 * ===========================================
 *
 * Project Info:  http://www.idrsolutions.com
 * Help section for developers at http://www.idrsolutions.com/support/
 *
 * (C) Copyright 1997-2016 IDRsolutions and Contributors.
 *
 * This file is part of JPedal/JPDF2HTML5
 *
     This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 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
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


 *
 * ---------------
 * T1Glyph.java
 * ---------------
 */
package org.jpedal.fonts.glyph;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
import java.awt.geom.Area;
import java.awt.geom.GeneralPath;
import java.awt.geom.PathIterator;
import java.io.IOException;
import java.io.ObjectOutput;
import org.jpedal.color.PdfTexturePaint;
import org.jpedal.io.PathSerializer;
import org.jpedal.objects.GraphicsState;
import org.jpedal.utils.repositories.Vector_Path;


/**
 * 

defines the current shape which is created by command stream

*

This class is NOT part of the API

. * Shapes can be drawn onto pdf or used as a clip on other image/shape/text. * Shape is built up by storing commands and then turning these commands into a * shape. Has to be done this way as Winding rule is not necessarily * declared at start. */ public class T1Glyph extends BaseT1Glyph { /** marked as transient so it wont be serialized */ private transient Vector_Path cached_current_path; private Paint strokePaint; /** * store scaling factors */ public T1Glyph(final Vector_Path cached_current_path){ this.cached_current_path=cached_current_path; } ////////////////////////////////////////////////////////////////////////// /** * turn shape commands into a Shape object, storing info for later. Has to * be done this way because we need the winding rule to initialise the shape * in Java, and it could be set awywhere in the command stream */ @Override public void render(final int text_fill_type, final Graphics2D g2, final float scaling, final boolean isFormGlyph) { if(cached_current_path!=null){ //Shape c=g2.getClip(); // // g2.setClip(null); // // g2.setPaint(Color.RED); // g2.fillRect(0, 0, 300, 600); // g2.setPaint(Color.BLUE); // g2.fillRect(300, 0, 300, 600); // g2.drawLine(0,0,600,600); // g2.setClip(c); // // final GeneralPath[] paths=cached_current_path.get(); for (final GeneralPath path : paths) { if (path == null) { break; } if ((text_fill_type == GraphicsState.FILL)) { //replicate shadow effect if (isStroked) { final Paint fillPaint = g2.getPaint(); if (!(fillPaint instanceof PdfTexturePaint) && ((Color) strokePaint).getRGB() != ((Color) fillPaint).getRGB() && strokedPositions.containsKey(String.valueOf((int) g2.getTransform().getTranslateX()) + '-' + (int) g2.getTransform().getTranslateY())) { g2.setPaint(strokePaint); g2.draw(path); g2.setPaint(fillPaint); } } g2.fill(path); } if (text_fill_type == GraphicsState.STROKE) { g2.draw(path); strokePaint = g2.getPaint(); strokedPositions.put(String.valueOf((int) g2.getTransform().getTranslateX()) + '-' + (int) g2.getTransform().getTranslateY(), "x"); } } } } Area glyphShape; /**return shape of glyph*/ @Override public Area getShape() { if((cached_current_path!=null && glyphShape==null)){ final GeneralPath[] paths=cached_current_path.get(); final int cacheCount=paths.length; for(int i=1;ib.x) { minX = b.x; } if(minY>b.y) { minY = b.y; } if(maxX




© 2015 - 2024 Weber Informatics LLC | Privacy Policy