if (desc != null) desc.resolve(); firstIndex += desc.getPointCount(); firstContour += desc.getContourCount();
/** * Set the points of a glyph from the GlyphDescription. */ private Point[] describe(GlyphDescription gd) { int endPtIndex = 0; int endPtOfContourIndex = -1; Point[] points = new Point[gd.getPointCount()]; for (int i = 0; i < gd.getPointCount(); i++) { if (endPtOfContourIndex == -1) { endPtOfContourIndex = gd.getEndPtOfContours(endPtIndex); } boolean endPt = endPtOfContourIndex == i; if (endPt) { endPtIndex++; endPtOfContourIndex = -1; } points[i] = new Point(gd.getXCoordinate(i), gd.getYCoordinate(i), (gd.getFlags(i) & GlyfDescript.ON_CURVE) != 0, endPt); } return points; }
private GlyphData getGlyphData(int gid) throws IOException { GlyphData glyph = new GlyphData(); HorizontalMetricsTable hmt = font.getHorizontalMetrics(); int leftSideBearing = hmt == null ? 0 : hmt.getLeftSideBearing(gid); glyph.initData(this, data, leftSideBearing); // resolve composite glyph if (glyph.getDescription().isComposite()) { glyph.getDescription().resolve(); } return glyph; } }
/** * {@inheritDoc} */ @Override public short getXCoordinate(int i) { GlyfCompositeComp c = getCompositeComp(i); if (c != null) { GlyphDescription gd = descriptions.get(c.getGlyphIndex()); int n = i - c.getFirstIndex(); int x = gd.getXCoordinate(n); int y = gd.getYCoordinate(n); short x1 = (short) c.scaleX(x, y); x1 += c.getXTranslate(); return x1; } return 0; }
private GlyfCompositeComp getCompositeComp(int i) { for (GlyfCompositeComp c : components) { GlyphDescription gd = descriptions.get(c.getGlyphIndex()); if (c.getFirstIndex() <= i && gd != null && i < (c.getFirstIndex() + gd.getPointCount())) { return c; } } return null; }
/** * {@inheritDoc} */ @Override public int getContourCount() { if (!resolved) { LOG.error("getContourCount called on unresolved GlyfCompositeDescript"); } if (contourCount < 0) { GlyfCompositeComp c = components.get(components.size() - 1); contourCount = c.getFirstContour() + descriptions.get(c.getGlyphIndex()).getContourCount(); } return contourCount; }
/** * {@inheritDoc} */ @Override public int getEndPtOfContours(int i) { GlyfCompositeComp c = getCompositeCompEndPt(i); if (c != null) { GlyphDescription gd = descriptions.get(c.getGlyphIndex()); return gd.getEndPtOfContours(i - c.getFirstContour()) + c.getFirstIndex(); } return 0; }
/** * {@inheritDoc} */ @Override public byte getFlags(int i) { GlyfCompositeComp c = getCompositeComp(i); if (c != null) { GlyphDescription gd = descriptions.get(c.getGlyphIndex()); return gd.getFlags(i - c.getFirstIndex()); } return 0; }
/** * {@inheritDoc} */ @Override public short getYCoordinate(int i) { GlyfCompositeComp c = getCompositeComp(i); if (c != null) { GlyphDescription gd = descriptions.get(c.getGlyphIndex()); int n = i - c.getFirstIndex(); int x = gd.getXCoordinate(n); int y = gd.getYCoordinate(n); short y1 = (short) c.scaleY(x, y); y1 += c.getYTranslate(); return y1; } return 0; }
/** * {@inheritDoc} */ @Override public int getPointCount() { if (!resolved) { LOG.error("getPointCount called on unresolved GlyfCompositeDescript"); } if (pointCount < 0) { GlyfCompositeComp c = components.get(components.size() - 1); GlyphDescription gd = descriptions.get(c.getGlyphIndex()); if (gd == null) { LOG.error("getGlypDescription(" + c.getGlyphIndex() + ") is null, returning 0"); pointCount = 0; } else { pointCount = c.getFirstIndex() + gd.getPointCount(); } } return pointCount; }
private GlyfCompositeComp getCompositeCompEndPt(int i) { for (GlyfCompositeComp c : components) { GlyphDescription gd = descriptions.get(c.getGlyphIndex()); if (c.getFirstContour() <= i && gd != null && i < (c.getFirstContour() + gd.getContourCount())) { return c; } } return null; }
/** * {@inheritDoc} */ @Override public int getEndPtOfContours(int i) { GlyfCompositeComp c = getCompositeCompEndPt(i); if (c != null) { GlyphDescription gd = descriptions.get(c.getGlyphIndex()); return gd.getEndPtOfContours(i - c.getFirstContour()) + c.getFirstIndex(); } return 0; }
/** * {@inheritDoc} */ @Override public byte getFlags(int i) { GlyfCompositeComp c = getCompositeComp(i); if (c != null) { GlyphDescription gd = descriptions.get(c.getGlyphIndex()); return gd.getFlags(i - c.getFirstIndex()); } return 0; }
/** * Set the points of a glyph from the GlyphDescription. */ private Point[] describe(GlyphDescription gd) { int endPtIndex = 0; int endPtOfContourIndex = -1; Point[] points = new Point[gd.getPointCount()]; for (int i = 0; i < gd.getPointCount(); i++) { if (endPtOfContourIndex == -1) { endPtOfContourIndex = gd.getEndPtOfContours(endPtIndex); } boolean endPt = endPtOfContourIndex == i; if (endPt) { endPtIndex++; endPtOfContourIndex = -1; } points[i] = new Point(gd.getXCoordinate(i), gd.getYCoordinate(i), (gd.getFlags(i) & GlyfDescript.ON_CURVE) != 0, endPt); } return points; }
if (desc != null) desc.resolve(); firstIndex += desc.getPointCount(); firstContour += desc.getContourCount();
/** * {@inheritDoc} */ @Override public short getXCoordinate(int i) { GlyfCompositeComp c = getCompositeComp(i); if (c != null) { GlyphDescription gd = descriptions.get(c.getGlyphIndex()); int n = i - c.getFirstIndex(); int x = gd.getXCoordinate(n); int y = gd.getYCoordinate(n); short x1 = (short) c.scaleX(x, y); x1 += c.getXTranslate(); return x1; } return 0; }
private GlyphData getGlyphData(int gid) throws IOException { GlyphData glyph = new GlyphData(); HorizontalMetricsTable hmt = font.getHorizontalMetrics(); int leftSideBearing = hmt == null ? 0 : hmt.getLeftSideBearing(gid); glyph.initData(this, data, leftSideBearing); // resolve composite glyph if (glyph.getDescription().isComposite()) { glyph.getDescription().resolve(); } return glyph; } }
private GlyfCompositeComp getCompositeComp(int i) { for (GlyfCompositeComp c : components) { GlyphDescription gd = descriptions.get(c.getGlyphIndex()); if (c.getFirstIndex() <= i && gd != null && i < (c.getFirstIndex() + gd.getPointCount())) { return c; } } return null; }
/** * {@inheritDoc} */ @Override public int getContourCount() { if (!resolved) { LOG.error("getContourCount called on unresolved GlyfCompositeDescript"); } if (contourCount < 0) { GlyfCompositeComp c = components.get(components.size() - 1); contourCount = c.getFirstContour() + descriptions.get(c.getGlyphIndex()).getContourCount(); } return contourCount; }
/** * {@inheritDoc} */ @Override public int getEndPtOfContours(int i) { GlyfCompositeComp c = getCompositeCompEndPt(i); if (c != null) { GlyphDescription gd = descriptions.get(c.getGlyphIndex()); return gd.getEndPtOfContours(i - c.getFirstContour()) + c.getFirstIndex(); } return 0; }