From: Kevin Lamonte Date: Sun, 11 Aug 2019 20:10:07 +0000 (-0500) Subject: #35 fix demo X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=bfa37f3b2ef87d39c15fad7d565c00cbabd92acf;p=fanfix-jexer.git #35 fix demo --- diff --git a/src/jexer/TApplication.java b/src/jexer/TApplication.java index b21c066..ec93629 100644 --- a/src/jexer/TApplication.java +++ b/src/jexer/TApplication.java @@ -1723,12 +1723,12 @@ public class TApplication implements Runnable { } } } - assert (cell.getWidth() == Cell.Width.RIGHT); - - if (x > 0) { - Cell leftHalf = getScreen().getCharXY(x - 1, y); - if (leftHalf.getWidth() == Cell.Width.LEFT) { - invertCell(x - 1, y, true); + if (cell.getWidth() == Cell.Width.RIGHT) { + if (x > 0) { + Cell leftHalf = getScreen().getCharXY(x - 1, y); + if (leftHalf.getWidth() == Cell.Width.LEFT) { + invertCell(x - 1, y, true); + } } } } diff --git a/src/jexer/backend/GlyphMaker.java b/src/jexer/backend/GlyphMaker.java index 08cbee8..91bda6d 100644 --- a/src/jexer/backend/GlyphMaker.java +++ b/src/jexer/backend/GlyphMaker.java @@ -237,6 +237,11 @@ class GlyphMakerFont { glyphCache.put(key, image); } + /* + System.err.println("cellWidth " + cellWidth + + " cellHeight " + cellHeight + " image " + image); + */ + return image; } @@ -265,6 +270,13 @@ class GlyphMakerFont { textHeight = fontTextHeight + textAdjustHeight; textWidth = fontTextWidth + textAdjustWidth; + /* + System.err.println("font " + font); + System.err.println("fontTextWidth " + fontTextWidth); + System.err.println("fontTextHeight " + fontTextHeight); + System.err.println("textWidth " + textWidth); + System.err.println("textHeight " + textHeight); + */ gotFontDimensions = true; } @@ -345,6 +357,7 @@ public class GlyphMaker { * @param fontSize the size of these fonts in pixels */ private GlyphMaker(final int fontSize) { + assert (fontSize > 3); makerMono = new GlyphMakerFont(MONO, fontSize); // makerCJKhk = new GlyphMakerFont(CJKhk, fontSize); // makerCJKkr = new GlyphMakerFont(CJKkr, fontSize); diff --git a/src/jexer/backend/LogicalScreen.java b/src/jexer/backend/LogicalScreen.java index e8d2662..558fdc4 100644 --- a/src/jexer/backend/LogicalScreen.java +++ b/src/jexer/backend/LogicalScreen.java @@ -967,16 +967,19 @@ public class LogicalScreen implements Screen { public final void putFullwidthCharXY(final int x, final int y, final Cell cell) { - if (lastTextHeight != getTextHeight()) { - glyphMaker = GlyphMaker.getInstance(getTextHeight()); - lastTextHeight = getTextHeight(); + int cellWidth = getTextWidth(); + int cellHeight = getTextHeight(); + + if (lastTextHeight != cellHeight) { + glyphMaker = GlyphMaker.getInstance(cellHeight); + lastTextHeight = cellHeight; } - BufferedImage image = glyphMaker.getImage(cell, getTextWidth() * 2, - getTextHeight()); - BufferedImage leftImage = image.getSubimage(0, 0, getTextWidth(), - getTextHeight()); - BufferedImage rightImage = image.getSubimage(getTextWidth(), 0, - getTextWidth(), getTextHeight()); + BufferedImage image = glyphMaker.getImage(cell, cellWidth * 2, + cellHeight); + BufferedImage leftImage = image.getSubimage(0, 0, cellWidth, + cellHeight); + BufferedImage rightImage = image.getSubimage(cellWidth, 0, cellWidth, + cellHeight); Cell left = new Cell(cell); left.setImage(leftImage); diff --git a/src/jexer/backend/SwingTerminal.java b/src/jexer/backend/SwingTerminal.java index d32cf1e..134eced 100644 --- a/src/jexer/backend/SwingTerminal.java +++ b/src/jexer/backend/SwingTerminal.java @@ -182,12 +182,12 @@ public class SwingTerminal extends LogicalScreen /** * Width of a character cell in pixels. */ - private int textWidth = 1; + private int textWidth = 16; /** * Height of a character cell in pixels. */ - private int textHeight = 1; + private int textHeight = 20; /** * Width of a character cell in pixels, as reported by font.