Last active
October 22, 2018 02:08
-
-
Save motoishmz/4c946d3417b8d6cfcb266fb7166af347 to your computer and use it in GitHub Desktop.
openframeworks example: convert std::string with an external file --> std::wstring
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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