raster: fix text not scaling for half_int_scaling; UPCEAN font

This commit is contained in:
gitlost 2020-09-13 13:37:15 +01:00
parent e41cb71fd1
commit 1adba12fce
20 changed files with 5496 additions and 324 deletions

View file

@ -2,7 +2,7 @@
/*
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2008 - 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -29,8 +29,14 @@
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
static const char ascii_font[] = {
typedef const unsigned short font_item;
#define NORMAL_FONT_WIDTH 7
#define NORMAL_FONT_HEIGHT 14
static font_item ascii_font[] = {
/* Each character is 7 x 14 pixels */
0, 0, 8, 8, 8, 8, 8, 8, 8, 0, 8, 8, 0, 0, /* ! */
0, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* " */
@ -224,7 +230,10 @@ static const char ascii_font[] = {
0, 0, 0, 36, 0, 66, 66, 34, 36, 20, 28, 8, 72, 48, /* ÿ */
};
static const char small_font[] = {
#define SMALL_FONT_WIDTH 5
#define SMALL_FONT_HEIGHT 9
static font_item small_font[] = {
/* Each character is 5 x 9 pixels */
0, 2, 2, 2, 2, 0, 2, 0, 0, /* ! */
0, 5, 5, 5, 0, 0, 0, 0, 0, /* " */
@ -417,3 +426,61 @@ static const char small_font[] = {
0, 0, 8, 14, 9, 9, 14, 8, 0, /* þ */
0, 5, 0, 9, 9, 5, 2, 4, 0, /* ÿ */
};
/* Adapted from OCR-B font version 0.2 Matthew Skala
* https://tsukurimashou.osdn.jp/ocr.php.en
*
* Copyright Matthew Skala (2011); based on code by Norbert Schwarz (1986, 2011)
*
* "The version in this package descends from a set of Metafont
* definitions by Norbert Schwarz of Ruhr-Universitaet Bochum,
* bearing dates ranging from 1986 to 2010. He originally
* distributed it under a "non-commercial use only"
* restriction but has since released it for unrestricted use
* and distribution. See the README file for more details."
*
* The README states (http://mirrors.ctan.org/fonts/ocr-b.zip)
*
* "As far as the digitization in METAFONT input which I have
* developed, you may freely use, modify, and/or distribute any of
* these files or the resulting fonts, without limitation. A previous
* release of ocr-b only granted rights for non-commercial use; that
* restriction is now lifted."
*
* Used OCRB.otf with FontForge to create OCRB-18.bdf (normal) and OCRB-16.bdf (small) and then touched up using gbdfed
* Note there's no bold version of OCR-B.
*/
#define UPCEAN_FONT_WIDTH 9
#define UPCEAN_FONT_HEIGHT 14
/* Each character is 9 x 14 pixels */
static font_item upcean_font[] = {
/*30*/ 0x007C, 0x00FE, 0x00C6, 0x0183, 0x0183, 0x0183, 0x0183, 0x0183, 0x0183, 0x0183, 0x0183, 0x00C6, 0x00FE, 0x007C, /* 0 */
/*31*/ 0x000C, 0x001C, 0x003C, 0x006C, 0x004C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, /* 1 */
/*32*/ 0x007C, 0x00FE, 0x0183, 0x0003, 0x0007, 0x000E, 0x001C, 0x0038, 0x0070, 0x00E0, 0x01C0, 0x0180, 0x01FE, 0x00FF, /* 2 */
/*33*/ 0x01FE, 0x01FE, 0x0006, 0x000C, 0x0018, 0x0038, 0x003C, 0x0006, 0x0003, 0x0003, 0x0003, 0x0006, 0x01FE, 0x00F8, /* 3 */
/*34*/ 0x0018, 0x0018, 0x0030, 0x0030, 0x0060, 0x0060, 0x00C4, 0x00CC, 0x018C, 0x01FF, 0x01FF, 0x000C, 0x000C, 0x000C, /* 4 */
/*35*/ 0x00FE, 0x00FE, 0x00C0, 0x00C0, 0x00C0, 0x00F8, 0x00FC, 0x0006, 0x0006, 0x0006, 0x0006, 0x000C, 0x01FC, 0x00F8, /* 5 */
/*36*/ 0x000C, 0x001C, 0x0038, 0x0030, 0x0060, 0x00F8, 0x00FE, 0x01C7, 0x0183, 0x0183, 0x0183, 0x01C3, 0x00FE, 0x007C, /* 6 */
/*37*/ 0x01FF, 0x01FF, 0x0003, 0x0006, 0x000E, 0x000C, 0x0018, 0x0030, 0x0030, 0x0030, 0x0060, 0x0060, 0x0060, 0x0060, /* 7 */
/*38*/ 0x007C, 0x00FE, 0x00C6, 0x0082, 0x00C6, 0x007C, 0x007C, 0x00EE, 0x01C7, 0x0183, 0x0183, 0x0183, 0x00FE, 0x007C, /* 8 */
/*39*/ 0x007C, 0x00FE, 0x00C7, 0x0183, 0x0183, 0x0183, 0x01C3, 0x00FE, 0x007E, 0x000C, 0x000C, 0x0018, 0x0030, 0x0060, /* 9 */
};
#define UPCEAN_SMALL_FONT_WIDTH 8
#define UPCEAN_SMALL_FONT_HEIGHT 13
/* Each character is 8 x 13 pixels */
static font_item upcean_small_font[] = {
/*30*/ 0x3C, 0x7E, 0x66, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0x66, 0x7E, 0x3C, /* 0 */
/*31*/ 0x00, 0x0E, 0x1E, 0x36, 0x26, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, /* 1 */
/*32*/ 0x38, 0x7C, 0xC6, 0x02, 0x02, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0xFC, 0x7E, /* 2 */
/*33*/ 0x00, 0xFE, 0xFE, 0x06, 0x1C, 0x38, 0x3E, 0x07, 0x03, 0x03, 0x06, 0xFC, 0x78, /* 3 */
/*34*/ 0x00, 0x18, 0x18, 0x30, 0x30, 0x60, 0x64, 0xCC, 0xCC, 0xFF, 0xFF, 0x0C, 0x0C, /* 4 */
/*35*/ 0x00, 0x7E, 0x7E, 0x40, 0x40, 0x78, 0x7C, 0x06, 0x02, 0x02, 0x06, 0xFC, 0x78, /* 5 */
/*36*/ 0x00, 0x0C, 0x1C, 0x30, 0x30, 0x7C, 0xFE, 0xC7, 0xC3, 0xC3, 0xC3, 0x7E, 0x3C, /* 6 */
/*37*/ 0x00, 0xFF, 0xFF, 0x03, 0x06, 0x0C, 0x18, 0x18, 0x30, 0x30, 0x30, 0x30, 0x30, /* 7 */
/*38*/ 0x3C, 0x7E, 0x66, 0x42, 0x66, 0x3C, 0x3C, 0x66, 0xC3, 0xC3, 0xC3, 0x7E, 0x3C, /* 8 */
/*39*/ 0x3C, 0x7E, 0xE7, 0xC3, 0xC3, 0xC3, 0xE3, 0x7E, 0x1E, 0x0C, 0x18, 0x30, 0x60, /* 9 */
};