mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-21 19:26:09 +03:00
refactor: define FreetypeLoadFlags
struct and default in font.face
This commit is contained in:
@ -11,18 +11,6 @@ pub const url = @import("config/url.zig");
|
|||||||
pub const FileFormatter = formatter.FileFormatter;
|
pub const FileFormatter = formatter.FileFormatter;
|
||||||
pub const entryFormatter = formatter.entryFormatter;
|
pub const entryFormatter = formatter.entryFormatter;
|
||||||
pub const formatEntry = formatter.formatEntry;
|
pub const formatEntry = formatter.formatEntry;
|
||||||
pub const FreetypeLoadFlags = switch (options.backend) {
|
|
||||||
.freetype,
|
|
||||||
.fontconfig_freetype,
|
|
||||||
.coretext_freetype,
|
|
||||||
=> Config.FreetypeLoadFlags,
|
|
||||||
|
|
||||||
.coretext,
|
|
||||||
.coretext_harfbuzz,
|
|
||||||
.coretext_noshape,
|
|
||||||
.web_canvas,
|
|
||||||
=> void,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Field types
|
// Field types
|
||||||
pub const ClipboardAccess = Config.ClipboardAccess;
|
pub const ClipboardAccess = Config.ClipboardAccess;
|
||||||
|
@ -452,18 +452,7 @@ pub const LoadOptions = struct {
|
|||||||
/// for this is owned by the user and is not freed by the collection.
|
/// for this is owned by the user and is not freed by the collection.
|
||||||
metric_modifiers: Metrics.ModifierSet = .{},
|
metric_modifiers: Metrics.ModifierSet = .{},
|
||||||
|
|
||||||
freetype_load_flags: config.FreetypeLoadFlags = switch (font.options.backend) {
|
freetype_load_flags: font.face.FreetypeLoadFlags = font.face.freetype_load_flags_default,
|
||||||
.freetype,
|
|
||||||
.fontconfig_freetype,
|
|
||||||
.coretext_freetype,
|
|
||||||
=> .{},
|
|
||||||
|
|
||||||
.coretext,
|
|
||||||
.coretext_harfbuzz,
|
|
||||||
.coretext_noshape,
|
|
||||||
.web_canvas,
|
|
||||||
=> {},
|
|
||||||
},
|
|
||||||
|
|
||||||
pub fn deinit(self: *LoadOptions, alloc: Allocator) void {
|
pub fn deinit(self: *LoadOptions, alloc: Allocator) void {
|
||||||
_ = self;
|
_ = self;
|
||||||
|
@ -428,7 +428,7 @@ pub const DerivedConfig = struct {
|
|||||||
@"adjust-strikethrough-position": ?Metrics.Modifier,
|
@"adjust-strikethrough-position": ?Metrics.Modifier,
|
||||||
@"adjust-strikethrough-thickness": ?Metrics.Modifier,
|
@"adjust-strikethrough-thickness": ?Metrics.Modifier,
|
||||||
@"adjust-cursor-thickness": ?Metrics.Modifier,
|
@"adjust-cursor-thickness": ?Metrics.Modifier,
|
||||||
@"freetype-load-flags": configpkg.FreetypeLoadFlags,
|
@"freetype-load-flags": font.face.FreetypeLoadFlags,
|
||||||
|
|
||||||
/// Initialize a DerivedConfig. The config should be either a
|
/// Initialize a DerivedConfig. The config should be either a
|
||||||
/// config.Config or another DerivedConfig to clone from.
|
/// config.Config or another DerivedConfig to clone from.
|
||||||
@ -514,18 +514,7 @@ pub const Key = struct {
|
|||||||
/// font grid.
|
/// font grid.
|
||||||
font_size: DesiredSize = .{ .points = 12 },
|
font_size: DesiredSize = .{ .points = 12 },
|
||||||
|
|
||||||
load_flags: configpkg.FreetypeLoadFlags = switch (font.options.backend) {
|
load_flags: configpkg.FreetypeLoadFlags = font.face.freetype_load_flags_default,
|
||||||
.freetype,
|
|
||||||
.fontconfig_freetype,
|
|
||||||
.coretext_freetype,
|
|
||||||
=> .{},
|
|
||||||
|
|
||||||
.coretext,
|
|
||||||
.coretext_harfbuzz,
|
|
||||||
.coretext_noshape,
|
|
||||||
.web_canvas,
|
|
||||||
=> {},
|
|
||||||
},
|
|
||||||
|
|
||||||
const style_offsets_len = std.enums.directEnumArrayLen(Style, 0);
|
const style_offsets_len = std.enums.directEnumArrayLen(Style, 0);
|
||||||
const StyleOffsets = [style_offsets_len]usize;
|
const StyleOffsets = [style_offsets_len]usize;
|
||||||
|
@ -27,11 +27,25 @@ pub const Face = switch (options.backend) {
|
|||||||
/// using whatever platform method you can.
|
/// using whatever platform method you can.
|
||||||
pub const default_dpi = if (builtin.os.tag == .macos) 72 else 96;
|
pub const default_dpi = if (builtin.os.tag == .macos) 72 else 96;
|
||||||
|
|
||||||
|
pub const FreetypeLoadFlags = switch (options.backend) {
|
||||||
|
.freetype,
|
||||||
|
.fontconfig_freetype,
|
||||||
|
.coretext_freetype,
|
||||||
|
=> config.Config.FreetypeLoadFlags,
|
||||||
|
|
||||||
|
.coretext,
|
||||||
|
.coretext_harfbuzz,
|
||||||
|
.coretext_noshape,
|
||||||
|
.web_canvas,
|
||||||
|
=> void,
|
||||||
|
};
|
||||||
|
pub const freetype_load_flags_default = if (options.backend.hasFreetype()) .{} else {};
|
||||||
|
|
||||||
/// Options for initializing a font face.
|
/// Options for initializing a font face.
|
||||||
pub const Options = struct {
|
pub const Options = struct {
|
||||||
size: DesiredSize,
|
size: DesiredSize,
|
||||||
metric_modifiers: ?*const Metrics.ModifierSet = null,
|
metric_modifiers: ?*const Metrics.ModifierSet = null,
|
||||||
freetype_load_flags: config.FreetypeLoadFlags,
|
freetype_load_flags: FreetypeLoadFlags,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The desired size for loading a font.
|
/// The desired size for loading a font.
|
||||||
|
@ -36,7 +36,7 @@ pub const Face = struct {
|
|||||||
metrics: font.face.Metrics,
|
metrics: font.face.Metrics,
|
||||||
|
|
||||||
/// Freetype load flags for this font face.
|
/// Freetype load flags for this font face.
|
||||||
load_flags: config.FreetypeLoadFlags,
|
load_flags: font.face.FreetypeLoadFlags,
|
||||||
|
|
||||||
/// Set quirks.disableDefaultFontFeatures
|
/// Set quirks.disableDefaultFontFeatures
|
||||||
quirks_disable_default_font_features: bool = false,
|
quirks_disable_default_font_features: bool = false,
|
||||||
|
Reference in New Issue
Block a user