Skip to content
Browse files

Merge pull request #733 from pjrobertson/largeType

Ensure large type text is sized based on screen HEIGHT as well as width
  • Loading branch information...
2 parents c0e881e + 25b1d58 commit 63f456d4c837d82345d39780a965df732f041e6e @skurfer skurfer committed Mar 23, 2012
Showing with 11 additions and 8 deletions.
  1. +11 −8 Quicksilver/Code-QuickStepInterface/QSLargeTypeDisplay.m
View
19 Quicksilver/Code-QuickStepInterface/QSLargeTypeDisplay.m
@@ -13,33 +13,36 @@
#define EDGEINSET 16
-void QSShowLargeType(NSString *number) {
+void QSShowLargeType(NSString *aString) {
NSRect screenRect = [[NSScreen mainScreen] frame];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSColor *textColor = [defaults colorForKey:@"QSAppearance1T"];
NSColor *backColor = [defaults colorForKey:@"QSAppearance1B"];
- if (![number length]) {
+ if (![aString length]) {
NSBeep();
return;
}
float displayWidth = NSWidth(screenRect) *11/12-2*EDGEINSET;
- NSRange fullRange = NSMakeRange(0, [number length]);
- NSMutableAttributedString *formattedNumber = [[NSMutableAttributedString alloc] initWithString:number];
+ float displayHeight = NSHeight(screenRect) * 11/12 - 2*EDGEINSET;
+ NSRange fullRange = NSMakeRange(0, [aString length]);
+
+ NSMutableAttributedString *formattedNumber = [[NSMutableAttributedString alloc] initWithString:aString];
int size;
NSSize textSize;
NSFont *textFont;
for (size = 24; size<300; size++) {
textFont = [NSFont boldSystemFontOfSize:size+1];
- textSize = [number sizeWithAttributes:[NSDictionary dictionaryWithObject:textFont forKey:NSFontAttributeName]];
- if (textSize.width> displayWidth+[textFont descender] *2) break;
- // ***warning * use ascenders to calculate
+ textSize = [aString sizeWithAttributes:[NSDictionary dictionaryWithObject:textFont forKey:NSFontAttributeName]];
+ if (textSize.width > displayWidth+[textFont descender] *2 || (textSize.height > displayHeight+[textFont descender] *2)) {
+ break;
+ } // ***warning * use ascenders to calculate
}
[formattedNumber addAttribute:NSFontAttributeName value:[NSFont boldSystemFontOfSize:size] range:fullRange];
[formattedNumber addAttribute:NSForegroundColorAttributeName value:textColor range:fullRange];
NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
- if ([number rangeOfString:@"\n"] .location == NSNotFound && [number rangeOfString:@"\r"] .location == NSNotFound)
+ if ([aString rangeOfString:@"\n"] .location == NSNotFound && [aString rangeOfString:@"\r"] .location == NSNotFound)
[style setAlignment:NSCenterTextAlignment];
[style setLineBreakMode: NSLineBreakByWordWrapping];

0 comments on commit 63f456d

Please sign in to comment.
Something went wrong with that request. Please try again.