Hello folks!
When Windows 10 display scaling is set to 125%, the sketch window rendered with JAVA2D is scaled up, making it appear larger and pixelated.
In contrast, the P2D renderer does not scale the window but may have limited Unicode character support.
JAVA2D renderer (default):
Scales up 125% on my system and has a larger and pixelated output. ![]()
Displays ALL Unicode characters in example.
P2D renderer:
Does NOT scale up on my system. ![]()
Does NOT display all Unicode characters in example.
I do not want my JAVA2D sketch windows scaled up 125% and use P2D most of the time.
Still looking for a solution for this behaviour.
The solution for generating some Unicode fonts (which require JAVA2D) was to generate the text in a JAVA2D PGraphic and overlay the transparent image on the P2D sketch window.
Code:
// Display Unicode characters generated in a PGraphics
// Author: glv
// Date: 2025-10-21
// Version: 1.0.0
// JAVA2D renderer (default):
// Scales up 125% on my system and has a blurry output
// Displays all Unicode characters in example
// P2D renderer:
// Does NOT scale up on my system
// Does NOT displays all Unicode characters in example
// The solution was to generate the text in a JAVA2D PGraphics
// and overlay the image on the P2D sketch window.
// :)
PFont f;
String s = "";
// List of candidate system fonts covering Unicode / symbols
String[] candidateFonts =
{
"SansSerif", //Default
//"AppleColorEmoji", // macOS, color emoji
"Segoe UI Symbol", // Windows
"Segoe UI Emoji", // Windows
//"NotoColorEmoji", // Linux / if installed
//"Apple Symbols", // macOS alternative
//"DejaVu Sans", // Linux alternative
};
// Unicode Media control symbols from:
// https://discourse.processing.org/t/java-unicode-chars/34284/5
int[] symbols =
{
// 11x 0x2300
0x23F5, 0x23F8, 0x23EF, 0x23F4, 0x23F9,
0x23EA, 0x23E9, 0x23EE, 0x23ED, 0x23FA,
0x23CF,
// 5x 0x1F000
0x1F500, 0x1F501, 0x1F502, 0x1F503, 0x1F504,
// 1x 0x2139
0x2139
// 0x5125A is not valid UNICODE and was removed
};
int i = 1;
PGraphics pg;
PImage img;
void setup()
{
//size(800, 400, JAVA2D); // Windows scales this by 125%
size(800, 400, P2D); // Preferred
String urlString = "http://learningprocessing.com/code/assets/sunflower.jpg";
img = loadImage(urlString);
f = createFont(candidateFonts[i], 32);
textFont(f); // switch to the new font
// reset and rebuild string
s = ""; // 0x5125A was removed
for (int cp : symbols)
{
s += new String(Character.toChars(cp)) + " ";
}
pg = createGraphics(width, height/2, JAVA2D);
// Orange background
pg.beginDraw();
//f = createFont(candidateFonts[i], 32);
pg.textFont(f); // switch to the new font
pg.clear(); // default is clear and transparent
//pg.background(200, 128, 0);
pg.fill(255);
pg.text(candidateFonts[i], 50, pg.height/3);
pg.text(s, 50, 2*pg.height/3);
pg.endDraw();
// Sunflower background
image (img, 0, 0, width, height);
// Unicode text with transparent bacgkround
image(pg, 0, 0);
fill(255);
text(candidateFonts[i], 50, height/2 + height/6);
text(s, 50, height/2 + 2*height/6);
noLoop();
}
void draw()
{
}
Output:
Top is the text from the JAVA2D PGraphic and all characters shown.
Bottom is the text displayed in the P2D sketch and not all characters show.
:)
