kopia lustrzana https://github.com/jameshball/osci-render
Add default font
rodzic
8379c7ffa3
commit
b2b63df91c
|
@ -24,7 +24,8 @@ final class AudioArgs {
|
||||||
|
|
||||||
filePath = args[0];
|
filePath = args[0];
|
||||||
optionalArgs = new float[args.length - 1];
|
optionalArgs = new float[args.length - 1];
|
||||||
if (filePath.matches(".*\\.txt")) {
|
/* Second argument is a path to a font .svg if the first argument is a .txt file. */
|
||||||
|
if (filePath.matches(".*\\.txt") && args.length > 1) {
|
||||||
fontPath = args[1];
|
fontPath = args[1];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +43,7 @@ final class AudioArgs {
|
||||||
} else if (filePath.matches(".*\\.svg")) {
|
} else if (filePath.matches(".*\\.svg")) {
|
||||||
return new SvgParser(filePath);
|
return new SvgParser(filePath);
|
||||||
} else if (filePath.matches(".*\\.txt")) {
|
} else if (filePath.matches(".*\\.txt")) {
|
||||||
return new TextParser(filePath, fontPath);
|
return fontPath.isEmpty() ? new TextParser(filePath) : new TextParser(filePath, fontPath);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Provided file extension in file " + filePath + " not supported.");
|
"Provided file extension in file " + filePath + " not supported.");
|
||||||
|
@ -79,8 +80,9 @@ final class AudioArgs {
|
||||||
|
|
||||||
private static class IllegalAudioArgumentException extends IllegalArgumentException {
|
private static class IllegalAudioArgumentException extends IllegalArgumentException {
|
||||||
|
|
||||||
private static final String USAGE = "Incorrect usage.\nUsage: osci-render objFilePath "
|
private static final String USAGE = "Incorrect usage.\nUsage: osci-render filePath "
|
||||||
+ "[rotateSpeed] [focalLength] [cameraX] [cameraY] [cameraZ]";
|
+ "[rotateSpeed] [focalLength] [cameraX] [cameraY] [cameraZ]\nOR: osci-render textFilePath "
|
||||||
|
+ "[fontFilePath]";
|
||||||
|
|
||||||
public IllegalAudioArgumentException() {
|
public IllegalAudioArgumentException() {
|
||||||
super(USAGE);
|
super(USAGE);
|
||||||
|
|
|
@ -8,6 +8,7 @@ import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import javax.swing.table.DefaultTableCellRenderer;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import shapes.Shape;
|
import shapes.Shape;
|
||||||
|
@ -17,6 +18,7 @@ public class TextParser extends FileParser{
|
||||||
|
|
||||||
private static final char WIDE_CHAR = 'W';
|
private static final char WIDE_CHAR = 'W';
|
||||||
private static final double HEIGHT_SCALAR = 1.6;
|
private static final double HEIGHT_SCALAR = 1.6;
|
||||||
|
private static final String DEFAULT_FONT = "fonts/SourceCodePro-ExtraLight.svg";
|
||||||
|
|
||||||
private final Map<Character, List<Shape>> charToShape;
|
private final Map<Character, List<Shape>> charToShape;
|
||||||
private final List<String> text;
|
private final List<String> text;
|
||||||
|
@ -31,6 +33,11 @@ public class TextParser extends FileParser{
|
||||||
parseFile(font);
|
parseFile(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TextParser(String path)
|
||||||
|
throws IOException, SAXException, ParserConfigurationException {
|
||||||
|
this(path, DEFAULT_FONT);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getFileExtension() {
|
protected String getFileExtension() {
|
||||||
return ".txt";
|
return ".txt";
|
||||||
|
|
Ładowanie…
Reference in New Issue