coretext: calculate units per em/point

This commit is contained in:
Mitchell Hashimoto
2023-03-04 11:29:40 -08:00
parent a3401d9690
commit 2a1cbb4f21
2 changed files with 12 additions and 0 deletions

View File

@ -130,6 +130,14 @@ pub const Font = opaque {
pub fn getUnderlineThickness(self: *Font) f64 { pub fn getUnderlineThickness(self: *Font) f64 {
return c.CTFontGetUnderlineThickness(@ptrCast(self)); return c.CTFontGetUnderlineThickness(@ptrCast(self));
} }
pub fn getUnitsPerEm(self: *Font) u32 {
return c.CTFontGetUnitsPerEm(@ptrCast(c.CTFontRef, self));
}
pub fn getSize(self: *Font) f64 {
return c.CTFontGetSize(@ptrCast(c.CTFontRef, self));
}
}; };
pub const FontOrientation = enum(c_uint) { pub const FontOrientation = enum(c_uint) {

View File

@ -317,6 +317,10 @@ pub const Face = struct {
const strikethrough_position = cell_baseline * 0.6; const strikethrough_position = cell_baseline * 0.6;
const strikethrough_thickness = underline_thickness; const strikethrough_thickness = underline_thickness;
// Note: is this useful?
// const units_per_em = ct_font.getUnitsPerEm();
// const units_per_point = @intToFloat(f64, units_per_em) / ct_font.getSize();
// std.log.warn("width={d}, height={d} baseline={d} underline_pos={d} underline_thickness={d}", .{ // std.log.warn("width={d}, height={d} baseline={d} underline_pos={d} underline_thickness={d}", .{
// cell_width, // cell_width,
// cell_height, // cell_height,