riuson / lcd-image-converter

Tool to create bitmaps and fonts for embedded applications, v.2
https://lcd-image-converter.riuson.com/
GNU General Public License v3.0
337 stars 80 forks source link

Patch with "out_blocks_offset" tag #56

Closed dsalychev closed 4 years ago

dsalychev commented 4 years ago

Hi,

You'll find a patch which adds a new "out_blocks_offset" tag to the templates in the archive. It might be useful to provide an offset in a single image data array (see TestFont.c and TestFont2.c with their _glyphs and _bitmaps variables) to a glyph:

/* Glyphs bitmap */
static const uint8_t PROGMEM _bitmaps[] = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0xe0, 0x18, 0x00, 0x00, 0x0c, 0x01, 0x00, 0x00,
    0x00, 0x38, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        ...
};

/* Glyphs */
static const MSIM_SH1106Glyph_t _glyphs[] = {
    { .code=0x20, .data=&_bitmaps[0], .width=4, .height=15, .data_size=8, },    /* ' ' */
    { .code=0x21, .data=&_bitmaps[8], .width=5, .height=15, .data_size=8, },    /* '!' */
    { .code=0x22, .data=&_bitmaps[18], .width=6, .height=15, .data_size=8, },   /* '\"' */
        ...

/* Font */
const MSIM_SH1106Font_t XG_FONT_TestFont = {
    .length = 95,
    .glyphs = _glyphs,
};

This is how I generate fonts for my tamagotchi-like toy.

out_blocks_offset_patch.zip

dsalychev commented 4 years ago

@riuson Any thoughts?

riuson commented 4 years ago

@dsalychev , Hi, it is useful, accepted. Thanks.

riuson commented 4 years ago

Added in rev. d56faf9

dsalychev commented 4 years ago

Looks good to me :) I tried to build and run it with my font template - no problem. The only adjustment is for the tag's name itself needed. Thanks for accepting.