Skip to content
Snippets Groups Projects
Commit b5e3ca41 authored by George Nachman's avatar George Nachman
Browse files

Merge branch 'feature/italic' of https://github.com/sos4nt/iTerm2 into v3

parents 1769ae2a e8cea2ea
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -239,6 +239,8 @@
<true/>
<key>Use Bright Bold</key>
<true/>
<key>Use Italic Font</key>
<true/>
<key>Disable Window Resizing</key>
<true/>
<key>Flashing Bell</key>
Loading
Loading
Source diff could not be displayed: it is too large. Options to address this: view the blob.
Loading
Loading
@@ -1095,6 +1095,12 @@ set t_Co=256
 
<p><br/><br/></p>
 
<h4>Draw italic text in italic font</h4>
<p>If selected, italic text will be drawn in an italic version of the selected font. If the font does not have an italic version, then the normal font will be used.</p>
<p><br/><br/></p>
<h4>Regular font</h4>
 
<p>ASCII text (latin letters, numbers, and some symbols) will be drawn using this font. Select "Anti-aliased" to draw the text with smooth edges.</p>
Loading
Loading
Loading
Loading
@@ -96,6 +96,7 @@ enum {
sct.alternateBackgroundSemantics = NO;
sct.alternateForegroundSemantics = NO;
sct.bold = NO;
sct.italic = NO;
sct.blink = NO;
sct.underline = NO;
switch ([self.param intValue]) {
Loading
Loading
Loading
Loading
@@ -114,6 +114,7 @@
#define KEY_DISABLE_BOLD @"Disable Bold" // DEPRECATED
#define KEY_USE_BOLD_FONT @"Use Bold Font"
#define KEY_USE_BRIGHT_BOLD @"Use Bright Bold"
#define KEY_USE_ITALIC_FONT @"Use Italic Font"
#define KEY_TRANSPARENCY @"Transparency"
#define KEY_BLEND @"Blend"
#define KEY_BLUR @"Blur"
Loading
Loading
Loading
Loading
@@ -466,6 +466,8 @@ typedef enum {
- (void)setBlend:(float)blend;
- (BOOL)useBoldFont;
- (void)setUseBoldFont:(BOOL)boldFlag;
- (BOOL)useItalicFont;
- (void)setUseItalicFont:(BOOL)boldFlag;
- (void)setColorTable:(int)index color:(NSColor *)c;
- (int)optionKey;
- (int)rightOptionKey;
Loading
Loading
Loading
Loading
@@ -2256,6 +2256,9 @@ static NSString *kTmuxFontChanged = @"kTmuxFontChanged";
}
[TEXTVIEW setUseBrightBold:[aDict objectForKey:KEY_USE_BRIGHT_BOLD] ? [[aDict objectForKey:KEY_USE_BRIGHT_BOLD] boolValue] : YES];
 
// italic
[self setUseItalicFont:[[aDict objectForKey:KEY_USE_ITALIC_FONT] boolValue]];
// set up the rest of the preferences
[SCREEN setPlayBellFlag:![[aDict objectForKey:KEY_SILENCE_BELL] boolValue]];
[SCREEN setShowBellFlag:[[aDict objectForKey:KEY_VISUAL_BELL] boolValue]];
Loading
Loading
@@ -2868,6 +2871,16 @@ static NSString *kTmuxFontChanged = @"kTmuxFontChanged";
[TEXTVIEW setUseBoldFont:boldFlag];
}
 
- (BOOL)useItalicFont
{
return [TEXTVIEW useItalicFont];
}
- (void)setUseItalicFont:(BOOL)italicFlag
{
[TEXTVIEW setUseItalicFont:italicFlag];
}
- (BOOL)doubleWidth
{
return doubleWidth;
Loading
Loading
Loading
Loading
@@ -61,7 +61,8 @@ struct PTYFontInfo {
// Metrics
double baselineOffset;
 
struct PTYFontInfo* boldVersion; // may be NULL
struct PTYFontInfo* boldVersion; // may be NULL
struct PTYFontInfo* italicVersion; // may be NULL
};
typedef struct PTYFontInfo PTYFontInfo;
 
Loading
Loading
@@ -98,6 +99,9 @@ typedef struct PTYFontInfo PTYFontInfo;
// Option to draw bold text as brighter colors.
BOOL useBrightBold;
// option to not render in italic
BOOL useItalicFont;
// NSTextInput support
BOOL IM_INPUT_INSERT;
NSRange IM_INPUT_SELRANGE;
Loading
Loading
@@ -413,6 +417,8 @@ typedef struct PTYFontInfo PTYFontInfo;
- (BOOL)useBoldFont;
- (void)setUseBoldFont:(BOOL)boldFlag;
- (void)setUseBrightBold:(BOOL)flag;
- (BOOL)useItalicFont;
- (void)setUseItalicFont:(BOOL)italicFlag;
- (BOOL)blinkingCursor;
- (void)setBlinkingCursor:(BOOL)bFlag;
- (void)setBlinkAllowed:(BOOL)value;
Loading
Loading
@@ -653,7 +659,8 @@ typedef enum {
- (PTYFontInfo*)getFontForChar:(UniChar)ch
isComplex:(BOOL)complex
fgColor:(int)fgColor
renderBold:(BOOL*)renderBold;
renderBold:(BOOL*)renderBold
renderItalic:(BOOL)renderItalic;
 
- (PTYFontInfo*)getOrAddFallbackFont:(NSFont*)font;
- (void)releaseAllFallbackFonts;
Loading
Loading
Loading
Loading
@@ -495,6 +495,18 @@ static CGFloat PerceivedBrightness(CGFloat r, CGFloat g, CGFloat b) {
[self setNeedsDisplay:YES];
}
 
- (BOOL)useItalicFont
{
return useItalicFont;
}
- (void)setUseItalicFont:(BOOL)italicFlag
{
useItalicFont = italicFlag;
[self setNeedsDisplay:YES];
}
- (void)setUseBrightBold:(BOOL)flag
{
useBrightBold = flag;
Loading
Loading
@@ -840,6 +852,13 @@ static CGFloat PerceivedBrightness(CGFloat r, CGFloat g, CGFloat b) {
secondaryFont.boldVersion->baselineOffset = secondaryFont.baselineOffset;
}
}
if (secondaryFont.italicVersion) {
if (primaryFont.italicVersion) {
secondaryFont.italicVersion->baselineOffset = primaryFont.italicVersion->baselineOffset;
} else {
secondaryFont.italicVersion->baselineOffset = secondaryFont.baselineOffset;
}
}
 
[self setMarkedTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
Loading
Loading
@@ -5539,8 +5558,10 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
isComplex:(BOOL)complex
fgColor:(int)fgColor
renderBold:(BOOL*)renderBold
renderItalic:(BOOL)renderItalic
{
BOOL isBold = *renderBold && useBoldFont;
BOOL isItalic = renderItalic && useItalicFont;
*renderBold = NO;
PTYFontInfo* theFont;
BOOL usePrimary = !complex && (ch < 128);
Loading
Loading
@@ -5559,6 +5580,11 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
theFont = &primaryFont;
*renderBold = YES;
}
} else if (isItalic) {
theFont = primaryFont.italicVersion;
if (!theFont) {
theFont = &primaryFont;
}
} else {
theFont = &primaryFont;
}
Loading
Loading
@@ -5569,7 +5595,13 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
theFont = &secondaryFont;
*renderBold = YES;
}
} else {
} else if (isItalic) {
theFont = secondaryFont.italicVersion;
if (!theFont) {
theFont = &secondaryFont;
}
}
else {
theFont = &secondaryFont;
}
}
Loading
Loading
@@ -5976,7 +6008,8 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
thisCharFont = [self getFontForChar:theLine[i].code
isComplex:theLine[i].complexChar
fgColor:theLine[i].foregroundColor
renderBold:&thisCharFakeBold];
renderBold:&thisCharFakeBold
renderItalic:theLine[i].italic];
 
// Create a new run if needed (this char differs from the previous
// or is the first in this line or comes after a nondrawable.
Loading
Loading
@@ -6638,6 +6671,7 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
fg.foregroundColor = ALTSEM_FG_DEFAULT;
fg.alternateForegroundSemantics = YES;
fg.bold = NO;
fg.italic = NO;
fg.blink = NO;
fg.underline = NO;
memset(&bg, 0, sizeof(bg));
Loading
Loading
@@ -7960,6 +7994,7 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
[fontInfo->font retain];
fontInfo->baselineOffset = baseline;
fontInfo->boldVersion = NULL;
fontInfo->italicVersion = NULL;
}
 
- (void)modifyFont:(NSFont*)font baseline:(double)baseline info:(PTYFontInfo*)fontInfo
Loading
Loading
@@ -7972,6 +8007,12 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
fontInfo->boldVersion->font = NULL;
[self _modifyFont:boldFont baseline:baseline into:fontInfo->boldVersion];
}
NSFont* italicFont = [fontManager convertFont:font toHaveTrait:NSItalicFontMask];
if (italicFont && ([fontManager traitsOfFont:italicFont] & NSItalicFontMask)) {
fontInfo->italicVersion = (PTYFontInfo*)malloc(sizeof(PTYFontInfo));
fontInfo->italicVersion->font = NULL;
[self _modifyFont:italicFont baseline:baseline into:fontInfo->italicVersion];
}
}
 
- (PTYFontInfo*)getOrAddFallbackFont:(NSFont*)font
Loading
Loading
@@ -7990,6 +8031,9 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
if (info->boldVersion) {
info->boldVersion->baselineOffset = primaryFont.baselineOffset;
}
if (info->italicVersion) {
info->italicVersion->baselineOffset = primaryFont.baselineOffset;
}
 
[fallbackFonts setObject:[NSValue valueWithPointer:info] forKey:name];
return info;
Loading
Loading
@@ -8014,6 +8058,9 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
if (fontInfo->boldVersion) {
[self releaseFontInfo:fontInfo->boldVersion];
}
if (fontInfo->italicVersion) {
[self releaseFontInfo:fontInfo->italicVersion];
}
}
 
// WARNING: Do not call this function directly. Call
Loading
Loading
Loading
Loading
@@ -446,6 +446,7 @@ typedef enum { CURSOR_UNDERLINE, CURSOR_VERTICAL, CURSOR_BOX } ITermCursorType;
IBOutlet NSButton* blinkAllowed;
IBOutlet NSButton* useBoldFont;
IBOutlet NSButton* useBrightBold;
IBOutlet NSButton* useItalicFont;
IBOutlet NSSlider *transparency;
IBOutlet NSSlider *blend;
IBOutlet NSButton* blur;
Loading
Loading
Loading
Loading
@@ -2807,6 +2807,8 @@ static float versionNumber;
[useBrightBold setState:NSOnState];
}
 
[useItalicFont setState:[[dict objectForKey:KEY_USE_ITALIC_FONT] boolValue] ? NSOnState : NSOffState];
[transparency setFloatValue:[[dict objectForKey:KEY_TRANSPARENCY] floatValue]];
if ([dict objectForKey:KEY_BLEND]) {
[blend setFloatValue:[[dict objectForKey:KEY_BLEND] floatValue]];
Loading
Loading
@@ -3251,6 +3253,7 @@ static float versionNumber;
[newDict setObject:[NSNumber numberWithInt:[[cursorType selectedCell] tag]] forKey:KEY_CURSOR_TYPE];
[newDict setObject:[NSNumber numberWithBool:([useBoldFont state]==NSOnState)] forKey:KEY_USE_BOLD_FONT];
[newDict setObject:[NSNumber numberWithBool:([useBrightBold state]==NSOnState)] forKey:KEY_USE_BRIGHT_BOLD];
[newDict setObject:[NSNumber numberWithBool:([useItalicFont state]==NSOnState)] forKey:KEY_USE_ITALIC_FONT];
[newDict setObject:[NSNumber numberWithFloat:[transparency floatValue]] forKey:KEY_TRANSPARENCY];
[newDict setObject:[NSNumber numberWithFloat:[blend floatValue]] forKey:KEY_BLEND];
[newDict setObject:[NSNumber numberWithFloat:[blurRadius floatValue]] forKey:KEY_BLUR_RADIUS];
Loading
Loading
@@ -4193,6 +4196,7 @@ static float versionNumber;
KEY_CURSOR_TYPE,
KEY_USE_BOLD_FONT,
KEY_USE_BRIGHT_BOLD,
KEY_USE_ITALIC_FONT,
KEY_ASCII_ANTI_ALIASED,
KEY_NONASCII_ANTI_ALIASED,
KEY_ANTI_ALIASING,
Loading
Loading
Loading
Loading
@@ -125,6 +125,7 @@ typedef struct screen_char_t
// and may be rendered as some combination of font choice and color
// intensity.
unsigned int bold : 1;
unsigned int italic : 1;
unsigned int blink : 1;
unsigned int underline : 1;
Loading
Loading
@@ -146,6 +147,7 @@ static inline void CopyForegroundColor(screen_char_t* to, const screen_char_t fr
to->foregroundColor = from.foregroundColor;
to->alternateForegroundSemantics = from.alternateForegroundSemantics;
to->bold = from.bold;
to->italic = from.italic;
to->blink = from.blink;
to->underline = from.underline;
}
Loading
Loading
@@ -172,6 +174,7 @@ static inline BOOL ForegroundColorsEqual(const screen_char_t a,
return a.foregroundColor == b.foregroundColor &&
a.alternateForegroundSemantics == b.alternateForegroundSemantics &&
a.bold == b.bold &&
a.italic == b.italic &&
a.blink == b.blink &&
a.underline == b.underline;
}
Loading
Loading
Loading
Loading
@@ -98,7 +98,7 @@ typedef struct {
// TODO not supported (SGR 8)
}
if (attributes & GRID_ATTR_ITALICS) {
// TODO not supported
temp.italic = YES;
}
if (attributes & GRID_ATTR_CHARSET) {
// TODO not supported
Loading
Loading
Loading
Loading
@@ -124,6 +124,7 @@ void StringToScreenChars(NSString *s,
buf[j].foregroundColor = fg.foregroundColor;
buf[j].alternateForegroundSemantics = fg.alternateForegroundSemantics;
buf[j].bold = fg.bold;
buf[j].italic = fg.italic;
buf[j].blink = fg.blink;
buf[j].underline = fg.underline;
 
Loading
Loading
@@ -151,6 +152,7 @@ void StringToScreenChars(NSString *s,
buf[j].foregroundColor = fg.foregroundColor;
buf[j].alternateForegroundSemantics = fg.alternateForegroundSemantics;
buf[j].bold = fg.bold;
buf[j].italic = fg.italic;
buf[j].blink = fg.blink;
buf[j].underline = fg.underline;
 
Loading
Loading
@@ -186,6 +188,7 @@ void StringToScreenChars(NSString *s,
buf[j].foregroundColor = fg.foregroundColor;
buf[j].alternateForegroundSemantics = fg.alternateForegroundSemantics;
buf[j].bold = fg.bold;
buf[j].italic = fg.italic;
buf[j].blink = fg.blink;
buf[j].underline = fg.underline;
 
Loading
Loading
Loading
Loading
@@ -172,12 +172,14 @@ typedef struct {
// character attributes
#define VT100CHARATTR_ALLOFF 0
#define VT100CHARATTR_BOLD 1
#define VT100CHARATTR_ITALIC 3
#define VT100CHARATTR_UNDER 4
#define VT100CHARATTR_BLINK 5
#define VT100CHARATTR_REVERSE 7
 
// xterm additions
#define VT100CHARATTR_NORMAL 22
#define VT100CHARATTR_NOT_ITALIC 23
#define VT100CHARATTR_NOT_UNDER 24
#define VT100CHARATTR_STEADY 25
#define VT100CHARATTR_POSITIVE 27
Loading
Loading
@@ -341,9 +343,9 @@ typedef enum {
BOOL alternateForegroundSemantics;
int BG_COLORCODE;
BOOL alternateBackgroundSemantics;
int bold, under, blink, reversed;
int bold, italic, under, blink, reversed;
 
int saveBold, saveUnder, saveBlink, saveReversed;
int saveBold, saveItalic, saveUnder, saveBlink, saveReversed;
int saveCHARSET;
int saveForeground;
BOOL saveAltForeground;
Loading
Loading
Loading
Loading
@@ -1661,8 +1661,8 @@ static VT100TCC decode_string(unsigned char *datap,
INSERT_MODE = NO;
saveCHARSET=CHARSET = NO;
XON = YES;
bold = blink = reversed = under = NO;
saveBold = saveBlink = saveReversed = saveUnder = NO;
bold = italic = blink = reversed = under = NO;
saveBold = saveItalic = saveBlink = saveReversed = saveUnder = NO;
FG_COLORCODE = ALTSEM_FG_DEFAULT;
alternateForegroundSemantics = YES;
BG_COLORCODE = ALTSEM_BG_DEFAULT;
Loading
Loading
@@ -1770,6 +1770,7 @@ static VT100TCC decode_string(unsigned char *datap,
- (void)saveCursorAttributes
{
saveBold = bold;
saveItalic = italic;
saveUnder = under;
saveBlink = blink;
saveReversed = reversed;
Loading
Loading
@@ -1783,6 +1784,7 @@ static VT100TCC decode_string(unsigned char *datap,
- (void)restoreCursorAttributes
{
bold=saveBold;
italic=saveItalic;
under=saveUnder;
blink=saveBlink;
reversed=saveReversed;
Loading
Loading
@@ -1820,8 +1822,8 @@ static VT100TCC decode_string(unsigned char *datap,
INSERT_MODE = NO;
saveCHARSET=CHARSET = NO;
XON = YES;
bold = blink = reversed = under = NO;
saveBold = saveBlink = saveReversed = saveUnder = NO;
bold = italic = blink = reversed = under = NO;
saveBold = saveItalic = saveBlink = saveReversed = saveUnder = NO;
FG_COLORCODE = ALTSEM_FG_DEFAULT;
alternateForegroundSemantics = YES;
BG_COLORCODE = ALTSEM_BG_DEFAULT;
Loading
Loading
@@ -2519,6 +2521,7 @@ static VT100TCC decode_string(unsigned char *datap,
result.alternateForegroundSemantics = alternateForegroundSemantics;
}
result.bold = bold;
result.italic = italic;
result.underline = under;
result.blink = blink;
return result;
Loading
Loading
@@ -2543,6 +2546,7 @@ static VT100TCC decode_string(unsigned char *datap,
result.foregroundColor = FG_COLORCODE;
result.alternateForegroundSemantics = alternateForegroundSemantics;
result.bold = bold;
result.italic = italic;
result.underline = under;
result.blink = blink;
return result;
Loading
Loading
@@ -2737,7 +2741,7 @@ static VT100TCC decode_string(unsigned char *datap,
if (token.type == VT100CSI_SGR) {
if (token.u.csi.count == 0) {
// all attribute off
bold = under = blink = reversed = NO;
bold = italic = under = blink = reversed = NO;
FG_COLORCODE = ALTSEM_FG_DEFAULT;
alternateForegroundSemantics = YES;
BG_COLORCODE = ALTSEM_BG_DEFAULT;
Loading
Loading
@@ -2749,7 +2753,7 @@ static VT100TCC decode_string(unsigned char *datap,
switch (n) {
case VT100CHARATTR_ALLOFF:
// all attribute off
bold = under = blink = reversed = NO;
bold = italic = under = blink = reversed = NO;
FG_COLORCODE = ALTSEM_FG_DEFAULT;
alternateForegroundSemantics = YES;
BG_COLORCODE = ALTSEM_BG_DEFAULT;
Loading
Loading
@@ -2762,6 +2766,12 @@ static VT100TCC decode_string(unsigned char *datap,
case VT100CHARATTR_NORMAL:
bold = NO;
break;
case VT100CHARATTR_ITALIC:
italic = YES;
break;
case VT100CHARATTR_NOT_ITALIC:
italic = NO;
break;
case VT100CHARATTR_UNDER:
under = YES;
break;
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment