Fixing overlapping fonts in story titles.

This commit is contained in:
Samuel Clay 2014-10-01 14:54:06 -07:00
parent 01af62e900
commit 6102c8e613
3 changed files with 26 additions and 22 deletions

View file

@ -204,6 +204,7 @@ static UIFont *indicatorFont = nil;
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy];
paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping;
paragraphStyle.alignment = NSTextAlignmentLeft;
paragraphStyle.lineHeightMultiple = 0.95f;
if (cell.isRiverOrSocial) {
NSInteger siteTitleY = (20 - font.pointSize/2)/2;
@ -243,9 +244,9 @@ static UIFont *indicatorFont = nil;
NSParagraphStyleAttributeName: paragraphStyle}
context:nil].size;
int storyTitleY = 12 + riverPadding + ((font.pointSize*2 - theSize.height)/2);
int storyTitleY = 14 + riverPadding + ((font.pointSize*2 - theSize.height)/2);
if (cell.isShort) {
storyTitleY = 12 + riverPadding - (theSize.height/font.pointSize*2);
storyTitleY = 14 + riverPadding - (theSize.height/font.pointSize*2);
}
int storyTitleX = leftMargin;
if (cell.isSaved) {
@ -280,13 +281,13 @@ static UIFont *indicatorFont = nil;
NSParagraphStyleAttributeName: paragraphStyle}
context:nil].size;
int storyContentY = r.size.height - 18 - 4 - ((font.pointSize*2 + font.lineHeight) + contentSize.height)/2;
int storyContentY = r.size.height - 16 - 4 - ((font.pointSize*2 + font.lineHeight) + contentSize.height)/2;
if (cell.isShort) {
storyContentY = r.size.height - 12 - 4 - ((font.pointSize + font.lineHeight) + contentSize.height)/2;
storyContentY = r.size.height - 10 - 4 - ((font.pointSize + font.lineHeight) + contentSize.height)/2;
}
if (cell.isRead) {
textColor = UIColorFromRGB(0x848484);
textColor = UIColorFromRGB(0xB8B8B8);
font = [UIFont fontWithDescriptor:fontDescriptor size:0.0];
} else {
textColor = UIColorFromRGB(0x404040);
@ -294,7 +295,7 @@ static UIFont *indicatorFont = nil;
}
if (cell.highlighted || cell.selected) {
if (cell.isRead) {
textColor = UIColorFromRGB(0x787878);
textColor = UIColorFromRGB(0xB8B8B8);
} else {
textColor = UIColorFromRGB(0x686868);
}
@ -342,14 +343,18 @@ static UIFont *indicatorFont = nil;
// Story author
if (cell.isRead) {
textColor = UIColorFromRGB(0x959595);
font = [UIFont fontWithName:@"Helvetica" size:10];
textColor = UIColorFromRGB(0xB8B8B8);
font = [UIFont fontWithName:@"Helvetica-Bold" size:10];
} else {
textColor = UIColorFromRGB(0xA6A8A2);
font = [UIFont fontWithName:@"Helvetica-Bold" size:10];
}
if (cell.highlighted || cell.selected) {
textColor = UIColorFromRGB(0x959595);
if (cell.isRead) {
textColor = UIColorFromRGB(0xA8A8A8);
} else {
textColor = UIColorFromRGB(0x959595);
}
}
paragraphStyle.alignment = NSTextAlignmentLeft;

View file

@ -41,7 +41,6 @@
WEPopoverController *popoverController;
Class popoverClass;
NBNotifier *notifier;
UIFontDescriptor *fontDescriptorSize;
}
@property (nonatomic) IBOutlet NewsBlurAppDelegate *appDelegate;

View file

@ -35,9 +35,9 @@
#import "DashboardViewController.h"
#import "StoriesCollection.h"
#define kTableViewRowHeight 38;
#define kTableViewRiverRowHeight 60;
#define kTableViewShortRowDifference 15;
#define kTableViewRowHeight 46;
#define kTableViewRiverRowHeight 68;
#define kTableViewShortRowDifference 17;
#define kMarkReadActionSheet 1;
#define kSettingsActionSheet 2;
@ -220,7 +220,6 @@
[super viewWillAppear:animated];
self.appDelegate = (NewsBlurAppDelegate *)[[UIApplication sharedApplication] delegate];
fontDescriptorSize = nil;
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
[self setUserAvatarLayout:orientation];
@ -1376,25 +1375,26 @@ heightForRowAtIndexPath:(NSIndexPath *)indexPath {
}
- (UIFontDescriptor *)fontDescriptorUsingPreferredSize:(NSString *)textStyle {
if (fontDescriptorSize) return fontDescriptorSize;
UIFontDescriptor *fontDescriptor = appDelegate.fontDescriptorTitleSize;
if (fontDescriptor) return fontDescriptor;
fontDescriptorSize = [UIFontDescriptor preferredFontDescriptorWithTextStyle:textStyle];
fontDescriptor = [UIFontDescriptor preferredFontDescriptorWithTextStyle:textStyle];
NSUserDefaults *userPreferences = [NSUserDefaults standardUserDefaults];
if (![userPreferences boolForKey:@"use_system_font_size"]) {
if ([[userPreferences stringForKey:@"feed_list_font_size"] isEqualToString:@"xs"]) {
fontDescriptorSize = [fontDescriptorSize fontDescriptorWithSize:10.0f];
fontDescriptor = [fontDescriptor fontDescriptorWithSize:10.0f];
} else if ([[userPreferences stringForKey:@"feed_list_font_size"] isEqualToString:@"small"]) {
fontDescriptorSize = [fontDescriptorSize fontDescriptorWithSize:11.0f];
fontDescriptor = [fontDescriptor fontDescriptorWithSize:11.0f];
} else if ([[userPreferences stringForKey:@"feed_list_font_size"] isEqualToString:@"medium"]) {
fontDescriptorSize = [fontDescriptorSize fontDescriptorWithSize:12.0f];
fontDescriptor = [fontDescriptor fontDescriptorWithSize:12.0f];
} else if ([[userPreferences stringForKey:@"feed_list_font_size"] isEqualToString:@"large"]) {
fontDescriptorSize = [fontDescriptorSize fontDescriptorWithSize:14.0f];
fontDescriptor = [fontDescriptor fontDescriptorWithSize:14.0f];
} else if ([[userPreferences stringForKey:@"feed_list_font_size"] isEqualToString:@"xl"]) {
fontDescriptorSize = [fontDescriptorSize fontDescriptorWithSize:16.0f];
fontDescriptor = [fontDescriptor fontDescriptorWithSize:16.0f];
}
}
return fontDescriptorSize;
return fontDescriptor;
}
- (BOOL)isShortTitles {