ofxTrueTypeFontUC 를 이용한 한글 출력 (0.9.0)


1. addon download


ofxTrueTypeFontUC https://github.com/hironishihara/ofxTrueTypeFontUC



2. 0.9.0 에서 적용하기

1) ofxTrueTypeFontUC.cpp 의 include 수정 (13줄) " /freetype/ " 삭제


#include "freetype2/freetype/freetype.h"

#include "freetype2/freetype/ftglyph.h"

#include "freetype2/freetype/ftoutln.h"

#include "freetype2/freetype/fttrigon.h"


을 


#include "freetype2/freetype.h"

#include "freetype2/ftglyph.h"

#include "freetype2/ftoutln.h"

#include "freetype2/fttrigon.h"


로 바꿈.




3. 적용 및 확인 


ofApp.h

#pragma once

#include "ofMain.h"
#include "ofxTrueTypeFontUC.h"
#include "ofxGui.h"

class ofApp : public ofBaseApp{

public:
    ofxTrueTypeFontUC myFont;
    ofxPanel gui;
    ofxFloatSlider fontSpaceSlider;
    

    public:
        void setup();
        void update();
        void draw();

        /*
        void keyPressed(int key);
        void keyReleased(int key);
        void mouseMoved(int x, int y );
        void mouseDragged(int x, int y, int button);
        void mousePressed(int x, int y, int button);
        void mouseReleased(int x, int y, int button);
        void mouseEntered(int x, int y);
        void mouseExited(int x, int y);
        void windowResized(int w, int h);
        void dragEvent(ofDragInfo dragInfo);
        void gotMessage(ofMessage msg);
        */
        
};



ofApp.cpp

#include "ofApp.h"


//--------------------------------------------------------------
void ofApp::setup(){
    
    myFont.loadFont("HMFMPYUN.TTF", 64, true, true);

    gui.setup();
    gui.add(fontSpaceSlider.setup("font latter spaceing", myFont.getLetterSpacing() , 0.0f , 2.0f ));
    fontSpaceSlider.setSize(300, 30);
}

//--------------------------------------------------------------
void ofApp::update(){
    //자간 조절
    myFont.setLetterSpacing(fontSpaceSlider);
}

//--------------------------------------------------------------
void ofApp::draw(){
    ofSetColor(ofColor::red);

    myFont.drawString("안녕 !", 100, 150);

    ofSetColor(ofColor::green);
    myFont.drawStringAsShapes("하세요?", 100, 250);

    ofSetColor(ofColor::blue);
    myFont.drawString("supersc", 100, 350);

    gui.draw();
}







Yamecoder 야매코더_
C++(oF) 2016.01.08 17:42
Powerd by Tistory, designed by criuce
rss