bug fix for text() getting smashed together

This commit is contained in:
benfry
2005-03-02 22:10:00 +00:00
parent 0057c86d1f
commit 0d030573c5
3 changed files with 34 additions and 6 deletions

View File

@@ -631,7 +631,7 @@ public class PFont implements PConstants {
for (int index = start; index < stop; index++) {
textImpl(textBuffer[index], x, y, z, parent);
x += width(textBuffer[index]);
x += parent.textSize * width(textBuffer[index]);
}
}
@@ -688,7 +688,8 @@ public class PFont implements PConstants {
if ((textBuffer[index] == ' ') ||
(index == length-1)) {
// boundary of a word
float wordWidth = calcWidth(textBuffer, wordStart, index);
float wordWidth = parent.textSize *
calcWidth(textBuffer, wordStart, index);
if (runningX + wordWidth > boxX2) {
if (runningX == boxX1) {
// if this is the first word, and its width is
@@ -701,7 +702,8 @@ public class PFont implements PConstants {
// not a single char will fit on this line. screw 'em.
return;
}
wordWidth = calcWidth(textBuffer, wordStart, index);
wordWidth = parent.textSize *
calcWidth(textBuffer, wordStart, index);
} while (wordWidth > boxWidth);
textLine(lineStart, index, lineX, currentY, boxZ, parent);

View File

@@ -1436,7 +1436,7 @@ public class PGraphics extends PImage implements PConstants {
public void textSize(float size) {
if (textFont != null) {
textSize = size;
resetLeading();
textLeadingReset();
} else {
throw new RuntimeException("use textFont() before textSize()");
@@ -1444,8 +1444,9 @@ public class PGraphics extends PImage implements PConstants {
}
protected void resetLeading() {
textLeading = (textFont.ascent() + textFont.descent()) * 1.275f;
protected void textLeadingReset() {
textLeading = textSize *
((textFont.ascent() + textFont.descent()) * 1.275f);
}

View File

@@ -1,4 +1,29 @@
0078 core
X text lines were getting horizontally mashed together
X text lines also getting vertically smashed together
X make a note of the change to font.width()
_ get SCREEN_SPACE text working again
_ backwards rects may not be getting drawn in PGraphics2
_ updatePixels() not setting PApplet.pixels
_ also throwing NPEs
_ make loadPixels in PGraphics ignored, and put it in PApplet
_ closing window w/o first hitting stop() causes freak out
_ opengl gives an OutOfMemoryError
_ java2d just goes into a lock
_ could also be code that's in an infinite loop (i.e. text error)
_ which then causes a full lock
_ why is java2d so flickery?
_ is it because the lock was taken off (g) in PApplet?
_ stop() not working very well
_ doesn't seem to actually be stopping things
_ sphere() and box() should set normals and take textures
- applets on osx sometimes show up 20 pixels off the top