Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Massively cleaning up the display.

I have permission from Jos to distribute a single-character OpenType file for Fertigo, so that’s what is vendored into the package.
  • Loading branch information...
commit 056ef45386aec9d3b85e9ce09e7ad113ee18b1ea 1 parent 056cd64
@ELLIOTTCABLE authored
View
BIN  Fonts/FertigoPro-Truncated.otf
Binary file not shown
View
4 Solcounter.xcodeproj/project.pbxproj
@@ -12,6 +12,7 @@
5128772D11BC125600C68C2A /* UserDefaults.plist in Resources */ = {isa = PBXBuildFile; fileRef = 5128772C11BC125600C68C2A /* UserDefaults.plist */; };
5128777511BC45B700C68C2A /* Solcounter.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5128777411BC45B700C68C2A /* Solcounter.xib */; };
5128B9FB11BC0A3600EA38A3 /* BundleUserDefaults.m in Sources */ = {isa = PBXBuildFile; fileRef = 5128B9F911BC0A3600EA38A3 /* BundleUserDefaults.m */; };
+ 516859CA11BFD0E800DC7D20 /* Fonts in Resources */ = {isa = PBXBuildFile; fileRef = 516859C711BFD0E800DC7D20 /* Fonts */; };
8D5B49B0048680CD000E48DA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; };
8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; };
/* End PBXBuildFile section */
@@ -29,6 +30,7 @@
5128777411BC45B700C68C2A /* Solcounter.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = Solcounter.xib; sourceTree = "<group>"; };
5128B9F911BC0A3600EA38A3 /* BundleUserDefaults.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BundleUserDefaults.m; sourceTree = "<group>"; };
5128B9FA11BC0A3600EA38A3 /* BundleUserDefaults.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BundleUserDefaults.h; sourceTree = "<group>"; };
+ 516859C711BFD0E800DC7D20 /* Fonts */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Fonts; sourceTree = "<group>"; };
8D5B49B6048680CD000E48DA /* Solcounter.menu */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Solcounter.menu; sourceTree = BUILT_PRODUCTS_DIR; };
8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
D2F7E65807B2D6F200F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; };
@@ -71,6 +73,7 @@
089C167CFE841241C02AAC07 /* Resources */ = {
isa = PBXGroup;
children = (
+ 516859C711BFD0E800DC7D20 /* Fonts */,
8D5B49B7048680CD000E48DA /* Info.plist */,
089C167DFE841241C02AAC07 /* InfoPlist.strings */,
5128772C11BC125600C68C2A /* UserDefaults.plist */,
@@ -179,6 +182,7 @@
8D5B49B0048680CD000E48DA /* InfoPlist.strings in Resources */,
5128772D11BC125600C68C2A /* UserDefaults.plist in Resources */,
5128777511BC45B700C68C2A /* Solcounter.xib in Resources */,
+ 516859CA11BFD0E800DC7D20 /* Fonts in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
1  YRSolcounter.h
@@ -18,6 +18,7 @@
NSTextField *textField;
BundleUserDefaults *defaults;
NSTimer *timer;
+ NSFont *radixFont;
}
-(id) initWithBundle: (NSBundle*)bundle;
View
53 YRSolcounter.m
@@ -33,6 +33,15 @@ -(id) initWithBundle: (NSBundle*)bundle {
NSRect frame = [textField frame];
[textField setFrame: NSMakeRect(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height - 1)];
+ NSURL *fontURL = [NSURL fileURLWithPath: [[self bundle] pathForResource: @"FertigoPro-Truncated"
+ ofType: @"otf"
+ inDirectory: @"Fonts"]];
+
+ // Core Foundation pain
+ radixFont = CTFontCreateWithGraphicsFont(
+ CGFontCreateWithDataProvider(CGDataProviderCreateWithURL((CFURLRef)fontURL)), 14.0, NULL, NULL);
+ // end Core Foundation pain
+
[self handleTimer: nil];
[nib dealloc];
@@ -42,13 +51,43 @@ -(id) initWithBundle: (NSBundle*)bundle {
-(void) handleTimer: (NSTimer*)_ {
double date = [[NSDate date] timeIntervalSince1970];
- [textField setStringValue:
- [NSString stringWithFormat: @"%3llu %03llu ſ %03llu %03llu %03llu",
- (unsigned long long int)(date / 86400000) % 1000,
- (unsigned long long int)(date / 86400) % 1000,
- (unsigned long long int)(date / 86.4) % 1000,
- (unsigned long long int)(date / 0.0864) % 1000,
- (unsigned long long int)(date / 0.0000864) % 1000]];
+ NSString *solCount = [NSString stringWithFormat: @"%3llu %03llu ſ %03llu %03llu %03llu",
+ (unsigned long long int)(date / 86400000.0) % 1000,
+ (unsigned long long int)(date / 86400.0) % 1000,
+ (unsigned long long int)(date / 86.4) % 1000,
+ (unsigned long long int)(date / 0.0864) % 1000,
+ (unsigned long long int)(date / 0.0000864) % 1000];
+
+ NSDictionary *solCountAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
+ [NSFont systemFontOfSize: 14.0], NSFontAttributeName,
+ [[NSColor blackColor] colorWithAlphaComponent:.9], NSForegroundColorAttributeName,
+ nil];
+ NSMutableAttributedString *attributedSolCount = //»
+ [[NSMutableAttributedString alloc] initWithString: solCount
+ attributes: solCountAttributes];
+
+ int length = [solCount length];
+ NSRange nanosolRange = NSMakeRange(length - (1 * 4), 4);
+ NSRange microsolRange = NSMakeRange(length - (2 * 4), 4);
+ NSRange millisolRange = NSMakeRange(length - (3 * 4), 4);
+ NSRange radixRange = NSMakeRange(length - (3 * 4) - 1, 1);
+ NSRange solRange = NSMakeRange(length - (4 * 4) - 1, 4);
+ NSRange kilosolRange = NSMakeRange(0, 3);
+
+ [attributedSolCount addAttribute: NSForegroundColorAttributeName
+ value: [[NSColor blackColor] colorWithAlphaComponent:.3]
+ range: nanosolRange];
+ [attributedSolCount addAttribute: NSForegroundColorAttributeName
+ value: [[NSColor blackColor] colorWithAlphaComponent:.3]
+ range: microsolRange];
+ [attributedSolCount addAttribute: NSFontAttributeName value: radixFont range: radixRange];
+ [attributedSolCount addAttribute: NSForegroundColorAttributeName
+ value: [[NSColor blackColor] colorWithAlphaComponent:.3]
+ range: kilosolRange];
+
+ [textField setAttributedStringValue: attributedSolCount];
+ [attributedSolCount release];
+ [solCountAttributes release];
}
-(void) dealloc
Please sign in to comment.
Something went wrong with that request. Please try again.