feat(font): add option to disable kerning (#4725)
This commit is contained in:
@@ -208,6 +208,20 @@ because
|
||||
- they can be compressed better
|
||||
- and probably they are used less frequently then the medium-sized fonts, so the performance cost is smaller.
|
||||
|
||||
Kerning
|
||||
-------
|
||||
|
||||
Fonts may provide kerning information to adjust the spacing between specific
|
||||
characters.
|
||||
|
||||
- The online converter generates kerning tables.
|
||||
- The offline converter generates kerning tables unless ``--no-kerning`` is
|
||||
specified.
|
||||
- FreeType integration does not currently support kerning.
|
||||
- The Tiny TTF font engine supports GPOS and Kern tables.
|
||||
|
||||
To configure kerning at runtime, use :cpp:func:`lv_font_set_kerning`.
|
||||
|
||||
.. _add_font:
|
||||
|
||||
Add a new font
|
||||
|
||||
@@ -62,7 +62,7 @@ bool lv_font_get_glyph_dsc(const lv_font_t * font_p, lv_font_glyph_dsc_t * dsc_o
|
||||
dsc_out->resolved_font = NULL;
|
||||
|
||||
while(f) {
|
||||
bool found = f->get_glyph_dsc(f, dsc_out, letter, letter_next);
|
||||
bool found = f->get_glyph_dsc(f, dsc_out, letter, f->kerning == LV_FONT_KERNING_NONE ? 0 : letter_next);
|
||||
if(found) {
|
||||
if(!dsc_out->is_placeholder) {
|
||||
dsc_out->resolved_font = f;
|
||||
@@ -79,7 +79,8 @@ bool lv_font_get_glyph_dsc(const lv_font_t * font_p, lv_font_glyph_dsc_t * dsc_o
|
||||
|
||||
#if LV_USE_FONT_PLACEHOLDER
|
||||
if(placeholder_font != NULL) {
|
||||
placeholder_font->get_glyph_dsc(placeholder_font, dsc_out, letter, letter_next);
|
||||
placeholder_font->get_glyph_dsc(placeholder_font, dsc_out, letter,
|
||||
placeholder_font->kerning == LV_FONT_KERNING_NONE ? 0 : letter_next);
|
||||
dsc_out->resolved_font = placeholder_font;
|
||||
return true;
|
||||
}
|
||||
@@ -119,6 +120,12 @@ uint16_t lv_font_get_glyph_width(const lv_font_t * font, uint32_t letter, uint32
|
||||
return g.adv_w;
|
||||
}
|
||||
|
||||
void lv_font_set_kerning(lv_font_t * font, lv_font_kerning_t kerning)
|
||||
{
|
||||
LV_ASSERT_NULL(font);
|
||||
font->kerning = kerning;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
@@ -64,6 +64,18 @@ typedef _lv_font_subpx_t lv_font_subpx_t;
|
||||
typedef uint8_t lv_font_subpx_t;
|
||||
#endif /*DOXYGEN*/
|
||||
|
||||
/** Adjust letter spacing for specific character pairs.*/
|
||||
enum _lv_font_kerning_t {
|
||||
LV_FONT_KERNING_NORMAL,
|
||||
LV_FONT_KERNING_NONE,
|
||||
};
|
||||
|
||||
#ifdef DOXYGEN
|
||||
typedef _lv_font_kerning_t lv_font_kerning_t;
|
||||
#else
|
||||
typedef uint8_t lv_font_kerning_t;
|
||||
#endif /*DOXYGEN*/
|
||||
|
||||
/** Describe the properties of a font*/
|
||||
typedef struct _lv_font_t {
|
||||
/** Get a glyph's descriptor from a font*/
|
||||
@@ -75,7 +87,8 @@ typedef struct _lv_font_t {
|
||||
/*Pointer to the font in a font pack (must have the same line height)*/
|
||||
lv_coord_t line_height; /**< The real line height where any text fits*/
|
||||
lv_coord_t base_line; /**< Base line measured from the top of the line_height*/
|
||||
uint8_t subpx : 2; /**< An element of `lv_font_subpx_t`*/
|
||||
uint8_t subpx : 2; /**< An element of `lv_font_subpx_t`*/
|
||||
uint8_t kerning : 1; /**< An element of `lv_font_kerning_t`*/
|
||||
|
||||
int8_t underline_position; /**< Distance between the top of the underline and base line (< 0 means below the base line)*/
|
||||
int8_t underline_thickness; /**< Thickness of the underline*/
|
||||
@@ -128,6 +141,13 @@ static inline lv_coord_t lv_font_get_line_height(const lv_font_t * font)
|
||||
return font->line_height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the use of kerning information stored in a font
|
||||
* @param font pointer to a font
|
||||
* @param kerning `LV_FONT_KERNING_NORMAL` (default) or `LV_FONT_KERNING_NONE`
|
||||
*/
|
||||
void lv_font_set_kerning(lv_font_t * font, lv_font_kerning_t kerning);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
@@ -572,6 +572,7 @@ static bool lvgl_load_font(lv_fs_file_t * fp, lv_font_t * font)
|
||||
return false;
|
||||
}
|
||||
|
||||
/*kerning*/
|
||||
if(font_header.tables_count < 4) {
|
||||
font_dsc->kern_dsc = NULL;
|
||||
font_dsc->kern_classes = 0;
|
||||
|
||||
@@ -162,6 +162,7 @@ add_library(test_common
|
||||
src/test_assets/test_img_lvgl_logo_png.c
|
||||
src/test_assets/test_img_lvgl_logo_jpg.c
|
||||
src/test_assets/ubuntu_font.c
|
||||
src/test_assets/kern_one_otf.c
|
||||
unity/unity_support.c
|
||||
unity/unity.c
|
||||
)
|
||||
|
||||
BIN
tests/ref_imgs/tiny_ttf_2.png
Normal file
BIN
tests/ref_imgs/tiny_ttf_2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
95
tests/src/test_assets/kern_one_otf.c
Normal file
95
tests/src/test_assets/kern_one_otf.c
Normal file
@@ -0,0 +1,95 @@
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/*TestKERNOne.otf from https://github.com/unicode-org/text-rendering-tests*/
|
||||
const uint8_t kern_one_otf[] = {
|
||||
0x4f, 0x54, 0x54, 0x4f, 0x00, 0x0a, 0x00, 0x80, 0x00, 0x03, 0x00, 0x20, 0x43, 0x46, 0x46, 0x20,
|
||||
0x20, 0xda, 0x90, 0x5b, 0x00, 0x00, 0x03, 0xb8, 0x00, 0x00, 0x01, 0x66, 0x4f, 0x53, 0x2f, 0x32,
|
||||
0x5a, 0x11, 0x87, 0xea, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x60, 0x63, 0x6d, 0x61, 0x70,
|
||||
0x02, 0x92, 0x00, 0x18, 0x00, 0x00, 0x03, 0x4c, 0x00, 0x00, 0x00, 0x4c, 0x68, 0x65, 0x61, 0x64,
|
||||
0x0d, 0xf9, 0x3b, 0x43, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00, 0x36, 0x68, 0x68, 0x65, 0x61,
|
||||
0x06, 0x42, 0x01, 0xc8, 0x00, 0x00, 0x00, 0xe4, 0x00, 0x00, 0x00, 0x24, 0x68, 0x6d, 0x74, 0x78,
|
||||
0x08, 0xfc, 0x00, 0xf3, 0x00, 0x00, 0x05, 0x20, 0x00, 0x00, 0x00, 0x14, 0x6b, 0x65, 0x72, 0x6e,
|
||||
0x01, 0x54, 0xfd, 0xe7, 0x00, 0x00, 0x05, 0x34, 0x00, 0x00, 0x00, 0x30, 0x6d, 0x61, 0x78, 0x70,
|
||||
0x00, 0x05, 0x50, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, 0x06, 0x6e, 0x61, 0x6d, 0x65,
|
||||
0xe2, 0x60, 0xf2, 0x44, 0x00, 0x00, 0x01, 0x70, 0x00, 0x00, 0x01, 0xda, 0x70, 0x6f, 0x73, 0x74,
|
||||
0xff, 0xb8, 0x00, 0x32, 0x00, 0x00, 0x03, 0x98, 0x00, 0x00, 0x00, 0x20, 0x00, 0x01, 0x00, 0x00,
|
||||
0x00, 0x01, 0x00, 0x00, 0x7f, 0x24, 0x30, 0xed, 0x5f, 0x0f, 0x3c, 0xf5, 0x00, 0x03, 0x03, 0xe8,
|
||||
0x00, 0x00, 0x00, 0x00, 0xd3, 0xef, 0x1e, 0xed, 0x00, 0x00, 0x00, 0x00, 0xd8, 0x9a, 0xd9, 0x1e,
|
||||
0x00, 0x32, 0xff, 0x38, 0x02, 0x26, 0x03, 0x20, 0x00, 0x00, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0xe8, 0xff, 0x38, 0x00, 0x00, 0x02, 0x58,
|
||||
0x00, 0x32, 0x00, 0x32, 0x02, 0x26, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x50, 0x00, 0x00, 0x05, 0x00, 0x00,
|
||||
0x00, 0x03, 0x01, 0xcc, 0x01, 0x90, 0x00, 0x05, 0x00, 0x08, 0x02, 0x8a, 0x02, 0x58, 0x00, 0x00,
|
||||
0x00, 0x4b, 0x02, 0x8a, 0x02, 0x58, 0x00, 0x00, 0x01, 0x5e, 0x00, 0x32, 0x01, 0x2c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x4e, 0x49, 0x43, 0x00, 0x40,
|
||||
0x00, 0x20, 0x01, 0x31, 0x03, 0x20, 0xff, 0x38, 0x00, 0xc8, 0x03, 0xe8, 0x00, 0xc8, 0x20, 0x00,
|
||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xf4, 0x02, 0xbc, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x0c, 0x00, 0x96, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e,
|
||||
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x15, 0x00, 0x1e, 0x00, 0x01,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x07, 0x00, 0x33, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x06, 0x00, 0x1b, 0x00, 0x3a, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x0d,
|
||||
0x00, 0x55, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x0a, 0x00, 0x62, 0x00, 0x03,
|
||||
0x00, 0x01, 0x04, 0x09, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x6c, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09,
|
||||
0x00, 0x01, 0x00, 0x2a, 0x00, 0xa8, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09, 0x00, 0x02, 0x00, 0x0e,
|
||||
0x00, 0xd2, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09, 0x00, 0x06, 0x00, 0x36, 0x00, 0xe0, 0x00, 0x03,
|
||||
0x00, 0x01, 0x04, 0x09, 0x00, 0x09, 0x00, 0x1a, 0x01, 0x16, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09,
|
||||
0x00, 0x13, 0x00, 0x14, 0x01, 0x30, 0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68, 0x74, 0x20,
|
||||
0xa9, 0x20, 0x32, 0x30, 0x31, 0x36, 0x20, 0x55, 0x6e, 0x69, 0x63, 0x6f, 0x64, 0x65, 0x2c, 0x20,
|
||||
0x49, 0x6e, 0x63, 0x2e, 0x4f, 0x70, 0x65, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x54, 0x65, 0x73, 0x74,
|
||||
0x20, 0x4b, 0x45, 0x52, 0x4e, 0x20, 0x4f, 0x6e, 0x65, 0x52, 0x65, 0x67, 0x75, 0x6c, 0x61, 0x72,
|
||||
0x4f, 0x70, 0x65, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x54, 0x65, 0x73, 0x74, 0x4b, 0x45, 0x52, 0x4e,
|
||||
0x4f, 0x6e, 0x65, 0x2d, 0x52, 0x65, 0x67, 0x75, 0x6c, 0x61, 0x72, 0x53, 0x61, 0x73, 0x63, 0x68,
|
||||
0x61, 0x20, 0x42, 0x72, 0x61, 0x77, 0x65, 0x72, 0xf5, 0x54, 0x75, 0x54, 0xf5, 0xf5, 0x54, 0x75,
|
||||
0x54, 0xf5, 0x00, 0x43, 0x00, 0x6f, 0x00, 0x70, 0x00, 0x79, 0x00, 0x72, 0x00, 0x69, 0x00, 0x67,
|
||||
0x00, 0x68, 0x00, 0x74, 0x00, 0x20, 0x00, 0xa9, 0x00, 0x20, 0x00, 0x32, 0x00, 0x30, 0x00, 0x31,
|
||||
0x00, 0x36, 0x00, 0x20, 0x00, 0x55, 0x00, 0x6e, 0x00, 0x69, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x64,
|
||||
0x00, 0x65, 0x00, 0x2c, 0x00, 0x20, 0x00, 0x49, 0x00, 0x6e, 0x00, 0x63, 0x00, 0x2e, 0x00, 0x4f,
|
||||
0x00, 0x70, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x54, 0x00, 0x79, 0x00, 0x70, 0x00, 0x65, 0x00, 0x54,
|
||||
0x00, 0x65, 0x00, 0x73, 0x00, 0x74, 0x00, 0x20, 0x00, 0x4b, 0x00, 0x45, 0x00, 0x52, 0x00, 0x4e,
|
||||
0x00, 0x20, 0x00, 0x4f, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x52, 0x00, 0x65, 0x00, 0x67, 0x00, 0x75,
|
||||
0x00, 0x6c, 0x00, 0x61, 0x00, 0x72, 0x00, 0x4f, 0x00, 0x70, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x54,
|
||||
0x00, 0x79, 0x00, 0x70, 0x00, 0x65, 0x00, 0x54, 0x00, 0x65, 0x00, 0x73, 0x00, 0x74, 0x00, 0x4b,
|
||||
0x00, 0x45, 0x00, 0x52, 0x00, 0x4e, 0x00, 0x4f, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x2d, 0x00, 0x52,
|
||||
0x00, 0x65, 0x00, 0x67, 0x00, 0x75, 0x00, 0x6c, 0x00, 0x61, 0x00, 0x72, 0x00, 0x53, 0x00, 0x61,
|
||||
0x00, 0x73, 0x00, 0x63, 0x00, 0x68, 0x00, 0x61, 0x00, 0x20, 0x00, 0x42, 0x00, 0x72, 0x00, 0x61,
|
||||
0x00, 0x77, 0x00, 0x65, 0x00, 0x72, 0x01, 0x31, 0x00, 0x54, 0x00, 0x75, 0x00, 0x54, 0x01, 0x31,
|
||||
0x01, 0x31, 0x00, 0x54, 0x00, 0x75, 0x00, 0x54, 0x01, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
|
||||
0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x14, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x14,
|
||||
0x00, 0x04, 0x00, 0x38, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x08, 0x00, 0x02, 0x00, 0x02, 0x00, 0x20,
|
||||
0x00, 0x54, 0x00, 0x75, 0x01, 0x31, 0xff, 0xff, 0x00, 0x00, 0x00, 0x20, 0x00, 0x54, 0x00, 0x75,
|
||||
0x01, 0x31, 0xff, 0xff, 0xff, 0xe4, 0xff, 0xad, 0xff, 0x8e, 0xfe, 0xd1, 0x00, 0x01, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xff, 0xb5, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x04, 0x00, 0x01, 0x01, 0x01,
|
||||
0x1c, 0x4f, 0x70, 0x65, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x54, 0x65, 0x73, 0x74, 0x4b, 0x45, 0x52,
|
||||
0x4e, 0x4f, 0x6e, 0x65, 0x2d, 0x52, 0x65, 0x67, 0x75, 0x6c, 0x61, 0x72, 0x00, 0x01, 0x01, 0x01,
|
||||
0x1f, 0xf8, 0x0f, 0x00, 0xf8, 0x1b, 0x01, 0xf8, 0x1c, 0x02, 0xf8, 0x18, 0x04, 0xbd, 0xfb, 0x5c,
|
||||
0xf8, 0xba, 0xf9, 0xb4, 0x05, 0xf7, 0x22, 0x0f, 0x94, 0xf7, 0xf1, 0x12, 0xf7, 0x2b, 0x11, 0x00,
|
||||
0x02, 0x01, 0x01, 0x21, 0x3e, 0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68, 0x74, 0x20, 0x28,
|
||||
0x43, 0x29, 0x20, 0x32, 0x30, 0x31, 0x36, 0x20, 0x55, 0x6e, 0x69, 0x63, 0x6f, 0x64, 0x65, 0x2c,
|
||||
0x20, 0x49, 0x6e, 0x63, 0x2e, 0x4f, 0x70, 0x65, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x54, 0x65, 0x73,
|
||||
0x74, 0x20, 0x4b, 0x45, 0x52, 0x4e, 0x20, 0x4f, 0x6e, 0x65, 0x20, 0x52, 0x65, 0x67, 0x75, 0x6c,
|
||||
0x61, 0x72, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x35, 0x00, 0x91, 0x00, 0x56, 0x00, 0x01, 0x00,
|
||||
0x05, 0x01, 0x01, 0x89, 0xa0, 0xaa, 0xbb, 0xbe, 0xf8, 0x88, 0xf8, 0x2e, 0xf9, 0xb4, 0x15, 0xfb,
|
||||
0xd1, 0xfe, 0x7c, 0xf7, 0xd1, 0x06, 0x3e, 0xf7, 0xd2, 0x15, 0xfb, 0x05, 0xfb, 0x3a, 0xf7, 0x05,
|
||||
0x07, 0xf7, 0x19, 0x6a, 0x15, 0x27, 0x5c, 0xef, 0x06, 0xac, 0xf7, 0x91, 0x15, 0xfb, 0x05, 0xfb,
|
||||
0x3a, 0xf7, 0x05, 0xac, 0x3b, 0xef, 0xba, 0x6a, 0x74, 0x69, 0xc3, 0x07, 0xef, 0xf7, 0x0e, 0x15,
|
||||
0x27, 0xfb, 0x3a, 0xad, 0xf7, 0x19, 0xcd, 0x07, 0xac, 0xc7, 0x15, 0x6a, 0x49, 0x45, 0x27, 0xac,
|
||||
0xcd, 0xb0, 0x49, 0xac, 0x07, 0xcd, 0xec, 0x15, 0x6a, 0x67, 0xac, 0x06, 0xad, 0xd1, 0x15, 0x45,
|
||||
0xcd, 0x69, 0xfb, 0x3a, 0xf3, 0x07, 0xf7, 0x3a, 0xf7, 0x15, 0x15, 0x6a, 0x49, 0x66, 0xcd, 0x6a,
|
||||
0xfb, 0x3a, 0xac, 0xcd, 0xb0, 0x4a, 0xac, 0x07, 0xf7, 0x39, 0xfd, 0x83, 0x15, 0x6a, 0x6b, 0x07,
|
||||
0x45, 0x5c, 0x05, 0xf1, 0x6a, 0xfb, 0x3a, 0xac, 0x06, 0xd1, 0xba, 0x05, 0x45, 0xac, 0x06, 0x0e,
|
||||
0xf8, 0xec, 0xbd, 0xf8, 0x88, 0x15, 0xef, 0xef, 0xef, 0xfc, 0xec, 0xef, 0xf8, 0xec, 0xef, 0x27,
|
||||
0xef, 0xf7, 0x5c, 0xfc, 0x88, 0x06, 0x0e, 0xf7, 0x5c, 0xbd, 0x16, 0xef, 0xf8, 0x88, 0x27, 0x06,
|
||||
0x0e, 0xf8, 0x24, 0xbd, 0x16, 0xf7, 0xc0, 0xf8, 0x88, 0x27, 0xfc, 0x24, 0x27, 0xf8, 0x24, 0x27,
|
||||
0x06, 0x0e, 0xf8, 0xec, 0x0e, 0x1e, 0xa0, 0x37, 0xff, 0x0c, 0x09, 0x8b, 0x0c, 0x0b, 0x00, 0x00,
|
||||
0x01, 0xf4, 0x00, 0x5d, 0x02, 0x58, 0x00, 0x32, 0x00, 0xc8, 0x00, 0x32, 0x01, 0x90, 0x00, 0x32,
|
||||
0x02, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x01, 0x00, 0x05,
|
||||
0x00, 0x18, 0x00, 0x02, 0x00, 0x06, 0x00, 0x01, 0x00, 0x02, 0xff, 0x38, 0x00, 0x01, 0x00, 0x03,
|
||||
0xff, 0x38, 0x00, 0x02, 0x00, 0x01, 0xff, 0x38, 0x00, 0x02, 0x00, 0x02, 0x01, 0xf4, 0x00, 0x03,
|
||||
0x00, 0x01, 0xff, 0x38
|
||||
};
|
||||
|
||||
const size_t kern_one_otf_size = sizeof(kern_one_otf);
|
||||
@@ -1,6 +1,3 @@
|
||||
#ifndef UBUNTU_FONT_H
|
||||
#define UBUNTU_FONT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
@@ -11971,4 +11968,3 @@ const uint8_t ubuntu_font[] = {
|
||||
};
|
||||
|
||||
size_t ubuntu_font_size = sizeof(ubuntu_font);
|
||||
#endif
|
||||
|
||||
@@ -29,7 +29,6 @@ void test_tiny_ttf_rendering_test(void)
|
||||
lv_style_set_bg_opa(&style, LV_OPA_COVER);
|
||||
lv_style_set_bg_color(&style, lv_color_hex(0xffaaaa));
|
||||
|
||||
|
||||
/*Create a label with the new style*/
|
||||
lv_obj_t * label = lv_label_create(lv_screen_active());
|
||||
lv_obj_add_style(label, &style, 0);
|
||||
@@ -39,6 +38,42 @@ void test_tiny_ttf_rendering_test(void)
|
||||
lv_obj_center(label);
|
||||
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("tiny_ttf_1.png");
|
||||
|
||||
lv_obj_del(label);
|
||||
lv_tiny_ttf_destroy(font);
|
||||
#else
|
||||
TEST_PASS();
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_tiny_ttf_kerning()
|
||||
{
|
||||
#if LV_USE_TINY_TTF
|
||||
extern const uint8_t kern_one_otf[];
|
||||
extern size_t kern_one_otf_size;
|
||||
lv_font_t * font_normal = lv_tiny_ttf_create_data(kern_one_otf, kern_one_otf_size, 80);
|
||||
lv_font_t * font_none = lv_tiny_ttf_create_data(kern_one_otf, kern_one_otf_size, 80);
|
||||
lv_font_set_kerning(font_none, LV_FONT_KERNING_NONE);
|
||||
|
||||
lv_obj_t * cont = lv_obj_create(lv_screen_active());
|
||||
lv_obj_set_size(cont, lv_pct(90), lv_pct(90));
|
||||
lv_obj_center(cont);
|
||||
lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_ROW);
|
||||
lv_obj_set_flex_align(cont, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
||||
|
||||
lv_obj_t * label_normal = lv_label_create(cont);
|
||||
lv_label_set_text(label_normal, "ıTuTuTı");
|
||||
lv_obj_set_style_text_font(label_normal, font_normal, LV_PART_MAIN);
|
||||
|
||||
lv_obj_t * label_none = lv_label_create(cont);
|
||||
lv_label_set_text(label_none, "ıTuTuTı");
|
||||
lv_obj_set_style_text_font(label_none, font_none, LV_PART_MAIN);
|
||||
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("tiny_ttf_2.png");
|
||||
|
||||
lv_obj_del(cont);
|
||||
lv_tiny_ttf_destroy(font_normal);
|
||||
lv_tiny_ttf_destroy(font_none);
|
||||
#else
|
||||
TEST_PASS();
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user