Skip to content

Commit

Permalink
Font fixes and nifty size definition.
Browse files Browse the repository at this point in the history
Added fixes for font where font:
- Lines where rendering too close to each other. Added a 142% increase
in font height to separate them more.
- RGB numbers for fonts were jumbled. Fixed with the correct values.
Added option to define nifty gui size.
  • Loading branch information
barefists committed Mar 17, 2015
1 parent 944787c commit 7701388
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,11 @@
*/
public class GraphicsWrapperProcessing implements GraphicsWrapper {

private PGraphicsJava2D canvas;
private final PGraphicsJava2D canvas;

/**
* Initialize the GraphicsWrapper.
* @param app PApplet instance Processing is running in.
*/
public GraphicsWrapperProcessing(PApplet app) {
this(app, app.width, app.height);
}

/**
* Initialize the GraphicsWrapper (verbose version)
* @param app PApplet instance Processing is running in.
* @param width Width of canvas to draw Nifty on.
* @param height Height of canvas to draw Nifty on.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,19 @@ public class RenderDeviceProcessing implements RenderDevice {
/**
* Instantiate RenderDeviceProcessing.
* @param app PApplet instance that Processing is currently running in.
* @param nifty Nifty instance that is in use.
*/
public RenderDeviceProcessing(PApplet app) {
GraphicsWrapperProcessing graphicsWrapper = new GraphicsWrapperProcessing(app);
this(app, app.width, app.height);
}

/**
* Instantiate RenderDeviceProcessing (verbose version)
* @param app PApplet instance that Processing is currently running in.
* @param width Desired width of Nifty instance.
* @param height Desired height of Nifty instance.
*/
public RenderDeviceProcessing(PApplet app, int width, int height) {
GraphicsWrapperProcessing graphicsWrapper = new GraphicsWrapperProcessing(app, width, height);
this.graphics = graphicsWrapper.getCanvas();
this.renderDevice = new RenderDeviceJava2dImpl(graphicsWrapper);
this.app = app;
Expand Down Expand Up @@ -117,8 +126,8 @@ public void renderFont(RenderFont font, String text, int x, int y,
if (font instanceof RenderFontProcessing){
graphics.textFont(((RenderFontProcessing) font).getFont());
graphics.textSize(((RenderFontProcessing) font).getSize() * sizeX);
graphics.fill(fontColor.getRed() * 255, fontColor.getBlue() * 255, fontColor.getGreen() * 255, fontColor.getAlpha() * 255);
graphics.text(text, x, y + font.getHeight());
graphics.fill(fontColor.getRed() * 255, fontColor.getGreen() * 255, fontColor.getBlue() * 255, fontColor.getAlpha() * 255);
graphics.text(text, x, y + graphics.textDescent() + graphics.textAscent());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public int getWidth(String text, float size) {
@Override
public int getHeight() {
canvas.textFont(font);
return (int)(canvas.textDescent() + canvas.textAscent());
return (int)((canvas.textDescent() + canvas.textAscent()) * 1.42);
}

@Override
Expand Down

0 comments on commit 7701388

Please sign in to comment.