Skip to content

Instantly share code, notes, and snippets.

@motoishmz
Last active October 22, 2018 02:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save motoishmz/4c946d3417b8d6cfcb266fb7166af347 to your computer and use it in GitHub Desktop.
Save motoishmz/4c946d3417b8d6cfcb266fb7166af347 to your computer and use it in GitHub Desktop.
openframeworks example: convert std::string with an external file --> std::wstring
#include <codecvt>
#include "ofxTrueTypeFontUL2.h" // https://github.com/kentaroid/ofxTrueTypeFontUL2
std::wstring text;
ofxTrueTypeFontUL2 typeface;
void ofApp::setup() {
ofXml xml("multilingual_words.xml"); // have to be saved as UTF-8 with BOM
// do something with xml...
std::string text_from_xml = xml.getAttribute("my_chinese_word");
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> cv;
text = cv.from_bytes(text_from_xml);
// typeface.loadFont("my_chinese_font.otf", 20);
}
void draw() {
// typeface.drawString(text, ofGetMouseX(), ofGetMouseY());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment