From 2dbf829bd5f6f70f2cd5f7aa34f1522c477d3039 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Tue, 24 Sep 2013 20:10:47 +0200 Subject: [PATCH] fixed internal viewer for fonts --- .../flash/tags/GFxDefineCompactedFont.java | 2 +- .../flash/types/shaperecords/SHAPERECORD.java | 22 +++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/GFxDefineCompactedFont.java b/trunk/src/com/jpexs/decompiler/flash/tags/GFxDefineCompactedFont.java index 88f848c29..6017cdf38 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/GFxDefineCompactedFont.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/GFxDefineCompactedFont.java @@ -156,7 +156,7 @@ public class GFxDefineCompactedFont extends FontTag implements DrawableTag { } int cols = (int) Math.ceil(Math.sqrt(shapes.size())); int size = 500; - if(size/cols < 30){ + if (size / cols < 30) { size = cols * 30; } BufferedImage ret = SHAPERECORD.shapeListToImage(shapes, size, size, Color.black); 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 312462651..03185ee64 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java @@ -845,24 +845,22 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali public static BufferedImage shapeListToImage(List shapes, int prevWidth, int prevHeight, Color color) { BufferedImage ret = new BufferedImage(prevWidth, prevHeight, BufferedImage.TYPE_INT_ARGB); Graphics g = ret.getGraphics(); - int p = 0; - int ps=0; - + int maxw = 0; int maxh = 0; for (SHAPE s : shapes) { - RECT r=SHAPERECORD.getBounds(s.shapeRecords); - if(r.getWidth() >maxw){ + RECT r = SHAPERECORD.getBounds(s.shapeRecords); + if (r.getWidth() > maxw) { maxw = r.getWidth(); } - if(r.getHeight()>maxh){ + if (r.getHeight() > maxh) { maxh = r.getHeight(); } } maxw = maxw / 20; maxh = maxh / 20; - - + + int cols = (int) Math.ceil(Math.sqrt(shapes.size())); int pos = 0; int w2 = prevWidth / cols; @@ -886,15 +884,15 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali if (pos >= shapes.size()) { break loopy; } - BufferedImage img=shapes.get(pos).toImage(1, new ArrayList(), color); - + BufferedImage img = shapes.get(pos).toImage(1, new ArrayList(), color); + int w1 = img.getWidth(); int h1 = img.getHeight(); int w = Math.round(ratio * w1); int h = Math.round(ratio * h1); - int px = x * mw + mw / 2 - w / 2; - int py = y * mh + mh - h; + int px = x * w2 + w2 / 2 - w / 2; + int py = y * h2 + w2 - h; g.drawImage(img, px, py, px + w, py + h, 0, 0, w1, h1, null); pos++; SHAPERECORD.clearShapeCache();