mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-18 21:40:29 +00:00
font: freetype supports font variation settings
This commit is contained in:
@@ -57,6 +57,11 @@ pub fn initMemoryFace(self: Library, data: []const u8, index: i32) Error!Face {
|
||||
return face;
|
||||
}
|
||||
|
||||
/// Call when you're done with a loaded MM var.
|
||||
pub fn doneMMVar(self: Library, mm: *c.FT_MM_Var) void {
|
||||
_ = c.FT_Done_MM_Var(self.handle, mm);
|
||||
}
|
||||
|
||||
pub const Version = struct {
|
||||
major: i32,
|
||||
minor: i32,
|
||||
|
||||
@@ -24,6 +24,12 @@ pub const Face = struct {
|
||||
return c.FT_HAS_COLOR(self.handle);
|
||||
}
|
||||
|
||||
/// A macro that returns true whenever a face object contains some
|
||||
/// multiple masters.
|
||||
pub fn hasMultipleMasters(self: Face) bool {
|
||||
return c.FT_HAS_MULTIPLE_MASTERS(self.handle);
|
||||
}
|
||||
|
||||
/// A macro that returns true whenever a face object contains a scalable
|
||||
/// font face (true for TrueType, Type 1, Type 42, CID, OpenType/CFF,
|
||||
/// and PFR font formats).
|
||||
@@ -95,6 +101,33 @@ pub const Face = struct {
|
||||
const res = c.FT_Get_Sfnt_Name(self.handle, @intCast(i), &name);
|
||||
return if (intToError(res)) |_| name else |err| err;
|
||||
}
|
||||
|
||||
/// Retrieve the font variation descriptor for a font.
|
||||
pub fn getMMVar(self: Face) Error!*c.FT_MM_Var {
|
||||
var result: *c.FT_MM_Var = undefined;
|
||||
const res = c.FT_Get_MM_Var(self.handle, @ptrCast(&result));
|
||||
return if (intToError(res)) |_| result else |err| err;
|
||||
}
|
||||
|
||||
/// Get the design coordinates of the currently selected interpolated font.
|
||||
pub fn getVarDesignCoordinates(self: Face, coords: []c.FT_Fixed) Error!void {
|
||||
const res = c.FT_Get_Var_Design_Coordinates(
|
||||
self.handle,
|
||||
@intCast(coords.len),
|
||||
coords.ptr,
|
||||
);
|
||||
return intToError(res);
|
||||
}
|
||||
|
||||
/// Choose an interpolated font design through design coordinates.
|
||||
pub fn setVarDesignCoordinates(self: Face, coords: []c.FT_Fixed) Error!void {
|
||||
const res = c.FT_Set_Var_Design_Coordinates(
|
||||
self.handle,
|
||||
@intCast(coords.len),
|
||||
coords.ptr,
|
||||
);
|
||||
return intToError(res);
|
||||
}
|
||||
};
|
||||
|
||||
/// An enumeration to specify indices of SFNT tables loaded and parsed by
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_TRUETYPE_TABLES_H
|
||||
#include <freetype/ftmm.h>
|
||||
#include <freetype/ftsnames.h>
|
||||
#include <freetype/ttnameid.h>
|
||||
|
||||
Reference in New Issue
Block a user