diff --git a/processing/core/PFont.java b/processing/core/PFont.java index efba90fbe..5eb4fb6d3 100644 --- a/processing/core/PFont.java +++ b/processing/core/PFont.java @@ -609,8 +609,7 @@ public class PFont implements PConstants { // boundary of a word float wordWidth = calcWidth(textBuffer, wordStart, index); if (runningX + wordWidth > boxX2) { - if ((runningX == boxX1) && - (wordWidth > boxWidth)) { + if (runningX == boxX1) { // if this is the first word, and its width is // greater than the width of the text box, // then break the word where at the max width, @@ -634,7 +633,7 @@ public class PFont implements PConstants { // because multiple spaces don't count for shit when they're // at the end of a line like this. - //index = wordStop + 1; // back that ass up + index = wordStop; // back that ass up while ((index < length) && (textBuffer[index] == ' ')) { index++; diff --git a/processing/core/PFont2.java b/processing/core/PFont2.java index 7080e4a43..d93a70976 100644 --- a/processing/core/PFont2.java +++ b/processing/core/PFont2.java @@ -11,46 +11,46 @@ import java.awt.image.*; public class PFont2 extends PFont { /** - * This is the union of the Mac Roman and Windows ANSI + * 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. + * 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). + * 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, + 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 }; @@ -87,7 +87,7 @@ public class PFont2 extends PFont { /* // size for image/texture is next power of 2 over font size - iwidth = iheight = (int) + iwidth = iheight = (int) Math.pow(2, Math.ceil(Math.log(mbox) / Math.log(2))); iwidthf = iheightf = (float) iwidth; @@ -108,12 +108,12 @@ public class PFont2 extends PFont { int mbox3 = mbox * 3; - BufferedImage playground = + BufferedImage playground = new BufferedImage(mbox3, mbox3, BufferedImage.TYPE_INT_RGB); Graphics2D g = (Graphics2D) playground.getGraphics(); - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - smooth ? + g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + smooth ? RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF); @@ -156,7 +156,7 @@ public class PFont2 extends PFont { if (y < minY) minY = y; if (x > maxX) maxX = x; if (y > maxY) maxY = y; - pixelFound = true; + pixelFound = true; //System.out.println(x + " " + y + " = " + sample); } } @@ -232,19 +232,18 @@ public class PFont2 extends PFont { } } // size for image/texture is next power of 2 over largest char - mbox2 = (int) + mbox2 = (int) Math.pow(2, Math.ceil(Math.log(maxWidthHeight) / Math.log(2))); twidth = theight = mbox2; - //images = bitmaps; - //System.out.println("Mbox 2 is " + mbox2); + // shove the smaller PImage data into textures of next-power-of-2 size, + // so that this font can be used immediately by p5. images = new PImage[charCount]; - // copy from bitmaps into actual image pixels for (int i = 0; i < charCount; i++) { images[i] = new PImage(new int[mbox2*mbox2], mbox2, mbox2, ALPHA); for (int y = 0; y < height[i]; y++) { System.arraycopy(bitmaps[i].pixels, y*width[i], - images[i].pixels, y*mbox2, + images[i].pixels, y*mbox2, width[i]); } bitmaps[i] = null; diff --git a/processing/core/todo.txt b/processing/core/todo.txt index e1655eebc..8573b3423 100644 --- a/processing/core/todo.txt +++ b/processing/core/todo.txt @@ -10,37 +10,47 @@ X probably wasn't using textFont() properly X now that it's actually a key, should it be a char? (what's keyChar?) X that way println(c) would work a little better.. X libraryCalls() not properly working for pre, post, or draw() +o image(myg, x, y) doesn't work but image(myg, x, y, w, h) does +o (image kind prolly not set right and so image() gets pissy) +o http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1091798655 + +_ depth testing of lines vs text is problematic +_ use depth()/noDepth() to handle depth test _ y2 position of rectangles not same as y2 position of lines text fixes X make text rect use rectMode for placement X if a word (no spaces) is too long to fit, insert a 'space' +X move left/center/right aligning into the font class +X otherwise text with alignment has problems with returns -_ need to resolve rotated text in SCREEN_SPACE -_ SCREEN_SPACE is weird for text +text issues +_ need to resolve SCREEN_SPACE vs OBJECT_SPACE +_ how does rotated text work? +_ PFont.rotate(180) rotate(PI) _ does the font or PApplet control the size? (the font, ala java) -_ without setting the font, the values come out weird rotated text -_ get rotated text into the screen space stuff -_ move left/center/right aligning into the font class -_ otherwise text with alignment has problems with returns +_ without setting the font, SCREEN_SPACE comes out weird +_ move SCREEN_SPACE into ScreenFont() class? +_ probably not, casey thinks screen space text is prolly more useful +_ that way can clear up some of the general confusion in the code + +text wish list +_ look into fixing the texture mapping to not squash fonts +_ NEW_GRAPHICS totally smashes everything _ could PFont2 be done entirely with reflection? _ that way other font types can properly extend PFont -_ move SCREEN_SPACE into ScreenFont() class? -_ probably not, casey thinks screen space text is prolly more useful -_ that way can clear up some of the general confusion in the code -_ also handle things like rotation _ not having kerning really blows _ could this be pulled from the OpenType font stuff? _ it could be placed at the end of the file _ simple way to just use java text in p5 applets? _ the current text support is just so hokey -_ look into fixing the texture mapping to not squash fonts -_ NEW_GRAPHICS totally smashes everything + _ need to try jogl to make sure no further changes _ and the illustrator stuff _ 404 error because first searches applet directory on zipdecode _ image(String name) and textFont(String name) +_ do we change to font(arial, 12) ? _ write PApplet2, a full screen version of PApplet _ this might be used for presentation mode @@ -80,9 +90,6 @@ _ z-clipping _ light(x, y, z, c1, c2, c3, TYPE) _ also BLight with same constructor, and on() and off() fxn -_ image(myg, x, y) doesn't work but image(myg, x, y, w, h) does -_ (image kind prolly not set right and so image() gets pissy) -_ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1091798655 //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// diff --git a/processing/todo.txt b/processing/todo.txt index b090be820..a55a2cbb9 100644 --- a/processing/todo.txt +++ b/processing/todo.txt @@ -418,6 +418,8 @@ PDE / Features b _ could be a separate window that's always around if needed 1 _ external editor -> add a command to launch 1 _ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;action=display;num=1043734580;start=0 + _ refresh sketchbook menu upon returning to the app from elsewhere? + _ this would need to track whether coming just from an ext runtime PDE / Console