protected List readEncoding()

in src/java/org/apache/fop/render/pdf/pdfbox/MergeType1Fonts.java [153:188]


    protected List<String> readEncoding(List<Integer> glyphs,
                                        PostscriptParser.PSElement encoding) {
        List<String> subsetEncodingEntries = new ArrayList<String>();
        //Handle custom encoding
        if (encoding instanceof PostscriptParser.PSFixedArray) {
            PostscriptParser.PSFixedArray encodingArray = (PostscriptParser.PSFixedArray)encoding;
            for (int glyph : glyphs) {
                if (glyph != 0) {
                    //Find matching entries in the encoding table from the given glyph
                    List<String> matches = searchEntries(encodingArray.getEntries(), glyph);
                    /* If no matches are found, perform a lookup using the glyph index.
                     * This isn't done by default as some symbol based type-1 fonts do not
                     * place their characters according to the glyph index. */
                    if (matches.isEmpty()) {
                        matches.clear();
                        matches.add(encodingArray.getEntries().get(glyph));
                    }
                    for (String match : matches) {
                        subsetEncodingEntries.add(match);
                    }
                }
            }
            //Handle fixed encoding
        } else if (encoding instanceof PostscriptParser.PSVariable) {
            if (((PostscriptParser.PSVariable) encoding).getValue().equals("StandardEncoding")) {
                standardEncoding = true;
                for (Map.Entry<Integer, String> v : nameMap.entrySet()) {
                    subsetEncodingEntries.add(String.format("dup %d /%s put", v.getKey(), v.getValue()));
                }
            } else {
                throw new RuntimeException(
                        "Only Custom or StandardEncoding is supported when creating a Type 1 subset.");
            }
        }
        return subsetEncodingEntries;
    }