I want to change the size of Georgian-language text that I have input from a .txt file in the data folder (.txt file encoded in UTF-8). I can display the Georgian script (this is Georgian language script, not the Georgia text font) in my Processing window. But when I change its size with textSize(), the program displays a series of boxes, one for each letter, but no actual text. This also happens if I input the text directly into the text() line command. It also happens if I specify a font (and size) with PFont. Any ideas? Here’s the code—any help appreciated.
OK—question #2: Now I can change the size of the font, but for the purposes of my program, I’d like to be able to randomize it. If I insert this,
textSize(random(10, 48));
the result reverts to the little boxes instead of letters. It does randomize the size of the boxes. Also, if I randomize the size in createFont, it does the same thing. I could work around this, but I’d rather not. Ideas appreciated!
Many thanks! Excellent idea about the for loop. I tried it, and it seems that textSize is interfering in some way. So here’s the for loop. Where textSize is 0 (so the command doesn’t do anything), you get actual text. Otherwise just boxes, even at the created size of 80.
String[] s = loadStrings("Georgian_01.txt");
size(1400, 1000);
textFont(createFont("Calibri", 80));
textAlign(CENTER);
fill(0);
for (int i = 0; i<81; i++) {
textSize(i);
fill(255, 0, 0);
text(i, width/8, 100+i*10); // NUMBER OF EACH LOOP
fill(0);
text(s[0], width/2, 100+i*10); // OUTPUT OF TEXT
}
However, if you create the font every time through the loop, then you get actual text every time.
String[] s = loadStrings("Georgian_01.txt");
size(1400, 1000);
textAlign(CENTER);
fill(0);
for (int i = 1; i<81; i++) {
textSize(i);
fill(255, 0, 0);
textFont(createFont("Calibri", i));
text(i, width/8, 100+i*10); // NUMBER OF EACH LOOP
fill(0);
text(s[0], width/2, 100+i*10); // OUTPUT OF TEXT
}
OK, tried Arial. Same result (little boxes instead of characters) if I create the font dynamically, using this:
textFont(createFont("Arial", 40));
If I use the font selection tool and put ArialMT-80 in my data folder, then I use this code:
PFont f;
f = loadFont("ArialMT-80.vlw");
textFont(f, 80);
Then when I run the program, I get no text at all (see below) and the editor window says, “No glyph found for the [strange symbol here] (\u10D8) character.” The number in parentheses varies. So, creating the font dynamically at least gives me little boxes.
I am jealous! I run the exact same code as you have (see below), using a string instead of reading from a file, and get boxes in place of the Georgian text, except in the 0 loop. Roman alphabet characters are OK.
//String[] s = loadStrings("Georgian_01.txt");
String s = "გამარჯობა მსოფლიოabc";
size(1400, 1000);
textFont(createFont("Calibri", 40));
textAlign(CENTER);
fill(0);
for (int i = 0; i<81; i+=5) {
textSize(i);
fill(255, 0, 0);
text(i, width/8, 100+i*10); // NUMBER OF EACH LOOP
fill(0);
text(s, width/2, 100+i*10); // OUTPUT OF TEXT
}
save("Georgian_testfile_03readtext.png");
Hi glv—Thanks. The last 2 posts are making me think I should switch to a Windows machine. (I’m running Processing 3.5.3 on a MacBook.) I tried your solution, but when I get to the “Sample Text” window, it’s different from yours. It will let me type into it from the keyboard, but–unbelievably–there’s no way to paste. The Edit function disappears from the IDE function bar when you open Create Font. I can’t type in the Georgian text, so I’m stuck. Ugh.