Package org.jpedal.fonts.glyph

Examples of org.jpedal.fonts.glyph.PdfGlyph


        if (text_fill_type == GraphicsState.STROKE && lineWidth >= 1.0) {
            strokeOnlyLine = scaling;
        }

        //get glyph to draw
        PdfGlyph glyph = FontFactory.chooseGlyph(glyphType, rawglyph);

        AffineTransform at = g2.getTransform();

        //and also as flat values so we can test below
        double[] affValues = new double[6];
        at.getMatrix(affValues);

        if (glyph != null) {

            Stroke currentStoke = g2.getStroke();

            if (lineWidth != 0) {
                float w = lineWidth * (float)g2.getTransform().getScaleX();
                if (w < 0)
                    w = -w;
                g2.setStroke(new BasicStroke(w));
            }

            //set transform
            g2.transform(glyphAT);

            //type of draw operation to use
            Composite comp = g2.getComposite();

            /**
             * Fill Text
             */
            if ((text_fill_type & GraphicsState.FILL) == GraphicsState.FILL) {

                fillPaint.setScaling(cropX, cropH, scaling, 0, 0);

                if (customColorHandler != null) {
                    customColorHandler.setPaint(g2, fillPaint, pageNumber, isPrinting);
                } else if (PdfDecoder.Helper != null) {
                    PdfDecoder.Helper.setPaint(g2, fillPaint, pageNumber, isPrinting);
                } else {
                    g2.setPaint(fillPaint);
                }

                if (fillOpacity != 1f) {
                    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, fillOpacity));
                }

                if (textHighlight != null) {
                    if (invertHighlight) {
                        Color color = g2.getColor();
                        g2.setColor(new Color(255 - color.getRed(), 255 - color.getGreen(), 255 - color.getBlue()));
                    } else if (DecoderOptions.backgroundColor != null) {
                        g2.setColor(DecoderOptions.backgroundColor);
                    }
                }

                glyph.render(GraphicsState.FILL, g2, scaling, false);

                //reset opacity
                g2.setComposite(comp);

            }

            /**
             * Stroke Text (Can be fill and stroke so not in else)
             */
            if (text_fill_type == GraphicsState.STROKE) {
                glyph.setStrokedOnly(true);
            }

            //creates shadow printing to Mac so added work around
            if (PdfDecoder.isRunningOnMac && isPrinting && text_fill_type == GraphicsState.FILLSTROKE) {
            } else if ((text_fill_type & GraphicsState.STROKE) == GraphicsState.STROKE) {

                if (strokePaint != null) {
                    strokePaint.setScaling(cropX, cropH, scaling, 0, 0);
                }

                if (customColorHandler != null) {
                    customColorHandler.setPaint(g2, strokePaint, pageNumber, isPrinting);
                } else if (PdfDecoder.Helper != null) {
                    PdfDecoder.Helper.setPaint(g2, strokePaint, pageNumber, isPrinting);
                } else {
                    g2.setPaint(strokePaint);
                }

                if (strokeOpacity != 1f) {
                    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, strokeOpacity));
                }

                if (textHighlight != null) {
                    if (invertHighlight) {
                        Color color = g2.getColor();
                        g2.setColor(new Color(255 - color.getRed(), 255 - color.getGreen(), 255 - color.getBlue()));
                    } else if (DecoderOptions.backgroundColor != null) {
                        g2.setColor(DecoderOptions.backgroundColor);
                    }
                }

                try {
                    glyph.render(GraphicsState.STROKE, g2, strokeOnlyLine, false);
                } catch (Exception e) {
                    System.out.println("Exception " + e + " rendering glyph");
                    e.printStackTrace();
                }

View Full Code Here


      lastTrm=Trm;
      flush();
    }

    //either calculate the glyph to draw or reuse if alreasy drawn
    PdfGlyph transformedGlyph2 = getEmbeddedCachedShape(id);

    if (transformedGlyph2 == null) {

            //use CMAP to get actual glyph ID
            int idx=rawInt;


            if((!isCID || !isIdentity()) && currentCMAP!=null)
                idx=currentCMAP.convertIndexToCharacterCode(glyph,rawInt,remapFont,isSubsetted, diffTable);

            //if no value use post to lookup
            if(idx<1)
                idx=currentPost.convertGlyphToCharacterCode(glyph);

            //shape to draw onto
      try{
                if(hasCFF){

                  transformedGlyph2=currentCFF.getCFFGlyph(factory,glyph,Trm,idx, displayValue,currentWidth,key);

                    //set raw width to use for scaling
                  if(transformedGlyph2!=null)
                    transformedGlyph2.setWidth(getUnscaledWidth(glyph, rawInt, displayValue,false));


                }else
                    transformedGlyph2=getTTGlyph(idx,glyph,rawInt, displayValue,currentWidth);
      }catch(Exception e){
View Full Code Here

  public PdfGlyph getTTGlyph(int idx,String glyph,int rawInt, String displayValue, float currentWidth) {

       if(isCorrupted)
        idx=rawInt;

    PdfGlyph currentGlyph=null;
    /**
    if(rawInt>glyphCount){
      LogWriter.writeLog("Font index out of bounds using defaul t"+glyphCount);
      rawInt=0;

View Full Code Here

            xAvgCharWidth= (int) ((double)totalWidth/(double)glyphCount);

        //Collect glyph metrics
        double maxX = Double.MIN_VALUE;
        for (int i=0; i<glyphCount && i<256; i++) {
            PdfGlyph glyph = glyphs.getEmbeddedGlyph(new org.jpedal.fonts.glyph.T1GlyphFactory(),
                                                     pdfFont.getMappedChar(i, false),
                                                     new float[][]{{1,0},{0,1}},
                                                     i,
                                                     pdfFont.getGlyphValue(i),
                                                     pdfFont.getWidth(i),
                                                     pdfFont.getMappedChar(i, false));

            if (glyph != null && glyph.getShape() != null) {

                Rectangle2D area = glyph.getShape().getBounds2D();

                double lsb = area.getMinX();
                double rsb = advanceWidths[i]-area.getMaxX();
                double extent = area.getMinX() + area.getWidth();
View Full Code Here

TOP

Related Classes of org.jpedal.fonts.glyph.PdfGlyph

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.