', { cookie_domain: 'auto', cookie_flags: 'max-age=0;domain=.tistory.com', cookie_expires: 7 * 24 * 60 * 60 // 7 days, in seconds }); 아두이노 U8glib 에서 한글폰트 만들어 넣기 테스트. :: MakerLee's Workspace
728x90

소닉님의 블로그(링크) 에서 U8G2 라이브러리에 한글 폰트를 넣어 테스트한 포스팅을 보았습니다. 

 

<출처 : https://blog.naver.com/todigital >

기존에 있던 폰트를 직접 변환해서 넣으셨다는 얘기에 

폰트를 직접 넣는 방법이 있었구나 하고 깨달았네요

 

일단 컴퓨터에서 쓰이는 폰트들은 벡터 기반 폰트들이라 소닉님도 비트맵 기반 폰트 몇개만 테스트를 해 보셨더군요. 

저는 이걸 보고 예전에 도두가이님을 통해 받은 프로젝트(링크) 가 생각나서 자료를 찾아봤습니다. 

 

일단 네이버 자료실에서 '이지뷰어' 라는 프로그램을 검색해서 다운로드받습니다. 

버전업이 많이 되었지만 비트맵 폰트만 필요하기 때문에 구버전이라도 상관 없습니다. 

 

 

 

 

다운받은 프로그램의 Font 폴더로 들어가면

 

 

 

 

 

 

비트맵 폰트들이 폴더 한가득합니다. 

han 확장자는 한글 폰트이고 eng 확장자는 영문 폰트입니다. 

 

이 폰트를 어떻게 U8Glib에 넣을 수 있나 검색을 해 봤습니다. 

Re: Custom font with u8glib

#2

Aug 22, 2015, 12:07 pm

@gfk:
Each font comes with three variants: full, reduced and numbers only. As MAS3 pointed out details should be listed on the wiki page. You could use "u8g_font_helvB24r" to use the reduced font (however, this will still include a-z and A-Z). helvB24 has 11K, helvB24r has around 5K,  helvB24n has only 800 Bytes (see the wiki page).

In order to create a custom font, which only includes the chars you really need, you have to modify the font source.
Download the font source (bdf file) from here: https://raw.githubusercontent.com/olikraus/u8glib/master/tools/font/bdf/helvB24.bdf

Remove all chars, which are not required for your project. Use a normal plain texteditor for this. Chars start with the keyword "STARTCHAR" and end with "ENDCHAR".

Use bdf2u8g_101.exe to convert the bdf file to a u8glib readable array.
See https://github.com/olikraus/u8glib/wiki/bdf2u8g for details.

Download bdf2u8g here: https://drive.google.com/folderview?id=0B5b6Dv0wCeCRLWJkYTh2TUlYVDg&usp=sharing

Oliver

U8Glib github에 변환 프로그램이 있다는군요.

drive.google.com/drive/folders/0B5b6Dv0wCeCRLWJkYTh2TUlYVDg

에서 bdf2u8g를 다운받아 실행해 보니 도스 프로그램이더군요. 

 

번거롭지만 윈도우키 > cmd 입력 > cd bdf2u8g가설치된폴더 해서 >bdf2u8g를 실행해봤습니다. 

github.com/olikraus/u8glib/wiki/bdf2u8g

에서 프로그램 사용법을 볼 수 있습니다. 

하지만 Optional arguments는 봐도 뭔소린지 모르겠고.... 

 

 

그래서 일단 기본폰트 001.han을 폰트명 test로 하고 test.h 로 변환시켰습니다. 

이 폰트를 어디에 넣어야 하는지 잘 모르겠어서 하루종일 골머리를 썩이다가 소닉님께 질문해서 답을 얻었습니다. 

 

 

 

 

아두이노 라이브러리 폴더에 test 폴더를 만들고 파일을 집어넣은 후

스케치에 #include "test.h"를 해주면 됩니다. 

 

 

 

이제 U8Glib 기본예제 helloworld를 불러와서 u8g.setFont에 test를 넣어주고

아래쪽 helloworld 문을 '안녕 세상'으로 바꿔봤습니다. 

 

 

 

 

 

결과는 이렇습니다. 

 

일단 글자가 꼬인건 그렇다치고 용량 면에서도 훌륭하네요.

 

기본 HelloWorld 컴파일시 9524바이트. 

 

 

 

test 폰트 사용시 7810바이트입니다. 

2개 이상의 폰트를 병행 사용할수도 있을듯 합니다. 

 

 

글자가 꼬인건 bdf2u8g 의 Optional arguments 에서 변환옵션을 뭔가 잘 주면 해결될 것 같은데

이 부분은 좀 공부를 해 봐야 할듯 합니다. 솔직히 지금은 전혀 감이 안잡히네요

 

728x90

+ Recent posts