public TTGlyph toSimpleGlyph() { // convert the file into array of contours XContour[] contours = toContours(); if ((contours == null) && (!isRequiredGlyph())) { return null; } // if TTGlyph retval = new TTGlyph(); retval.setSimple(true); retval.setAdvanceWidth(getAdvanceWidth()); if (contours == null) { return retval; } // if ArrayList<EContourPoint> points = new ArrayList<>(); for (int i = 0; i < contours.length; i++) { XContour contour = contours[i]; XContourPoint[] contourPoints = contour.getContourPoint(); for (int j = 0; j < contourPoints.length; j++) { points.add((EContourPoint) contourPoints[j]); } // for j retval.addEndPoint(points.size() - 1); } // for i for (EContourPoint point : points) { loadContourPoint(retval, point); } // for point boolean hasGridfit = false; // I need int i here. for (int i = 0; i < points.size(); i++) { EContourPoint point = points.get(i); if (!point.isRounded()) { continue; } // if hasGridfit = true; loadGridfit(retval, point, i); } // for i if (hasGridfit) { retval.addInstruction(TTGlyph.IUP1); retval.addInstruction(TTGlyph.IUP0); } // if // I need int i here. for (int i = 0; i < points.size(); i++) { EContourPoint point = points.get(i); if (point.getHint().length == 0) { continue; } // if loadHint(retval, point, i); } // for i return retval; }
/** Generates array of XContour from local contours and modules. Used for TTF building. */ private XContour[] toContours() { XContour[] retval; ArrayList<XContour> list = new ArrayList<>(); XContour[] contours = m_glyph.getBody().getContour(); for (int i = 0; i < contours.length; i++) { EContour contour = (EContour) contours[i]; list.add(contour.toQuadratic()); } // for i XModule[] modules = m_glyph.getBody().getModule(); for (int i = 0; i < modules.length; i++) { EModuleInvoke module = (EModuleInvoke) modules[i]; // push and pop happens inside toContour list.add(module.toContour(new AffineTransform())); } // for i if (list.size() == 0) return null; retval = new XContour[list.size()]; for (int i = 0; i < list.size(); i++) { retval[i] = list.get(i); } // for i return retval; }