Introduction to Computational Media – Strings

I wqs working on a problem with Strings for this week’s assignment in ICM. For my sins, I was treated to the best error message I’ve seen since “Keyboard Failure: Press F1 to Continue. Screen capture of the error message follows:

Processing message
Error message confirming my lack of knowledge

Turned out what I thought was my incompetence/idiocy was actually a bug in processing.

The traditional way to use a specialized font in Processing is to include the font set within your Processing sketch’s data folder. My experiment was to work with generating text on screen using fonts which were local to the server.

In order to check what fonts are available on the serve, you are running the script below in your browser. At the bottom of your browser window there should be a section with a black background and a list of available fonts. This script also works on your local machine (if run locally).

<align=”left”>

You can close that “font information window” by clicking around. (On FIrefox there is an “X” in the window’s top right corner. Click that to get your browser’s real estate back.)

Running the script locally indicated that I had 347 fonts available. I used the script below to and it worked fine. On my browser I had:” sans-serif,serif,monospace,fantasy,cursive ” listed as fonts.

I posted and ran the script below with the expectation that I would not see characters using SYMBOL font; only that I would see something else. Instead of a text character, I saw the ASCII code for each letter. If you click anywhere on the red area and type, you will see numbers appear. That numbers appear and not characters is the issue.

If you did not close the window at the bottom of your browser you will see the intended characters appear as invoked by the println command.

Font used = SYMBOL:

On desktop machine works as expected:
desktop
Not working on server.

Font used = SERIF:

Code:

char letter;
String words = “font name”;void setup() {
size(640, 360);
// Create the font
textFont(createFont(“serif”, 18));
}

void draw() {
background(116,11,11);

// Draw the letter to the center of the screen
textSize(14);
text(“Mouse click on sketch. Type to add to characters to String”, 50, 50);
text(“Current key: ” + letter, 50, 70);
text(“String length is ” + words.length() +  ” characters”, 50, 90);

textSize(36);
text(words, 50, 120, 540, 300);
}

void keyPressed() {
// The variable “key” always contains the value
// of the most recent key pressed.
if ((key >= ‘A’ && key <= ‘z’) || key == ‘ ‘) {
letter = key;
words = words + key;
// Write the letter to the console
println(key);
}
}

Peter Terezakis
ITP, Tisch School of the Arts
New York City