Last active
November 29, 2024 16:50
-
-
Save simmsb/ae2f9a00b0e404a0ec1e19c81a6d8880 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From dca42a2d6dc75da977dd3918499a2668e65f88ec Mon Sep 17 00:00:00 2001 | |
From: Ben Simms <[email protected]> | |
Date: Mon, 7 Aug 2023 08:12:42 +0100 | |
Subject: [PATCH] whoah | |
--- | |
src/macappkit.m | 25 +++++++++++++++++++++++-- | |
1 file changed, 23 insertions(+), 2 deletions(-) | |
diff --git a/src/macappkit.m b/src/macappkit.m | |
index 28c6b38..1964a15 100644 | |
--- a/src/macappkit.m | |
+++ b/src/macappkit.m | |
@@ -1980,6 +1980,19 @@ - (BOOL)doesHoldQuit | |
@implementation EmacsWindow | |
+ | |
++ (NSButton *)standardWindowButton:(NSWindowButton)b forStyleMask:(NSWindowStyleMask)styleMask | |
+{ | |
+ | |
+ NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; | |
+ NSString *hideDocumentIcon = [userDefaults stringForKey: @"HideDocumentIcon"]; | |
+ | |
+ if([hideDocumentIcon isEqualToString: @"YES"] && (b == NSWindowDocumentIconButton || b == NSWindowDocumentVersionsButton)) { | |
+ return nil; | |
+ } | |
+ return [NSWindow standardWindowButton:b forStyleMask:styleMask]; | |
+} | |
+ | |
- (instancetype)initWithContentRect:(NSRect)contentRect | |
styleMask:(NSWindowStyleMask)windowStyle | |
backing:(NSBackingStoreType)bufferingType | |
@@ -2544,6 +2557,12 @@ - (void)setupWindow | |
window.contentView = visualEffectView; | |
MRC_RELEASE (visualEffectView); | |
FRAME_BACKGROUND_ALPHA_ENABLED_P (f) = true; | |
+ NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; | |
+ NSString *transparentTitleBar = [userDefaults stringForKey: @"TransparentTitleBar"]; | |
+ | |
+ window.titlebarAppearsTransparent = true; | |
+ window.appearance = [NSAppearance appearanceNamed: NSAppearanceNameVibrantDark]; | |
+ [window setToolbarStyle: NSWindowToolbarStyleUnifiedCompact]; | |
if (FRAME_MAC_DOUBLE_BUFFERED_P (f)) | |
{ | |
FRAME_SYNTHETIC_BOLD_WORKAROUND_DISABLED_P (f) = true; | |
@@ -6414,8 +6433,10 @@ + (void)initialize | |
{ | |
NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults; | |
- if ([defaults objectForKey:@"ApplePressAndHoldEnabled"] == nil) | |
- [defaults registerDefaults:@{@"ApplePressAndHoldEnabled" : @"NO"}]; | |
+ if ([defaults objectForKey:@"ApplePressAndHoldEnabled"] == nil) { | |
+ [defaults registerDefaults:@{@"ApplePressAndHoldEnabled" : @"NO"}]; | |
+ [NSDictionary dictionaryWithObjectsAndKeys:@"NO", @"ApplePressAndHoldEnabled", @"NO", @"TransparentTitleBar", @"NO", @"HideDocumentIcon", nil]; | |
+ } | |
} | |
} | |
-- | |
2.41.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(pkgs'.emacs-macport.overrideAttrs (old: { | |
version = "31.0"; | |
src = flake.inputs.emacs-mac; | |
patches = [ | |
./emacs/macos-titlebar.patch | |
./emacs/fonts.patch | |
(let | |
stdenv = pkgs.llvmPackages_19.stdenv; | |
libGccJitLibraryPaths = [ | |
"${lib.getLib pkgs.libgccjit}/lib/gcc" | |
# !!!! with the recent apple sdk rework, we need to use this instead of "${super.lib.getLib self.stdenv.cc.libc}/lib" (which now evaluates to an empty package) | |
"${lib.getLib pkgs.apple-sdk.sdkroot}/usr/lib" | |
] ++ lib.optionals (stdenv.cc?cc.libgcc) [ | |
"${lib.getLib stdenv.cc.cc.libgcc}/lib" | |
]; | |
in | |
pkgs.substituteAll { | |
src = ./emacs/native-comp-driver-options.patch; | |
backendPath = (lib.concatStringsSep " " | |
(builtins.map (x: ''"-B${x}"'') ([ | |
# Paths necessary so the JIT compiler finds its libraries: | |
"${lib.getLib pkgs.libgccjit}/lib" | |
] ++ libGccJitLibraryPaths ++ [ | |
# Executable paths necessary for compilation (ld, as): | |
"${lib.getBin stdenv.cc.cc}/bin" | |
"${lib.getBin stdenv.cc.bintools}/bin" | |
"${lib.getBin stdenv.cc.bintools.bintools}/bin" | |
]))); | |
}) | |
]; | |
configureFlags = old.configureFlags ++ [ | |
"--with-rsvg" | |
]; | |
env = old.env // { | |
NIX_CFLAGS_COMPILE = "-DFD_SETSIZE=10000 -DDARWIN_UNLIMITED_SELECT"; | |
}; | |
stdenv = pkgs.llvmPackages_19.stdenv; | |
})).override { | |
withSQLite3 = true; | |
withTreeSitter = true; | |
withWebP = true; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/macfont.m b/src/macfont.m | |
index 91ff2f0..fc522f7 100644 | |
--- a/src/macfont.m | |
+++ b/src/macfont.m | |
@@ -2563,6 +2563,12 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no | |
unblock_input (); | |
} | |
+static short | |
+read_short_from_os2_table(const UInt8* p) | |
+{ | |
+ return (p[0] << 8) | p[1]; | |
+} | |
+ | |
static Lisp_Object | |
macfont_open (struct frame * f, Lisp_Object entity, int pixel_size) | |
{ | |
@@ -2711,6 +2717,36 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no | |
} | |
CFRelease (family_name); | |
} | |
+ | |
+ // https://github.com/WebKit/WebKit/blob/4e349ca/Source/WebCore/platform/graphics/coretext/FontCoreText.cpp#L166 | |
+ CFDataRef os2Table = CTFontCopyTable (macfont, kCTFontTableOS2, kCTFontTableOptionNoOptions); | |
+ if (os2Table) | |
+ { | |
+ // For the structure of the OS/2 table, see | |
+ // https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6OS2.html | |
+ const CFIndex fsSelectionOffset = 16 * 2 + 10 + 4 * 4 + 4 * 1; | |
+ const CFIndex sTypoAscenderOffset = fsSelectionOffset + 3 * 2; | |
+ const CFIndex sTypoDescenderOffset = sTypoAscenderOffset + 2; | |
+ const CFIndex sTypoLineGapOffset = sTypoDescenderOffset + 2; | |
+ if (CFDataGetLength (os2Table) >= sTypoLineGapOffset + 2) | |
+ { | |
+ const UInt8* os2Data = CFDataGetBytePtr (os2Table); | |
+ // We test the use typo bit on the least significant byte of fsSelection. | |
+ //const UInt8 useTypoMetricsMask = 1 << 7; | |
+ //if (*(os2Data + fsSelectionOffset + 1) & useTypoMetricsMask) | |
+ // -- XXX: often fonts don't set USE_TYPO_METRICS bit, so just ignore it | |
+ { | |
+ CGFloat unitsPerEm = (CGFloat) CTFontGetUnitsPerEm (macfont); | |
+ short sTypoAscender = read_short_from_os2_table (os2Data + sTypoAscenderOffset); | |
+ short sTypoDescender = read_short_from_os2_table (os2Data + sTypoDescenderOffset); | |
+ short sTypoLineGap = read_short_from_os2_table (os2Data + sTypoLineGapOffset); | |
+ ascent = font->pixel_size * sTypoAscender / unitsPerEm; | |
+ descent = - font->pixel_size * sTypoDescender / unitsPerEm; | |
+ leading = font->pixel_size * sTypoLineGap / unitsPerEm; | |
+ } | |
+ } | |
+ CFRelease(os2Table); | |
+ } | |
} | |
font->ascent = ascent + 0.5f; | |
val = assq_no_quit (QCminspace, AREF (entity, FONT_EXTRA_INDEX)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment