-
-
Save kylemcdonald/527f27e5fe780574cbda to your computer and use it in GitHub Desktop.
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 "ofMain.h" | |
#include "ft2build.h" | |
#include "freetype2/freetype/freetype.h" | |
#include "freetype2/freetype/ftglyph.h" | |
#include "freetype2/freetype/ftoutln.h" | |
#include "freetype2/freetype/fttrigon.h" | |
int n = 18; | |
int minSize = 5; | |
class testApp : public ofBaseApp { | |
public: | |
vector<ofTrueTypeFont> fonts; | |
vector<string> styles; | |
void setup(){ | |
styles.push_back(OF_TTF_SANS); | |
//styles.push_back(OF_TTF_SERIF); | |
//styles.push_back(OF_TTF_MONO); | |
for(int i = 0; i < n; i++) { | |
for(int j = 0; j < styles.size(); j++) { | |
ofTrueTypeFont font; | |
float curSize = ofMap(i, 0, n, minSize, minSize + n); | |
font.loadFont(styles[j], curSize); | |
fonts.push_back( font); | |
} | |
} | |
ofBackground(50); | |
} | |
void draw(){ | |
ofTranslate(10, 10); | |
int k = 0; | |
for(int i = 0; i < n; i++) { | |
for(int j = 0; j < styles.size(); j++) { | |
float curSize = ofMap(i, 0, n, minSize, minSize + n); | |
float x = ofMap(j, 0, styles.size() + 1, 0, ofGetWidth()); | |
float y = ofMap(i, -1, n, 0, ofGetHeight()); | |
fonts[k++].drawString("I should be " + styles[j] + " " + ofToString(curSize) + "px", x, y); | |
} | |
} | |
} | |
}; | |
int main( ){ | |
ofSetupOpenGL(400, 600, OF_WINDOW); | |
ofRunApp(new testApp()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment