kdchambers / fontana

OpenType and TrueType font loading and rasterizing library
MIT License
9 stars 1 forks source link

Implement Kerning #1

Open kdchambers opened 1 year ago

kdchambers commented 1 year ago

I regressed Kerning support due to the aggressive API changes. All the hard stuff should already be in place but it should be verified to working by comparing against Harfbuzz results and using a couple of different fonts.

kdchambers commented 1 year ago

This is turning out to be troublesome for Harfbuzz. I've tried various fonts and hb_buffer_get_glyph_positions is not returning values with kerning. Drawing a string such as "Y.YWYAYHYTY", x_advance will always return the same value for 'Y'.

I tried enabling additional harfbuzz features but couldn't elicit a change. Code for reference.

const gpos_feature = harfbuzz.Feature {
    .tag = harfbuzz.makeTag("GPOS"),
    .value = 1,
    .start = harfbuzz.feature_global_start,
    .end = harfbuzz.feature_global_end,
};
const kern_feature = harfbuzz.Feature {
    .tag = harfbuzz.makeTag("kern"),
    .value = 1,
    .start = harfbuzz.feature_global_start,
    .end = harfbuzz.feature_global_end,
};
const features = [_]harfbuzz.Feature {
    gpos_feature,
    kern_feature,
};
impl.hbShapeFn(impl.harfbuzz_font, buffer, &features, features.len);