Skip to content

Commit 2ea424b

Browse files
authored
Merge pull request #9 from Pconti31/pconti-201
fix for no error reporting
2 parents c1cd80c + 915c1bd commit 2ea424b

File tree

8 files changed

+52
-56
lines changed

8 files changed

+52
-56
lines changed
-17 Bytes
Binary file not shown.

.gradle/buildOutputCleanup/cache.properties

Lines changed: 0 additions & 2 deletions
This file was deleted.
-18.6 KB
Binary file not shown.

.gradle/vcs-1/gc.properties

Whitespace-only changes.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ the release so you no longer need to deal with its installation.
7575

7676
A windows installer has also been added.
7777

78+
### Bug fixes for 2.01
79+
Export didn't always inform you of problems and simply looked like it was hung.
80+
7881
### Bug fixes for 2.00
7982

8083
Added execute permissions to Java for Linux and MacOS.

src/main/java/ttf2gfx/DrawGFX.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* The MIT License
44
*
5-
* Copyright 2020 Paul Conti
5+
* Copyright 2020-2022 Paul Conti
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
88
* of this software and associated documentation files (the "Software"), to deal
@@ -176,7 +176,7 @@ public void dropChar(CharacterHelper selected, Point p) {
176176
currentCharacter.ch = selected.ch;
177177
currentCharacter.replace_code = selected.nCode;
178178
currentCharacter.bValid = true;
179-
System.out.println("Drop loc: "+ currentCharacter.r);
179+
// System.out.println("Drop loc: "+ currentCharacter.r);
180180
clearCurChar();
181181
FontBuilder.availableCharPane.clearCurChar();
182182
repaint();

src/main/java/ttf2gfx/FontGenerator.java

Lines changed: 45 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* The MIT License
44
*
5-
* Copyright 2020 Paul Conti
5+
* Copyright 2020-2022 Paul Conti
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
88
* of this software and associated documentation files (the "Software"), to deal
@@ -38,7 +38,6 @@
3838
import java.io.BufferedWriter;
3939
import java.io.File;
4040
import java.io.FileOutputStream;
41-
import java.io.IOException;
4241
import java.io.OutputStreamWriter;
4342
import java.util.ArrayList;
4443

@@ -96,29 +95,32 @@ public FontGenerator() {
9695
* the ttf font file
9796
*/
9897
public static void generateFontSet(File ttfFile) {
99-
JComboBox<Integer> cbSizes = new JComboBox<Integer>(FontSizes);
100-
JTextField txtOutputName = new JTextField();
101-
String outputFileName = ttfFile.getName();
102-
int idx = outputFileName.indexOf(".ttf");
103-
outputFileName = outputFileName.substring(0,idx);
104-
outputFileName = outputFileName.replaceAll("[\\s\\-\\.]", "_");
105-
txtOutputName.setText(outputFileName);
106-
nTotalBytes = 0;
107-
Object[] message = {
108-
"Font Size:", cbSizes,
109-
"Output file:", txtOutputName
110-
};
111-
int option = JOptionPane.showConfirmDialog(null, message, "Export", JOptionPane.OK_CANCEL_OPTION);
112-
if (option != JOptionPane.OK_OPTION) {
113-
return;
114-
}
115-
Integer iSize = (Integer) cbSizes.getSelectedItem();
116-
String userFileName = txtOutputName.getText();
117-
userFileName = userFileName.replaceAll("[\\s\\-\\.]", "_");
118-
119-
outputFileName = FontBuilder.getWorkingDir() + userFileName + "_" + iSize.toString() + "pt" + ".h";
120-
//create the font to use.
12198
try {
99+
JComboBox<Integer> cbSizes = new JComboBox<Integer>(FontSizes);
100+
JTextField txtOutputName = new JTextField();
101+
String outputFileName = ttfFile.getName().toLowerCase();
102+
int idx = outputFileName.indexOf(".ttf");
103+
if (idx != -1) {
104+
outputFileName = outputFileName.substring(0,idx);
105+
}
106+
outputFileName = outputFileName.substring(0,idx);
107+
outputFileName = outputFileName.replaceAll("[\\s\\-\\.]", "_");
108+
txtOutputName.setText(outputFileName);
109+
nTotalBytes = 0;
110+
Object[] message = {
111+
"Font Size:", cbSizes,
112+
"Output file:", txtOutputName
113+
};
114+
int option = JOptionPane.showConfirmDialog(null, message, "Export", JOptionPane.OK_CANCEL_OPTION);
115+
if (option != JOptionPane.OK_OPTION) {
116+
return;
117+
}
118+
Integer iSize = (Integer) cbSizes.getSelectedItem();
119+
String userFileName = txtOutputName.getText();
120+
userFileName = userFileName.replaceAll("[\\s\\-\\.]", "_");
121+
122+
outputFileName = FontBuilder.getWorkingDir() + userFileName + "_" + iSize.toString() + "pt" + ".h";
123+
//create the font to use.
122124
/* Use scaling factor to reset size of font,
123125
* If we don't account for this the font will appear half the size
124126
* of Adafruit's Free Fonts.
@@ -128,40 +130,33 @@ public static void generateFontSet(File ttfFile) {
128130
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
129131
//register the font
130132
ge.registerFont(font);
131-
} catch (Exception e) {
132-
JOptionPane.showMessageDialog(null,
133-
e.toString(),
134-
"ERROR",
135-
JOptionPane.ERROR_MESSAGE);
136-
return;
137-
}
138133

139-
image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
140-
g2d = (Graphics2D) image.getGraphics();
141-
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
142-
RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
143-
g2d.setFont(font);
144-
fontMetrics = g2d.getFontMetrics();
134+
image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
135+
g2d = (Graphics2D) image.getGraphics();
136+
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
137+
RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
138+
g2d.setFont(font);
139+
fontMetrics = g2d.getFontMetrics();
145140
// baselineY = fontMetrics.getMaxAscent();
146-
ArrayList<FontGFXGlyph> fontList = new ArrayList<FontGFXGlyph>();
147-
for (CharacterHelper h : DrawGFX.characterList) {
148-
fontList.add(decodeChar(h));
149-
}
150-
StringBuilder sBd = new StringBuilder();
151-
File fontSet = new File(outputFileName);
152-
String fontName = fontSet.getName();
153-
int n = fontName.indexOf(".h");
154-
fontName = fontName.substring(0,n);
155-
buildFontSet(sBd, fontName, fontList);
156-
BufferedWriter bw = null;
157-
try {
141+
ArrayList<FontGFXGlyph> fontList = new ArrayList<FontGFXGlyph>();
142+
for (CharacterHelper h : DrawGFX.characterList) {
143+
fontList.add(decodeChar(h));
144+
}
145+
StringBuilder sBd = new StringBuilder();
146+
File fontSet = new File(outputFileName);
147+
String fontName = fontSet.getName();
148+
int n = fontName.indexOf(".h");
149+
fontName = fontName.substring(0,n);
150+
buildFontSet(sBd, fontName, fontList);
151+
BufferedWriter bw = null;
152+
158153
bw = new BufferedWriter(new OutputStreamWriter(
159154
new FileOutputStream(fontSet), "UTF-8"));
160155
bw.write(sBd.toString());
161156
bw.flush();
162157
bw.close();
163158
FontBuilder.postStatusMsg(String.format("created->%s",outputFileName),10000);
164-
} catch (IOException e) {
159+
} catch (Exception e) {
165160
JOptionPane.showMessageDialog(null,
166161
e.toString(),
167162
"ERROR",

src/main/java/ttf2gfx/Ttf2GfxApp.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* The MIT License
44
*
5-
* Copyright 2020 Paul Conti
5+
* Copyright 2020-2022 Paul Conti
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
88
* of this software and associated documentation files (the "Software"), to deal
@@ -54,7 +54,7 @@ public class Ttf2GfxApp implements ActionListener {
5454
private FontBuilder contentPane;
5555

5656
/** version number for our appliaction */
57-
public static final String VERSION = "2.00";
57+
public static final String VERSION = "2.01";
5858

5959
/** version number for user preferences */
6060
public static final String VERSION_NO = "-1";

0 commit comments

Comments
 (0)