fontium
1.0.0
프로젝트에는 두 가지 구성 요소가 포함되어 있습니다
fontium 은 C ++ 라이브러리로 사용자 정의 레이아웃 알고리즘으로 비트 맵 글꼴을 생성합니다.fontium-cli 는 fontium 사용하여fontiumlib 및 CLI 설치 $ cd path/to/fontium
$ mkdir cmake-build-release
$ cd cmake-build-release
$ cmake -DCMAKE_BUILD_TYPE=Release ..
$ cmake --build . --target install cli 대상은 <install-folder>/bin/fontium 에 설치되며, 글로벌이면
쉘/터미널에서 바로 사용하십시오
$ fontium -hfontiumlib 소비다음 옵션을 사용할 수 있습니다.
CMakeLists.txt 추가 내부 add_subdirectory (/ path /to/fontium)
target_link_libraries (your_app fontium)fontium (위 참조)을 설치 한 경우 대신 find_package (fontium CONFIG REQUIRED)
target_link_libraries (your_app fontium::fontium) TrueType , CFF , WOFF , OpenType , SFNT , PCF , BDF , FNT , PFR
BDF 의 경우 파일에 끝에 새 줄이 있는지 확인하십시오. box , line , box_optimal , grid , gridline
fontium-cli 의 지원되는 수출 형식 이것은 fontium-cli 에만 적용됩니다
생성 된 이미지는 png 형식이며 다음 데이터 형식을 선택할 수 있습니다.
lib를 다음과 같이 사용할 수 있습니다
# include < fontium/Fontium.h >
using namespace fontium ;
// input data
using bytearray = std::vector< unsigned char >;
FontConfig fontConfig = FontConfig::getDefault();
LayoutConfig layoutConfig = LayoutConfig::getDefault();
// here you can load font data into the bytearray from disk or memory
bytearray font{};
// change some config
fontConfig.size= 16 ;
fontConfig.antialiasing= Antialiasing::Normal;
fontConfig.characters= " abcd,ABCD " ;
layoutConfig.layout_type=LayoutType::box;
// create the bitmap font, which contains a single channel frame buffer
// and layout data and font data of each glyph
bitmap_font bm_font = Fontium::create(
" bitmap font name " ,
font,
fontConfig,
layoutConfig);
bitmap_font 결과를 다른 형식으로 내보내려면 다음과 같은 형식을 따르십시오
# include < fontium/Fontium.h >
# include < fontium/ExportFactory.h >
using namespace fontium ;
using str = std::string;
bitmap_font bm_font= ...; // created in previous step
// export as BMF ( Angel Code's format xml)
str output_export_type = " bmf " ;
auto * exporter = ExportFactory::create(output_export_type);
str result = exporter-> apply (bm_font);
str data_file_name= " font. " + exporter-> fileExtension ();
// write data file
std::ofstream out (data_file_name);
out << result;
out.close();
std::cout << std::endl << " created data file :: "
<< data_file_name << std::endl;
// free memory
delete exporter;
cmake 또는 설치로 fontium-cli 대상을 구축하십시오 (위의 지침을 확인하십시오)
$ cd fontium
$ mkdir cmake_build
$ cd cmake_build
$ cmake .. -DCMAKE_BUILD_TYPE=Release
$ cmake --build . --target fontium-cli
$ cd ../bin
$ ./fontium -h usage:
fontium <font path> [options]
description:
fontium creates bitmap fonts with custom export formats for
TrueType, CFF, WOFF, OpenType, SFNT, PCF, FNT, BDF, PFR fonts
options include:
* FONT options
-font.size size of font in points, default 14
-font.dpi dots per inch, usually { 72, 96, 100, 110, 120, 128 }, default 72
-font.characters (string) the characters, by default will use
" !"#$%&'()*+,-./0123456789:;<=>?@"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`"
"abcdefghijklmnopqrstuvwxyz{|}~"
-font.antialiasing { None, Normal, Light, LCDH, LCDV }, default Normal
-font.hinting { Disable, Default, ForceFreetypeAuto, DisableFreetypeAuto }, default to Default
-font.scale_width percentages, scale horizontally every glyph, default is 100
-font.scale_height percentages, scale vertically every glyph, default is 100
-font.char_spacing integer, add spacing to each glyph advance in export, default 0
-font.line_spacing integer, add height to export's gylph metrics baseline, default 0
-font.bold [0, 10] - boldness, , default 0
-font.italic [-20, 20] - italicness, default 0
-font.face_index the face index to load, default 0
* LAYOUT options
-layout.type { box, box_optimal, grid, gridline, line }, default=box
-layout.one_pixel_offset ( false | true) if set, adds at least one pixel separation between glyphs, default to true
-layout.pot_image ( false | true) if set, create power of 2 image, default false
-layout.offset_left integer, sets the left padding, default 0
-layout.offset_top integer, sets the top padding, default 0
-layout.offset_right integer, sets the right padding, default 0
-layout.offset_bottom integer, sets the bottom padding, default 0
* OUTPUT options
-output.export { bmf (Angel Code XML) }, default to bmf
-output.name name of the export files, default to <font-name>
* misc
-h show help
example:
fontium minecraft.ttf -font.size 12 -output.export bmf -output.name minecraft
Author:
Tomer Shalev ([email protected])
