mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
some tweaks
This commit is contained in:
@ -16,6 +16,7 @@ pub const CopyOnSelect = Config.CopyOnSelect;
|
||||
pub const CustomShaderAnimation = Config.CustomShaderAnimation;
|
||||
pub const FontSyntheticStyle = Config.FontSyntheticStyle;
|
||||
pub const FontStyle = Config.FontStyle;
|
||||
pub const FreetypeLoadFlags = Config.FreetypeLoadFlags;
|
||||
pub const Keybinds = Config.Keybinds;
|
||||
pub const MouseShiftCapture = Config.MouseShiftCapture;
|
||||
pub const NonNativeFullscreen = Config.NonNativeFullscreen;
|
||||
|
@ -287,21 +287,24 @@ const c = @cImport({
|
||||
/// terminals. Only new terminals will use the new configuration.
|
||||
@"grapheme-width-method": GraphemeWidthMethod = .unicode,
|
||||
|
||||
/// Freetype load flags to enable. The format of this is a list of flags to
|
||||
/// FreeType load flags to enable. The format of this is a list of flags to
|
||||
/// enable separated by commas. If you prefix a flag with `no-` then it is
|
||||
/// disabled. If you omit a flag, it's default value is used, so you must
|
||||
/// explicitly disable flags you don't want. You can also use `true` or `false`
|
||||
/// to turn all flags on or off.
|
||||
///
|
||||
/// This configuration only applies to Ghostty builds that use FreeType.
|
||||
/// This is usually the case only for Linux builds. macOS uses CoreText
|
||||
/// and does not have an equivalent configuration.
|
||||
///
|
||||
/// Available flags:
|
||||
///
|
||||
/// * `hinting` - Enable or disable hinting, enabled by default.
|
||||
/// * `bitmap` - Enable or disable loading of any pre-rendered bitmap strikes,
|
||||
/// enabled by default
|
||||
/// * `force-autohint` - Use the freetype auto-hinter rather than the font's
|
||||
/// native hinter. Enabled by default.
|
||||
/// * `monochrome` - Instructs renderer to use 1-bit monochrome rendering.
|
||||
/// This option doesn't impact the hinter. Enabled by default.
|
||||
/// * `force-autohint` - Use the freetype auto-hinter rather than the
|
||||
/// font's native hinter. Enabled by default.
|
||||
/// * `monochrome` - Instructs renderer to use 1-bit monochrome
|
||||
/// rendering. This option doesn't impact the hinter.
|
||||
/// Enabled by default.
|
||||
/// * `autohint` - Use the freetype auto-hinter. Enabled by default.
|
||||
///
|
||||
/// Example: `hinting`, `no-hinting`, `force-autohint`, `no-force-autohint`
|
||||
@ -4587,10 +4590,12 @@ pub const GraphemeWidthMethod = enum {
|
||||
|
||||
/// See freetype-load-flag
|
||||
pub const FreetypeLoadFlags = packed struct {
|
||||
// The defaults here at the time of writing this match the defaults
|
||||
// for Freetype itself. Ghostty hasn't made any opinionated changes
|
||||
// to these defaults.
|
||||
hinting: bool = true,
|
||||
bitmap: bool = true,
|
||||
@"force-autohint": bool = false,
|
||||
monochrome: bool = false,
|
||||
@"force-autohint": bool = true,
|
||||
monochrome: bool = true,
|
||||
autohint: bool = true,
|
||||
};
|
||||
|
||||
|
@ -168,7 +168,7 @@ fn collection(
|
||||
.library = self.font_lib,
|
||||
.size = size,
|
||||
.metric_modifiers = key.metric_modifiers,
|
||||
.freetype_load_flags = config.@"freetype-load-flags",
|
||||
.freetype_load_flags = key.freetype_load_flags,
|
||||
};
|
||||
|
||||
var c = Collection.init();
|
||||
@ -463,7 +463,7 @@ pub const DerivedConfig = struct {
|
||||
.@"adjust-strikethrough-position" = config.@"adjust-strikethrough-position",
|
||||
.@"adjust-strikethrough-thickness" = config.@"adjust-strikethrough-thickness",
|
||||
.@"adjust-cursor-thickness" = config.@"adjust-cursor-thickness",
|
||||
.@"freetype-load-flags" = if (comptime font.options.backend.hasFreetype()) config.@"freetype-load-flags" else {},
|
||||
.@"freetype-load-flags" = if (font.face.FreetypeLoadFlags != void) config.@"freetype-load-flags" else {},
|
||||
|
||||
// This must be last so the arena contains all our allocations
|
||||
// from above since Zig does assignment in order.
|
||||
@ -503,7 +503,9 @@ pub const Key = struct {
|
||||
/// font grid.
|
||||
font_size: DesiredSize = .{ .points = 12 },
|
||||
|
||||
load_flags: font.face.FreetypeLoadFlags = font.face.freetype_load_flags_default,
|
||||
/// The freetype load flags configuration, only non-void if the
|
||||
/// freetype backend is enabled.
|
||||
freetype_load_flags: font.face.FreetypeLoadFlags = font.face.freetype_load_flags_default,
|
||||
|
||||
const style_offsets_len = std.enums.directEnumArrayLen(Style, 0);
|
||||
const StyleOffsets = [style_offsets_len]usize;
|
||||
@ -623,7 +625,10 @@ pub const Key = struct {
|
||||
.codepoint_map = codepoint_map,
|
||||
.metric_modifiers = metric_modifiers,
|
||||
.font_size = font_size,
|
||||
.load_flags = config.@"freetype-load-flags",
|
||||
.freetype_load_flags = if (font.face.FreetypeLoadFlags != void)
|
||||
config.@"freetype-load-flags"
|
||||
else
|
||||
font.face.freetype_load_flags_default,
|
||||
};
|
||||
}
|
||||
|
||||
@ -653,7 +658,7 @@ pub const Key = struct {
|
||||
for (self.descriptors) |d| d.hash(hasher);
|
||||
self.codepoint_map.hash(hasher);
|
||||
autoHash(hasher, self.metric_modifiers.count());
|
||||
autoHash(hasher, self.load_flags);
|
||||
autoHash(hasher, self.freetype_load_flags);
|
||||
if (self.metric_modifiers.count() > 0) {
|
||||
inline for (@typeInfo(Metrics.Key).Enum.fields) |field| {
|
||||
const key = @field(Metrics.Key, field.name);
|
||||
|
@ -27,8 +27,13 @@ pub const Face = switch (options.backend) {
|
||||
/// using whatever platform method you can.
|
||||
pub const default_dpi = if (builtin.os.tag == .macos) 72 else 96;
|
||||
|
||||
pub const FreetypeLoadFlags = if (options.backend.hasFreetype()) config.Config.FreetypeLoadFlags else void;
|
||||
pub const freetype_load_flags_default = if (options.backend.hasFreetype()) .{} else {};
|
||||
/// These are the flags to customize how freetype loads fonts. This is
|
||||
/// only non-void if the freetype backend is enabled.
|
||||
pub const FreetypeLoadFlags = if (options.backend.hasFreetype())
|
||||
config.FreetypeLoadFlags
|
||||
else
|
||||
void;
|
||||
pub const freetype_load_flags_default = if (FreetypeLoadFlags != void) .{} else {};
|
||||
|
||||
/// Options for initializing a font face.
|
||||
pub const Options = struct {
|
||||
|
@ -23,6 +23,11 @@ const config = @import("../../config.zig");
|
||||
const log = std.log.scoped(.font_face);
|
||||
|
||||
pub const Face = struct {
|
||||
comptime {
|
||||
// If we have the freetype backend, we should have load flags.
|
||||
assert(font.face.FreetypeLoadFlags != void);
|
||||
}
|
||||
|
||||
/// Our freetype library
|
||||
lib: freetype.Library,
|
||||
|
||||
@ -323,7 +328,7 @@ pub const Face = struct {
|
||||
//
|
||||
// This must be enabled for color faces though because those are
|
||||
// often colored bitmaps, which we support.
|
||||
.no_bitmap = !self.face.hasColor() or !self.load_flags.bitmap,
|
||||
.no_bitmap = !self.face.hasColor(),
|
||||
|
||||
// use options from config
|
||||
.no_hinting = !self.load_flags.hinting,
|
||||
|
Reference in New Issue
Block a user