2018-02-21 19:36:38 +08:00
|
|
|
/**
|
|
|
|
* File: main.c
|
|
|
|
* Author: Li XianJing <xianjimli@hotmail.com>
|
|
|
|
* Brief: bitmap font generator
|
|
|
|
*
|
2018-05-08 10:22:32 +08:00
|
|
|
* Copyright (c) 2018 - 2018 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
2018-02-21 19:36:38 +08:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* License file for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* History:
|
|
|
|
* ================================================================
|
|
|
|
* 2018-01-21 Li XianJing <xianjimli@hotmail.com> created
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "base/mem.h"
|
|
|
|
#include "common/utils.h"
|
|
|
|
#include "font/font_bitmap.h"
|
|
|
|
#include "font/font_stb.h"
|
|
|
|
#include "font_gen.h"
|
|
|
|
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
uint32_t size = 0;
|
|
|
|
font_t* font = NULL;
|
|
|
|
char* str_buff = NULL;
|
|
|
|
uint8_t* ttf_buff = NULL;
|
|
|
|
uint32_t font_size = 20;
|
|
|
|
const char* ttf_filename = NULL;
|
|
|
|
const char* str_filename = NULL;
|
|
|
|
const char* output_filename = NULL;
|
|
|
|
|
2018-05-04 11:45:09 +08:00
|
|
|
TKMEM_INIT(4 * 1024 * 1024);
|
2018-02-22 11:37:13 +08:00
|
|
|
|
2018-02-21 19:36:38 +08:00
|
|
|
if (argc != 5) {
|
2018-04-01 11:34:05 +08:00
|
|
|
printf("Usage: %s ttf_filename str_filename output_filename font_size\n", argv[0]);
|
2018-02-21 19:36:38 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ttf_filename = argv[1];
|
|
|
|
str_filename = argv[2];
|
|
|
|
output_filename = argv[3];
|
|
|
|
font_size = atoi(argv[4]);
|
|
|
|
|
|
|
|
ttf_buff = (uint8_t*)read_file(ttf_filename, &size);
|
|
|
|
return_value_if_fail(ttf_buff != NULL, 0);
|
2018-04-15 17:58:24 +08:00
|
|
|
|
2018-04-13 10:25:58 +08:00
|
|
|
font = font_stb_create("default", ttf_buff, size);
|
2018-02-21 19:36:38 +08:00
|
|
|
|
|
|
|
str_buff = read_file(str_filename, &size);
|
|
|
|
return_value_if_fail(str_buff != NULL, 0);
|
|
|
|
|
|
|
|
if (font != NULL) {
|
2018-03-18 11:29:31 +08:00
|
|
|
font_gen(font, (uint16_t)font_size, str_buff, output_filename);
|
2018-02-21 19:36:38 +08:00
|
|
|
}
|
|
|
|
|
2018-04-29 16:51:54 +08:00
|
|
|
TKMEM_FREE(ttf_buff);
|
|
|
|
TKMEM_FREE(str_buff);
|
2018-02-21 19:36:38 +08:00
|
|
|
|
|
|
|
printf("done\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|