From 60c41976d67a37e296da7c56e324d51b322293f9 Mon Sep 17 00:00:00 2001 From: Honfika Date: Thu, 30 Jan 2014 19:27:27 +0100 Subject: [PATCH] limit the nuber of the characters in the fontpanel preview 2 --- .../com/jpexs/decompiler/flash/gui/MainPanel.java | 14 ++++++++------ .../flash/types/shaperecords/SHAPERECORD.java | 4 +++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 3adff7777..15c12d547 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -104,6 +104,7 @@ import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.RGB; import com.jpexs.decompiler.flash.types.TEXTRECORD; +import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD; import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.helpers.CancellableWorker; import com.jpexs.helpers.Helper; @@ -2579,19 +2580,20 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec if (tagObj instanceof FontTag) { int countGlyphs = ((FontTag) tagObj).getGlyphShapeTable().size(); + countGlyphs = Math.min(SHAPERECORD.MAX_CHARACTERS_IN_FONT_PREVIEW, countGlyphs); int fontId = ((FontTag) tagObj).getFontId(); - int sloupcu = (int) Math.ceil(Math.sqrt(countGlyphs)); - int radku = (int) Math.ceil(((float) countGlyphs) / ((float) sloupcu)); + int cols = (int) Math.ceil(Math.sqrt(countGlyphs)); + int rows = (int) Math.ceil(((float) countGlyphs) / ((float) cols)); int x = 0; int y = 1; for (int f = 0; f < countGlyphs; f++) { - if (x >= sloupcu) { + if (x >= cols) { x = 0; y++; } List rec = new ArrayList<>(); TEXTRECORD tr = new TEXTRECORD(); - int textHeight = height / radku; + int textHeight = height / rows; tr.fontId = fontId; tr.styleFlagsHasFont = true; tr.textHeight = textHeight; @@ -2602,8 +2604,8 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec tr.glyphEntries[0].glyphAdvance = 0; tr.glyphEntries[0].glyphIndex = f; rec.add(tr); - mat.translateX = x * width / sloupcu; - mat.translateY = y * height / radku; + mat.translateX = x * width / cols; + mat.translateY = y * height / rows; sos2.writeTag(new DefineTextTag(null, 999 + f, new RECT(0, width, 0, height), new MATRIX(), rec)); sos2.writeTag(new PlaceObject2Tag(null, false, false, false, true, false, true, true, false, 1 + f, 999 + f, mat, null, 0, null, 0, null)); x++; 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 52ca63033..e37b7fd45 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java @@ -45,6 +45,8 @@ import javax.swing.JPanel; */ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Serializable { + public static final int MAX_CHARACTERS_IN_FONT_PREVIEW = 400; + public abstract void calculateBits(); @Override @@ -137,7 +139,7 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali maxw /= SWF.unitDivisor; maxh /= SWF.unitDivisor; - int shapeCount = Math.min(400, shapes.size()); + int shapeCount = Math.min(MAX_CHARACTERS_IN_FONT_PREVIEW, shapes.size()); int cols = (int) Math.ceil(Math.sqrt(shapeCount)); int pos = 0; int w2 = prevWidth / cols;