Need help because processing can't read slovak

int currentSlide;
String[] slide;

String tl;
String tr;
String bl;
String br;

int time;
int wait=5000;

void setup(){
  size(800,1000);
  time=millis();
  currentSlide=0;
  slide=new String[500];
  slide=loadStrings("data for rosetta stone.txt"));
  tl=slide[0];
  tr=slide[2];
  bl=slide[1];
  br=slide[3];
}


void draw(){
  textSize(35);
  rectMode(CENTER);
  if(millis()-time>=wait){
    time=millis();
    print("tick");
    tl=slide[currentSlide+4];
    tr=slide[currentSlide+6];
    bl=slide[currentSlide+3];
    br=slide[currentSlide+5];
  }
  background(255/2+50);
  fill(0);
  text(tl,50,50);
  text(tr,width/2+100,50);
  text(bl,50,height/2+50);
  text(br,width/2+50,height/2+50);
}

data in the text file

Ahoj

Hello

Zbohom

Goodbye

Ako sa máš

How are you

Ako sa voláš

What is your name

Answers

  • edited July 2017

    http://Studio.SketchPad.cc/sp/pad/view/ro.9hlrt8LyDd9uA/latest

    /** 
     * Unicode Letters Test (v1.0)
     * GoToLoop (2017/Jul/12)
     *
     * https://Forum.Processing.org/two/discussion/23416/
     * need-help-because-processing-can-t-read-slovak#Item_1
     *
     * http://Studio.SketchPad.cc/sp/pad/view/ro.9hlrt8LyDd9uA/latest
     * http://p5ide.HerokuApp.com/editor#?sketch=57fa34e9980f18030076c28f
     */
    
    static final boolean JAVA = 1/2 != 1/2.;
    static final int FONT_SIZE = 24;
    static final String FONT_JAVA = "Roman";
    
    void setup() {
      size(600, 200);
      smooth(3);
      noLoop();
    
      colorMode(RGB);
      fill(#FFFF00);
    
      textMode(MODEL);
      textAlign(CENTER, CENTER);
    
      if (JAVA)  textFont(createFont(FONT_JAVA, FONT_SIZE, true));
      else textSize(FONT_SIZE);
    }
    
    void draw() {
      background(#0000FF);
    
      text("διχθαδίας κῆρας φερέμεν θανάτοιο τέλος δέ.\n" +
        "Бу́ря мгло́ю не́бо кро́ет, Ви́хри сне́жные крутя́;\n" + 
        "富士の風や扇にのせて江戸土産\n" + "Ako sa voláš", width>>1, height>>1);
    }
    
  • It looks like your problem is:

    Slovak contains Unicode characters that are not in the default processing font.

    In order to display those characters correctly, use createFont and textFont (or just textFont) as per @GoToLoop's example.

  • edited August 2017

    Indeed Processing's default font is enough to display accented characters. :-bd
    Only for the ancient Chinese text under Java Mode I had to pick another font, such as ("Roman"). :-\"

Sign In or Register to comment.