almost acceptable letter spacing
This commit is contained in:
parent
7c7485e2f0
commit
170c8cc34e
2 changed files with 6 additions and 60 deletions
|
@ -44,15 +44,10 @@ void MsdfLayer::draw(glm::vec3 position) const {
|
|||
ofSetColor(ofColor::pink);
|
||||
ofDrawLine(glm::vec2(0, 0), glm::vec2(ofGetWidth(), 0));
|
||||
ofPopStyle();
|
||||
//atlas->getAtlasImage().draw(0, 0);
|
||||
//cout << "drawing letters (" << ofToString(propsBuffer.size()) << ")" << endl;
|
||||
char previous_c;
|
||||
bool firstLetter = true;
|
||||
for(const char c : propsBuffer[0].text){
|
||||
ofxMsdfgen::GlyphGeometry gg = atlas->getGlyphGeometry(c);
|
||||
int x, y, w, h;
|
||||
gg.getBoxRect(x, y, w, h);
|
||||
//y = atlas_h - (y + h);
|
||||
if(y < 0){
|
||||
// FIXME: make sure this does not happen
|
||||
ofLogError("MsdfLayer::draw") << "y smaller 0, this is not good" << endl;
|
||||
|
@ -66,66 +61,16 @@ void MsdfLayer::draw(glm::vec3 position) const {
|
|||
ofPushMatrix();
|
||||
float magic = ofMap(sin(ofGetElapsedTimeMicros() * 0.000001), -1, 1, 1, 200);
|
||||
magic = atlas->settings.scale;
|
||||
//if(ofGetFrameNum() % 30 == 0){
|
||||
//cout << "drawing letter " << c << endl
|
||||
//<< "\tpl: " << ofToString(pl)
|
||||
//<< "\tpb: " << ofToString(pb)
|
||||
//<< "\tpr: " << ofToString(pr)
|
||||
//<< "\tpt: " << ofToString(pt)
|
||||
//<< endl;
|
||||
//}
|
||||
|
||||
ofPushMatrix();
|
||||
for(int i = 0; i < 2; i++){
|
||||
if(i == 1){
|
||||
ofRotateDeg(90);
|
||||
ofTranslate(200, -150, 0);
|
||||
}
|
||||
ofNoFill();
|
||||
ofSetColor(ofColor::white);
|
||||
ofDrawLine(glm::vec2(0, 90), glm::vec2(0, 140));
|
||||
ofSetColor(ofColor::lightGray);
|
||||
for(int i = 1; i < 3; i++){
|
||||
ofDrawLine(glm::vec2(i * 20, 90), glm::vec2(i * 20, 140));
|
||||
}
|
||||
ofFill();
|
||||
if(i == 0){
|
||||
ofSetColor(ofColor::red);
|
||||
ofDrawRectangle(0, 100, pl * 50, 10);
|
||||
ofSetColor(ofColor::lightBlue);
|
||||
ofDrawRectangle(0, 120, pr * 50, 10);
|
||||
}else{
|
||||
ofSetColor(ofColor::green);
|
||||
ofDrawRectangle(0, 110, pb * 50, 10);
|
||||
ofSetColor(ofColor::yellow);
|
||||
ofDrawRectangle(0, 130, pt * 50, 10);
|
||||
}
|
||||
}
|
||||
ofPopMatrix();
|
||||
shader->begin();
|
||||
ofSetColor(ofFloatColor(1, 1, 1, 1));
|
||||
ofTranslate(-1 * pl * magic, -1 * pt * magic, 0);
|
||||
//msdf_atlas::unicode_t a = previous_c;
|
||||
//msdf_atlas::unicode_t b = c;
|
||||
//if(!firstLetter){
|
||||
//double advance;
|
||||
//cout << "this is being printed" << endl;
|
||||
//atlas->getFontGeometry();
|
||||
//cout << "this is maybeh being printed" << endl;
|
||||
//bool gotAdvance = atlas->getFontGeometry().getAdvance(advance, a, b);
|
||||
//cout << "this is being not printed" << endl;
|
||||
//if(gotAdvance){
|
||||
////ofTranslate(advance * magic, 0, 0);
|
||||
//}
|
||||
//}else{
|
||||
//firstLetter = false;
|
||||
//}
|
||||
ofTranslate(pl * magic, 0, 0);
|
||||
ofTranslate(0, -1 * pt * magic, 0);
|
||||
atlasImage.drawSubsection(0, 0, w, h, x, y, w, h);
|
||||
shader->end();
|
||||
ofPopMatrix();
|
||||
ofPopStyle();
|
||||
ofTranslate(pr * magic, 0, 0);
|
||||
previous_c = c;
|
||||
ofTranslate(gg.getAdvance() * magic, 0, 0);
|
||||
}
|
||||
ofPopMatrix();
|
||||
//atlasImage.draw(x, y);
|
||||
|
|
|
@ -7,11 +7,12 @@ namespace ofxVariableLab {
|
|||
void LayerComposition::setup(){
|
||||
ofxMsdfgen::AtlasSettings settings;
|
||||
//settings.characters = "ABCDEFGHIJKL";
|
||||
settings.scale = 256;
|
||||
settings.scale = 64;
|
||||
//string fontName = "RobotoFlex.ttf";
|
||||
//string fontPath = "data/fonts/" + fontName;
|
||||
//string fontPath = "data/celines-fonts/testing2VF.ttf";
|
||||
string fontPath = "data/celines-fonts/Version-2-var.ttf";
|
||||
//string fontPath = "data/celines-fonts/Alfarn2.otf";
|
||||
//string fontPath = "data/celines-fonts/Cottagecore.ttf";
|
||||
atlas = make_shared <ofxMsdfgen::Atlas>();
|
||||
atlas->setup(fontPath, settings);
|
||||
|
@ -22,7 +23,7 @@ void LayerComposition::setup(){
|
|||
#ifdef TARGET_EMSCRIPTEN
|
||||
msdfShader->load("ofxMsdfgen/shaders/unitRange/ES3/shader");
|
||||
#else
|
||||
shader->load("ofxMsdfgen/shaders/unitRange/GL3/shader");
|
||||
msdfShader->load("ofxMsdfgen/shaders/unitRange/GL3/shader");
|
||||
#endif
|
||||
|
||||
auto layer = make_unique <ofxVariableLab::MsdfLayer>();
|
||||
|
|
Loading…
Reference in a new issue