mirror of
https://github.com/badvision/jace.git
synced 2024-11-28 10:52:33 +00:00
Removal of swing imageio for reading font, also switching to use a PNG file because it is slightly smaller.
This commit is contained in:
parent
175484b4b3
commit
4f4febc16b
@ -18,19 +18,22 @@
|
|||||||
*/
|
*/
|
||||||
package jace.core;
|
package jace.core;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import javax.imageio.ImageIO;
|
import javafx.scene.image.Image;
|
||||||
|
import javafx.scene.image.PixelReader;
|
||||||
|
import javafx.scene.paint.Color;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the Apple ][ character font used in text modes.
|
* Represents the Apple ][ character font used in text modes. Created on January
|
||||||
* Created on January 16, 2007, 8:16 PM
|
* 16, 2007, 8:16 PM
|
||||||
|
*
|
||||||
* @author Brendan Robert (BLuRry) brendan.robert@gmail.com
|
* @author Brendan Robert (BLuRry) brendan.robert@gmail.com
|
||||||
*/
|
*/
|
||||||
public class Font {
|
public class Font {
|
||||||
|
|
||||||
static public int[][] font;
|
static public int[][] font;
|
||||||
static public boolean initialized = false;
|
static public boolean initialized = false;
|
||||||
|
|
||||||
static public int getByte(int c, int yOffset) {
|
static public int getByte(int c, int yOffset) {
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
initalize();
|
initalize();
|
||||||
@ -39,31 +42,32 @@ public class Font {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void initalize() {
|
private static void initalize() {
|
||||||
font = new int[256][8];
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
try {
|
font = new int[256][8];
|
||||||
InputStream in = ClassLoader.getSystemResourceAsStream("jace/data/font.gif");
|
Thread fontLoader = new Thread(() -> {
|
||||||
BufferedImage fontImage = ImageIO.read(in);
|
InputStream in = ClassLoader.getSystemResourceAsStream("jace/data/font.png");
|
||||||
|
Image image = new Image(in);
|
||||||
|
PixelReader reader = image.getPixelReader();
|
||||||
for (int i = 0; i < 256; i++) {
|
for (int i = 0; i < 256; i++) {
|
||||||
int x = (i >> 4) * 13 + 2;
|
int x = (i >> 4) * 13 + 2;
|
||||||
int y = (i & 15) * 13 + 4;
|
int y = (i & 15) * 13 + 4;
|
||||||
for (int j = 0; j < 8; j++) {
|
for (int j = 0; j < 8; j++) {
|
||||||
int row = 0;
|
int row = 0;
|
||||||
for (int k = 0; k < 7; k++) {
|
for (int k = 0; k < 7; k++) {
|
||||||
int color = fontImage.getRGB((7-k)+x, j+y);
|
Color color = reader.getColor((7 - k) + x, j + y);
|
||||||
row = (row<<1) | (1-(color&1));
|
boolean on = color.getRed() != 0;
|
||||||
// row = (row<<1) | (color&1);
|
row = (row << 1) | (on ? 0 : 1);
|
||||||
}
|
}
|
||||||
font[i][j] = row;
|
font[i][j] = row;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException ex) {
|
});
|
||||||
ex.printStackTrace();
|
fontLoader.start();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Creates a new instance of Font */
|
* Creates a new instance of Font
|
||||||
|
*/
|
||||||
private Font() {
|
private Font() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user