Issue #395 Displaying GFx fonts in Flash player

This commit is contained in:
Jindra Petk
2013-09-24 12:03:09 +02:00
parent f5cd43836a
commit 8f4f88ebcc
3 changed files with 28 additions and 17 deletions

View File

@@ -3127,7 +3127,7 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel
} else if ((tagObj instanceof DrawableTag) && (!(tagObj instanceof TextTag)) && (!(tagObj instanceof FontTag)) && (miInternalViewer.isSelected())) {
showCard(CARDDRAWPREVIEWPANEL);
previewImagePanel.setDrawable((DrawableTag) tagObj, swf, characters, 50/*FIXME*/);
} else if ((tagObj instanceof FontTag) && (miInternalViewer.isSelected() || (tagObj instanceof GFxDefineCompactedFont))) {
} else if ((tagObj instanceof FontTag) && (miInternalViewer.isSelected())) {
showCard(CARDFLASHPANEL);
previewImagePanel.setDrawable((DrawableTag) tagObj, swf, characters, 50/*FIXME*/);
showFontTag((FontTag) tagObj);
@@ -3534,7 +3534,7 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel
}
private void showFontTag(FontTag ft) {
if (miInternalViewer.isSelected() || ft instanceof GFxDefineCompactedFont) {
if (miInternalViewer.isSelected() /*|| ft instanceof GFxDefineCompactedFont*/) {
((CardLayout) viewerCards.getLayout()).show(viewerCards, INTERNAL_VIEWER_CARD);
internelViewerPanel.setDrawable(ft, swf, characters, 1);
} else {

View File

@@ -154,7 +154,12 @@ public class GFxDefineCompactedFont extends FontTag implements DrawableTag {
for (int i = 0; i < shapeCache.size(); i++) {
shapes.add(SHAPERECORD.resizeSHAPE(shapeCache.get(i), 20));
}
BufferedImage ret = SHAPERECORD.shapeListToImage(shapes, 500, 500, Color.black);
int cols = (int) Math.ceil(Math.sqrt(shapes.size()));
int size = 500;
if(size/cols < 30){
size = cols * 30;
}
BufferedImage ret = SHAPERECORD.shapeListToImage(shapes, size, size, Color.black);
imageCache.put("font" + fontId, new SerializableImage(ret));
return ret;
}

View File

@@ -846,21 +846,24 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali
BufferedImage ret = new BufferedImage(prevWidth, prevHeight, BufferedImage.TYPE_INT_ARGB);
Graphics g = ret.getGraphics();
int p = 0;
List<BufferedImage> images = new ArrayList<>();
for (SHAPE s : shapes) {
images.add(s.toImage(1, new ArrayList<Tag>(), color));
}
int ps=0;
int maxw = 0;
int maxh = 0;
for (BufferedImage im : images) {
if (im.getWidth() > maxw) {
maxw = im.getWidth();
for (SHAPE s : shapes) {
RECT r=SHAPERECORD.getBounds(s.shapeRecords);
if(r.getWidth() >maxw){
maxw = r.getWidth();
}
if (im.getHeight() > maxh) {
maxh = im.getHeight();
if(r.getHeight()>maxh){
maxh = r.getHeight();
}
}
int cols = (int) Math.ceil(Math.sqrt(images.size()));
maxw = maxw / 20;
maxh = maxh / 20;
int cols = (int) Math.ceil(Math.sqrt(shapes.size()));
int pos = 0;
int w2 = prevWidth / cols;
int h2 = prevHeight / cols;
@@ -880,18 +883,21 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali
loopy:
for (int y = 0; y < cols; y++) {
for (int x = 0; x < cols; x++) {
if (pos >= images.size()) {
if (pos >= shapes.size()) {
break loopy;
}
int w1 = images.get(pos).getWidth();
int h1 = images.get(pos).getHeight();
BufferedImage img=shapes.get(pos).toImage(1, new ArrayList<Tag>(), 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;
g.drawImage(images.get(pos), px, py, px + w, py + h, 0, 0, w1, h1, null);
g.drawImage(img, px, py, px + w, py + h, 0, 0, w1, h1, null);
pos++;
SHAPERECORD.clearShapeCache();
}
}