DVUI

kern

Parameters

#
fce:*Entry
*Entry
codepoint1:u32
u32
codepoint2:u32
u32

Source

Implementation

#
pub fn kern(fce: *Entry, codepoint1: u32, codepoint2: u32) f32 {
            if (impl == .FreeType) {
                const index1 = c.FT_Get_Char_Index(fce.face, codepoint1);
                const index2 = c.FT_Get_Char_Index(fce.face, codepoint2);
                var k: c.FT_Vector = undefined;
                FreeType.intToError(c.FT_Get_Kerning(fce.face, index1, index2, c.FT_KERNING_DEFAULT, &k)) catch |err| {
                    dvui.log.warn("renderText freetype error {any} trying to FT_Get_Kerning font {s} codepoints {d} {d}\n", .{ err, fce.name, codepoint1, codepoint2 });
                    k.x = 0;
                    k.y = 0;
                };

                return @as(f32, @floatFromInt(k.x)) / 64.0;
            } else {
                const kern_adv: c_int = c.stbtt_GetCodepointKernAdvance(&fce.face, @as(c_int, @intCast(codepoint1)), @as(c_int, @intCast(codepoint2)));
                return fce.scaleFactor * @as(f32, @floatFromInt(kern_adv));
            }
        }