void writeFont(PdfWriter writer, PdfIndirectReference ref, Object params[]) throws DocumentException, IOException {
        HashMap longTag = (HashMap)params[0];
        addRangeUni(longTag, true, subset);
        Object metrics[] = longTag.values().toArray();
        Arrays.sort(metrics, this);
        PdfIndirectReference ind_font = null;
        PdfObject pobj = null;
        PdfIndirectObject obj = null;
        PdfIndirectReference cidset = null;
        if (writer.getPDFXConformance() == PdfWriter.PDFA1A || writer.getPDFXConformance() == PdfWriter.PDFA1B) {
            PdfStream stream;
            if (metrics.length == 0) {
                stream = new PdfStream(new byte[]{(byte)0x80});
            }
            else {
                int top = ((int[])metrics[metrics.length - 1])[0];
                byte[] bt = new byte[top / 8 + 1];
                for (int k = 0; k < metrics.length; ++k) {
                    int v = ((int[])metrics[k])[0];
                    bt[v / 8] |= rotbits[v % 8];
                }
                stream = new PdfStream(bt);
                stream.flateCompress(compressionLevel);
            }
            cidset = writer.addToBody(stream).getIndirectReference();
        }
        // sivan: cff
        if (cff) {
			byte b[] = readCffFont();
            if (subset || subsetRanges != null) {
                CFFFontSubset cff = new CFFFontSubset(new RandomAccessFileOrArray(b),longTag);
                b = cff.Process(cff.getNames()[0]);
            }
			pobj = new StreamFont(b, "CIDFontType0C", compressionLevel);
			obj = writer.addToBody(pobj);
			ind_font = obj.getIndirectReference();
        } else {
            byte[] b;
            if (subset || directoryOffset != 0) {
                TrueTypeFontSubSet sb = new TrueTypeFontSubSet(fileName, new RandomAccessFileOrArray(rf), longTag, directoryOffset, false, false);
                b = sb.process();
            }
            else {
                b = getFullFont();
            }
            int lengths[] = new int[]{b.length};
            pobj = new StreamFont(b, lengths, compressionLevel);
            obj = writer.addToBody(pobj);
            ind_font = obj.getIndirectReference();
        }
        String subsetPrefix = "";
        if (subset)
            subsetPrefix = createSubsetPrefix();
        PdfDictionary dic = getFontDescriptor(ind_font, subsetPrefix, cidset);
        obj = writer.addToBody(dic);
        ind_font = obj.getIndirectReference();

        pobj = getCIDFontType2(ind_font, subsetPrefix, metrics);
        obj = writer.addToBody(pobj);
        ind_font = obj.getIndirectReference();

        pobj = getToUnicode(metrics);
        PdfIndirectReference toUnicodeRef = null;
        
        if (pobj != null) {
            obj = writer.addToBody(pobj);
            toUnicodeRef = obj.getIndirectReference();
        }

        pobj = getFontBaseType(ind_font, subsetPrefix, toUnicodeRef);
        writer.addToBody(pobj, ref);
    }
void writeFont ( PdfWriter writer , PdfIndirectReference ref , Object params [ ] ) throws DocumentException , IOException { HashMap longTag = ( HashMap ) params [ 0 ] ; addRangeUni ( longTag , true , subset ) ; Object metrics [ ] = longTag . values ( ) . toArray ( ) ; Arrays . sort ( metrics , this ) ; PdfIndirectReference ind_font = null ; PdfObject pobj = null ; PdfIndirectObject obj = null ; PdfIndirectReference cidset = null ; if ( writer . getPDFXConformance ( ) == PdfWriter . PDFA1A || writer . getPDFXConformance ( ) == PdfWriter . PDFA1B ) { PdfStream stream ; if ( metrics . length == 0 ) { stream = new PdfStream ( new byte [ ] { ( byte ) 0x80 } ) ; } else { int top = ( ( int [ ] ) metrics [ metrics . length - 1 ] ) [ 0 ] ; byte [ ] bt = new byte [ top / 8 + 1 ] ; for ( int k = 0 ; k < metrics . length ; ++ k ) { int v = ( ( int [ ] ) metrics [ k ] ) [ 0 ] ; bt [ v / 8 ] |= rotbits [ v % 8 ] ; } stream = new PdfStream ( bt ) ; stream . flateCompress ( compressionLevel ) ; } cidset = writer . addToBody ( stream ) . getIndirectReference ( ) ; } if ( cff ) { byte b [ ] = readCffFont ( ) ; if ( subset || subsetRanges != null ) { CFFFontSubset cff = new CFFFontSubset ( new RandomAccessFileOrArray ( b ) , longTag ) ; b = cff . Process ( cff . getNames ( ) [ 0 ] ) ; } pobj = new StreamFont ( b , "CIDFontType0C" , compressionLevel ) ; obj = writer . addToBody ( pobj ) ; ind_font = obj . getIndirectReference ( ) ; } else { byte [ ] b ; if ( subset || directoryOffset != 0 ) { TrueTypeFontSubSet sb = new TrueTypeFontSubSet ( fileName , new RandomAccessFileOrArray ( rf ) , longTag , directoryOffset , false , false ) ; b = sb . process ( ) ; } else { b = getFullFont ( ) ; } int lengths [ ] = new int [ ] { b . length } ; pobj = new StreamFont ( b , lengths , compressionLevel ) ; obj = writer . addToBody ( pobj ) ; ind_font = obj . getIndirectReference ( ) ; } String subsetPrefix = "" ; if ( subset ) subsetPrefix = createSubsetPrefix ( ) ; PdfDictionary dic = getFontDescriptor ( ind_font , subsetPrefix , cidset ) ; obj = writer . addToBody ( dic ) ; ind_font = obj . getIndirectReference ( ) ; pobj = getCIDFontType2 ( ind_font , subsetPrefix , metrics ) ; obj = writer . addToBody ( pobj ) ; ind_font = obj . getIndirectReference ( ) ; pobj = getToUnicode ( metrics ) ; PdfIndirectReference toUnicodeRef = null ; if ( pobj != null ) { obj = writer . addToBody ( pobj ) ; toUnicodeRef = obj . getIndirectReference ( ) ; } pobj = getFontBaseType ( ind_font , subsetPrefix , toUnicodeRef ) ; writer . addToBody ( pobj , ref ) ; }
Outputs to the writer the font dictionaries and streams.
@param writer the writer for this document
@param ref the font indirect reference
@param params several parameters that depend on the font type
@throws IOException on error
@throws DocumentException error in generating the object