freetype: reduce code size

This commit is contained in:
Ali Chraghi 2022-05-26 03:20:00 +04:30 committed by Stephen Gutekanst
parent 643753c80a
commit a1f756b4cd
3 changed files with 9 additions and 15 deletions

View file

@ -239,19 +239,17 @@ pub fn numGlyphs(self: Face) i64 {
}
pub fn familyName(self: Face) ?[:0]const u8 {
const family = self.handle.*.family_name;
return if (family == null)
null
return if (self.handle.*.family_name) |family|
std.mem.span(family)
else
std.mem.span(family);
null;
}
pub fn styleName(self: Face) ?[:0]const u8 {
const style = self.handle.*.style_name;
return if (style == null)
null
return if (self.handle.*.style_name) |style_name|
std.mem.span(style_name)
else
std.mem.span(style);
null;
}
pub fn styleFlags(self: Face) StyleFlags {
@ -267,9 +265,8 @@ pub fn sizeMetrics(self: Face) ?SizeMetrics {
}
pub fn postscriptName(self: Face) ?[:0]const u8 {
const face_name = c.FT_Get_Postscript_Name(self.handle);
return if (face_name == null)
null
return if (c.FT_Get_Postscript_Name(self.handle)) |face_name|
std.mem.span(face_name)
else
std.mem.span(face_name);
null;
}

View file

@ -9,7 +9,6 @@ pub const StrokerLineCap = enum(u2) {
round = c.FT_STROKER_LINECAP_ROUND,
square = c.FT_STROKER_LINECAP_SQUARE,
};
pub const StrokerLineJoin = enum(u2) {
round = c.FT_STROKER_LINEJOIN_ROUND,
bevel = c.FT_STROKER_LINEJOIN_BEVEL,

View file

@ -18,7 +18,6 @@ pub const BBox = extern struct {
xMax: c_long,
yMax: c_long,
};
pub const RenderMode = enum(u3) {
normal = c.FT_RENDER_MODE_NORMAL,
light = c.FT_RENDER_MODE_LIGHT,
@ -27,7 +26,6 @@ pub const RenderMode = enum(u3) {
lcd_v = c.FT_RENDER_MODE_LCD_V,
sdf = c.FT_RENDER_MODE_SDF,
};
pub const OpenFlags = packed struct {
memory: bool = false,
stream: bool = false,