mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
refactor: make freetype flags void for non-freetype backend
This is an attempt to use `void` as type for Freetype Load Flags when backend does not use these flags.
This commit is contained in:
@ -1,6 +1,8 @@
|
|||||||
const builtin = @import("builtin");
|
const builtin = @import("builtin");
|
||||||
|
|
||||||
const formatter = @import("config/formatter.zig");
|
const formatter = @import("config/formatter.zig");
|
||||||
|
const font = @import("font/main.zig");
|
||||||
|
const options = font.options;
|
||||||
pub const Config = @import("config/Config.zig");
|
pub const Config = @import("config/Config.zig");
|
||||||
pub const string = @import("config/string.zig");
|
pub const string = @import("config/string.zig");
|
||||||
pub const edit = @import("config/edit.zig");
|
pub const edit = @import("config/edit.zig");
|
||||||
@ -9,6 +11,18 @@ 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,7 +452,18 @@ 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.Config.FreetypeLoadFlags = .{},
|
freetype_load_flags: config.FreetypeLoadFlags = switch (font.options.backend) {
|
||||||
|
.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.Config.FreetypeLoadFlags,
|
@"freetype-load-flags": configpkg.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.
|
||||||
@ -463,7 +463,18 @@ pub const DerivedConfig = struct {
|
|||||||
.@"adjust-strikethrough-position" = config.@"adjust-strikethrough-position",
|
.@"adjust-strikethrough-position" = config.@"adjust-strikethrough-position",
|
||||||
.@"adjust-strikethrough-thickness" = config.@"adjust-strikethrough-thickness",
|
.@"adjust-strikethrough-thickness" = config.@"adjust-strikethrough-thickness",
|
||||||
.@"adjust-cursor-thickness" = config.@"adjust-cursor-thickness",
|
.@"adjust-cursor-thickness" = config.@"adjust-cursor-thickness",
|
||||||
.@"freetype-load-flags" = config.@"freetype-load-flags",
|
.@"freetype-load-flags" = switch (font.options.backend) {
|
||||||
|
.freetype,
|
||||||
|
.fontconfig_freetype,
|
||||||
|
.coretext_freetype,
|
||||||
|
=> config.@"freetype-load-flags",
|
||||||
|
|
||||||
|
.coretext,
|
||||||
|
.coretext_harfbuzz,
|
||||||
|
.coretext_noshape,
|
||||||
|
.web_canvas,
|
||||||
|
=> {},
|
||||||
|
},
|
||||||
|
|
||||||
// This must be last so the arena contains all our allocations
|
// This must be last so the arena contains all our allocations
|
||||||
// from above since Zig does assignment in order.
|
// from above since Zig does assignment in order.
|
||||||
@ -503,7 +514,18 @@ pub const Key = struct {
|
|||||||
/// font grid.
|
/// font grid.
|
||||||
font_size: DesiredSize = .{ .points = 12 },
|
font_size: DesiredSize = .{ .points = 12 },
|
||||||
|
|
||||||
load_flags: configpkg.Config.FreetypeLoadFlags = .{},
|
load_flags: configpkg.FreetypeLoadFlags = switch (font.options.backend) {
|
||||||
|
.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;
|
||||||
|
@ -2,7 +2,7 @@ const std = @import("std");
|
|||||||
const builtin = @import("builtin");
|
const builtin = @import("builtin");
|
||||||
const options = @import("main.zig").options;
|
const options = @import("main.zig").options;
|
||||||
pub const Metrics = @import("face/Metrics.zig");
|
pub const Metrics = @import("face/Metrics.zig");
|
||||||
const FreetypeLoadFlags = @import("../config/Config.zig").FreetypeLoadFlags;
|
const config = @import("../config.zig");
|
||||||
const freetype = @import("face/freetype.zig");
|
const freetype = @import("face/freetype.zig");
|
||||||
const coretext = @import("face/coretext.zig");
|
const coretext = @import("face/coretext.zig");
|
||||||
pub const web_canvas = @import("face/web_canvas.zig");
|
pub const web_canvas = @import("face/web_canvas.zig");
|
||||||
@ -31,7 +31,7 @@ pub const default_dpi = if (builtin.os.tag == .macos) 72 else 96;
|
|||||||
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: FreetypeLoadFlags,
|
freetype_load_flags: config.FreetypeLoadFlags,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The desired size for loading a font.
|
/// The desired size for loading a font.
|
||||||
|
@ -18,7 +18,7 @@ const Library = font.Library;
|
|||||||
const convert = @import("freetype_convert.zig");
|
const convert = @import("freetype_convert.zig");
|
||||||
const fastmem = @import("../../fastmem.zig");
|
const fastmem = @import("../../fastmem.zig");
|
||||||
const quirks = @import("../../quirks.zig");
|
const quirks = @import("../../quirks.zig");
|
||||||
const FreetypeLoadFlags = @import("../../config/Config.zig").FreetypeLoadFlags;
|
const config = @import("../../config.zig");
|
||||||
|
|
||||||
const log = std.log.scoped(.font_face);
|
const log = std.log.scoped(.font_face);
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ pub const Face = struct {
|
|||||||
metrics: font.face.Metrics,
|
metrics: font.face.Metrics,
|
||||||
|
|
||||||
/// Metrics for this font face. These are useful for renderers.
|
/// Metrics for this font face. These are useful for renderers.
|
||||||
load_flags: FreetypeLoadFlags,
|
load_flags: config.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