• 1 Post
  • 100 Comments
Joined 2 years ago
cake
Cake day: June 23rd, 2024

help-circle









  • Get a better take on the 5x7 font or a higher-resolution one, the ESP32 can even handle vector fonts. You’re using Adafruit’s objectively ugly glcdfont:

    ugly glcdfont

    I suggest you use this one:

    my pretty 5x7 font

    Raw bytes

    This is a drop-in replacement for the array in Adafruit’s glcdfont.c.

    0x00, 0x00, 0x00, 0x00, 0x00, 
    0x20, 0x4c, 0x40, 0x4c, 0x20, 
    0x3e, 0x6b, 0x4f, 0x6b, 0x3e, 
    0x0c, 0x12, 0x24, 0x12, 0x0c, 
    0x08, 0x14, 0x22, 0x14, 0x08, 
    0x18, 0x1e, 0x2e, 0x1e, 0x18, 
    0x18, 0x1c, 0x2e, 0x1c, 0x18, 
    0x1c, 0x3e, 0x3e, 0x3e, 0x1c, 
    0xe3, 0xc1, 0xc1, 0xc1, 0xe3, 
    0x1c, 0x22, 0x22, 0x22, 0x1c, 
    0xe3, 0xdd, 0xdd, 0xdd, 0xe3, 
    0x30, 0x48, 0x4a, 0x36, 0x0e, 
    0x06, 0x29, 0x79, 0x29, 0x06, 
    0x60, 0x60, 0x7f, 0x06, 0x1c, 
    0x60, 0x7f, 0x03, 0x63, 0x7f, 
    0x2a, 0x1c, 0x36, 0x1c, 0x2a, 
    0x00, 0x3e, 0x1c, 0x08, 0x00, 
    0x00, 0x08, 0x1c, 0x3e, 0x00, 
    0x24, 0x66, 0xe7, 0x66, 0x24, 
    0x00, 0x5f, 0x00, 0x5f, 0x00, 
    0x06, 0x0f, 0x7f, 0x01, 0x7f, 
    0x00, 0x4c, 0x57, 0x75, 0x19, 
    0x60, 0x60, 0x60, 0x60, 0x60, 
    0x24, 0x42, 0xff, 0x42, 0x24, 
    0x08, 0x04, 0x7e, 0x04, 0x08, 
    0x10, 0x20, 0x7e, 0x20, 0x10, 
    0x08, 0x08, 0x2a, 0x1c, 0x08, 
    0x08, 0x1c, 0x2a, 0x08, 0x08, 
    0x78, 0x40, 0x40, 0x40, 0x40, 
    0x08, 0x0c, 0x2a, 0x18, 0x08, 
    0x10, 0x18, 0x1c, 0x18, 0x10, 
    0x04, 0x0c, 0x1c, 0x0c, 0x04, 
    0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x5f, 0x00, 0x00, 
    0x00, 0x07, 0x00, 0x07, 0x00, 
    0x14, 0x7f, 0x14, 0x7f, 0x14, 
    0x24, 0x2a, 0x7f, 0x2a, 0x12, 
    0x23, 0x13, 0x08, 0x64, 0x62, 
    0x36, 0x49, 0x56, 0x20, 0x50, 
    0x00, 0x05, 0x03, 0x00, 0x00, 
    0x00, 0x1c, 0x22, 0x41, 0x00, 
    0x00, 0x41, 0x22, 0x1c, 0x00, 
    0x14, 0x08, 0x3e, 0x08, 0x14, 
    0x08, 0x08, 0x3e, 0x08, 0x08, 
    0x00, 0xa0, 0x60, 0x00, 0x00, 
    0x08, 0x08, 0x08, 0x08, 0x08, 
    0x00, 0x60, 0x60, 0x00, 0x00, 
    0x60, 0x10, 0x08, 0x04, 0x03, 
    0x3e, 0x51, 0x49, 0x45, 0x3e, 
    0x00, 0x42, 0x7f, 0x40, 0x00, 
    0x42, 0x61, 0x51, 0x49, 0x46, 
    0x21, 0x41, 0x45, 0x4b, 0x31, 
    0x18, 0x14, 0x12, 0x7f, 0x10, 
    0x27, 0x45, 0x45, 0x45, 0x39, 
    0x3c, 0x4a, 0x49, 0x49, 0x30, 
    0x01, 0x71, 0x09, 0x05, 0x03, 
    0x36, 0x49, 0x49, 0x49, 0x36, 
    0x06, 0x49, 0x49, 0x29, 0x1e, 
    0x00, 0x6c, 0x6c, 0x00, 0x00, 
    0x00, 0xac, 0x6c, 0x00, 0x00, 
    0x08, 0x14, 0x22, 0x41, 0x00, 
    0x14, 0x14, 0x14, 0x14, 0x14, 
    0x00, 0x41, 0x22, 0x14, 0x08, 
    0x02, 0x01, 0x51, 0x09, 0x06, 
    0x3e, 0x41, 0x5d, 0x55, 0x5e, 
    0x7c, 0x12, 0x11, 0x12, 0x7c, 
    0x7f, 0x49, 0x49, 0x49, 0x36, 
    0x3e, 0x41, 0x41, 0x41, 0x22, 
    0x7f, 0x41, 0x41, 0x22, 0x1c, 
    0x7f, 0x49, 0x49, 0x49, 0x41, 
    0x7f, 0x09, 0x09, 0x09, 0x01, 
    0x3e, 0x41, 0x49, 0x49, 0x7a, 
    0x7f, 0x08, 0x08, 0x08, 0x7f, 
    0x00, 0x41, 0x7f, 0x41, 0x00, 
    0x20, 0x40, 0x41, 0x3f, 0x01, 
    0x7f, 0x08, 0x14, 0x22, 0x41, 
    0x7f, 0x40, 0x40, 0x40, 0x40, 
    0x7f, 0x02, 0x0c, 0x02, 0x7f, 
    0x7f, 0x04, 0x08, 0x10, 0x7f, 
    0x3e, 0x41, 0x41, 0x41, 0x3e, 
    0x7f, 0x09, 0x09, 0x09, 0x06, 
    0x3e, 0x41, 0x51, 0x61, 0xbe, 
    0x7f, 0x09, 0x19, 0x29, 0x46, 
    0x26, 0x49, 0x49, 0x49, 0x32, 
    0x01, 0x01, 0x7f, 0x01, 0x01, 
    0x3f, 0x40, 0x40, 0x40, 0x3f, 
    0x1f, 0x20, 0x40, 0x20, 0x1f, 
    0x3f, 0x40, 0x38, 0x40, 0x3f, 
    0x63, 0x14, 0x08, 0x14, 0x63, 
    0x07, 0x08, 0x70, 0x08, 0x07, 
    0x61, 0x51, 0x49, 0x45, 0x43, 
    0x00, 0x00, 0x7f, 0x41, 0x00, 
    0x03, 0x04, 0x08, 0x10, 0x60, 
    0x00, 0x41, 0x7f, 0x00, 0x00, 
    0x04, 0x02, 0x01, 0x02, 0x04, 
    0x80, 0x80, 0x80, 0x80, 0x80, 
    0x00, 0x01, 0x02, 0x04, 0x00, 
    0x20, 0x54, 0x54, 0x54, 0x78, 
    0x7f, 0x48, 0x44, 0x44, 0x38, 
    0x38, 0x44, 0x44, 0x44, 0x20, 
    0x38, 0x44, 0x44, 0x48, 0x7f, 
    0x38, 0x54, 0x54, 0x54, 0x18, 
    0x08, 0x7e, 0x09, 0x09, 0x02, 
    0x18, 0xa4, 0xa4, 0xa4, 0x7c, 
    0x7f, 0x08, 0x04, 0x04, 0x78, 
    0x00, 0x44, 0x7d, 0x40, 0x00, 
    0x40, 0x80, 0x84, 0x7d, 0x00, 
    0x7f, 0x10, 0x28, 0x44, 0x00, 
    0x00, 0x41, 0x7f, 0x40, 0x00, 
    0x7c, 0x04, 0x38, 0x04, 0x78, 
    0x7c, 0x08, 0x04, 0x04, 0x78, 
    0x38, 0x44, 0x44, 0x44, 0x38, 
    0xfc, 0x24, 0x24, 0x24, 0x18, 
    0x18, 0x24, 0x24, 0x24, 0xfc, 
    0x7c, 0x08, 0x04, 0x04, 0x08, 
    0x48, 0x54, 0x54, 0x54, 0x20, 
    0x04, 0x3f, 0x44, 0x44, 0x20, 
    0x3c, 0x40, 0x40, 0x20, 0x7c, 
    0x1c, 0x20, 0x40, 0x20, 0x1c, 
    0x3c, 0x40, 0x30, 0x40, 0x3c, 
    0x44, 0x28, 0x10, 0x28, 0x44, 
    0x1c, 0xa0, 0xa0, 0xa0, 0x7c, 
    0x44, 0x64, 0x54, 0x4c, 0x44, 
    0x00, 0x08, 0x77, 0x41, 0x00, 
    0x00, 0x00, 0x7f, 0x00, 0x00, 
    0x00, 0x41, 0x77, 0x08, 0x00, 
    0x08, 0x04, 0x08, 0x10, 0x08, 
    0x38, 0x24, 0x22, 0x24, 0x38, 
    0x3e, 0x41, 0x41, 0xc1, 0x22, 
    0x3c, 0x41, 0x40, 0x21, 0x7c, 
    0x38, 0x54, 0x56, 0x55, 0x18, 
    0x20, 0x56, 0x55, 0x56, 0x78, 
    0x20, 0x55, 0x54, 0x55, 0x78, 
    0x20, 0x55, 0x56, 0x54, 0x78, 
    0x20, 0x54, 0x56, 0x55, 0x78, 
    0x38, 0x44, 0x44, 0xc4, 0x20, 
    0x38, 0x56, 0x55, 0x56, 0x18, 
    0x38, 0x55, 0x54, 0x55, 0x18, 
    0x38, 0x55, 0x56, 0x54, 0x18, 
    0x00, 0x45, 0x7c, 0x41, 0x00, 
    0x00, 0x46, 0x7d, 0x42, 0x00, 
    0x00, 0x45, 0x7e, 0x40, 0x00, 
    0x78, 0x15, 0x12, 0x15, 0x78, 
    0x78, 0x14, 0x13, 0x14, 0x78, 
    0x7e, 0x4a, 0x4b, 0x4b, 0x42, 
    0x60, 0x54, 0x78, 0x54, 0x58, 
    0x7e, 0x09, 0x7f, 0x49, 0x49, 
    0x38, 0x46, 0x45, 0x46, 0x38, 
    0x38, 0x45, 0x44, 0x45, 0x38, 
    0x38, 0x45, 0x46, 0x44, 0x38, 
    0x3c, 0x42, 0x41, 0x22, 0x7c, 
    0x3c, 0x41, 0x42, 0x20, 0x7c, 
    0x1c, 0xa1, 0xa0, 0xa1, 0x7c, 
    0x3c, 0x43, 0x42, 0x43, 0x3c, 
    0x3e, 0x41, 0x40, 0x41, 0x3e, 
    0x38, 0x44, 0xfe, 0x44, 0x20, 
    0x48, 0x7e, 0x49, 0x49, 0x42, 
    0x2b, 0x2c, 0x78, 0x2c, 0x2b, 
    0x7f, 0x09, 0x06, 0x3c, 0x48, 
    0x80, 0x88, 0x7e, 0x09, 0x01, 
    0x20, 0x54, 0x56, 0x55, 0x78, 
    0x00, 0x00, 0x44, 0x7e, 0x41, 
    0x38, 0x44, 0x46, 0x45, 0x38, 
    0x3c, 0x40, 0x42, 0x21, 0x7c, 
    0x7c, 0x09, 0x05, 0x05, 0x78, 
    0x7e, 0x05, 0x09, 0x11, 0x7e, 
    0x06, 0x09, 0x0f, 0x00, 0x00, 
    0x06, 0x09, 0x06, 0x00, 0x00, 
    0x60, 0x90, 0x8a, 0x80, 0x40, 
    0x38, 0x08, 0x08, 0x08, 0x08, 
    0x08, 0x08, 0x08, 0x08, 0x38, 
    0x2f, 0x10, 0x98, 0xd4, 0xa2, 
    0x2f, 0x10, 0x48, 0x64, 0xf2, 
    0x00, 0x00, 0x7d, 0x00, 0x00, 
    0x08, 0x14, 0x2a, 0x14, 0x22, 
    0x22, 0x14, 0x2a, 0x14, 0x08, 
    0x55, 0x00, 0x55, 0x00, 0x55, 
    0xaa, 0x55, 0xaa, 0x55, 0xaa, 
    0xff, 0x55, 0xff, 0x55, 0xff, 
    0x00, 0x00, 0xff, 0x00, 0x00, 
    0x08, 0x08, 0xff, 0x00, 0x00, 
    0x14, 0x14, 0xff, 0x00, 0x00, 
    0x08, 0xff, 0x00, 0xff, 0x00, 
    0x08, 0xf8, 0x08, 0xf8, 0x00, 
    0x14, 0x14, 0xfc, 0x00, 0x00, 
    0x14, 0xf7, 0x00, 0xff, 0x00, 
    0x00, 0xff, 0x00, 0xff, 0x00, 
    0x14, 0xf4, 0x04, 0xfc, 0x00, 
    0x14, 0x17, 0x10, 0x1f, 0x00, 
    0x08, 0x0f, 0x08, 0x0f, 0x00, 
    0x14, 0x14, 0x1f, 0x00, 0x00, 
    0x08, 0x08, 0xf8, 0x00, 0x00, 
    0x00, 0x00, 0x0f, 0x08, 0x08, 
    0x08, 0x08, 0x0f, 0x08, 0x08, 
    0x08, 0x08, 0x78, 0x08, 0x08, 
    0x00, 0x00, 0x7f, 0x08, 0x08, 
    0x08, 0x08, 0x08, 0x08, 0x08, 
    0x08, 0x08, 0x7f, 0x08, 0x08, 
    0x00, 0x00, 0xff, 0x14, 0x14, 
    0x00, 0xff, 0x00, 0xff, 0x00, 
    0x00, 0x1f, 0x10, 0x17, 0x14, 
    0x00, 0xfc, 0x04, 0xf4, 0x14, 
    0x14, 0x17, 0x10, 0x17, 0x14, 
    0x14, 0xf4, 0x04, 0xf4, 0x14, 
    0x00, 0xff, 0x00, 0xff, 0x00, 
    0x14, 0x14, 0x14, 0x14, 0x14, 
    0x14, 0xf7, 0x00, 0xf7, 0x14, 
    0x14, 0x14, 0x17, 0x14, 0x14, 
    0x08, 0x0f, 0x08, 0x0f, 0x08, 
    0x14, 0x14, 0xf4, 0x14, 0x14, 
    0x08, 0xf8, 0x08, 0xf8, 0x08, 
    0x00, 0x0f, 0x08, 0x0f, 0x08, 
    0x00, 0x00, 0x1f, 0x14, 0x14, 
    0x00, 0x00, 0xfc, 0x14, 0x14, 
    0x00, 0xf8, 0x08, 0xf8, 0x08, 
    0x08, 0xff, 0x08, 0xff, 0x08, 
    0x14, 0x14, 0xff, 0x14, 0x14, 
    0x08, 0x08, 0x0f, 0x00, 0x00, 
    0x00, 0x00, 0xf8, 0x08, 0x08, 
    0xff, 0xff, 0xff, 0xff, 0xff, 
    0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 
    0xff, 0xff, 0xff, 0x00, 0x00, 
    0x00, 0x00, 0xff, 0xff, 0xff, 
    0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 
    0x38, 0x44, 0x44, 0x38, 0x44, 
    0xfe, 0x01, 0x45, 0x4a, 0x30, 
    0x7f, 0x01, 0x01, 0x01, 0x01, 
    0x44, 0x3c, 0x04, 0x7c, 0x44, 
    0x63, 0x55, 0x49, 0x41, 0x63, 
    0x38, 0x44, 0x44, 0x3c, 0x04, 
    0xfc, 0x40, 0x40, 0x20, 0x7c, 
    0x04, 0x04, 0x7c, 0x44, 0x04, 
    0x1c, 0x22, 0x7f, 0x22, 0x1c, 
    0x3e, 0x49, 0x49, 0x49, 0x3e, 
    0x5e, 0x61, 0x01, 0x61, 0x5e, 
    0x32, 0x4d, 0x45, 0x49, 0x30, 
    0x18, 0x24, 0x18, 0x24, 0x18, 
    0xb8, 0x64, 0x54, 0x4c, 0x3a, 
    0x28, 0x54, 0x54, 0x44, 0x20, 
    0x7e, 0x01, 0x01, 0x01, 0x7e, 
    0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 
    0x44, 0x44, 0x5f, 0x44, 0x44, 
    0x51, 0x4a, 0x4a, 0x44, 0x44, 
    0x44, 0x44, 0x4a, 0x4a, 0x51, 
    0x00, 0x00, 0xfe, 0x01, 0x03, 
    0xc0, 0x80, 0x7f, 0x00, 0x00, 
    0x08, 0x08, 0x2a, 0x08, 0x08, 
    0x28, 0x14, 0x24, 0x28, 0x14, 
    0x00, 0x02, 0x05, 0x02, 0x00, 
    0x00, 0x00, 0x18, 0x18, 0x00, 
    0x00, 0x00, 0x10, 0x10, 0x00, 
    0x20, 0x40, 0xff, 0x01, 0x01, 
    0x0f, 0x01, 0x0e, 0x00, 0x00, 
    0x09, 0x0d, 0x0a, 0x00, 0x00, 
    0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 
    0x00, 0x00, 0x00, 0x00, 0x00
    


  • Identifying both is hard.

    Did you know that PDF files are valid even if the first 3 bytes aren’t “PDF”? A key to what makes a PDF “valid” is the second-to-last object in the PostScript structure, which points to the object that should be processed first (usually Page 1). Being almost at the end of the file, it makes it impossible to stream PDFs (portable my ass), also you can make a PDF that is also a PNG, HTML or almost whatever else if you change the extension. Even look different on different PDF readers!

    This is all explored in Funky File Formats, a 31c3 talk by Ange Albertini (and the follow-up 2024 talk Fearsome FIle Formats). (YouTube mirror)




  • Renumbering characters during font minimization? I haven’t encountered that, it would break searching and copying.

    Anyway, PDFs for example don’t even say whether a line of text is left, center or justified – they usually store the coordinates of the first character and then spacing to each subsequent one unless defined by the font.

    And what if the document contains text boxes, or other Word objects? Well, the text is separate from the underlying rectangle (if there is one) and it’s up to the conversion tool to guess if it’s part of the main text layer.

    Sorry, it’s really hard to edit PDFs. You might want to use Inkscape for editing the graphical parts. If you also need to edit paragraphs, I suggest recreating the document by pasting them into Word/LibreOffice, and importing any graphical shapes as SVGs (use Inkscape for the conversion, then you can try Word’s “Graphic > Convert to Shapes” feature).

    Really, every software that outputs PDF should treat it as an export process, hopefully making it clearer that “saving as PDF” is visually lossless but structurally lossy and messy.