summaryrefslogtreecommitdiff
path: root/struct.c
diff options
context:
space:
mode:
Diffstat (limited to 'struct.c')
-rw-r--r--struct.c89
1 files changed, 0 insertions, 89 deletions
diff --git a/struct.c b/struct.c
index 0317673..01f5e4d 100644
--- a/struct.c
+++ b/struct.c
@@ -483,92 +483,3 @@ glyphMetrics(FontPtr font, int code,
return -1;
}
-
-void
-fontMetrics(FontPtr font, MetricsPtr metrics)
-{
- int i, rc;
- double sumAwidth = 0;
- unsigned count = 0;
-
- metrics->height = UNDEF /* TODO */;
- metrics->maxAwidth = 0;
- metrics->maxX = -10000 * TWO_SIXTEENTH;
- metrics->maxY = -10000 * TWO_SIXTEENTH;
- metrics->minX = 10000 * TWO_SIXTEENTH;
- metrics->minY = 10000 * TWO_SIXTEENTH;
- metrics->ascent = UNDEF;
- metrics->descent = UNDEF;
- metrics->underlinePosition = UNDEF;
- metrics->underlineThickness = UNDEF;
-
- for(i = 0; i < FONT_CODES; i++) {
- int awidth, x0, y0, x1, y1;
- rc = glyphMetrics(font, i, &awidth, &x0, &y0, &x1, &y1);
- if(rc < 0)
- continue;
-
- if(awidth > metrics->maxAwidth) metrics->maxAwidth = awidth;
- if(x0 < metrics->minX) metrics->minX = x0;
- if(y0 < metrics->minY) metrics->minY = y0;
- if(x1 > metrics->maxX) metrics->maxX = x1;
- if(y1 > metrics->maxY) metrics->maxY = y1;
-
- if(awidth > 0) {
- sumAwidth += awidth;
- count++;
- }
- }
-
- if (count) metrics->awidth = sumAwidth / count;
-
- if(font->pxMetrics.ascent == UNDEF)
- metrics->ascent = metrics->maxY;
- else
- metrics->ascent =
- font->pxMetrics.ascent
- * TWO_SIXTEENTH / font->pxMetrics.height;
-
- if(font->pxMetrics.descent == UNDEF)
- metrics->descent = metrics->minY;
- else
- metrics->descent =
- font->pxMetrics.descent
- * TWO_SIXTEENTH / font->pxMetrics.height;
-
- if(font->pxMetrics.capHeight == UNDEF)
- /* TODO get ascent of letter 'X' - how to do lookups of ascii codes ? */
- metrics->capHeight = metrics->ascent;
- else
- metrics->capHeight =
- font->pxMetrics.capHeight
- * TWO_SIXTEENTH / font->pxMetrics.height;
-
- if(font->pxMetrics.xHeight == UNDEF)
- /* TODO get ascent of letter 'x' - how to do lookups of ascii codes ? */
- metrics->xHeight = metrics->ascent * 2 / 3;
- else
- metrics->xHeight =
- font->pxMetrics.xHeight
- * TWO_SIXTEENTH / font->pxMetrics.height;
-
- if(font->pxMetrics.underlinePosition == UNDEF)
- metrics->underlinePosition = - metrics->descent * 2;
- else
- metrics->underlinePosition =
- font->pxMetrics.underlinePosition
- * TWO_SIXTEENTH / font->pxMetrics.height;
-
- if(font->pxMetrics.underlineThickness == UNDEF)
- /* TODO: this could be refined according to
- * X Logical Font Description Conventions (xlfd.txt)
- * by also considering the font weight. */
- /* make sure thickness is at least one pixel. */
- metrics->underlineThickness =
- TWO_SIXTEENTH
- / (font->pxMetrics.height < 9 ? font->pxMetrics.height : 9);
- else
- metrics->underlineThickness =
- font->pxMetrics.underlineThickness
- * TWO_SIXTEENTH / font->pxMetrics.height;
-}