diff options
| author | tslil clingman <> | 2021-10-27 15:37:28 -0400 |
|---|---|---|
| committer | tslil clingman <> | 2021-10-27 15:37:28 -0400 |
| commit | 48dee0817f5fe8c09a085f0150e0c6b4a699ab7c (patch) | |
| tree | d6ab0a54f2260cb73c79e00ca1489c034f555f09 /src/sfml/graphics/Font.zig | |
| parent | 486935299e4b7e097754611d9f8dd40003351ae4 (diff) | |
Update SFML wrapper
Diffstat (limited to 'src/sfml/graphics/Font.zig')
| -rw-r--r-- | src/sfml/graphics/Font.zig | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/src/sfml/graphics/Font.zig b/src/sfml/graphics/Font.zig index 78bd5a6..ecc1a56 100644 --- a/src/sfml/graphics/Font.zig +++ b/src/sfml/graphics/Font.zig @@ -11,15 +11,41 @@ pub fn createFromFile(path: [:0]const u8) !Font { var font = sf.c.sfFont_createFromFile(path); if (font == null) return sf.Error.resourceLoadingError; - return Font{ .ptr = font.? }; + return Font{ ._ptr = font.? }; } /// Destroys a font -pub fn destroy(self: Font) void { - sf.c.sfFont_destroy(self.ptr); +pub fn destroy(self: *Font) void { + sf.c.sfFont_destroy(self._ptr); } +/// Gets the family name of this font +/// Normally, this is done through getInfo, but as info only contains this data, this makes more sense +pub fn getFamily(self: Font) [*:0]const u8 { + return sf.c.sfFont_getInfo(self._ptr).family; +} + +/// Gets the kerning offset of two glyphs +pub fn getKerning(self: Font, first: u32, second: u32, character_size: usize) f32 { + return sf.c.sfFont_getKerning(self._ptr, first, second, @intCast(c_uint, character_size)); +} + +/// Gets the default spacing between two lines +pub fn getLineSpacing(self: Font, character_size: usize) f32 { + return sf.c.sfFont_getLineSpacing(self._ptr, @intCast(c_uint, character_size)); +} + +/// Gets the vertical offset of the underline +pub fn getUnderlinePosition(self: Font, character_size: usize) f32 { + return sf.c.sfFont_getUnderlinePosition(self._ptr, @intCast(c_uint, character_size)); +} +/// Gets the underline thickness +pub fn getUnderlineThickness(self: Font, character_size: usize) f32 { + return sf.c.sfFont_getUnderlineThickness(self._ptr, @intCast(c_uint, character_size)); +} + +pub const getGlyph = @compileError("Function is not implemented yet."); pub const initFromMemory = @compileError("Function is not implemented yet."); pub const initFromStream = @compileError("Function is not implemented yet."); /// Pointer to the csfml font -ptr: *sf.c.sfFont, +_ptr: *sf.c.sfFont, |
