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

[C# , AS3 , ETC] 한글 유니 코딩 조합 원리


 





//참고 원문 : http://uuzazuk9.egloos.com/906488


한글 조합 공식 :
[{(초성)×588}+{(중성)×28}+(종성)]+44032

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace TEST_Keyboard2
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);
            string result = ResultKorean("ㅇ", "ㅢ", "ㅇ"); //읭
            Console.WriteLine(result);
        }

        private string row_chosung = "ㄱㄲㄴㄷㄸㄹㅁㅂㅃㅅㅆㅇㅈㅉㅊㅋㅌㅍㅎ";
        private string row_jungsung = "ㅏㅐㅑㅒㅓㅔㅕㅖㅗㅘㅙㅚㅛㅜㅝㅞㅟㅠㅡㅢㅣ";
        private string row_jongsung = " ㄱㄲㄳㄴㄵㄶㄷㄹㄺㄻㄼㄽㄾㄿㅀㅁㅂㅄㅅㅆㅇㅈㅊㅋㅌㅍㅎ";

        private string ResultKorean(string chosung, string jungsung, string jongsung)
        {
            int chosungIndex = row_chosung.IndexOf(chosung);
            int jungsungIndex = row_jungsung.IndexOf(jungsung);
            int jongsungIndex = row_jongsung.IndexOf(jongsung);


            //공식
            int result = ((chosungIndex * 588) + ((jungsungIndex * 28) + jongsungIndex)) + 44032;


            char temp = Convert.ToChar(result);
            return temp.ToString();
        }

    }
}



간단한 유니코드의 연속 이라 .. 다른 언어에도 쉽게 적용할수 있을것 같다.
Yamecoder 야매코더_
C# 2011.11.21 17:07
Powerd by Tistory, designed by criuce
rss