fontium
1.0.0
يحتوي المشروع على مكونين
fontium عبارة عن مكتبة C ++ ، تخلق خطوط Bitmap مع خوارزميات تخطيط مخصصة.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;
بناء هدف fontium-cli مع cmake أو تثبيت (انظر أعلاه للحصول على التعليمات)
$ 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])
