Files

54 lines
2.6 KiB
C
Raw Permalink Normal View History

/* Generated by tools/generate_call_status_font.py; do not hand edit.
* Source SHA256: abfffdf0cd809cf2e3cd9425988b8945786fb5166bf4c5e91d2b6e1fb3839f74
* 2x nearest-neighbor glyphs; packed 1bpp, GFX 1/256-pixel advance.
* The original source font's leading notice is preserved below.
*/
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include "widget/gfx_font_internal.h"
#include "echoear_call_status_font.h"
static const struct { uint32_t cp; int w, h, x, y, advance; uint32_t hash; } expected[] = {
{0x003F,16,26,2,-2,4960,0xE71CEB21},
{0x4E2D,26,30,2,-4,8192,0x3888DC51},
{0x5728,30,30,0,-4,8192,0x3089182D},
{0x5931,30,30,2,-4,8192,0xDA574F79},
{0x5F85,30,32,2,-4,8192,0xCE76BC5D},
{0x63A5,28,30,2,-4,8192,0x7D6D9261},
{0x65AD,28,30,2,-4,8192,0x77C36EB9},
{0x673A,30,30,2,-4,8192,0xDAC1CC21},
{0x675F,30,30,0,-4,8192,0xB9914901},
{0x6B63,30,26,0,-2,8192,0xB05EAE01},
{0x7ED3,30,30,0,-4,8192,0x652017C5},
{0x8BDD,30,30,0,-4,8192,0x35175309},
{0x8D25,32,32,0,-6,8192,0x99373BE1},
{0x8FDE,30,30,0,-4,8192,0x353F4839},
{0x901A,30,26,0,-2,8192,0x66E5D84D},
};
int main(void) {
const void *font=echoear_call_status_font(); assert(gfx_is_lvgl_font(font));
gfx_font_ctx_t ctx={0}; gfx_font_lv_init_context(&ctx,font);
assert(ctx.get_line_height(&ctx)==38 && ctx.get_base_line(&ctx)==10);
for (unsigned i=0;i<sizeof(expected)/sizeof(expected[0]);i++) {
gfx_glyph_dsc_t g={0}; assert(ctx.get_glyph_dsc(&ctx,&g,expected[i].cp,0));
assert(g.box_w==expected[i].w && g.box_h==expected[i].h);
assert(g.ofs_x==expected[i].x && g.ofs_y==expected[i].y && g.adv_w==(uint32_t)expected[i].advance);
assert(g.bitmap_index+(g.box_w*g.box_h+7)/8 <= 1595);
int top=ctx.adjust_baseline_offset(&ctx,&g); assert(top>=0 && top+g.box_h<=ctx.get_line_height(&ctx));
assert(ctx.get_advance_width(&ctx,&g)==32 || expected[i].cp==0x3F);
const uint8_t *bits=ctx.get_glyph_bitmap(&ctx,expected[i].cp,&g); assert(bits); uint32_t hash=2166136261u;
for(int y=0;y<g.box_h;y++) for(int x=0;x<g.box_w;x++) hash=(hash^ctx.get_pixel_value(&ctx,bits,x,y,g.box_w))*16777619u;
assert(hash==expected[i].hash);
}
/* Exhaustive Unicode lookup also exercises every cmap range-end boundary. */
for(uint32_t cp=0;cp<=0x10FFFF;cp++) {
int present=0; for(unsigned i=0;i<sizeof(expected)/sizeof(expected[0]);i++) present |= expected[i].cp==cp;
gfx_glyph_dsc_t g={0}; assert(ctx.get_glyph_dsc(&ctx,&g,cp,0)==(present!=0));
}
puts("GFX call-status font: ABI, coverage, exact pixels, metrics and Unicode boundaries PASS");
return 0;
}