pk:pk 字体的高度、上升、下降和大写高度

pk:pk 字体的高度、上升、下降和大写高度

仍在用dvi-to-pngGo 语言编写程序([1]),我试图将人脸指标从Go 字体库的这个结构中强行塞入pk其中:tfm

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
}

图片

我可以从TFM数据中提取:

  • XHeightIE: param[5]x_height
  • CaretSlopeIE: param[1]slant

我假设其他数量没有直接等价物,对吗?至少不是直接从tfmnorpk数据中得出的。我猜可以通过遍历所有 ASCII 字母并应用一些启发式方法来推断它们:

  • A...Z:最大height假设对应于CapHeight
  • a...z:最大height假设对应于Ascent
  • a...z:最大depth假设对应于Descent

假设上述启发式方法成立,我仍然会缺失Height(或上图中的“行高”)。

有任何想法吗?


编辑:好吧,看来Ascent和的启发式方法Descent会导致错误的结果(比预期更小的值)。的启发式方法CapHeight给出了一个合理的结果。(较小,但大致还可以)

相关内容