Leptonica
1.54
|
Макросы | |
#define | DEBUG_BASELINE 0 |
#define | DEBUG_CHARS 0 |
#define | DEBUG_FONT_GEN 0 |
Функции | |
static l_int32 | pixGetTextBaseline (PIX *pixs, l_int32 *tab8, l_int32 *py) |
static l_int32 | bmfMakeAsciiTables (L_BMF *bmf) |
L_BMF * | bmfCreate (const char *dir, l_int32 fontsize) |
void | bmfDestroy (L_BMF **pbmf) |
PIX * | bmfGetPix (L_BMF *bmf, char chr) |
l_int32 | bmfGetWidth (L_BMF *bmf, char chr, l_int32 *pw) |
l_int32 | bmfGetBaseline (L_BMF *bmf, char chr, l_int32 *pbaseline) |
PIXA * | pixaGetFont (const char *dir, l_int32 fontsize, l_int32 *pbl0, l_int32 *pbl1, l_int32 *pbl2) |
l_int32 | pixaSaveFont (const char *indir, const char *outdir, l_int32 fontsize) |
PIXA * | pixaGenerateFontFromFile (const char *dir, l_int32 fontsize, l_int32 *pbl0, l_int32 *pbl1, l_int32 *pbl2) |
PIXA * | pixaGenerateFontFromString (l_int32 fontsize, l_int32 *pbl0, l_int32 *pbl1, l_int32 *pbl2) |
PIXA * | pixaGenerateFont (PIX *pixs, l_int32 fontsize, l_int32 *pbl0, l_int32 *pbl1, l_int32 *pbl2) |
Переменные | |
static const l_float32 | VERT_FRACT_SEP = 0.3 |
#define DEBUG_BASELINE 0 |
#define DEBUG_CHARS 0 |
#define DEBUG_FONT_GEN 0 |
void bmfDestroy | ( | L_BMF ** | pbmf | ) |
Input: &bmf (<set to="" null>="">) Return: void
l_int32 bmfGetBaseline | ( | L_BMF * | bmf, |
char | chr, | ||
l_int32 * | pbaseline | ||
) |
Input: bmf chr (should be one of the 95 supported bitmaps) &baseline (<return>; distance below UL corner of bitmap char) Return: 0 if OK, 1 on error
Input: bmf chr (should be one of the 95 supported printable bitmaps) Return: pix (clone of pix in bmf), or null on error
l_int32 bmfGetWidth | ( | L_BMF * | bmf, |
char | chr, | ||
l_int32 * | pw | ||
) |
Input: bmf chr (should be one of the 95 supported bitmaps) &w (<return> character width; -1 if not printable) Return: 0 if OK, 1 on error
static l_int32 bmfMakeAsciiTables | ( | L_BMF * | bmf | ) | [static] |
bmfMakeAsciiTables
Input: bmf Return: 0 if OK, 1 on error
Notes: (1) This makes three tables, each of size 128, as follows:
PIXA* pixaGenerateFont | ( | PIX * | pixs, |
l_int32 | fontsize, | ||
l_int32 * | pbl0, | ||
l_int32 * | pbl1, | ||
l_int32 * | pbl2 | ||
) |
Input: pix (of 95 characters in 3 rows) fontsize (4, 6, 8, ... , 20, in pts at 300 ppi) &bl1 (<return> baseline of row 1) &bl2 (<return> baseline of row 2) &bl3 (<return> baseline of row 3) Return: pixa of font bitmaps for 95 characters, or null on error
Notes: (1) This does all the work. See pixaGenerateFontFromFile() for an overview. (2) The pix is for one of the 9 fonts. is only used here for debugging.
PIXA* pixaGenerateFontFromFile | ( | const char * | dir, |
l_int32 | fontsize, | ||
l_int32 * | pbl0, | ||
l_int32 * | pbl1, | ||
l_int32 * | pbl2 | ||
) |
Input: dir (directory holding image of character set) fontsize (4, 6, 8, ... , 20, in pts at 300 ppi) &bl1 (<return> baseline of row 1) &bl2 (<return> baseline of row 2) &bl3 (<return> baseline of row 3) Return: pixa of font bitmaps for 95 characters, or null on error
These font generation functions use 9 sets, each with bitmaps of 94 ascii characters, all in Palatino-Roman font. Each input bitmap has 3 rows of characters. The range of ascii values in each row is as follows: row 0: 32-57 (32 is a space) row 1: 58-91 (92, '\', is not represented in this font) row 2: 93-126 We LR flip the '/' char to generate a bitmap for the missing '\' character, so that we have representations of all 95 printable chars.
Typically, use pixaGetFont() to generate the character bitmaps in memory for a bmf. This will simply access the bitmap files in a serialized pixa that were produced in prog/genfonts.c using this function.
PIXA* pixaGenerateFontFromString | ( | l_int32 | fontsize, |
l_int32 * | pbl0, | ||
l_int32 * | pbl1, | ||
l_int32 * | pbl2 | ||
) |
Input: fontsize (4, 6, 8, ... , 20, in pts at 300 ppi) &bl1 (<return> baseline of row 1) &bl2 (<return> baseline of row 2) &bl3 (<return> baseline of row 3) Return: pixa of font bitmaps for 95 characters, or null on error
Notes: (1) See pixaGenerateFontFromFile() for details.
PIXA* pixaGetFont | ( | const char * | dir, |
l_int32 | fontsize, | ||
l_int32 * | pbl0, | ||
l_int32 * | pbl1, | ||
l_int32 * | pbl2 | ||
) |
Input: dir (directory holding pixa of character set) fontsize (4, 6, 8, ... , 20) &bl1 (<return> baseline of row 1) &bl2 (<return> baseline of row 2) &bl3 (<return> baseline of row 3) Return: pixa of font bitmaps for 95 characters, or null on error
Notes: (1) This reads a pre-computed pixa file with the 95 ascii chars.
l_int32 pixaSaveFont | ( | const char * | indir, |
const char * | outdir, | ||
l_int32 | fontsize | ||
) |
static l_int32 pixGetTextBaseline | ( | PIX * | pixs, |
l_int32 * | tab8, | ||
l_int32 * | py | ||
) | [static] |
Input: pixs (1 bpp, one textline character set) tab8 (<optional> pixel sum table) &y (<return> baseline value) Return: 0 if OK, 1 on error
Notes: (1) Method: find the largest difference in pixel sums from one raster line to the next one below it. The baseline is the upper raster line for the pair of raster lines that maximizes this function.
const l_float32 VERT_FRACT_SEP = 0.3 [static] |