mirror of
https://github.com/processing/processing4.git
synced 2026-05-22 16:14:27 +02:00
mostly font work, making multibyte fonts happen
This commit is contained in:
+1
-1
@@ -590,7 +590,7 @@ implements MRJAboutHandler, MRJQuitHandler, MRJPrefsHandler
|
||||
item = new JMenuItem("Create font...");
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new PdeFontBuilder(sketch.dataFolder);
|
||||
new PdeFontBuilder().show(sketch.dataFolder);
|
||||
}
|
||||
});
|
||||
menu.add(item);
|
||||
|
||||
+18
-6
@@ -43,11 +43,14 @@ public class PdeFontBuilder extends JFrame {
|
||||
JList fontSelector;
|
||||
JComboBox styleSelector;
|
||||
JTextField sizeSelector;
|
||||
JCheckBox allBox;
|
||||
JCheckBox smoothBox;
|
||||
JTextArea sample;
|
||||
JButton okButton;
|
||||
JTextField filenameField;
|
||||
|
||||
boolean smooth = true;
|
||||
boolean all = false;
|
||||
|
||||
Font font;
|
||||
|
||||
@@ -59,9 +62,7 @@ public class PdeFontBuilder extends JFrame {
|
||||
};
|
||||
|
||||
|
||||
// font.deriveFont(float size)
|
||||
|
||||
public PdeFontBuilder(File targetFolder) {
|
||||
public PdeFontBuilder() {
|
||||
super("Create Font");
|
||||
|
||||
Container paine = getContentPane();
|
||||
@@ -250,19 +251,21 @@ public class PdeFontBuilder extends JFrame {
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.add(new JLabel("Size:"));
|
||||
sizeSelector = new JTextField("48 ");
|
||||
sizeSelector = new JTextField(" 48 ");
|
||||
sizeSelector.getDocument().addDocumentListener(new DocumentListener() {
|
||||
public void insertUpdate(DocumentEvent e) { update(); }
|
||||
public void removeUpdate(DocumentEvent e) { update(); }
|
||||
public void changedUpdate(DocumentEvent e) { }
|
||||
});
|
||||
|
||||
panel.add(sizeSelector);
|
||||
|
||||
/*
|
||||
JLabel rec = new JLabel("(Recommended size for 3D use is 48 points)");
|
||||
if (PdeBase.platform == PdeBase.MACOSX) {
|
||||
rec.setFont(new Font("Dialog", Font.PLAIN, 10));
|
||||
}
|
||||
panel.add(rec);
|
||||
*/
|
||||
|
||||
smoothBox = new JCheckBox("Smooth");
|
||||
smoothBox.addActionListener(new ActionListener() {
|
||||
@@ -273,6 +276,15 @@ public class PdeFontBuilder extends JFrame {
|
||||
smoothBox.setSelected(smooth);
|
||||
panel.add(smoothBox);
|
||||
|
||||
allBox = new JCheckBox("All Characters");
|
||||
allBox.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
all = allBox.isSelected();
|
||||
}
|
||||
});
|
||||
allBox.setSelected(all);
|
||||
panel.add(allBox);
|
||||
|
||||
pain.add(panel);
|
||||
|
||||
JPanel filestuff = new JPanel();
|
||||
@@ -369,7 +381,7 @@ public class PdeFontBuilder extends JFrame {
|
||||
|
||||
try {
|
||||
font = new Font(list[selection], Font.PLAIN, fontsize);
|
||||
PFont2 f = new PFont2(font, smooth);
|
||||
PFont2 f = new PFont2(font, all, smooth);
|
||||
|
||||
// make sure the 'data' folder exists
|
||||
if (!targetFolder.exists()) targetFolder.mkdirs();
|
||||
|
||||
@@ -365,6 +365,7 @@ public class PdeRuntime implements PdeMessageConsumer {
|
||||
}
|
||||
|
||||
//System.err.println("message " + s.length() + ":" + s);
|
||||
// is this only for debugging, or?
|
||||
if (s.length() > 2) System.err.println(s);
|
||||
|
||||
// this is PApplet sending a message saying "i'm about to spew
|
||||
|
||||
@@ -1679,6 +1679,7 @@ public class PApplet extends Applet
|
||||
|
||||
//} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.err.println("Could not load font " + filename);
|
||||
System.err.println("Make sure that the font has been copied");
|
||||
System.err.println("to the data folder of your sketch.");
|
||||
@@ -3442,6 +3443,16 @@ public class PApplet extends Applet
|
||||
}
|
||||
|
||||
|
||||
public void text(String s, float x, float y, float w, float h) {
|
||||
g.text(s, x, y, w, h);
|
||||
}
|
||||
|
||||
|
||||
public void text(String s, float x, float y, float z, float w, float h) {
|
||||
g.text(s, x, y, z, w, h);
|
||||
}
|
||||
|
||||
|
||||
public void text(int num, float x, float y) {
|
||||
g.text(num, x, y);
|
||||
}
|
||||
|
||||
+99
-154
@@ -35,63 +35,6 @@ import java.util.*;
|
||||
|
||||
public class PFont implements PConstants {
|
||||
|
||||
/**
|
||||
* This is the union of the Mac Roman and Windows ANSI
|
||||
* character sets. ISO Latin 1 would be Unicode characters
|
||||
* 0x80 -> 0xFF, but in practice, it would seem that most
|
||||
* designers using P5 would rather have the characters
|
||||
* that they expect from their platform's fonts.
|
||||
*
|
||||
* This is more of an interim solution until a much better
|
||||
* font solution can be determined. (i.e. create fonts on
|
||||
* the fly from some sort of vector format).
|
||||
*
|
||||
* Not that I expect that to happen.
|
||||
*/
|
||||
static final char[] EXTRA_CHARS = {
|
||||
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
|
||||
0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
|
||||
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
|
||||
0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
|
||||
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
|
||||
0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
|
||||
0x00B0, 0x00B1, 0x00B4, 0x00B5, 0x00B6, 0x00B7, 0x00B8, 0x00BA,
|
||||
0x00BB, 0x00BF, 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5,
|
||||
0x00C6, 0x00C7, 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD,
|
||||
0x00CE, 0x00CF, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6,
|
||||
0x00D7, 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DF,
|
||||
0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
|
||||
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
|
||||
0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x00F8,
|
||||
0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FF, 0x0102, 0x0103,
|
||||
0x0104, 0x0105, 0x0106, 0x0107, 0x010C, 0x010D, 0x010E, 0x010F,
|
||||
0x0110, 0x0111, 0x0118, 0x0119, 0x011A, 0x011B, 0x0131, 0x0139,
|
||||
0x013A, 0x013D, 0x013E, 0x0141, 0x0142, 0x0143, 0x0144, 0x0147,
|
||||
0x0148, 0x0150, 0x0151, 0x0152, 0x0153, 0x0154, 0x0155, 0x0158,
|
||||
0x0159, 0x015A, 0x015B, 0x015E, 0x015F, 0x0160, 0x0161, 0x0162,
|
||||
0x0163, 0x0164, 0x0165, 0x016E, 0x016F, 0x0170, 0x0171, 0x0178,
|
||||
0x0179, 0x017A, 0x017B, 0x017C, 0x017D, 0x017E, 0x0192, 0x02C6,
|
||||
0x02C7, 0x02D8, 0x02D9, 0x02DA, 0x02DB, 0x02DC, 0x02DD, 0x03A9,
|
||||
0x03C0, 0x2013, 0x2014, 0x2018, 0x2019, 0x201A, 0x201C, 0x201D,
|
||||
0x201E, 0x2020, 0x2021, 0x2022, 0x2026, 0x2030, 0x2039, 0x203A,
|
||||
0x2044, 0x20AC, 0x2122, 0x2202, 0x2206, 0x220F, 0x2211, 0x221A,
|
||||
0x221E, 0x222B, 0x2248, 0x2260, 0x2264, 0x2265, 0x25CA, 0xF8FF,
|
||||
0xFB01, 0xFB02
|
||||
};
|
||||
|
||||
static char[] charset;
|
||||
static {
|
||||
charset = new char[126-33+1 + EXTRA_CHARS.length];
|
||||
int index = 0;
|
||||
for (int i = 33; i <= 126; i++) {
|
||||
charset[index++] = (char)i;
|
||||
}
|
||||
for (int i = 0; i < EXTRA_CHARS.length; i++) {
|
||||
charset[index++] = EXTRA_CHARS[i];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//int firstChar = 33; // always
|
||||
int charCount;
|
||||
PImage images[];
|
||||
@@ -116,79 +59,13 @@ public class PFont implements PConstants {
|
||||
float size;
|
||||
float leading;
|
||||
|
||||
int ascii[]; // quick lookup for the ascii chars
|
||||
boolean cached;
|
||||
|
||||
|
||||
public PFont() { } // for PFontAI subclass and font builder
|
||||
|
||||
|
||||
// can this throw an exception instead?
|
||||
/*
|
||||
public PFont(String filename, PApplet parent) throws IOException {
|
||||
//this.parent = parent;
|
||||
//this.valid = false;
|
||||
|
||||
String lower = filename.toLowerCase();
|
||||
if (lower.endsWith(".vlw")) {
|
||||
read(parent.openStream(filename));
|
||||
|
||||
} else if (lower.endsWith(".vlw.gz")) {
|
||||
read(new GZIPInputStream(parent.openStream(filename)));
|
||||
|
||||
} else {
|
||||
throw new IOException("don't know what type of file that is");
|
||||
}
|
||||
cached = false;
|
||||
size();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
public PFont(InputStream input) throws IOException {
|
||||
read(input);
|
||||
//cached = false;
|
||||
//size();
|
||||
}
|
||||
*/
|
||||
|
||||
public void write(OutputStream output) throws IOException {
|
||||
DataOutputStream os = new DataOutputStream(output);
|
||||
|
||||
os.writeInt(charCount);
|
||||
os.writeInt(8); // numBits
|
||||
os.writeInt(mbox); // mboxX (font size)
|
||||
os.writeInt(mbox); // mboxY (font size)
|
||||
os.writeInt(0); // baseHt, ignored
|
||||
os.writeInt(0); // struct padding for c version
|
||||
|
||||
for (int i = 0; i < charCount; i++) {
|
||||
os.writeInt(value[i]);
|
||||
os.writeInt(height[i]);
|
||||
os.writeInt(width[i]);
|
||||
os.writeInt(setWidth[i]);
|
||||
os.writeInt(topExtent[i]);
|
||||
os.writeInt(leftExtent[i]);
|
||||
os.writeInt(0); // padding
|
||||
}
|
||||
|
||||
for (int i = 0; i < charCount; i++) {
|
||||
//int bitmapSize = height[i] * width[i];
|
||||
//byte bitmap[] = new byte[bitmapSize];
|
||||
|
||||
for (int y = 0; y < height[i]; y++) {
|
||||
for (int x = 0; x < width[i]; x++) {
|
||||
os.write(images[i].pixels[y * width[i] + x] & 0xff);
|
||||
}
|
||||
}
|
||||
}
|
||||
os.flush();
|
||||
os.close(); // can/should i do this?
|
||||
}
|
||||
|
||||
|
||||
//private void load_vlw_font(String filename) throws IOException {
|
||||
//public void read(InputStream input) throws IOException {
|
||||
public PFont(InputStream input) throws IOException {
|
||||
DataInputStream is = new DataInputStream(input);
|
||||
|
||||
@@ -226,6 +103,9 @@ public class PFont implements PConstants {
|
||||
topExtent = new int[charCount];
|
||||
leftExtent = new int[charCount];
|
||||
|
||||
ascii = new int[128];
|
||||
for (int i = 0; i < 128; i++) ascii[i] = -1;
|
||||
|
||||
// read the information about the individual characters
|
||||
for (int i = 0; i < charCount; i++) {
|
||||
value[i] = is.readInt();
|
||||
@@ -237,6 +117,9 @@ public class PFont implements PConstants {
|
||||
|
||||
// pointer in the c version, ignored
|
||||
is.readInt();
|
||||
|
||||
// cache locations of the ascii charset
|
||||
if (value[i] < 128) ascii[value[i]] = i;
|
||||
}
|
||||
|
||||
images = new PImage[charCount];
|
||||
@@ -268,7 +151,43 @@ public class PFont implements PConstants {
|
||||
//System.out.println();
|
||||
}
|
||||
cached = false;
|
||||
size();
|
||||
resetSize();
|
||||
resetLeading(); // ??
|
||||
}
|
||||
|
||||
|
||||
public void write(OutputStream output) throws IOException {
|
||||
DataOutputStream os = new DataOutputStream(output);
|
||||
|
||||
os.writeInt(charCount);
|
||||
os.writeInt(8); // numBits
|
||||
os.writeInt(mbox); // mboxX (font size)
|
||||
os.writeInt(mbox); // mboxY (font size)
|
||||
os.writeInt(0); // baseHt, ignored
|
||||
os.writeInt(0); // struct padding for c version
|
||||
|
||||
for (int i = 0; i < charCount; i++) {
|
||||
os.writeInt(value[i]);
|
||||
os.writeInt(height[i]);
|
||||
os.writeInt(width[i]);
|
||||
os.writeInt(setWidth[i]);
|
||||
os.writeInt(topExtent[i]);
|
||||
os.writeInt(leftExtent[i]);
|
||||
os.writeInt(0); // padding
|
||||
}
|
||||
|
||||
for (int i = 0; i < charCount; i++) {
|
||||
//int bitmapSize = height[i] * width[i];
|
||||
//byte bitmap[] = new byte[bitmapSize];
|
||||
|
||||
for (int y = 0; y < height[i]; y++) {
|
||||
for (int x = 0; x < width[i]; x++) {
|
||||
os.write(images[i].pixels[y * width[i] + x] & 0xff);
|
||||
}
|
||||
}
|
||||
}
|
||||
os.flush();
|
||||
os.close(); // can/should i do this?
|
||||
}
|
||||
|
||||
|
||||
@@ -278,11 +197,13 @@ public class PFont implements PConstants {
|
||||
*/
|
||||
public int index(char c) {
|
||||
// these chars required in all fonts
|
||||
if ((c >= 33) && (c <= 126)) {
|
||||
return c - 33;
|
||||
}
|
||||
//if ((c >= 33) && (c <= 126)) {
|
||||
//return c - 33;
|
||||
//}
|
||||
// quicker lookup for the ascii fellers
|
||||
if (c < 128) return ascii[c];
|
||||
|
||||
// some other unicode char, hunt it out
|
||||
//return index_hunt(c, 0, charset.length-1);
|
||||
return index_hunt(c, 0, value.length-1);
|
||||
}
|
||||
|
||||
@@ -291,11 +212,10 @@ public class PFont implements PConstants {
|
||||
// meaning that old fonts would crash.. fixed for 0069
|
||||
|
||||
private int index_hunt(int c, int start, int stop) {
|
||||
//System.out.println("checking between " + start + " and " + stop);
|
||||
//System.err.println("checking between " + start + " and " + stop);
|
||||
int pivot = (start + stop) / 2;
|
||||
|
||||
// if this is the char, then return it
|
||||
//if (c == charset[pivot]) return pivot;
|
||||
if (c == value[pivot]) return pivot;
|
||||
|
||||
// char doesn't exist, otherwise would have been the pivot
|
||||
@@ -303,7 +223,6 @@ public class PFont implements PConstants {
|
||||
if (start >= stop) return -1;
|
||||
|
||||
// if it's in the lower half, continue searching that
|
||||
//if (c < charset[pivot]) return index_hunt(c, start, pivot-1);
|
||||
if (c < value[pivot]) return index_hunt(c, start, pivot-1);
|
||||
|
||||
// if it's in the upper half, continue there
|
||||
@@ -316,18 +235,17 @@ public class PFont implements PConstants {
|
||||
}
|
||||
|
||||
|
||||
public void size() {
|
||||
public void resetSize() {
|
||||
size = 12;
|
||||
}
|
||||
|
||||
|
||||
public void size(float isize) {
|
||||
size = isize;
|
||||
//leading();
|
||||
}
|
||||
|
||||
|
||||
public void leading() {
|
||||
public void resetLeading() {
|
||||
leading = size * ((float)mbox / iheightf) * 1.2f;
|
||||
}
|
||||
|
||||
@@ -442,11 +360,6 @@ public class PFont implements PConstants {
|
||||
int xx = (int) x + leftExtent[glyph];;
|
||||
int yy = (int) y - topExtent[glyph];
|
||||
|
||||
//int x1 = xx + leftExtent[glyph];
|
||||
//int y1 = yy - topExtent[glyph];
|
||||
//int x2 = x1 + width[glyph];
|
||||
//int y2 = y1 + height[glyph];
|
||||
|
||||
int x0 = 0;
|
||||
int y0 = 0;
|
||||
int w0 = width[glyph];
|
||||
@@ -508,27 +421,16 @@ public class PFont implements PConstants {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public final static int _blend(int p1, int p2, int a2) {
|
||||
// scale alpha by alpha of incoming pixel
|
||||
a2 = (a2 * (p2 >>> 24)) >> 8;
|
||||
|
||||
int a1 = a2 ^ 0xff;
|
||||
int r = (a1 * ((p1 >> 16) & 0xff) + a2 * ((p2 >> 16) & 0xff)) & 0xff00;
|
||||
int g = (a1 * ((p1 >> 8) & 0xff) + a2 * ((p2 >> 8) & 0xff)) & 0xff00;
|
||||
int b = (a1 * ( p1 & 0xff) + a2 * ( p2 & 0xff)) >> 8;
|
||||
|
||||
return 0xff000000 | (r << 8) | g | b;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// used by the text() functions to avoid over-allocation of memory
|
||||
private char c[] = new char[8192];
|
||||
|
||||
|
||||
public void text(String str, float x, float y, PGraphics parent) {
|
||||
text(str, x, y, 0, parent);
|
||||
}
|
||||
|
||||
|
||||
public void text(String str, float x, float y, float z, PGraphics parent) {
|
||||
float startX = x;
|
||||
int index = 0;
|
||||
@@ -555,4 +457,47 @@ public class PFont implements PConstants {
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Same as below, just without a z coordinate.
|
||||
*/
|
||||
public void text(String str, float x, float y,
|
||||
float w, float h, PGraphics parent) {
|
||||
text(str, x, y, 0, w, h, parent);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draw text in a text both that is constrained to a
|
||||
* particular width and height
|
||||
*/
|
||||
public void text(String str, float x, float y, float z,
|
||||
float w, float h, PGraphics parent) {
|
||||
float space = width(' ');
|
||||
float xx = x;
|
||||
float yy = y;
|
||||
float right = x + w;
|
||||
|
||||
String paragraphs[] = PApplet.split(str, '\n');
|
||||
for (int i = 0; i < paragraphs.length; i++) {
|
||||
String words[] = PApplet.split(paragraphs[i], ' ');
|
||||
float wide = 0;
|
||||
for (int j = 0; j < words.length; j++) {
|
||||
float size = width(words[j]);
|
||||
if (xx + size > right) {
|
||||
// this goes on the next line
|
||||
xx = 0;
|
||||
yy += leading;
|
||||
if (yy > h) return; // too big for box
|
||||
}
|
||||
text(words[j], xx, yy, z, parent);
|
||||
xx += size + space;
|
||||
}
|
||||
// end of paragraph, move to left and increment leading
|
||||
xx = 0;
|
||||
yy += leading;
|
||||
if (yy > h) return; // too big for box
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+74
-15
@@ -10,36 +10,85 @@ import java.awt.image.*;
|
||||
|
||||
public class PFont2 extends PFont {
|
||||
|
||||
/**
|
||||
* This is the union of the Mac Roman and Windows ANSI
|
||||
* character sets. ISO Latin 1 would be Unicode characters
|
||||
* 0x80 -> 0xFF, but in practice, it would seem that most
|
||||
* designers using P5 would rather have the characters
|
||||
* that they expect from their platform's fonts.
|
||||
*
|
||||
* This is more of an interim solution until a much better
|
||||
* font solution can be determined. (i.e. create fonts on
|
||||
* the fly from some sort of vector format).
|
||||
*
|
||||
* Not that I expect that to happen.
|
||||
*/
|
||||
static final char[] EXTRA_CHARS = {
|
||||
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
|
||||
0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
|
||||
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
|
||||
0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
|
||||
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
|
||||
0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
|
||||
0x00B0, 0x00B1, 0x00B4, 0x00B5, 0x00B6, 0x00B7, 0x00B8, 0x00BA,
|
||||
0x00BB, 0x00BF, 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5,
|
||||
0x00C6, 0x00C7, 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD,
|
||||
0x00CE, 0x00CF, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6,
|
||||
0x00D7, 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DF,
|
||||
0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
|
||||
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
|
||||
0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x00F8,
|
||||
0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FF, 0x0102, 0x0103,
|
||||
0x0104, 0x0105, 0x0106, 0x0107, 0x010C, 0x010D, 0x010E, 0x010F,
|
||||
0x0110, 0x0111, 0x0118, 0x0119, 0x011A, 0x011B, 0x0131, 0x0139,
|
||||
0x013A, 0x013D, 0x013E, 0x0141, 0x0142, 0x0143, 0x0144, 0x0147,
|
||||
0x0148, 0x0150, 0x0151, 0x0152, 0x0153, 0x0154, 0x0155, 0x0158,
|
||||
0x0159, 0x015A, 0x015B, 0x015E, 0x015F, 0x0160, 0x0161, 0x0162,
|
||||
0x0163, 0x0164, 0x0165, 0x016E, 0x016F, 0x0170, 0x0171, 0x0178,
|
||||
0x0179, 0x017A, 0x017B, 0x017C, 0x017D, 0x017E, 0x0192, 0x02C6,
|
||||
0x02C7, 0x02D8, 0x02D9, 0x02DA, 0x02DB, 0x02DC, 0x02DD, 0x03A9,
|
||||
0x03C0, 0x2013, 0x2014, 0x2018, 0x2019, 0x201A, 0x201C, 0x201D,
|
||||
0x201E, 0x2020, 0x2021, 0x2022, 0x2026, 0x2030, 0x2039, 0x203A,
|
||||
0x2044, 0x20AC, 0x2122, 0x2202, 0x2206, 0x220F, 0x2211, 0x221A,
|
||||
0x221E, 0x222B, 0x2248, 0x2260, 0x2264, 0x2265, 0x25CA, 0xF8FF,
|
||||
0xFB01, 0xFB02
|
||||
};
|
||||
|
||||
static char[] charset;
|
||||
static {
|
||||
charset = new char[126-33+1 + EXTRA_CHARS.length];
|
||||
int index = 0;
|
||||
for (int i = 33; i <= 126; i++) {
|
||||
charset[index++] = (char)i;
|
||||
}
|
||||
for (int i = 0; i < EXTRA_CHARS.length; i++) {
|
||||
charset[index++] = EXTRA_CHARS[i];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public PFont2(String name, int size) throws IOException {
|
||||
this(new Font(name, Font.PLAIN, size), true);
|
||||
this(new Font(name, Font.PLAIN, size), false, true);
|
||||
}
|
||||
|
||||
public PFont2(String name, int size, boolean smooth) throws IOException {
|
||||
this(new Font(name, Font.PLAIN, size), smooth);
|
||||
this(new Font(name, Font.PLAIN, size), false, smooth);
|
||||
}
|
||||
|
||||
public PFont2(Font font, boolean smooth) throws IOException {
|
||||
public PFont2(Font font, boolean all, boolean smooth) throws IOException {
|
||||
//int firstChar = 33;
|
||||
//int lastChar = 126;
|
||||
|
||||
//this.charCount = lastChar - firstChar + 1;
|
||||
this.charCount = charset.length;
|
||||
this.charCount = all ? 65536 : charset.length;
|
||||
this.mbox = font.getSize();
|
||||
|
||||
/*
|
||||
// size for image/texture is next power of 2 over font size
|
||||
iwidth = iheight = (int)
|
||||
Math.pow(2, Math.ceil(Math.log(mbox) / Math.log(2)));
|
||||
|
||||
iwidthf = iheightf = (float) iwidth;
|
||||
|
||||
/*
|
||||
iwidth = (int)
|
||||
Math.pow(2, Math.ceil(Math.log(mbox) / Math.log(2)));
|
||||
iheight = (int)
|
||||
Math.pow(2, Math.ceil(Math.log(mbox) / Math.log(2)));
|
||||
|
||||
iwidthf = (float) iwidth;
|
||||
iheightf = (float) iheight;
|
||||
*/
|
||||
|
||||
images = new PImage[charCount];
|
||||
@@ -66,9 +115,10 @@ public class PFont2 extends PFont {
|
||||
g.setFont(font);
|
||||
FontMetrics metrics = g.getFontMetrics();
|
||||
|
||||
int maxWidthHeight = 0;
|
||||
int index = 0;
|
||||
for (int i = 0; i < charCount; i++) {
|
||||
char c = charset[i];
|
||||
char c = all ? (char)i : charset[i];
|
||||
if (!font.canDisplay(c)) { // skip chars not in the font
|
||||
continue;
|
||||
}
|
||||
@@ -130,6 +180,9 @@ public class PFont2 extends PFont {
|
||||
// setWidth[index] + " " +
|
||||
// topExtent[index] + " " + leftExtent[index]);
|
||||
|
||||
if (width[index] > maxWidthHeight) maxWidthHeight = width[index];
|
||||
if (height[index] > maxWidthHeight) maxWidthHeight = height[index];
|
||||
|
||||
images[index] = new PImage(new int[width[index] * height[index]],
|
||||
width[index], height[index], ALPHA);
|
||||
|
||||
@@ -147,5 +200,11 @@ public class PFont2 extends PFont {
|
||||
index++;
|
||||
}
|
||||
charCount = index;
|
||||
|
||||
// size for image/texture is next power of 2 over largest char
|
||||
mbox = (int)
|
||||
Math.pow(2, Math.ceil(Math.log(maxWidthHeight) / Math.log(2)));
|
||||
//System.out.println("mbox is " + mbox);
|
||||
//System.out.println("found " + charCount + " chars
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+23
-4
@@ -4193,11 +4193,11 @@ public class PGraphics extends PImage
|
||||
}
|
||||
text_font = which;
|
||||
if (text_space != SCREEN_SPACE) {
|
||||
text_font.size();
|
||||
text_font.resetSize();
|
||||
} else {
|
||||
text_font.size(text_font.iwidth);
|
||||
}
|
||||
text_font.leading();
|
||||
text_font.resetLeading();
|
||||
}
|
||||
|
||||
public void textFont(PFont which, float size) {
|
||||
@@ -4212,7 +4212,7 @@ public class PGraphics extends PImage
|
||||
System.err.println("Cannot set size of SCREEN_SPACE fonts");
|
||||
text_font.size(text_font.iwidth);
|
||||
}
|
||||
text_font.leading();
|
||||
text_font.resetLeading();
|
||||
}
|
||||
|
||||
public void textSize(float size) {
|
||||
@@ -4244,7 +4244,7 @@ public class PGraphics extends PImage
|
||||
|
||||
if ((space == SCREEN_SPACE) && (text_font != null)) {
|
||||
text_font.size(text_font.iwidth);
|
||||
text_font.leading();
|
||||
text_font.resetLeading();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4287,6 +4287,25 @@ public class PGraphics extends PImage
|
||||
}
|
||||
|
||||
|
||||
public void text(String s, float x, float y, float w, float h) {
|
||||
text(s, x, y, 0, w, h);
|
||||
}
|
||||
|
||||
public void text(String s, float x, float y, float z, float w, float h) {
|
||||
if (text_font == null) {
|
||||
System.err.println("text(): first set a font before drawing text");
|
||||
return;
|
||||
}
|
||||
if (text_mode == ALIGN_CENTER) {
|
||||
x -= text_font.width(s) / 2f;
|
||||
|
||||
} else if (text_mode == ALIGN_RIGHT) {
|
||||
x -= text_font.width(s);
|
||||
}
|
||||
text_font.text(s, x, y, z, this);
|
||||
}
|
||||
|
||||
|
||||
public void text(int num, float x, float y) {
|
||||
text(String.valueOf(num), x, y, 0);
|
||||
}
|
||||
|
||||
@@ -185,6 +185,10 @@ public interface PMethods {
|
||||
|
||||
public void text(String s, float x, float y, float z);
|
||||
|
||||
public void text(String s, float x, float y, float w, float h);
|
||||
|
||||
public void text(String s, float x, float y, float z, float w, float h);
|
||||
|
||||
public void text(int num, float x, float y);
|
||||
|
||||
public void text(int num, float x, float y, float z);
|
||||
|
||||
+38
-30
@@ -59,9 +59,6 @@ X code now in zipdecode, maybe just list this as a standard thing?
|
||||
X do applets know when they're stopped? stop? dispose?
|
||||
X would be good to set a param in p5 so that the thread dies
|
||||
X if people have other threads they've spawned, impossible to stop
|
||||
X saveFrame() to a folder horks things up if a mkdirs() is required
|
||||
X on macosx, this makes things hang; on windows it complains
|
||||
X http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1081706752;start=0
|
||||
|
||||
cleaning up
|
||||
X make bagel more usable as standalone
|
||||
@@ -86,28 +83,26 @@ o sphere code needs only front face polygon
|
||||
o all triangles must be counter-clockwise (front-facing)
|
||||
X fix loadImage to be inside PApplet
|
||||
|
||||
040715
|
||||
X saveFrame() to a folder horks things up if a mkdirs() is required
|
||||
X on macosx, this makes things hang; on windows it complains
|
||||
X http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1081706752;start=0
|
||||
X decide on whether to use PTools
|
||||
X decided against, since it doesn't help anything
|
||||
X and some functions need the applet object, so it's just annoying
|
||||
o i.e. move math functions into utility library
|
||||
o check what other functions require PGraphics to exist but shouldn't
|
||||
o look at BGraphics to see if setting an 'applet' could be used
|
||||
o then other than that, if no applet set, no connection to PApplet
|
||||
|
||||
_ new graphics: test with rgb cube, shut off smoothing
|
||||
_ make sure line artifacts are because of smoothing
|
||||
040716
|
||||
X change font api to not use leading() as a way to reset the leading
|
||||
X resetLeading and resetSize are the things
|
||||
X embed all available chars from a font, so japanese, etc works
|
||||
X http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;action=display;num=1083598817;start=3
|
||||
X fix a bunch of font bugs regarding charsets and lookup
|
||||
|
||||
|
||||
|
||||
megabucket
|
||||
_ decide on whether to use PTools
|
||||
_ i.e. move math functions into utility library
|
||||
_ check what other functions require PGraphics to exist but shouldn't
|
||||
_ look at BGraphics to see if setting an 'applet' could be used
|
||||
_ then other than that, if no applet set, no connection to PApplet
|
||||
|
||||
high priority for beta
|
||||
_ light(x, y, z, c1, c2, c3, TYPE)
|
||||
_ also BLight with same constructor, and on() and off() fxn
|
||||
_ figure out how to handle cached images, multiple images
|
||||
_ MediaTracker blocking is prolly making jar download really slow
|
||||
_ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1089914280;start=0
|
||||
|
||||
_ new/old graphics, explicitly stating 2d/3d, huh?
|
||||
_ what to do about anti-aliasing.. oversample 2x?
|
||||
_ array operations: byte, char, int, float, String, Object
|
||||
_ expand/contract
|
||||
_ append/unappend.. (no push/pop) add/remove put/unput
|
||||
@@ -118,6 +113,13 @@ _ expand() on Object[] is worthless.. fix it with reflection?
|
||||
_ also, should it be named resize() instead?
|
||||
_ see if reflection will allow expand for all class types
|
||||
|
||||
megabucket
|
||||
_ move to new graphics engine
|
||||
_ test with rgb cube, shut off smoothing
|
||||
_ make sure line artifacts are because of smoothing
|
||||
_ explicitly state depth()/nodepth()
|
||||
_ implement 2x oversampling for anti-aliasing
|
||||
|
||||
_ illustrator export / rendering mode
|
||||
_ also postscript or pdf export?
|
||||
_ version of Illustrator.java that uses core api
|
||||
@@ -135,12 +137,19 @@ _ http://processing.org/discourse/yabb/YaBB.cgi?board=Tools;action=display;n
|
||||
............................................................
|
||||
|
||||
|
||||
0071 or later
|
||||
0071 or later (but high priority)
|
||||
|
||||
_ figure out how to handle cached images, multiple images
|
||||
_ MediaTracker blocking is prolly making jar download really slow
|
||||
_ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1089914280;start=0
|
||||
|
||||
_ mkoser wish list
|
||||
_ filled polygons working with smooth()
|
||||
_ z-clipping
|
||||
|
||||
_ light(x, y, z, c1, c2, c3, TYPE)
|
||||
_ also BLight with same constructor, and on() and off() fxn
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@@ -368,13 +377,12 @@ CORE / Mac OS X
|
||||
|
||||
CORE / PFont
|
||||
|
||||
b _ embed all available chars from a font, so japanese, etc works
|
||||
1 _ sbit font support
|
||||
1 _ both reading and building sbit fonts
|
||||
* _ mac -> vlw (or sbit?) font converter
|
||||
* _ need to also read the fond for metrics
|
||||
1 _ rotated text has a bug for when it goes offscreen
|
||||
1 _ patch rotated text (from visualclusto) into bfont
|
||||
1 _ text() with alignment doesn't work for multiple lines
|
||||
1 _ don't change the size of a font when in screen space mode
|
||||
1 _ patch rotated text (from visualclusto) into bfont
|
||||
1 _ what sort of api? textSpace(ROTATED) ?
|
||||
1 _ rotated text has a bug for when it goes offscreen
|
||||
|
||||
|
||||
|
||||
CORE / New Graphics
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
BAGEL / Future
|
||||
|
||||
2 _ sbit font support
|
||||
2 _ both reading and building sbit fonts
|
||||
2 _ materials and shading
|
||||
2 _ camera object for moving scene
|
||||
2 _ cartesian/polar conversion
|
||||
|
||||
@@ -24,10 +24,10 @@ o i.e. either return null, or block until it's available? -> ret null
|
||||
X "paste" isn't setting the "modified" bit for PdeEditor
|
||||
X i.e. cut -> new file -> paste doesn't mark any as changed
|
||||
|
||||
_ processing.net -> PClient, PServer
|
||||
_ System.out isn't being heard from P* classes
|
||||
_ errors inside those classes also causing weirdness
|
||||
|
||||
_ change font api to not use leading() as a way to reset the leading
|
||||
_ don't change the size of a font when in screen space mode
|
||||
_ processing.net -> PClient, PServer
|
||||
|
||||
_ "add library" menu item and submenu
|
||||
_ iterate through the 'library' folders
|
||||
@@ -514,3 +514,6 @@ _ walking through an entire directory, with a handler
|
||||
_ that throws out the . and .. items
|
||||
_ that knows about aliases (jdk13)
|
||||
_ overall contrast/color control (genomevalence for hulk)
|
||||
_ mac -> vlw (or sbit?) font converter
|
||||
_ need to also read the fond for metrics
|
||||
_ general font editor, see what chars are in font, etc
|
||||
Reference in New Issue
Block a user