Skip to content

Commit d7f3f4f

Browse files
committed
lots of work on fonts, internal vars for lighting, matrix work, etc
1 parent cb666b4 commit d7f3f4f

File tree

10 files changed

+363
-259
lines changed

10 files changed

+363
-259
lines changed

core/api.txt

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ no longer any abstract methods in PGraphics itself
1717
removed support for specular alpha (and its 'SPA' constant)
1818
clear() -> backgroundImpl()
1919
CENTER -> DIAMETER for ellipseMode and friends
20+
textFontNative and textFontNativeMetrics have been removed
21+
they require a font rendering context on which to draw
22+
and were a weird sort of hack
23+
see how the classes implement them now
24+
hint(ENABLE_NATIVE_FONTS) goes away
25+
need to mention in createFont() reference
26+
also maybe cover in the loadFont() reference? (maybe problem...)
2027

2128
//
2229

@@ -161,9 +168,11 @@ style(PStyle s)
161168
public void textFont(PFont which, float size)
162169
public void textLeading(float leading)
163170
public void textMode(int mode)
171+
protected boolean textModeCheck(int mode)
164172
public void textSize(float size)
165173
public float textWidth(char c)
166174
public float textWidth(String str)
175+
protected float textWidthImpl(char buffer[], int start, int stop)
167176

168177
public void text(char c)
169178
public void text(char c, float x, float y)
@@ -178,6 +187,19 @@ style(PStyle s)
178187
public void text(float num, float x, float y)
179188
public void text(float num, float x, float y, float z)
180189

190+
protected void textLineAlignImpl(char buffer[], int start, int stop,
191+
float x, float y)
192+
protected void textLineImpl(char buffer[], int start, int stop,
193+
float x, float y)
194+
protected void textCharImpl(char ch, float x, float y)
195+
protected void textCharModelImpl(PImage glyph,
196+
float x1, float y1, //float z1,
197+
float x2, float y2, //float z2,
198+
int u2, int v2)
199+
protected void textCharScreenImpl(PImage glyph,
200+
int xx, int yy,
201+
int w0, int h0)
202+
181203
public void translate(float tx, float ty)
182204
public void translate(float tx, float ty, float tz)
183205
public void rotate(float angle)
@@ -192,7 +214,8 @@ style(PStyle s)
192214
public void resetMatrix()
193215

194216
public PMatrix getMatrix()
195-
public getMatrix(PMatrix target)
217+
public getMatrix(PMatrix2D target)
218+
public getMatrix(PMatrix3D target)
196219
public void setMatrix(PMatrix source)
197220

198221
public void applyMatrix(PMatrix source)

core/src/processing/core/PConstants.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ public interface PConstants {
339339
static final int ENABLE_OPENGL_4X_SMOOTH = 2;
340340

341341
static final int ENABLE_NATIVE_FONTS = 3;
342-
static final int DISABLE_NATIVE_FONTS = -3;
343342

344343
static final int DISABLE_DEPTH_TEST = 4;
345344
static final int ENABLE_DEPTH_TEST = -4;

core/src/processing/core/PFont.java

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public class PFont implements PConstants {
6565
* in situations where that's faster.
6666
*/
6767
protected Font font;
68+
protected boolean fontSearched;
6869

6970
/**
7071
* Name of the font as seen by Java when it was created.
@@ -114,7 +115,7 @@ public class PFont implements PConstants {
114115
//protected char textBuffer[] = new char[8 * 1024];
115116
//protected char widthBuffer[] = new char[8 * 1024];
116117

117-
static public Font[] fonts;
118+
static protected Font[] fonts;
118119

119120

120121
public PFont() { } // for subclasses
@@ -236,31 +237,46 @@ public PFont(InputStream input) throws IOException {
236237
}
237238

238239

240+
/**
241+
* Set the native complement of this font.
242+
*/
243+
public void setFont(Font font) {
244+
this.font = font;
245+
}
246+
247+
239248
/**
240249
* Return the native java.awt.Font associated with this PFont (if any).
241250
*/
242251
public Font getFont() {
252+
// if (font == null && !fontSearched) {
253+
// font = findFont();
254+
// }
243255
return font;
244256
}
245-
246-
257+
258+
247259
/**
248-
* Try to find the native version of this font.
260+
* Attempt to find the native version of this font.
261+
* (Public so that it can be used by OpenGL or other renderers.)
249262
*/
250-
protected Font findFont() {
251-
// this font may or may not be installed
252-
font = new Font(name, Font.PLAIN, size);
253-
// if the ps name matches, then we're in fine shape
254-
if (!font.getPSName().equals(psname)) {
255-
// on osx java 1.4 (not 1.3.. ugh), you can specify the ps name
256-
// of the font, so try that in case this .vlw font was created on pc
257-
// and the name is different, but the ps name is found on the
258-
// java 1.4 mac that's currently running this sketch.
259-
font = new Font(psname, Font.PLAIN, size);
260-
}
261-
// check again, and if still bad, screw em
262-
if (!font.getPSName().equals(psname)) {
263-
font = null;
263+
public Font findFont() {
264+
if (!fontSearched) {
265+
// this font may or may not be installed
266+
font = new Font(name, Font.PLAIN, size);
267+
// if the ps name matches, then we're in fine shape
268+
if (!font.getPSName().equals(psname)) {
269+
// on osx java 1.4 (not 1.3.. ugh), you can specify the ps name
270+
// of the font, so try that in case this .vlw font was created on pc
271+
// and the name is different, but the ps name is found on the
272+
// java 1.4 mac that's currently running this sketch.
273+
font = new Font(psname, Font.PLAIN, size);
274+
}
275+
// check again, and if still bad, screw em
276+
if (!font.getPSName().equals(psname)) {
277+
font = null;
278+
}
279+
fontSearched = true;
264280
}
265281
return font;
266282
}

0 commit comments

Comments
 (0)