Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Ensure large type text is sized based on screen HEIGHT as well as width #733

Merged
merged 3 commits into from

3 participants

@pjrobertson
Owner

Also, change the string name from number to aString. Makes more sense

If you have a string that is really really long, or has many lies, then Quicksilver would previously not set the font size to ensure all the lines are included in the large type display.

e.g. paste this into QS's 1st pane before, and after this fix.

a
b
c
d
e
f
g
h
i
j
k

@pjrobertson pjrobertson Ensure large type text is sized based on screen HEIGHT as well as width
Also, change the string name from `number` to `aString`. Makes more sense
433842a
@skurfer
Owner

I like it. I’ll run with it for a while.

@HenningJ HenningJ commented on the diff
Quicksilver/Code-QuickStepInterface/QSLargeTypeDisplay.m
((22 lines not shown))
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
@HenningJ Owner

What is this warning? What does it mean? Is it still valid?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@HenningJ HenningJ commented on the diff
Quicksilver/Code-QuickStepInterface/QSLargeTypeDisplay.m
((12 lines not shown))
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;
@HenningJ Owner

Hmm...this calculation is strange. 11/12 of the screen-size...ok, so it doesn't fill the complete screen, only almost the complete screen. But what with - 2*EDGEINSET?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@HenningJ
Owner

I like it as well. I just had a few questions about the code. Not really about your changes, but about what was there before...

@pjrobertson
Owner
@HenningJ
Owner

I have no idea what a descender/ascender is (of course I could find out, so don't bother explaining!)

I don't have a clue either. :-)

@pjrobertson
Owner

Any further problems with this? It's annoying not having the full text when I want to see a song's lyrics... :)

@skurfer
Owner

I noticed one small thing. If you have a narrow column of text, the Large Type display is still very wide. For instance, try ls -1 ~ → Run Command in Shell then Large Type the result.

I don’t think that should hold this up, so I’ll merge it as is, but… Just in case you plan to fix it and would prefer to do it on this existing branch, I’ll give you a few hours to speak up before I merge.

@pjrobertson
Owner
@pjrobertson
Owner

OK @skurfer
Take a look at the change I've made :-)

@skurfer
Owner

Definitely better for narrow columns, but now I see other weirdness.

The shadow for some taller characters looks like it’s getting cut off at the bottom (You may have to look at it full size. See the ]; at the end in particular):

Truncated Shadow

If the text being displayed has some leading whitespace, the position gets weird:

Leading Whitespace

This message would have been much easier to put together with a Dropbox plug-in to grab those links for me. ;-)

@pjrobertson
Owner

Hmm... OK, I was worried there might be some problems.
I think I might just revert the commit and then let you merge it.

@skurfer
Owner

I think I might just revert the commit and then let you merge it.

Sounds fine.

@pjrobertson
Owner
@skurfer skurfer merged commit 63f456d into quicksilver:master
@skurfer
Owner

Merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 25, 2012
  1. @pjrobertson

    Ensure large type text is sized based on screen HEIGHT as well as width

    pjrobertson authored
    Also, change the string name from `number` to `aString`. Makes more sense
Commits on Mar 18, 2012
  1. @pjrobertson
Commits on Mar 22, 2012
  1. @pjrobertson
This page is out of date. Refresh to see the latest.
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;
@HenningJ Owner

Hmm...this calculation is strange. 11/12 of the screen-size...ok, so it doesn't fill the complete screen, only almost the complete screen. But what with - 2*EDGEINSET?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ 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
@HenningJ Owner

What is this warning? What does it mean? Is it still valid?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
}
[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];
Something went wrong with that request. Please try again.