aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Schweinsberg <[email protected]>2016-01-12 19:26:19 -0800
committerDavid Schweinsberg <[email protected]>2016-01-12 19:26:19 -0800
commitba9a762fe8bf5dd28a44b56d1b9b4e91d52d10cf (patch)
tree44cfff7fdc01fed17c06e5f2f44d8000570a019d
parent24a44c399342b6a80770c7fc931b62d9900cd5ef (diff)
Display of CFF hints (#3)
-rw-r--r--src/net/java/dev/typecast/app/editor/EditorMenu.java13
-rw-r--r--src/net/java/dev/typecast/app/editor/GlyphPanelToolBar.java7
-rw-r--r--src/net/java/dev/typecast/app/editor/Main.java3
-rw-r--r--src/net/java/dev/typecast/app/editor/Main.properties3
-rw-r--r--src/net/java/dev/typecast/cff/T2Interpreter.java76
-rw-r--r--src/net/java/dev/typecast/edit/GlyphEdit.java57
6 files changed, 90 insertions, 69 deletions
diff --git a/src/net/java/dev/typecast/app/editor/EditorMenu.java b/src/net/java/dev/typecast/app/editor/EditorMenu.java
index f23ebb8..47b4dcc 100644
--- a/src/net/java/dev/typecast/app/editor/EditorMenu.java
+++ b/src/net/java/dev/typecast/app/editor/EditorMenu.java
@@ -54,6 +54,7 @@ public class EditorMenu {
private String _closeMenuString;
private JCheckBoxMenuItem _previewMenuItem;
private JCheckBoxMenuItem _showPointsMenuItem;
+ private JCheckBoxMenuItem _showHintsMenuItem;
private boolean _macPlatform;
private int _primaryKeystrokeMask;
private JMenu _mruMenu;
@@ -100,6 +101,10 @@ public class EditorMenu {
return _showPointsMenuItem.getState();
}
+ public boolean isShowHints() {
+ return _showHintsMenuItem.getState();
+ }
+
private static void parseMenuString(String menuString, String[] tokens) {
try {
StreamTokenizer st = new StreamTokenizer(new StringReader(menuString));
@@ -422,6 +427,14 @@ public class EditorMenu {
_app.changeGlyphView();
}
}));
+ menu.add(_showHintsMenuItem = createCheckBoxMenuItem(
+ _rb.getString("Typecast.menu.view.showHints"),
+ KeyStroke.getKeyStroke(KeyEvent.VK_H, _primaryKeystrokeMask),
+ new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ _app.changeGlyphView();
+ }
+ }));
_showPointsMenuItem.setState(true);
JMenu subMenu = createMenu(_rb.getString("Typecast.menu.view.magnification"));
menu.add(subMenu);
diff --git a/src/net/java/dev/typecast/app/editor/GlyphPanelToolBar.java b/src/net/java/dev/typecast/app/editor/GlyphPanelToolBar.java
index 927ed81..22f229d 100644
--- a/src/net/java/dev/typecast/app/editor/GlyphPanelToolBar.java
+++ b/src/net/java/dev/typecast/app/editor/GlyphPanelToolBar.java
@@ -1,9 +1,7 @@
/*
- * $Id: GlyphPanelToolBar.java,v 1.1 2007-01-24 09:37:00 davidsch Exp $
- *
* Typecast - The Font Development Environment
*
- * Copyright (c) 2004 David Schweinsberg
+ * Copyright (c) 2004-2016 David Schweinsberg
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,9 +26,8 @@ import javax.swing.JToolBar;
/**
*
* @author <a href="mailto:[email protected]">David Schweinsberg</a>
- * @version $Id: GlyphPanelToolBar.java,v 1.1 2007-01-24 09:37:00 davidsch Exp $
*/
-public class GlyphPanelToolBar extends javax.swing.JToolBar {
+public class GlyphPanelToolBar extends JToolBar {
private static final long serialVersionUID = 1L;
diff --git a/src/net/java/dev/typecast/app/editor/Main.java b/src/net/java/dev/typecast/app/editor/Main.java
index ce173d3..91a17a0 100644
--- a/src/net/java/dev/typecast/app/editor/Main.java
+++ b/src/net/java/dev/typecast/app/editor/Main.java
@@ -1,7 +1,7 @@
/*
* Typecast - The Font Development Environment
*
- * Copyright (c) 2004-2015 David Schweinsberg
+ * Copyright (c) 2004-2016 David Schweinsberg
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -357,6 +357,7 @@ public class Main {
protected void changeGlyphView() {
_glyphPane.getGlyphEdit().setPreview(_menu.isPreview());
_glyphPane.getGlyphEdit().setDrawControlPoints(_menu.isShowPoints());
+ _glyphPane.getGlyphEdit().setDrawHints(_menu.isShowHints());
_glyphPane.getGlyphEdit().repaint();
}
diff --git a/src/net/java/dev/typecast/app/editor/Main.properties b/src/net/java/dev/typecast/app/editor/Main.properties
index 7de32db..6d44a51 100644
--- a/src/net/java/dev/typecast/app/editor/Main.properties
+++ b/src/net/java/dev/typecast/app/editor/Main.properties
@@ -1,7 +1,7 @@
#
# Typecast - The Font Development Environment
#
-# Copyright (c) 2004-2015 David Schweinsberg
+# Copyright (c) 2004-2016 David Schweinsberg
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -62,6 +62,7 @@ Typecast.menu.view.magnification.20000="200%" "2" "200%"
Typecast.menu.view.magnification.10000="100%" "1" "100%"
Typecast.menu.view.magnification.05000="50%" "5" "50%"
Typecast.menu.view.showPoints="Show Points" S "Show Points"
+Typecast.menu.view.showHints="Show Hints" H "Show Hints"
Typecast.menu.view.preview=Preview P "Preview"
Typecast.menu.file.new=New N "Create a new font"
diff --git a/src/net/java/dev/typecast/cff/T2Interpreter.java b/src/net/java/dev/typecast/cff/T2Interpreter.java
index ace1fd6..79bf51e 100644
--- a/src/net/java/dev/typecast/cff/T2Interpreter.java
+++ b/src/net/java/dev/typecast/cff/T2Interpreter.java
@@ -648,62 +648,94 @@ public class T2Interpreter {
}
}
+ /**
+ * Specifies one or more horizontal stem hints. This allows multiple pairs
+ * of numbers, limited by the stack depth, to be used as arguments to a
+ * single hstem operator.
+ */
private void _hstem() {
- if (getArgCount() % 2 == 1) {
+ int pairCount = getArgCount() / 2;
+ for (int i = 0; i < pairCount; ++i) {
+ _hstems.add(0, popArg().intValue());
+ _hstems.add(0, popArg().intValue());
+ }
+
+ if (getArgCount() > 0) {
// This will be the width value
popArg();
}
-
- while (getArgCount() > 0) {
- _hstems.add(popArg().intValue());
- }
}
+ /**
+ * Specifies one or more vertical stem hints between the x coordinates x
+ * and x+dx, where x is relative to the origin of the coordinate axes.
+ */
private void _vstem() {
- if (getArgCount() % 2 == 1) {
+ int pairCount = getArgCount() / 2;
+ for (int i = 0; i < pairCount; ++i) {
+ _vstems.add(0, popArg().intValue());
+ _vstems.add(0, popArg().intValue());
+ }
+
+ if (getArgCount() > 0) {
// This will be the width value
popArg();
}
-
- while (getArgCount() > 0) {
- _vstems.add(popArg().intValue());
- }
}
+ /**
+ * Has the same meaning as hstem, except that it must be used in place
+ * of hstem if the charstring contains one or more hintmask operators.
+ */
private void _hstemhm() {
- if (getArgCount() % 2 == 1) {
+ _stemCount += getArgCount() / 2;
+ int pairCount = getArgCount() / 2;
+ for (int i = 0; i < pairCount; ++i) {
+ _hstems.add(0, popArg().intValue());
+ _hstems.add(0, popArg().intValue());
+ }
+
+ if (getArgCount() > 0) {
// This will be the width value
popArg();
}
-
- _stemCount += getArgCount() / 2;
- while (getArgCount() > 0) {
- _hstems.add(popArg().intValue());
- }
}
+ /**
+ * Has the same meaning as vstem, except that it must be used in place
+ * of vstem if the charstring contains one or more hintmask operators.
+ */
private void _vstemhm() {
- if (getArgCount() % 2 == 1) {
+ _stemCount += getArgCount() / 2;
+ int pairCount = getArgCount() / 2;
+ for (int i = 0; i < pairCount; ++i) {
+ _vstems.add(0, popArg().intValue());
+ _vstems.add(0, popArg().intValue());
+ }
+
+ if (getArgCount() > 0) {
// This will be the width value
popArg();
}
-
- _stemCount += getArgCount() / 2;
- while (getArgCount() > 0) {
- _vstems.add(popArg().intValue());
- }
}
+ /**
+ * Specifies which hints are active and which are not active.
+ */
private void _hintmask() {
_stemCount += getArgCount() / 2;
_ip += (_stemCount - 1) / 8 + 1;
clearArg();
}
+ /**
+ * Specifies the counter spaces to be controlled, and their
+ * relative priority.
+ */
private void _cntrmask() {
_stemCount += getArgCount() / 2;
_ip += (_stemCount - 1) / 8 + 1;
diff --git a/src/net/java/dev/typecast/edit/GlyphEdit.java b/src/net/java/dev/typecast/edit/GlyphEdit.java
index c10ab28..a70d1e7 100644
--- a/src/net/java/dev/typecast/edit/GlyphEdit.java
+++ b/src/net/java/dev/typecast/edit/GlyphEdit.java
@@ -57,6 +57,7 @@ public class GlyphEdit extends JPanel implements Scrollable {
private double _scaleFactor = 0.25f;
private boolean _drawControlPoints = true;
+ private boolean _drawHints = false;
private boolean _preview = false;
private final Set<Point> _selectedPoints = new HashSet<>();
@@ -138,57 +139,25 @@ public class GlyphEdit extends JPanel implements Scrollable {
g2d.draw(new Line2D.Float(_glyph.getLeftSideBearing(), -unitsPerEmBy2, _glyph.getLeftSideBearing(), unitsPerEmBy2));
g2d.draw(new Line2D.Float(_glyph.getAdvanceWidth(), -unitsPerEmBy2, _glyph.getAdvanceWidth(), unitsPerEmBy2));
- if (_glyph instanceof T2Glyph) {
+ if (_drawHints && _glyph instanceof T2Glyph) {
T2Glyph t2g = (T2Glyph) _glyph;
- Rectangle2D bounds = t2g.getBounds();
+// Rectangle2D bounds = t2g.getBounds();
// g2d.setPaint(Color.PINK);
// g2d.fill(bounds);
-//
-// g2d.setPaint(Color.RED);
+
+ g2d.setPaint(Color.RED);
int y = 0;
- boolean isWidth = false;
for (Integer horiz : t2g.getHStems()) {
- if (isWidth) {
- if (horiz == -20) {
-
- // Top edge
- y = (int) bounds.getMaxY();
- } else if (horiz == -21) {
-
- // Bottom edge
- y = (int) bounds.getMinY();
- } else {
- y += horiz;
- }
- } else {
- y += horiz;
- }
-// g2d.draw(new Line2D.Float(0, y, 1000, y));
- isWidth = !isWidth;
+ y += horiz;
+ g2d.draw(new Line2D.Float(0, y, 1000, y));
}
int x = 0;
- isWidth = false;
for (Integer vert : t2g.getVStems()) {
- if (isWidth) {
- if (vert == -20) {
-
- // Right edge
- x = (int) bounds.getMaxX();
- } else if (vert == -21) {
-
- // Left edge
- x = (int) bounds.getMinX();
- } else {
- x += vert;
- }
- } else {
- x += vert;
- }
-// g2d.draw(new Line2D.Float(x, 0, x, 1000));
- isWidth = !isWidth;
+ x += vert;
+ g2d.draw(new Line2D.Float(x, 0, x, 1000));
}
}
@@ -291,6 +260,14 @@ public class GlyphEdit extends JPanel implements Scrollable {
_drawControlPoints = b;
}
+ public boolean isDrawHints() {
+ return _drawHints;
+ }
+
+ public void setDrawHints(boolean b) {
+ _drawHints = b;
+ }
+
public boolean isPreview() {
return _preview;
}