still working on my dvi-to-png program in Go ([1]), I am trying to shoehorn face metrics from pk and tfm into this structure from "the" Go font library:
package font // import "golang.org/x/image/font"
// Metrics holds the metrics for a Face. A visual depiction is at
// https://developer.apple.com/library/mac/documentation/TextFonts/Conceptual/CocoaTextArchitecture/Art/glyph_metrics_2x.png
type Metrics struct {
// Height is the recommended amount of vertical space between two lines of
// text.
Height fixed.Int26_6
// Ascent is the distance from the top of a line to its baseline.
Ascent fixed.Int26_6
// Descent is the distance from the bottom of a line to its baseline. The
// value is typically positive, even though a descender goes below the
// baseline.
Descent fixed.Int26_6
// XHeight is the distance from the top of non-ascending lowercase letters
// to the baseline.
XHeight fixed.Int26_6
// CapHeight is the distance from the top of uppercase letters to the
// baseline.
CapHeight fixed.Int26_6
// CaretSlope is the slope of a caret as a vector with the Y axis pointing up.
// The slope {0, 1} is the vertical caret.
CaretSlope image.Point
}

I could extract from the TFM data:
XHeight(ie:param[5],x_height)CaretSlope(ie:param[1],slant)
am I right in assuming there's no direct equivalent for the other quantities?
at least not from directly the tfm nor pk data.
I guess they could be inferred by going through all ASCII letters and applying some heuristics:
A...Z: largestheightassumed to correspond toCapHeighta...z: largestheightassumed to correspond toAscenta...z: largestdepthassumed to correspond toDescent
assuming the above heuristics holds, I would still be missing Height (or "Line height" in the picture above).
any ideas?
EDIT: well, it seems the heuristics for Ascent and Descent lead to bogus results (smaller values than what is expected). the one for CapHeight gives a reasonable result. (smaller, but ball park-ishly ok)
except if there is a way to get at these from TFM and/or PK font files... ?
– sbinet Sep 11 '21 at 11:04