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

View file

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

View file

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