This repository has been archived by the owner on Jul 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Tweak.xm
68 lines (60 loc) · 2.85 KB
/
Tweak.xm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <substrate.h>
#import <GraphicsServices/GraphicsServices.h>
/* iOS 6 and below */
BOOL forceUltraLight = NO;
static GSFontRef (*HBFTOldGSCreateFontWithName)(const char *fontName, GSFontTraitMask traits, CGFloat fontSize);
GSFontRef HBFTNewGSCreateFontWithName(const char *fontName, GSFontTraitMask traits, CGFloat fontSize) {
if (fontName == NULL || (fontName != NULL && (
strcmp(fontName, "Helvetica") == 0 || strcmp(fontName, "Helvetica-Bold") == 0 ||
strcmp(fontName, "Helvetica-Italic") == 0 || strcmp(fontName, "Helvetica-BoldItalic") == 0 ||
strcmp(fontName, "Helvetica Neue") == 0 || strcmp(fontName, "HelveticaNeue") == 0 ||
strcmp(fontName, "HelveticaNeue-Bold") == 0 || strcmp(fontName, "HelveticaNeue-Italic") == 0 ||
strcmp(fontName, "HelveticaNeue-BoldItalic") == 0 || strcmp(fontName, "HelveticaNeue-Light") == 0 ||
strcmp(fontName, ".Helvetica NeueUI") == 0 || strcmp(fontName, ".HelveticaNeueUI") == 0 ||
strcmp(fontName, ".PhoneKeyCaps") == 0 || strcmp(fontName, ".PhoneKeyCapsTwo") == 0
))) {
if (forceUltraLight || (fontName != NULL && (strcmp(fontName, ".PhoneKeyCaps") == 0 || strcmp(fontName, ".PhoneKeyCapsTwo") == 0))) {
return HBFTOldGSCreateFontWithName("HelveticaNeue-UltraLight", traits, fontSize);
} else if (traits == GSBoldFontMask + GSItalicFontMask || (fontName != NULL && (strcmp(fontName, "Helvetica-BoldItalic") == 0 || strcmp(fontName, "HelveticaNeue-BoldItalic") == 0))) {
return HBFTOldGSCreateFontWithName("HelveticaNeue", GSItalicFontMask, fontSize);
} else if (traits == GSBoldFontMask || (fontName != NULL && (strcmp(fontName, "Helvetica-Bold") == 0 || strcmp(fontName, "HelveticaNeue-Bold") == 0))) {
return HBFTOldGSCreateFontWithName("HelveticaNeue", kGSFontTraitNone, fontSize);
} else {
return HBFTOldGSCreateFontWithName("HelveticaNeue-Light", traits, fontSize);
}
} else {
return HBFTOldGSCreateFontWithName(fontName, traits, fontSize);
}
}
%group SBHooks
%hook TPLCDTextView
- (void)drawRect:(CGRect)rect {
forceUltraLight = YES;
UIFont *font = MSHookIvar<UIFont *>(self, "_font");
object_setInstanceVariable(self, "_font", [UIFont fontWithName:@"HelveticaNeue-UltraLight" size:font.pointSize]);
%orig;
forceUltraLight = NO;
}
%end
%hook TPLockTextView
- (id)initWithLabel:(id)arg1 fontSize:(float)arg2 trackWidthDelta:(float)arg3 {
forceUltraLight = YES;
self = %orig;
forceUltraLight = NO;
return self;
}
- (void)drawRect:(CGRect)rect {
forceUltraLight = YES;
UIFont *font = MSHookIvar<UIFont *>(self, "_labelFont");
object_setInstanceVariable(self, "_labelFont", [UIFont fontWithName:@"HelveticaNeue-UltraLight" size:font.pointSize]);
%orig;
forceUltraLight = NO;
}
%end
%end
%ctor {
MSHookFunction(GSFontCreateWithName, HBFTNewGSCreateFontWithName, &HBFTOldGSCreateFontWithName);
if ([[NSBundle mainBundle].bundleIdentifier isEqualToString:@"com.apple.springboard"]) {
%init(SBHooks);
}
}