Package org.jpedal.fonts

Examples of org.jpedal.fonts.PdfFont


                                    if(currentTextState.hasFontChanged()){

                                        //switch to correct font
                                        String fontID=currentTextState.getFontID();
                                        PdfFont restoredFont = resolveFont(fontID);
                                        if(restoredFont!=null){
                                            currentFontData=restoredFont;
                                            current.drawFontBounds(currentFontData.getBoundingBox());
                                        }
                                    }

                                    if(currentFontData==null)
                                        currentFontData=new PdfFont(currentPdfFile);

                                    if(currentTextState.hasFontChanged()){
                                        currentTextState.setFontChanged(false);
                                    }
View Full Code Here


     * decode or get font
     * @param fontID
     */
    private PdfFont resolveFont(String fontID) {

        PdfFont restoredFont=(PdfFont) cache.resolvedFonts.get(fontID);

        //check it was decoded
        if(restoredFont==null){

            String ref=(String)cache.unresolvedFonts.get(fontID);
View Full Code Here

    }

    public PdfFont createFont(PdfObject pdfObject, String font_id, ObjectStore objectStoreStreamRef, boolean renderPage, ErrorTracker errorTracker, boolean isPrinting) throws PdfException {


        PdfFont currentFontData=null;
        /**
         * allow for no actual object - ie /PDFdata/baseline_screens/debug/res.pdf
         **/
        //found examples with no type set so cannot rely on it
        //int rawType=pdfObject.getParameterConstant(PdfDictionary.Type);
        //if(rawType!=PdfDictionary.Font)
        //  return null;

        baseFont="";
        rawFontName=null;
        subFont=null;

        int fontType= PdfDictionary.Unknown;
        origfontType=PdfDictionary.Unknown;

        PdfObject descendantFont=pdfObject.getDictionary(PdfDictionary.DescendantFonts);

        boolean isEmbedded= isFontEmbedded(pdfObject);
        boolean isFontBroken=true; //ensure enters once

        while(isFontBroken){ //will try to sub font if error in embedded
            isFontBroken=false;

            /**
             * handle any font remapping but not on CID fonts or Type3 and gets too messy
             **/
            if(FontMappings.fontSubstitutionTable!=null && !isEmbedded &&
                    pdfObject.getParameterConstant(PdfDictionary.Subtype)!= StandardFonts.TYPE3)
                fontType = getFontMapping(pdfObject, font_id, fontType, descendantFont);

            //get subtype if not set above
            if(fontType==PdfDictionary.Unknown){
                fontType=pdfObject.getParameterConstant(PdfDictionary.Subtype);

                /**handle CID fonts where /Subtype stored inside sub object*/
                if (fontType==StandardFonts.TYPE0) {

                    //get CID type and use in preference to Type0 on CID fonts
                    PdfObject desc=pdfObject.getDictionary(PdfDictionary.DescendantFonts);
                    fontType=desc.getParameterConstant(PdfDictionary.Subtype);

                    origfontType=fontType;

                    //track non-embedded, non-substituted CID fonts
                    if(!isEmbedded && subFont==null) {
                        hasNonEmbeddedCIDFonts=true;

                        //track list
                        if(nonEmbeddedCIDFonts.length()>0)
                            nonEmbeddedCIDFonts.append(',');
                        nonEmbeddedCIDFonts.append(baseFont);
                    }
                }
            }

            if(fontType==PdfDictionary.Unknown){

              if(LogWriter.isOutput())
                LogWriter.writeLog("Font type not supported");


                currentFontData=new PdfFont(currentPdfFile);
            }

            /**
             * check for OpenType fonts and reassign type
             */
            if(fontType==StandardFonts.TYPE1 || fontType==StandardFonts.CIDTYPE2)
                fontType = scanForOpenType(pdfObject, currentPdfFile, fontType);

            try{
                currentFontData=FontFactory.createFont(fontType,currentPdfFile,subFont, isPrinting);

                /**set an alternative to Lucida*/
                if(FontMappings.defaultFont!=null)
                    currentFontData.setDefaultDisplayFont(FontMappings.defaultFont);

                currentFontData.createFont(pdfObject, font_id,renderPage, objectStoreStreamRef, fontsLoaded);

                //save raw version
                currentFontData.setRawFontName(rawFontName);

                //fix for odd file
                if(fontType==StandardFonts.TYPE1 && currentFontData.is1C() && pdfObject.getInt(PdfDictionary.FirstChar)==32 &&
                        pdfObject.getInt(PdfDictionary.FirstChar)==pdfObject.getInt(PdfDictionary.LastChar)){

                    if(isEmbedded){
                        isFontBroken=true;
                        isEmbedded=false;
View Full Code Here

            default:


                //LogWriter.writeLog("Font type " + subtype + " not supported");
                return new PdfFont(currentPdfFile);
        }

    }
View Full Code Here

      //special case used from PdfStreamDecoder to get font data
    case SAVE_EMBEDDED_FONT:

      //save ttf font data as file
      Object[] fontData= (Object[]) str;
      PdfFont pdfFont=(PdfFont)fontData[0];
      String fontName=pdfFont.getFontName();
      String fileType=(String)fontData[2];

      //make sure Dir exists
      String fontPath = rootDir + javaFxFileName + '/';
      File cssDir = new File(fontPath);
View Full Code Here

      //special case used from PdfStreamDecoder to get font data
    case SAVE_EMBEDDED_FONT:

      //save ttf font data as file
      Object[] fontData= (Object[]) str;
      PdfFont pdfFont=(PdfFont)fontData[0];
      String fontName=pdfFont.getFontName();
      String fileType=(String)fontData[2];

      //make sure Dir exists
      String fontPath = rootDir + javaFxFileName + '/';
      File cssDir = new File(fontPath);
View Full Code Here

                        font = font.substring(1);
                }catch(Exception e){
                    LogWriter.writeLog("Error in generating Tf font "+tokenValues[i]);
                }

                PdfFont currentFont=new PdfFont();

                formObject.setTextFont(currentFont.setFont(font, textSize));

                formObject.setTextSize(textSize);

            }else if(tokenValues[i].equals("rg") || tokenValues[i].equals("r")){
                i--;
View Full Code Here

TOP

Related Classes of org.jpedal.fonts.PdfFont

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.