diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2023-06-28 17:29:32 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2023-06-28 17:29:32 +0000 |
commit | 23ce26f64c34e30951ad9ade2151552ed77e7357 (patch) | |
tree | d73b31a0c2f7c7be4a69f8a8e84e00dd39c432b5 /lib/libpbmfont1.c | |
parent | 1b6e51a266008348ad93ed8b6ac9ec91b5024fea (diff) | |
download | netpbm-mirror-23ce26f64c34e30951ad9ade2151552ed77e7357.tar.gz netpbm-mirror-23ce26f64c34e30951ad9ade2151552ed77e7357.tar.xz netpbm-mirror-23ce26f64c34e30951ad9ade2151552ed77e7357.zip |
promote Advanced to Stable
git-svn-id: http://svn.code.sf.net/p/netpbm/code/stable@4558 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'lib/libpbmfont1.c')
-rw-r--r-- | lib/libpbmfont1.c | 71 |
1 files changed, 38 insertions, 33 deletions
diff --git a/lib/libpbmfont1.c b/lib/libpbmfont1.c index 2d269da7..a76d0e6b 100644 --- a/lib/libpbmfont1.c +++ b/lib/libpbmfont1.c @@ -47,7 +47,7 @@ The characters in the border you see are irrelevant except for character size compuations. The 12 x 8 array in the center is the font. The top left character there belongs to code point - 0, and the code points increase in standard reading order, so + 32, and the code points increase in standard reading order, so the bottom right character is code point 127. You can't define code points < 32 or > 127 with this font format. @@ -184,13 +184,13 @@ computeCharacterSize(const bit ** const font, -struct font* +struct font * pbm_dissectfont(const bit ** const fontsheet, unsigned int const frows, unsigned int const fcols) { /*---------------------------------------------------------------------------- - Dissect PBM sheet font data, create a font structre, - load bitmap data into it. + Dissect PBM sheet font data, create a font structure, load bitmap data into + it. Return value is a pointer to the newly created font structure @@ -205,7 +205,7 @@ pbm_dissectfont(const bit ** const fontsheet, just a matter of filling in all the coordinates. Struct font has fields 'oldfont', 'fcols', 'frows' for backward - compability. If there is any need to load data stored in this format + compatibility. If there is any need to load data stored in this format feed the above three, in order, as arguments to this function: pbm_dissectfont(oldfont, fcols, frows); @@ -222,56 +222,61 @@ pbm_dissectfont(const bit ** const fontsheet, unsigned int charWidth, charHeight; /* Maximum dimensions of glyph itself, inside its cell */ - int row, col, ch, r, c, i; - struct font * fn; + unsigned int row, col; + int ch; + unsigned int i; + struct font * fontP; computeCharacterSize(fontsheet, fcols, frows, &cellWidth, &cellHeight, &charWidth, &charHeight); /* Now convert to a general font */ - MALLOCVAR(fn); - if (fn == NULL) + MALLOCVAR(fontP); + if (fontP == NULL) pm_error("out of memory allocating font structure"); - fn->maxwidth = charWidth; - fn->maxheight = charHeight; - fn->x = fn->y = 0; + fontP->maxwidth = charWidth; + fontP->maxheight = charHeight; + fontP->x = fontP->y = 0; - fn->oldfont = fontsheet; - fn->frows = frows; - fn->fcols = fcols; + fontP->oldfont = fontsheet; + fontP->frows = frows; + fontP->fcols = fcols; /* Now fill in the 0,0 coords. */ row = cellHeight * 2; col = cellWidth * 2; /* Load individual glyphs */ - for ( ch = 0; ch < nCharsInFont; ++ch ) { + for (ch = 0; ch < nCharsInFont; ++ch) { /* Allocate memory separately for each glyph. pbm_loadbdffont2() does this in exactly the same manner. */ - struct glyph * const glyph = + struct glyph * const glyphP = (struct glyph *) malloc (sizeof (struct glyph)); - char * const bmap = (char*) malloc(fn->maxwidth * fn->maxheight); + char * const bmap = (char*) malloc(fontP->maxwidth * fontP->maxheight); - if ( bmap == NULL || glyph == NULL ) - pm_error( "out of memory allocating glyph data" ); + unsigned int r; - glyph->width = fn->maxwidth; - glyph->height = fn->maxheight; - glyph->x = glyph->y = 0; - glyph->xadd = cellWidth; + if (bmap == NULL || glyphP == NULL) + pm_error( "out of memory allocating glyph data" ); - for ( r = 0; r < glyph->height; ++r ) - for ( c = 0; c < glyph->width; ++c ) - bmap[r * glyph->width + c] = fontsheet[row + r][col + c]; + glyphP->width = fontP->maxwidth; + glyphP->height = fontP->maxheight; + glyphP->x = glyphP->y = 0; + glyphP->xadd = cellWidth; - glyph->bmap = bmap; - fn->glyph[firstCodePoint + ch] = glyph; + for (r = 0; r < glyphP->height; ++r) { + unsigned int c; + for (c = 0; c < glyphP->width; ++c) + bmap[r * glyphP->width + c] = fontsheet[row + r][col + c]; + } + glyphP->bmap = bmap; + fontP->glyph[firstCodePoint + ch] = glyphP; col += cellWidth; - if ( col >= cellWidth * 14 ) { + if (col >= cellWidth * 14) { col = cellWidth * 2; row += cellHeight; } @@ -279,12 +284,12 @@ pbm_dissectfont(const bit ** const fontsheet, /* Initialize all remaining character positions to "undefined." */ for (i = 0; i < firstCodePoint; ++i) - fn->glyph[i] = NULL; + fontP->glyph[i] = NULL; for (i = firstCodePoint + nCharsInFont; i <= PM_FONT_MAXGLYPH; ++i) - fn->glyph[i] = NULL; + fontP->glyph[i] = NULL; - return fn; + return fontP; } |