Skip to content

Commit 07d5d04

Browse files
committed
able to change the font
1 parent 0edd491 commit 07d5d04

5 files changed

Lines changed: 93 additions & 34 deletions

File tree

DeathCounter.xcodeproj/project.pbxproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
EA01F26024E997C200440305 /* OpenSansCondensed-Light.ttf in Resources */ = {isa = PBXBuildFile; fileRef = EA01F25F24E997C200440305 /* OpenSansCondensed-Light.ttf */; };
1011
EA03F87F24D1D2A70080E849 /* LabelView.h in Headers */ = {isa = PBXBuildFile; fileRef = EA03F87D24D1D2A70080E849 /* LabelView.h */; };
1112
EA03F88024D1D2A70080E849 /* LabelView.m in Sources */ = {isa = PBXBuildFile; fileRef = EA03F87E24D1D2A70080E849 /* LabelView.m */; };
1213
EA03F88324D1D6DE0080E849 /* SectionView.h in Headers */ = {isa = PBXBuildFile; fileRef = EA03F88124D1D6DE0080E849 /* SectionView.h */; };
@@ -18,6 +19,7 @@
1819
/* End PBXBuildFile section */
1920

2021
/* Begin PBXFileReference section */
22+
EA01F25F24E997C200440305 /* OpenSansCondensed-Light.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "OpenSansCondensed-Light.ttf"; sourceTree = "<group>"; };
2123
EA03F87D24D1D2A70080E849 /* LabelView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LabelView.h; sourceTree = "<group>"; };
2224
EA03F87E24D1D2A70080E849 /* LabelView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LabelView.m; sourceTree = "<group>"; };
2325
EA03F88124D1D6DE0080E849 /* SectionView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SectionView.h; sourceTree = "<group>"; };
@@ -44,6 +46,7 @@
4446
EA3B9D8924D26D9800FEFC13 /* Resources */ = {
4547
isa = PBXGroup;
4648
children = (
49+
EA01F25F24E997C200440305 /* OpenSansCondensed-Light.ttf */,
4750
EA3B9D8724D26D3700FEFC13 /* Iceland-Regular.ttf */,
4851
);
4952
path = Resources;
@@ -154,6 +157,7 @@
154157
files = (
155158
EA3B9DB024D2A43B00FEFC13 /* Iceland-Regular.ttf in Resources */,
156159
EA3B9DB224D2B78E00FEFC13 /* ConfigSheet.xib in Resources */,
160+
EA01F26024E997C200440305 /* OpenSansCondensed-Light.ttf in Resources */,
157161
);
158162
runOnlyForDeploymentPostprocessing = 0;
159163
};
@@ -295,7 +299,7 @@
295299
INFOPLIST_FILE = DeathCounter/Info.plist;
296300
INSTALL_PATH = "$(HOME)/Library/Screen Savers";
297301
MACOSX_DEPLOYMENT_TARGET = 10.11;
298-
MARKETING_VERSION = 2.1.0;
302+
MARKETING_VERSION = 2.2.0;
299303
PRODUCT_BUNDLE_IDENTIFIER = com.anhmv.DeathCounter;
300304
PRODUCT_NAME = "$(TARGET_NAME)";
301305
WRAPPER_EXTENSION = saver;
@@ -312,7 +316,7 @@
312316
INFOPLIST_FILE = DeathCounter/Info.plist;
313317
INSTALL_PATH = "$(HOME)/Library/Screen Savers";
314318
MACOSX_DEPLOYMENT_TARGET = 10.11;
315-
MARKETING_VERSION = 2.1.0;
319+
MARKETING_VERSION = 2.2.0;
316320
PRODUCT_BUNDLE_IDENTIFIER = com.anhmv.DeathCounter;
317321
PRODUCT_NAME = "$(TARGET_NAME)";
318322
WRAPPER_EXTENSION = saver;

DeathCounter/ConfigSheet.xib

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<outlet property="birthday" destination="jr2-GZ-1k3" id="yVH-sp-PcF"/>
1212
<outlet property="configSheet" destination="QvC-M9-y7g" id="vSq-gp-c1U"/>
1313
<outlet property="expectedDeathAge" destination="Kdk-kG-644" id="Dyr-jd-1LR"/>
14+
<outlet property="font" destination="25z-CO-qrm" id="7N7-kj-dCh"/>
1415
<outlet property="hideLabels" destination="xhv-C7-soh" id="7nq-DG-T9t"/>
1516
</connections>
1617
</customObject>
@@ -19,72 +20,94 @@
1920
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="QvC-M9-y7g">
2021
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
2122
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
22-
<rect key="contentRect" x="196" y="240" width="403" height="173"/>
23+
<rect key="contentRect" x="196" y="240" width="403" height="185"/>
2324
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
2425
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
25-
<rect key="frame" x="0.0" y="0.0" width="403" height="173"/>
26+
<rect key="frame" x="0.0" y="0.0" width="403" height="185"/>
2627
<autoresizingMask key="autoresizingMask"/>
2728
<subviews>
2829
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="vMu-ZO-UAs">
29-
<rect key="frame" x="18" y="133" width="165" height="16"/>
30+
<rect key="frame" x="18" y="145" width="165" height="16"/>
3031
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
3132
<textFieldCell key="cell" lineBreakMode="clipping" title="What is your date of birth?" id="4ul-qK-185">
32-
<font key="font" metaFont="system"/>
33+
<font key="font" metaFont="label" size="13"/>
3334
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
3435
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
3536
</textFieldCell>
3637
</textField>
3738
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="QNL-PU-Wgv">
38-
<rect key="frame" x="18" y="103" width="214" height="16"/>
39+
<rect key="frame" x="18" y="115" width="214" height="16"/>
3940
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
4041
<textFieldCell key="cell" lineBreakMode="clipping" title="When is your expected death age?" id="BvO-Ah-h8L">
41-
<font key="font" metaFont="system"/>
42+
<font key="font" metaFont="label" size="13"/>
4243
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
4344
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
4445
</textFieldCell>
4546
</textField>
4647
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="58x-Ww-Kel">
47-
<rect key="frame" x="18" y="75" width="72" height="16"/>
48+
<rect key="frame" x="18" y="87" width="72" height="16"/>
4849
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
4950
<textFieldCell key="cell" lineBreakMode="clipping" title="Hide labels" id="mKy-Cw-sfg">
50-
<font key="font" metaFont="system"/>
51+
<font key="font" metaFont="label" size="13"/>
52+
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
53+
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
54+
</textFieldCell>
55+
</textField>
56+
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="RV5-OQ-jcK">
57+
<rect key="frame" x="18" y="63" width="32" height="16"/>
58+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
59+
<textFieldCell key="cell" lineBreakMode="clipping" title="Font" id="R1y-J0-NAZ">
60+
<font key="font" metaFont="label" size="13"/>
5161
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
5262
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
5363
</textFieldCell>
5464
</textField>
5565
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Kdk-kG-644">
56-
<rect key="frame" x="286" y="103" width="97" height="21"/>
66+
<rect key="frame" x="286" y="115" width="97" height="21"/>
5767
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
5868
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="center" placeholderString="50" drawsBackground="YES" id="spC-Hj-IfO">
5969
<numberFormatter key="formatter" formatterBehavior="default10_4" numberStyle="decimal" formatWidth="-1" minimumIntegerDigits="1" maximumIntegerDigits="2000000000" maximumFractionDigits="3" id="l5o-xh-pgg"/>
60-
<font key="font" metaFont="system"/>
70+
<font key="font" metaFont="label" size="13"/>
6171
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
6272
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
6373
</textFieldCell>
6474
</textField>
6575
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="jr2-GZ-1k3">
66-
<rect key="frame" x="286" y="130" width="96" height="21"/>
76+
<rect key="frame" x="286" y="142" width="96" height="21"/>
6777
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
6878
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" alignment="center" placeholderString="yyyy/MM/dd" drawsBackground="YES" id="fCk-UA-JW2">
69-
<font key="font" metaFont="system"/>
79+
<font key="font" metaFont="label" size="13"/>
7080
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
7181
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
7282
</textFieldCell>
7383
</textField>
7484
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xhv-C7-soh">
75-
<rect key="frame" x="284" y="74" width="22" height="18"/>
85+
<rect key="frame" x="284" y="86" width="22" height="18"/>
7686
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
7787
<buttonCell key="cell" type="check" bezelStyle="regularSquare" imagePosition="left" inset="2" id="hW4-5y-q0Z">
7888
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
79-
<font key="font" metaFont="system"/>
89+
<font key="font" metaFont="label" size="13"/>
8090
</buttonCell>
8191
</button>
92+
<comboBox verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="25z-CO-qrm">
93+
<rect key="frame" x="286" y="57" width="100" height="25"/>
94+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
95+
<comboBoxCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" completes="NO" numberOfVisibleItems="5" id="rhF-aw-M8u">
96+
<font key="font" metaFont="label" size="13"/>
97+
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
98+
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
99+
<objectValues>
100+
<string>Iceland</string>
101+
<string>Open Sans Condensed</string>
102+
</objectValues>
103+
</comboBoxCell>
104+
</comboBox>
82105
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="hnq-vl-6oY">
83-
<rect key="frame" x="217" y="13" width="82" height="32"/>
106+
<rect key="frame" x="218" y="13" width="82" height="32"/>
84107
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
85108
<buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Vpq-No-erc">
86109
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
87-
<font key="font" metaFont="system"/>
110+
<font key="font" metaFont="label" size="13"/>
88111
<string key="keyEquivalent" base64-UTF8="YES">
89112
Gw
90113
</string>
@@ -94,11 +117,11 @@ Gw
94117
</connections>
95118
</button>
96119
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="78Q-re-sQW">
97-
<rect key="frame" x="299" y="13" width="89" height="32"/>
120+
<rect key="frame" x="300" y="13" width="89" height="32"/>
98121
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
99122
<buttonCell key="cell" type="push" title="Save" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="DQe-mn-vMW">
100123
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
101-
<font key="font" metaFont="system"/>
124+
<font key="font" metaFont="label" size="13"/>
102125
<string key="keyEquivalent" base64-UTF8="YES">
103126
DQ
104127
</string>
@@ -109,7 +132,7 @@ DQ
109132
</button>
110133
</subviews>
111134
</view>
112-
<point key="canvasLocation" x="-661" y="-57"/>
135+
<point key="canvasLocation" x="-661.5" y="-51.5"/>
113136
</window>
114137
</objects>
115138
</document>

DeathCounter/DeathCounterView.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
IBOutlet NSTextField *birthday;
2222
IBOutlet NSTextField *expectedDeathAge;
2323
IBOutlet NSButton *hideLabels;
24+
IBOutlet NSComboBox *font;
2425

2526
NSDate *userBirthday;
2627
NSDate *userDeathDate;

DeathCounter/DeathCounterView.m

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ - (void)animateOneFrame
4141

4242
NSCalendarUnit extractedUnits = NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;
4343
NSDateComponents *components = [[NSCalendar currentCalendar] components: extractedUnits
44-
fromDate: currentDay
44+
fromDate : currentDay
4545
toDate: self->userDeathDate options: 0];
4646

4747
NSInteger days = [components day];
@@ -85,6 +85,8 @@ - (NSWindow*)configureSheet
8585
[hideLabels setState:NSControlStateValueOff];
8686
}
8787

88+
[font setStringValue:[defaults stringForKey:@"font"]];
89+
8890
return configSheet;
8991
}
9092

@@ -106,6 +108,14 @@ - (IBAction)saveClick:(id)sender {
106108
[defaults setValue:@"OFF" forKey:@"hideLabels"];
107109
}
108110

111+
NSString *currentFont = [defaults stringForKey:@"font"];
112+
NSString *newFont = [font stringValue];
113+
114+
if ([currentFont isNotEqualTo:newFont]) {
115+
[defaults setValue:[font stringValue] forKey:@"font"];
116+
[self updateFont];
117+
}
118+
109119
[defaults synchronize];
110120

111121
[self fetchUserInfo];
@@ -118,8 +128,8 @@ - (IBAction)saveClick:(id)sender {
118128

119129
- (void)buildClock
120130
{
121-
NSFont *mainFont = [NSFont fontWithName:@"Iceland-Regular" size:self.frame.size.width * 0.1];
122-
NSFont *subFont = [NSFont fontWithName:@"Iceland-Regular" size:self.frame.size.width * 0.035];
131+
ScreenSaverDefaults *defaults;
132+
defaults = [ScreenSaverDefaults defaultsForModuleWithName:deathCounterModule];
123133

124134
if (self) {
125135
stackView = [NSStackView new];
@@ -138,37 +148,53 @@ - (void)buildClock
138148

139149
[self addSubview:stackView];
140150

141-
[stackView setSpacing:self.frame.size.width * 0.06];
151+
[stackView setSpacing:self.frame.size.width * 0.08];
142152

143153
[stackView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor].active = YES;
144154
[stackView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor].active = YES;
145155

146156
[daysView setValueText:@"0000"];
147157
[daysView setLabelText:@"DAYS"];
148-
[daysView setMainFont:mainFont];
149-
[daysView setSubFont:subFont];
150158

151159
[hoursView setValueText:@"24"];
152160
[hoursView setLabelText:@"HOURS"];
153-
[hoursView setMainFont:mainFont];
154-
[hoursView setSubFont:subFont];
155161

156162
[minutesView setValueText:@"00"];
157163
[minutesView setLabelText:@"MINUTES"];
158-
[minutesView setMainFont:mainFont];
159-
[minutesView setSubFont:subFont];
160164

161165
[secondsView setValueText:@"00"];
162166
[secondsView setLabelText:@"SECONDS"];
163-
[secondsView setMainFont:mainFont];
164-
[secondsView setSubFont:subFont];
165-
167+
168+
[self updateFont];
166169
[stackView setHidden:true];
167170

168171
[self hideLabelsIfPossible];
169172
}
170173
}
171174

175+
- (void)updateFont
176+
{
177+
ScreenSaverDefaults *defaults;
178+
defaults = [ScreenSaverDefaults defaultsForModuleWithName:deathCounterModule];
179+
180+
NSString *fontName = [defaults stringForKey:@"font"];
181+
182+
NSFont *mainFont = [NSFont fontWithName:fontName size:self.frame.size.width * 0.1];
183+
NSFont *subFont = [NSFont fontWithName:fontName size:self.frame.size.width * 0.035];
184+
185+
[daysView setMainFont:mainFont];
186+
[daysView setSubFont:subFont];
187+
188+
[hoursView setMainFont:mainFont];
189+
[hoursView setSubFont:subFont];
190+
191+
[minutesView setMainFont:mainFont];
192+
[minutesView setSubFont:subFont];
193+
194+
[secondsView setMainFont:mainFont];
195+
[secondsView setSubFont:subFont];
196+
}
197+
172198
- (void)registerCustomFonts
173199
{
174200
NSArray * paths = [[NSBundle bundleForClass:self.class] pathsForResourcesOfType:@"ttf" inDirectory:@""];
@@ -198,6 +224,11 @@ - (void)setDefaultUserInfoIfNeeded
198224
@"On",
199225
@"hideLabels",
200226
nil]];
227+
228+
[defaults registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
229+
@"Iceland",
230+
@"font",
231+
nil]];
201232
}
202233

203234
- (void)fetchUserInfo
98 KB
Binary file not shown.

0 commit comments

Comments
 (0)