한글을 사용하기 위해서는 Windows 에 있는 한글 폰트를 컨버팅 해야 한다.

(가능하면 무료로 풀린 제한없이 사용가능한 폰트를 사용하는 것을 추천한다.)

 

사이트 내에 폰트를 추출할수 있는 기능이 있다.

 

https://littlevgl.com/ttf-font-to-c-array

 

Online TTF to C Array Unicode Font Converter | LittlevGL

LittlevGL - Open-source Embedded GUI Library LittlevGL is a free and open-source graphics library providing everything you need to create embedded GUI with easy-to-use graphical elements, beautiful visual effects and low memory footprint. If you like Littl

littlevgl.com

폰트를 찾고 해당폰트를 임의의 디렉토리에 복사해 둔다.

window 자체가 font 디렉토리에 접근하는 것을 막는다.

TTF file 에 사용할 font를 지정한다.

Name에 함수에 사용할 명칭을 지정

완성형 Font 내부에 한글 위치 지정 44032 ! 55203

Height 는 폰트 최대 높이 즉 크기지정이다.

Bpp 는 1bit-per-pixel 이라면 1개의 bit가 1개의 pixel 이라는 뜻이다.

 

"Convert" 버튼을 누르면 파일 업로드 이후 컨버팅해서 파일을 내려 받을수 있다.

 

방금전 같은 설정으로 han1.c를 다운로드 받았다.

 

해당 소스를  \lv_examples\lv_apps\demo 아래에 복사를 하고 code block 에서 컴파일 할수 있도록

프로젝트에 첨가한다.

 

han1.c 소스를 보면 아래와 같이 선언 되어 있는데

lv_font_t han1 =
{
    .unicode_first = 44032, /*First Unicode letter in this font*/
    .unicode_last = 55203, /*Last Unicode letter in this font*/
    .h_px = 16, /*Font height in pixels*/
    .glyph_bitmap = han1_glyph_bitmap, /*Bitmap of glyphs*/
    .glyph_dsc = han1_glyph_dsc, /*Description of glyphs*/
    .glyph_cnt = 11172, /*Number of glyphs in the font*/
    .unicode_list = NULL, /*Every character in the font from 'unicode_first' to 'unicode_last'*/
    .get_bitmap = lv_font_get_bitmap_continuous, /*Function pointer to get glyph's bitmap*/
    .get_width = lv_font_get_width_continuous, /*Function pointer to get glyph's width*/
    .bpp = 1, /*Bit per pixel*/
    .monospace = 0, /*Fix width (0: if not used)*/
    .next_page = NULL, /*Pointer to a font extension*/
};

 

이중 " lv_font_t han1 " 선언내용을 보고 아래와 같이 폰트를 사용가능하도록 선언 한다.

 

/**********************
* GLOBAL FUNCTIONS
**********************/
LV_FONT_DECLARE(han1); /*hangle font*/

/**
* Create a demo application
*/
void demo_create(void)
{
         lv_font_add(&han1, &lv_font_dejavu_20);

아래와 같이 사용하면 된다.

lv_label_set_text (label1, "한글" ); 

 

주의할 점은 꼭 UTF-8 포멧으로 코드를 저장해야 한다.

 

codeblock 의 경우 Setting -> Editer -> General settings -> Encoding settings 에서 설정 가능하다.

 

 

'공부 > littlevgl' 카테고리의 다른 글

littlevgl 저작 도구  (0) 2019.09.24
LittlevGL STM32F103RC 에서 돌려 보기  (0) 2019.05.21
LittlevGL 여러 예제 돌려 보기  (0) 2019.05.21
Littlevgl simulator 돌려보기  (0) 2019.05.21
Littlevgl 소개  (0) 2019.05.21

+ Recent posts