font fiddling

This commit is contained in:
Denis Molony 2017-01-20 16:20:00 +11:00
parent 978aa8b6a0
commit ac8b0f9497
4 changed files with 21 additions and 18 deletions

View File

@ -169,7 +169,7 @@ public class QuickDrawFont extends AbstractFile
int charsHigh = (totalCharacters - 1) / charsWide + 1; int charsHigh = (totalCharacters - 1) / charsWide + 1;
image = new BufferedImage (charsWide * (widMax + spacing) + base * 2, image = new BufferedImage (charsWide * (widMax + spacing) + base * 2,
charsHigh * (fRectHeight + leading) + base * 2, BufferedImage.TYPE_BYTE_GRAY); charsHigh * (fRectHeight + spacing) + base * 2, BufferedImage.TYPE_BYTE_GRAY);
Graphics2D g2d = image.createGraphics (); Graphics2D g2d = image.createGraphics ();
g2d.setComposite ( g2d.setComposite (
@ -194,7 +194,7 @@ public class QuickDrawFont extends AbstractFile
if (++count % charsWide == 0) if (++count % charsWide == 0)
{ {
x = base; x = base;
y += fRectHeight + leading; y += fRectHeight + spacing;
} }
} }
g2d.dispose (); g2d.dispose ();

View File

@ -32,7 +32,7 @@ class DiskLayoutImage extends JPanel implements Scrollable, RedoListener
private boolean showFreeSectors; private boolean showFreeSectors;
private final DiskLayoutSelection selectionHandler = new DiskLayoutSelection (); private final DiskLayoutSelection selectionHandler = new DiskLayoutSelection ();
private boolean redo; private boolean redo;
private boolean retinaTest; private boolean isRetina;
// set defaults (used until a real disk is set) // set defaults (used until a real disk is set)
private int bw = 30; private int bw = 30;
@ -64,8 +64,9 @@ class DiskLayoutImage extends JPanel implements Scrollable, RedoListener
selectionHandler.setSelection (null); selectionHandler.setSelection (null);
Graphics2D g = (Graphics2D) this.getGraphics (); Graphics2D g = (Graphics2D) this.getGraphics ();
retinaTest = g.getFontRenderContext ().getTransform () if (g != null) // panel might not be showing
.equals (AffineTransform.getScaleInstance (2.0, 2.0)); isRetina = g.getFontRenderContext ().getTransform ()
.equals (AffineTransform.getScaleInstance (2.0, 2.0));
repaint (); repaint ();
} }
@ -138,9 +139,9 @@ class DiskLayoutImage extends JPanel implements Scrollable, RedoListener
Rectangle rect = new Rectangle (x, y, bw, bh); Rectangle rect = new Rectangle (x, y, bw, bh);
int width = rect.width - (retinaTest ? 2 : 3); int width = rect.width - (isRetina ? 2 : 3);
int height = rect.height - (retinaTest ? 2 : 3); int height = rect.height - (isRetina ? 2 : 3);
int offset2 = retinaTest ? 1 : 2; int offset2 = isRetina ? 1 : 2;
// draw frame // draw frame
if (true) if (true)

View File

@ -24,7 +24,7 @@ class DiskLegendPanel extends JPanel
private FormattedDisk disk; private FormattedDisk disk;
private LayoutDetails layoutDetails; private LayoutDetails layoutDetails;
private final Font font; private final Font font;
private boolean retinaTest; private boolean isRetina;
public DiskLegendPanel () public DiskLegendPanel ()
{ {
@ -38,8 +38,9 @@ class DiskLegendPanel extends JPanel
layoutDetails = details; layoutDetails = details;
Graphics2D g = (Graphics2D) this.getGraphics (); Graphics2D g = (Graphics2D) this.getGraphics ();
retinaTest = g.getFontRenderContext ().getTransform () if (g != null) // panel might not be showing
.equals (AffineTransform.getScaleInstance (2.0, 2.0)); isRetina = g.getFontRenderContext ().getTransform ()
.equals (AffineTransform.getScaleInstance (2.0, 2.0));
repaint (); repaint ();
} }
@ -62,9 +63,9 @@ class DiskLegendPanel extends JPanel
int count = 0; int count = 0;
int lineHeight = 20; int lineHeight = 20;
int width = layoutDetails.block.width - (retinaTest ? 2 : 3); int width = layoutDetails.block.width - (isRetina ? 2 : 3);
int height = layoutDetails.block.height - (retinaTest ? 2 : 3); int height = layoutDetails.block.height - (isRetina ? 2 : 3);
int offset = retinaTest ? 1 : 2; int offset = isRetina ? 1 : 2;
for (SectorType type : disk.getSectorTypeList ()) for (SectorType type : disk.getSectorTypeList ())
{ {
@ -88,13 +89,14 @@ class DiskLegendPanel extends JPanel
int val = disk.falseNegativeBlocks (); int val = disk.falseNegativeBlocks ();
if (val > 0) if (val > 0)
{ {
g.drawString (val + " empty sector" + (val == 1 ? "" : "s") g.drawString (
+ " marked as unavailable", 10, y); val + " empty sector" + (val == 1 ? "" : "s") + " marked as unavailable", 10,
y);
y += lineHeight; y += lineHeight;
} }
val = disk.falsePositiveBlocks (); val = disk.falsePositiveBlocks ();
if (val > 0) if (val > 0)
g.drawString (val + " used sector" + (val == 1 ? "" : "s") + " marked as available", g.drawString (val + " used sector" + (val == 1 ? "" : "s") + " marked as available",
10, y); 10, y);
} }
} }

View File

@ -380,7 +380,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
exactBuffer = new byte[buffer.length]; exactBuffer = new byte[buffer.length];
System.arraycopy (buffer, 0, exactBuffer, 0, buffer.length); System.arraycopy (buffer, 0, exactBuffer, 0, buffer.length);
} }
else if (buffer.length == endOfFile) else if (buffer.length == endOfFile || endOfFile == 512) // 512 seems like crap
exactBuffer = buffer; exactBuffer = buffer;
else else
{ {