diff --git a/EidosScribe/EidosCocoaExtra.mm b/EidosScribe/EidosCocoaExtra.mm index 5a0b398b..d6120374 100644 --- a/EidosScribe/EidosCocoaExtra.mm +++ b/EidosScribe/EidosCocoaExtra.mm @@ -252,6 +252,7 @@ + (NSDictionary *)eidosTextAttributesWithColor:(NSColor *)textColor size:(double static double menloFontSize = 0.0; static NSFont *menloFont = nil; static NSMutableParagraphStyle *paragraphStyle = nil; + bool recachedFont = false; if (!menloFont || (menloFontSize != fontSize)) { @@ -259,9 +260,10 @@ + (NSDictionary *)eidosTextAttributesWithColor:(NSColor *)textColor size:(double [menloFont release]; menloFont = [[NSFont fontWithName:@"Menlo" size:fontSize] retain]; + recachedFont = true; } - if (!paragraphStyle) + if (!paragraphStyle || recachedFont) { if (paragraphStyle) [paragraphStyle release]; diff --git a/EidosScribe/EidosTextView.mm b/EidosScribe/EidosTextView.mm index f51f9627..1653fde4 100644 --- a/EidosScribe/EidosTextView.mm +++ b/EidosScribe/EidosTextView.mm @@ -1356,10 +1356,28 @@ - (void)setDisplayFontSize:(int)fontSize // set the typing attributes; this code just makes an assumption about the correct typing attributes // based on the class, probably I ought to add a new method on EidosTextView to get a typing attr dict... + NSDictionary *textAttributes; + if ([self isKindOfClass:[EidosConsoleTextView class]]) - [self setTypingAttributes:[NSDictionary eidosInputAttrsWithSize:[self displayFontSize]]]; + textAttributes = [NSDictionary eidosInputAttrsWithSize:[self displayFontSize]]; else - [self setTypingAttributes:[NSDictionary eidosTextAttributesWithColor:nil size:_displayFontSize]]; + textAttributes = [NSDictionary eidosTextAttributesWithColor:nil size:_displayFontSize]; + + [self setTypingAttributes:textAttributes]; + + // fix the tab stops + NSParagraphStyle *pstyle = [textAttributes objectForKey:NSParagraphStyleAttributeName]; + + [ts beginEditing]; + + [ts enumerateAttribute:NSParagraphStyleAttributeName inRange:NSMakeRange(0, ts.length) options:0 usingBlock:^(id value, NSRange range, BOOL *stop) { + if (value) { + [ts removeAttribute:NSParagraphStyleAttributeName range:range]; + [ts addAttribute:NSParagraphStyleAttributeName value:pstyle range:range]; + } + }]; + + [ts endEditing]; } }