How to show Japanese words in buttons


#1

I want to show Japanese words in buttons.
For example

class ofApp : public ofBaseApp{
    ofxButton m_button;
    ofxPanel m_panel;
}
void ofApp::setup(){
    m_panel.setup();
    m_panel.add(m_button.setup("Test"));
}

This code can show a button in a panel.

But if I change “Test” to “テスト”
Nothing is shown.
so I added load font.

void ofApp::setup(){
    m_panel.setup();
    m_panel.loadFont("ipagp.ttf",100);
    m_panel.add(m_button.setup("テスト"));
}

But nothing is shown.
I checked ipagp.ttf exists in bin/data/ folder.

Can you tell me how to show Japanese?


#2

Hi! Have you seen this blog post about UTF-8 texts?


#3

Thank you.
I can show japanese

But Your solution have some promblems
Please watch this


I used your solution lile this

void ofApp::setup(){
  ofTrueTypeFontSettings settings("Noto Sans CJK JP", 12);
  settings.antialiased = true;
  settings.dpi = 72;
  settings.direction = OF_TTF_LEFT_TO_RIGHT;
  settings.addRanges(ofAlphabet::Japanese);
  m_panel.setup();
  m_panel.loadFont(setting)
  m_panel.add(m_button.setup("開始"));
etc....
}

Do you noticed?
Numeric + Latin word is lost.
Most abnormal error is slider value 's lost.
Do you know how to solve this?


#4

Solved

  ofTrueTypeFontSettings settings("Noto Sans CJK JP", 12);
  settings.antialiased = true;
  settings.dpi = 72;
  settings.direction = OF_TTF_LEFT_TO_RIGHT;
  settings.addRanges(ofAlphabet::Japanese);
 settings.addRanges(ofAlphabet::Latin);
  m_panel.setup();
  m_panel.loadFont(setting)
  m_panel.add(m_button.setup("開始"));
etc....
}