From 8fbc533ba0b756617951484a80b9c100e521b2be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Wed, 10 Jul 2013 23:07:59 +0200 Subject: [PATCH] fixed font shapes... rounding problem --- .../flash/types/shaperecords/SHAPERECORD.java | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java b/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java index 2871e6b0e..56b415552 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java @@ -869,74 +869,74 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters { GlyphVector v = f.createGlyphVector((new JPanel()).getFontMetrics(f).getFontRenderContext(), "" + character); Shape shp = v.getOutline(); double points[] = new double[6]; - double lastX = 0; - double lastY = 0; - double startX = 0; - double startY = 0; + int lastX = 0; + int lastY = 0; + int startX = 0; + int startY = 0; for (PathIterator it = shp.getPathIterator(null); !it.isDone(); it.next()) { int type = it.currentSegment(points); switch (type) { case PathIterator.SEG_MOVETO: - lastX = points[0]; - lastY = points[1]; - startX = lastX; - startY = lastY; StyleChangeRecord scr = new StyleChangeRecord(); scr.stateMoveTo = true; scr.moveDeltaX = (int) Math.round(points[0]); scr.moveDeltaY = (int) Math.round(points[1]); scr.moveBits = SWFOutputStream.getNeededBitsS(scr.moveDeltaX, scr.moveDeltaY); retList.add(scr); + lastX = (int) Math.round(points[0]); + lastY = (int) Math.round(points[1]); + startX = lastX; + startY = lastY; break; case PathIterator.SEG_LINETO: StraightEdgeRecord ser = new StraightEdgeRecord(); ser.generalLineFlag = true; - ser.deltaX = (int) Math.round((points[0] - lastX)); - ser.deltaY = (int) Math.round((points[1] - lastY)); + ser.deltaX = ((int) Math.round(points[0])) - lastX; + ser.deltaY = ((int) Math.round(points[1])) - lastY; ser.numBits = SWFOutputStream.getNeededBitsS(ser.deltaX, ser.deltaY) - 2; if (ser.numBits < 0) { ser.numBits = 0; } retList.add(ser); - lastX = points[0]; - lastY = points[1]; + lastX = (int) Math.round(points[0]); + lastY = (int) Math.round(points[1]); break; case PathIterator.SEG_CUBICTO: double cubicCoords[] = new double[]{ lastX, lastY, - points[0], points[1], - points[2], points[3], - points[4], points[5] + Math.round(points[0]), Math.round(points[1]), + Math.round(points[2]), Math.round(points[3]), + Math.round(points[4]), Math.round(points[5]) }; double quadCoords[][] = approximateCubic(cubicCoords); for (int i = 0; i < quadCoords.length; i++) { CurvedEdgeRecord cer = new CurvedEdgeRecord(); - cer.controlDeltaX = (int) Math.round((quadCoords[i][0] - lastX)); - cer.controlDeltaY = (int) Math.round((quadCoords[i][1] - lastY)); - cer.anchorDeltaX = (int) Math.round((quadCoords[i][2] - quadCoords[i][0])); - cer.anchorDeltaY = (int) Math.round((quadCoords[i][3] - quadCoords[i][1])); + cer.controlDeltaX = ((int) Math.round(quadCoords[i][0])) - lastX; + cer.controlDeltaY = ((int) Math.round(quadCoords[i][1])) - lastY; + cer.anchorDeltaX = ((int) Math.round(quadCoords[i][2])) - ((int) Math.round(quadCoords[i][0])); + cer.anchorDeltaY = ((int) Math.round(quadCoords[i][3])) - ((int) Math.round(quadCoords[i][1])); cer.numBits = SWFOutputStream.getNeededBitsS(cer.controlDeltaX, cer.controlDeltaY, cer.anchorDeltaX, cer.anchorDeltaY) - 2; if (cer.numBits < 0) { cer.numBits = 0; } - lastX = quadCoords[i][2]; - lastY = quadCoords[i][3]; + lastX = (int) Math.round(quadCoords[i][2]); + lastY = (int) Math.round(quadCoords[i][3]); retList.add(cer); } break; case PathIterator.SEG_QUADTO: CurvedEdgeRecord cer = new CurvedEdgeRecord(); - cer.controlDeltaX = (int) Math.round((points[0] - lastX)); - cer.controlDeltaY = (int) Math.round((points[1] - lastY)); - cer.anchorDeltaX = (int) Math.round((points[2] - points[0])); - cer.anchorDeltaY = (int) Math.round((points[3] - points[1])); + cer.controlDeltaX = ((int) Math.round(points[0])) - lastX; + cer.controlDeltaY = ((int) Math.round(points[1])) - lastY; + cer.anchorDeltaX = ((int) Math.round(points[2])) - (int) Math.round(points[0]); + cer.anchorDeltaY = ((int) Math.round(points[3])) - (int) Math.round(points[1]); cer.numBits = SWFOutputStream.getNeededBitsS(cer.controlDeltaX, cer.controlDeltaY, cer.anchorDeltaX, cer.anchorDeltaY) - 2; if (cer.numBits < 0) { cer.numBits = 0; } retList.add(cer); - lastX = points[2]; - lastY = points[3]; + lastX = (int) Math.round(points[2]); + lastY = (int) Math.round(points[3]); break; case PathIterator.SEG_CLOSE: //Closing line back to last SEG_MOVETO if ((startX == lastX) && (startY == lastY)) {