| 1111 | | } |
|---|
| 1112 | | |
|---|
| 1113 | | //XXX Jabber can send a tag like so: <span style='font-family: Helvetica; font-size: small; '> |
|---|
| 1114 | | |
|---|
| | 1111 | } else if ([arg caseInsensitiveCompare:@"style"] == NSOrderedSame) { |
|---|
| | 1112 | NSString *style = [inArgs objectForKey:arg]; |
|---|
| | 1113 | int styleLength = [style length]; |
|---|
| | 1114 | NSRange attributeRange; |
|---|
| | 1115 | |
|---|
| | 1116 | attributeRange = [style rangeOfString:@"font-family: " options:NSCaseInsensitiveSearch]; |
|---|
| | 1117 | if (attributeRange.location != NSNotFound) { |
|---|
| | 1118 | NSRange nextSemicolon =[style rangeOfString:@";" options:NSLiteralSearch range:NSMakeRange(attributeRange.location, styleLength - attributeRange.location)]; |
|---|
| | 1119 | NSString *fontFamily = [style substringWithRange:NSMakeRange(NSMaxRange(attributeRange), nextSemicolon.location - NSMaxRange(attributeRange))]; |
|---|
| | 1120 | |
|---|
| | 1121 | [textAttributes setFontFamily:fontFamily]; |
|---|
| | 1122 | } |
|---|
| | 1123 | |
|---|
| | 1124 | attributeRange = [style rangeOfString:@"font-size: " options:NSCaseInsensitiveSearch]; |
|---|
| | 1125 | if (attributeRange.location != NSNotFound) { |
|---|
| | 1126 | NSRange nextSemicolon =[style rangeOfString:@";" options:NSLiteralSearch range:NSMakeRange(attributeRange.location, styleLength - attributeRange.location)]; |
|---|
| | 1127 | NSString *fontSize = [style substringWithRange:NSMakeRange(NSMaxRange(attributeRange), nextSemicolon.location - NSMaxRange(attributeRange))]; |
|---|
| | 1128 | |
|---|
| | 1129 | static int stylePointSizes[] = { 9, 10, 12, 14, 18, 24 }; |
|---|
| | 1130 | int size = 12; |
|---|
| | 1131 | |
|---|
| | 1132 | if ([fontSize caseInsensitiveCompare:@"xx-small"] == NSOrderedSame) { |
|---|
| | 1133 | size = stylePointSizes[0]; |
|---|
| | 1134 | |
|---|
| | 1135 | } else if ([fontSize caseInsensitiveCompare:@"x-small"] == NSOrderedSame) { |
|---|
| | 1136 | size = stylePointSizes[1]; |
|---|
| | 1137 | |
|---|
| | 1138 | } else if ([fontSize caseInsensitiveCompare:@"small"] == NSOrderedSame) { |
|---|
| | 1139 | size = stylePointSizes[2]; |
|---|
| | 1140 | |
|---|
| | 1141 | } else if ([fontSize caseInsensitiveCompare:@"medium"] == NSOrderedSame) { |
|---|
| | 1142 | size = stylePointSizes[3]; |
|---|
| | 1143 | |
|---|
| | 1144 | } else if ([fontSize caseInsensitiveCompare:@"large"] == NSOrderedSame) { |
|---|
| | 1145 | size = stylePointSizes[4]; |
|---|
| | 1146 | |
|---|
| | 1147 | } else if ([fontSize caseInsensitiveCompare:@"x-large"] == NSOrderedSame) { |
|---|
| | 1148 | size = stylePointSizes[5]; |
|---|
| | 1149 | } |
|---|
| | 1150 | |
|---|
| | 1151 | [textAttributes setFontSize:size]; |
|---|
| | 1152 | } |
|---|
| | 1153 | |
|---|
| | 1154 | attributeRange = [style rangeOfString:@"color: " options:NSCaseInsensitiveSearch]; |
|---|
| | 1155 | if (attributeRange.location != NSNotFound) { |
|---|
| | 1156 | NSRange nextSemicolon =[style rangeOfString:@";" options:NSLiteralSearch range:NSMakeRange(attributeRange.location, styleLength - attributeRange.location)]; |
|---|
| | 1157 | NSString *hexColor = [style substringWithRange:NSMakeRange(NSMaxRange(attributeRange), nextSemicolon.location - NSMaxRange(attributeRange))]; |
|---|
| | 1158 | |
|---|
| | 1159 | [textAttributes setTextColor:[NSColor colorWithHTMLString:hexColor |
|---|
| | 1160 | defaultColor:[NSColor blackColor]]]; |
|---|
| | 1161 | |
|---|
| | 1162 | } |
|---|
| | 1163 | } |
|---|