Ios 如何在Xcode 9中禁用字体平滑?
我有一种很棒的编程字体,只有在Xcode中禁用字体平滑(抗锯齿)时才好看。对于Xcode 8,以下内容可以实现此目的:Ios 如何在Xcode 9中禁用字体平滑?,ios,iphone,xcode,ide,xcode9,Ios,Iphone,Xcode,Ide,Xcode9,我有一种很棒的编程字体,只有在Xcode中禁用字体平滑(抗锯齿)时才好看。对于Xcode 8,以下内容可以实现此目的: defaults write com.apple.dt.Xcode NSFontDefaultScreenFontSubstitutionEnabled -bool YES defaults write com.apple.dt.Xcode AppleAntiAliasingThreshold 24 但这不再适用于Xcode 9 是否可以在Xcode 9中禁用字体平滑功能?以
defaults write com.apple.dt.Xcode NSFontDefaultScreenFontSubstitutionEnabled -bool YES
defaults write com.apple.dt.Xcode AppleAntiAliasingThreshold 24
但这不再适用于Xcode 9
是否可以在Xcode 9中禁用字体平滑功能?以下是可能适合您的替代步骤
注意:为了安全起见,请保留原始文件的备份。如果您“生活”在XCode中,并且需要此TrueType字体的清晰呈现,则使用默认值编辑XCode应用程序默认值,或
默认值编写com.apple.dt.XCode.
无效
跳出框框思考,你可能会对以下几点感兴趣,从而在你的Mac电脑上实现crispyness
由于Deccy字体最好在12pt处查看,因此有必要将全局域中的AppleAntiAliasingThreshold提高到13,此设置的默认值为4。您也可以建议不要使用AppleFontSmoothing
默认写入-g AppleFontSmoothing-int 0
默认写入-g AppleAntiAliasingThreshold-int 13
除了这些调整之外,还可以在系统首选项中的“辅助功能首选项”窗格中实现更多功能:显示屏上有两个复选标记,您应该尝试:“无颜色区分”和“增加对比度”
“情人眼里出西施”我希望这能有所帮助。恶作剧怎么办?
这是我的Xcode 9的屏幕截图,Deccy在13点:
我相信以上就是你想要的。下面是显示相同文件的股票Xcode:
但是怎么做呢?
我深入探索了一种非侵入性的方法来实现这一点,但失败了。据我所知,Xcode 9中的文本呈现路径非常有意地启用字体平滑
在继续之前,请向Apple提交功能请求。这只需要几分钟的时间,你最有希望得到一个答案,这个答案可以在那些有着良好安全本能和紧张心血管系统的人面前讨论:
我写了一个Xcode插件。您可能听说过Xcode 9使用代码签名限制来禁止加载插件。这是真的,但是一些小牛继续前进,今晚我们和他们一起骑
第一步
有一个工具。您可以使用它从您的Xcode副本中删除代码签名,并使用它取消捆绑包加载限制:
$ gem install update_xcode_plugins
$ update_xcode_plugins --unsign
如果您改变主意,您可以这样做以恢复到签名Xcode的(我想是备份副本):
$ update_xcode_plugins --restore
第二步
还有另一个工具。它是Xcode的插件管理器。我选择安装它是因为它提供了一个插件,为插件提供了一个项目模板。我随后安装了恶魔岛,归结起来就是:
$ git clone https://github.com/alcatraz/Alcatraz.git
$ cd Alcatraz
$ xcodebuild
我启动了Xcode,点击警告我新插件的对话框,然后使用新添加的窗口>软件包管理器安装“Xcode插件”模板
第三步
我用这个模板做了一个项目
在我写这篇文章时,“Xcode插件”模板还没有更新到支持Xcode 9。别担心。我运行此命令以获取Xcode 9的兼容性UUID:
$ defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID
我访问了新项目的Info.plist,并将UUID添加到dvtpluginCompatibilityUIDS
数组中
然后,我将SourceEditor.framework
链接到我的项目中。这是一个分两步的过程:
/Applications/Xcode.app/Contents/SharedFrameworks/
SourceEditor.framework
。它应该出现在列表中。该项目仍将继续建设.mm
文件看起来像这样(我删除了.h
文件,这个PoC不需要它):
#导入
#包括
外部无效CGContextSetAllowsFontAntialiasing(CGContextRef,BOOL);
静态void hooked_sourceEditorSetFontSmoothingStyle(CGContextRef ctx){
CGContextSetAllowsFontAntialiasing(ctx,编号);
}
@接口NoAA:NSObject
@结束
@实施NoAA
+(void)pluginddload:(NSBundle*)插件
{
NSArray*allowedLoaders=[InfoDictionaryKey的插件对象:@“me.delisa.XcodePluginBase.allowedLoaders”];
如果(![allowedLoaders包含对象:[[NSBundle mainBundle]bundleIdentifier]])
返回;
类cls=NSClassFromString(@“SourceEditorScrollView”);
NSBundle*bundle=[NSBundle bundleForClass:cls];
void*handle=dlopen(bundle.executablePath.fileSystemRepresentation,RTLD_NOW);
如果(!句柄)
返回;
uint8_t*set_font_smoothing_fn=dlsym(句柄,“sourceEditorSetFontSmoothingStyle”);
如果(!设置字体平滑)
后藤鳍;
void*设置字体平滑页面=(void*)((长)设置字体平滑页面大小);
if(保护(设置字体平滑页面、页面大小、保护读取、保护写入、保护执行))
后藤鳍;
设置\u font\u平滑\u fn[0]=0xe9;//jmp
uint32_t*jmp_arg=(uint32_t*)(设置字体平滑\u fn+1);
*jmp_arg=(uint32_t)((长)钩形_源编辑器setFontSmoothingStyle-(长)(jmp_arg+1));
保护(设置字体平滑页面、页面大小、保护读取、保护执行);
鳍:
dlclose(手柄);
}
@结束
…我认为goto
s添加了字符。基本上,它只定义一个函数,该函数接受CGContextRef
,并为其关闭文本抗锯齿。然后,它将覆盖SourceEditor框架内函数的开头
#import <AppKit/AppKit.h>
#include <dlfcn.h>
extern void CGContextSetAllowsFontAntialiasing(CGContextRef, BOOL);
static void hooked_sourceEditorSetFontSmoothingStyle(CGContextRef ctx) {
CGContextSetAllowsFontAntialiasing(ctx, NO);
}
@interface NoAA : NSObject
@end
@implementation NoAA
+ (void)pluginDidLoad:(NSBundle *)plugin
{
NSArray *allowedLoaders = [plugin objectForInfoDictionaryKey:@"me.delisa.XcodePluginBase.AllowedLoaders"];
if (![allowedLoaders containsObject:[[NSBundle mainBundle] bundleIdentifier]])
return;
Class cls = NSClassFromString(@"SourceEditorScrollView");
NSBundle* bundle = [NSBundle bundleForClass:cls];
void *handle = dlopen(bundle.executablePath.fileSystemRepresentation, RTLD_NOW);
if (!handle)
return;
uint8_t* set_font_smoothing_fn = dlsym(handle, "sourceEditorSetFontSmoothingStyle");
if (!set_font_smoothing_fn)
goto fin;
void* set_font_smoothing_fn_page = (void*)((long)set_font_smoothing_fn & -PAGE_SIZE);
if (mprotect(set_font_smoothing_fn_page, PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC))
goto fin;
set_font_smoothing_fn[0] = 0xe9; // jmp
uint32_t* jmp_arg = (uint32_t*)(set_font_smoothing_fn + 1);
*jmp_arg = (uint32_t)((long)hooked_sourceEditorSetFontSmoothingStyle - (long)(jmp_arg + 1));
mprotect(set_font_smoothing_fn_page, PAGE_SIZE, PROT_READ | PROT_EXEC);
fin:
dlclose(handle);
}
@end