/** * Returns the units per EM (Header.unitsPerEm). * * @return units per EM * @throws IOException if there was an error reading the table. */ public int getUnitsPerEm() throws IOException { if (unitsPerEm == -1) { HeaderTable header = getHeader(); if (header != null) { unitsPerEm = header.getUnitsPerEm(); } else { // this should never happen unitsPerEm = 0; } } return unitsPerEm; }
float scaling = 1000f / ttf.getHeader().getUnitsPerEm(); HorizontalMetricsTable hmtx = ttf.getHorizontalMetrics();
private boolean buildVerticalHeader(COSDictionary cidFont) throws IOException { VerticalHeaderTable vhea = ttf.getVerticalHeader(); if (vhea == null) { LOG.warn("Font to be subset is set to vertical, but has no 'vhea' table"); return false; } float scaling = 1000f / ttf.getHeader().getUnitsPerEm(); long v = Math.round(vhea.getAscender() * scaling); long w1 = Math.round(-vhea.getAdvanceHeightMax() * scaling); if (v != 880 || w1 != -1000) { COSArray cosDw2 = new COSArray(); cosDw2.add(COSInteger.get(v)); cosDw2.add(COSInteger.get(w1)); cidFont.setItem(COSName.DW2, cosDw2); } return true; }
float scaling = 1000f / ttf.getHeader().getUnitsPerEm();
int unitsPerEm = ttFont.getTrueTypeFont().getHeader().getUnitsPerEm(); at.scale(1000d / unitsPerEm, 1000d / unitsPerEm); if (t0font.getDescendantFont() instanceof PDCIDFontType2) int unitsPerEm = ((PDCIDFontType2) t0font.getDescendantFont()).getTrueTypeFont().getHeader().getUnitsPerEm(); at.scale(1000d / unitsPerEm, 1000d / unitsPerEm);
float scaling = 1000f / ttf.getHeader().getUnitsPerEm();
private TTFGlyph2D(TrueTypeFont ttf, PDFont font, boolean isCIDFont) throws IOException { this.font = font; this.ttf = ttf; this.isCIDFont = isCIDFont; // get units per em, which is used as scaling factor HeaderTable header = this.ttf.getHeader(); if (header != null && header.getUnitsPerEm() != 1000) { // in most case the scaling factor is set to 1.0f // due to the fact that units per em is set to 1000 scale = 1000f / header.getUnitsPerEm(); hasScaling = true; } }
private byte[] buildHeadTable() throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream out = new DataOutputStream(bos); HeaderTable h = ttf.getHeader(); writeFixed(out, h.getVersion()); writeFixed(out, h.getFontRevision()); writeUint32(out, 0); // h.getCheckSumAdjustment() writeUint32(out, h.getMagicNumber()); writeUint16(out, h.getFlags()); writeUint16(out, h.getUnitsPerEm()); writeLongDateTime(out, h.getCreated()); writeLongDateTime(out, h.getModified()); writeSInt16(out, h.getXMin()); writeSInt16(out, h.getYMin()); writeSInt16(out, h.getXMax()); writeSInt16(out, h.getYMax()); writeUint16(out, h.getMacStyle()); writeUint16(out, h.getLowestRecPPEM()); writeSInt16(out, h.getFontDirectionHint()); // force long format of 'loca' table writeSInt16(out, (short)1); // h.getIndexToLocFormat() writeSInt16(out, h.getGlyphDataFormat()); out.flush(); return bos.toByteArray(); }
/** * Returns the units per EM (Header.unitsPerEm). * * @return units per EM * @throws IOException if there was an error reading the table. */ public int getUnitsPerEm() throws IOException { if (unitsPerEm == -1) { HeaderTable header = getHeader(); if (header != null) { unitsPerEm = header.getUnitsPerEm(); } else { // this should never happen unitsPerEm = 0; } } return unitsPerEm; }
/** * Returns the units per EM (Header.unitsPerEm). * * @return units per EM * @throws IOException if there was an error reading the table. */ public int getUnitsPerEm() throws IOException { if (unitsPerEm == -1) { HeaderTable header = getHeader(); if (header != null) { unitsPerEm = header.getUnitsPerEm(); } else { // this should never happen unitsPerEm = 0; } } return unitsPerEm; }
float scaling = 1000f / ttf.getHeader().getUnitsPerEm();
float scaling = 1000f / header.getUnitsPerEm(); rect.setLowerLeftX(header.getXMin() * scaling); rect.setLowerLeftY(header.getYMin() * scaling);
float scaling = 1000f / ttf.getHeader().getUnitsPerEm();
float scaling = 1000f / ttf.getHeader().getUnitsPerEm(); HorizontalMetricsTable hmtx = ttf.getHorizontalMetrics();
float scaling = 1000f / ttf.getHeader().getUnitsPerEm(); HorizontalMetricsTable hmtx = ttf.getHorizontalMetrics();
private boolean buildVerticalHeader(COSDictionary cidFont) throws IOException { VerticalHeaderTable vhea = ttf.getVerticalHeader(); if (vhea == null) { LOG.warn("Font to be subset is set to vertical, but has no 'vhea' table"); return false; } float scaling = 1000f / ttf.getHeader().getUnitsPerEm(); long v = Math.round(vhea.getAscender() * scaling); long w1 = Math.round(-vhea.getAdvanceHeightMax() * scaling); if (v != 880 || w1 != -1000) { COSArray cosDw2 = new COSArray(); cosDw2.add(COSInteger.get(v)); cosDw2.add(COSInteger.get(w1)); cidFont.setItem(COSName.DW2, cosDw2); } return true; }
float scaling = 1000f / ttf.getHeader().getUnitsPerEm();
float scaling = 1000f / ttf.getHeader().getUnitsPerEm();
private byte[] buildHeadTable() throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream out = new DataOutputStream(bos); HeaderTable h = ttf.getHeader(); writeFixed(out, h.getVersion()); writeFixed(out, h.getFontRevision()); writeUint32(out, 0); // h.getCheckSumAdjustment() writeUint32(out, h.getMagicNumber()); writeUint16(out, h.getFlags()); writeUint16(out, h.getUnitsPerEm()); writeLongDateTime(out, h.getCreated()); writeLongDateTime(out, h.getModified()); writeSInt16(out, h.getXMin()); writeSInt16(out, h.getYMin()); writeSInt16(out, h.getXMax()); writeSInt16(out, h.getYMax()); writeUint16(out, h.getMacStyle()); writeUint16(out, h.getLowestRecPPEM()); writeSInt16(out, h.getFontDirectionHint()); // force long format of 'loca' table writeSInt16(out, (short)1); // h.getIndexToLocFormat() writeSInt16(out, h.getGlyphDataFormat()); out.flush(); return bos.toByteArray(); }
private byte[] buildHeadTable() throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream out = new DataOutputStream(bos); HeaderTable h = ttf.getHeader(); writeFixed(out, h.getVersion()); writeFixed(out, h.getFontRevision()); writeUint32(out, 0); // h.getCheckSumAdjustment() writeUint32(out, h.getMagicNumber()); writeUint16(out, h.getFlags()); writeUint16(out, h.getUnitsPerEm()); writeLongDateTime(out, h.getCreated()); writeLongDateTime(out, h.getModified()); writeSInt16(out, h.getXMin()); writeSInt16(out, h.getYMin()); writeSInt16(out, h.getXMax()); writeSInt16(out, h.getYMax()); writeUint16(out, h.getMacStyle()); writeUint16(out, h.getLowestRecPPEM()); writeSInt16(out, h.getFontDirectionHint()); // force long format of 'loca' table writeSInt16(out, (short)1); // h.getIndexToLocFormat() writeSInt16(out, h.getGlyphDataFormat()); out.flush(); return bos.toByteArray(); }