From 50dc752f75cebb2e03d566f278b319cd8e828455 Mon Sep 17 00:00:00 2001 From: gildea Date: Mon, 7 Feb 1994 14:34:44 +0000 Subject: ignore non-existent chars when computing font metrics. XBUG #5938, #6363. --- xc/lib/font/bitmap/bitmaputil.c | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) (limited to 'xc/lib/font/bitmap') diff --git a/xc/lib/font/bitmap/bitmaputil.c b/xc/lib/font/bitmap/bitmaputil.c index af10b2d76..9e4f74823 100644 --- a/xc/lib/font/bitmap/bitmaputil.c +++ b/xc/lib/font/bitmap/bitmaputil.c @@ -1,5 +1,5 @@ /* - * $XConsortium: bitmaputil.c,v 1.3 91/05/31 14:23:06 rws Exp $ + * $XConsortium: bitmaputil.c,v 1.4 93/09/17 18:26:57 gildea Exp $ * * Copyright 1990 Massachusetts Institute of Technology * @@ -44,6 +44,18 @@ MINSHORT, MINSHORT, MINSHORT, MINSHORT, MINSHORT, 0x0000}; if (maxbounds->field < (ci)->field) \ maxbounds->field = (ci)->field; +#define COMPUTE_MINMAX(ci) \ + if ((ci)->ascent != -(ci)->descent || \ + (ci)->leftSideBearing != (ci)->rightSideBearing || \ + (ci)->characterWidth) \ + { \ + MINMAX(ascent, (ci)); \ + MINMAX(descent, (ci)); \ + MINMAX(leftSideBearing, (ci)); \ + MINMAX(rightSideBearing, (ci)); \ + MINMAX(characterWidth, (ci)); \ + } + void bitmapComputeFontBounds(pFont) FontPtr pFont; @@ -73,11 +85,7 @@ bitmapComputeFontBounds(pFont) maxOverlap = MINSHORT; nchars = bitmapFont->num_chars; for (i = 0, ci = bitmapFont->metrics; i < nchars; i++, ci++) { - MINMAX(ascent, &ci->metrics); - MINMAX(descent, &ci->metrics); - MINMAX(leftSideBearing, &ci->metrics); - MINMAX(rightSideBearing, &ci->metrics); - MINMAX(characterWidth, &ci->metrics); + COMPUTE_MINMAX(&ci->metrics); if (ci->metrics.characterWidth < 0) numneg++; else @@ -104,11 +112,7 @@ bitmapComputeFontBounds(pFont) for (c = pFont->info.firstCol; c <= pFont->info.lastCol; c++) { ci = *pci++; if (ci) { - MINMAX(ascent, &ci->metrics); - MINMAX(descent, &ci->metrics); - MINMAX(leftSideBearing, &ci->metrics); - MINMAX(rightSideBearing, &ci->metrics); - MINMAX(characterWidth, &ci->metrics); + COMPUTE_MINMAX(&ci->metrics); if (ci->metrics.characterWidth < 0) numneg++; else @@ -165,11 +169,7 @@ bitmapComputeFontInkBounds(pFont) *maxbounds = initMaxMetrics; nchars = bitmapFont->num_chars; for (i = 0, ci = bitmapFont->ink_metrics; i < nchars; i++, ci++) { - MINMAX(ascent, ci); - MINMAX(descent, ci); - MINMAX(leftSideBearing, ci); - MINMAX(rightSideBearing, ci); - MINMAX(characterWidth, ci); + COMPUTE_MINMAX(ci); minbounds->attributes &= ci->attributes; maxbounds->attributes |= ci->attributes; } @@ -185,11 +185,7 @@ bitmapComputeFontInkBounds(pFont) if (cit) { offset = cit - bitmapFont->metrics; ci = &bitmapFont->ink_metrics[offset]; - MINMAX(ascent, ci); - MINMAX(descent, ci); - MINMAX(leftSideBearing, ci); - MINMAX(rightSideBearing, ci); - MINMAX(characterWidth, ci); + COMPUTE_MINMAX(ci); minbounds->attributes &= ci->attributes; maxbounds->attributes |= ci->attributes; } -- cgit v1.2.3