├── .gitattributes ├── .gitignore ├── .gitmodules ├── MNCoder.xcworkspace └── contents.xcworkspacedata ├── MNCoder ├── IntermediateObjects │ ├── MNCAttributedString.h │ ├── MNCAttributedString.m │ ├── MNCColor.h │ ├── MNCColor.m │ ├── MNCFont.h │ ├── MNCFont.m │ └── NSAttributedStrings │ │ ├── MNASCharacterShape.h │ │ ├── MNASCharacterShape.m │ │ ├── MNASFont.h │ │ ├── MNASFont.m │ │ ├── MNASForegroundColor.h │ │ ├── MNASForegroundColor.m │ │ ├── MNASGlyphInfo.h │ │ ├── MNASGlyphInfo.m │ │ ├── MNASKern.h │ │ ├── MNASKern.m │ │ ├── MNASLigature.h │ │ ├── MNASLigature.m │ │ ├── MNASParagraphyStyle.h │ │ ├── MNASParagraphyStyle.m │ │ ├── MNASStrokeColor.h │ │ ├── MNASStrokeColor.m │ │ ├── MNASStrokeWidth.h │ │ ├── MNASStrokeWidth.m │ │ ├── MNASSuperScript.h │ │ ├── MNASSuperScript.m │ │ ├── MNASTextTab.h │ │ ├── MNASTextTab.m │ │ ├── MNASUnderlineColor.h │ │ ├── MNASUnderlineColor.m │ │ ├── MNASUnderlineStyle.h │ │ ├── MNASUnderlineStyle.m │ │ ├── MNASVerticalForms.h │ │ └── MNASVerticalForms.m ├── MNArchiver.h ├── MNArchiver.m ├── MNCIntermediateObjectProtocol.h ├── MNCoder.h ├── MNCoder.m ├── MNUnarchiver.h └── MNUnarchiver.m ├── Mac ├── Mac.xcodeproj │ ├── project.pbxproj │ └── xcshareddata │ │ └── xcschemes │ │ └── Mac.xcscheme └── Mac │ ├── MNAppDelegate.h │ ├── MNAppDelegate.m │ ├── Mac-Info.plist │ ├── Mac-Prefix.pch │ ├── en.lproj │ ├── Credits.rtf │ ├── InfoPlist.strings │ └── MainMenu.xib │ └── main.m ├── NSAttributedStringsMappingModel.csv ├── README.md └── iOS ├── iOS.xcodeproj ├── project.pbxproj └── xcshareddata │ └── xcschemes │ └── iOS.xcscheme └── iOS ├── MNAppDelegate.h ├── MNAppDelegate.m ├── MNViewController.h ├── MNViewController.m ├── en.lproj ├── InfoPlist.strings └── MNViewController.xib ├── iOS-Info.plist ├── iOS-Prefix.pch └── main.m /.gitattributes: -------------------------------------------------------------------------------- 1 | *.m diff=objc 2 | *.mm diff=objc 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | build/* 3 | *.pbxuser 4 | !default.pbxuser 5 | *.mode1v3 6 | !default.mode1v3 7 | *.mode2v3 8 | !default.mode2v3 9 | *.perspectivev3 10 | !default.perspectivev3 11 | !default.xcworkspace 12 | !project.xcworkspace 13 | xcuserdata 14 | profile 15 | *.moved-aside 16 | .com.apple.timemachine.supported 17 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Vendor/EGOTextView"] 2 | path = Vendor/EGOTextView 3 | url = https://github.com/enormego/EGOTextView.git 4 | -------------------------------------------------------------------------------- /MNCoder.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/MNCAttributedString.h: -------------------------------------------------------------------------------- 1 | // 2 | // MNAttributedString.h 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/16/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import 31 | #import "MNCIntermediateObjectProtocol.h" 32 | 33 | extern NSString *const kMNAttributedStringAttributeAttributeKey; 34 | extern NSString *const kMNAttributedStringAttributeRangeKey; 35 | 36 | @protocol MNCAttributedStringAttributeProtocol 37 | @required 38 | -(NSDictionary *)platformRepresentation; 39 | +(BOOL)isSubstituteForObject:(void *)object; 40 | -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range:(NSRange)range forAttributedString:(NSAttributedString *)string; 41 | @end 42 | 43 | @interface MNCAttributedString : NSObject { 44 | @private 45 | NSMutableSet *__substituteClasses; 46 | 47 | NSString *_string; 48 | NSArray *_attributes; 49 | } 50 | 51 | @property (readonly) NSString *string; 52 | @property (readonly) NSArray *attributes; 53 | 54 | -(id)initWithAttributedString:(NSAttributedString *)string; 55 | -(NSAttributedString *)attributedString; 56 | 57 | -(void)registerSubstituteClass:(Class)cls; 58 | -(void)unregisterSubtituteClass:(Class)cls; 59 | 60 | +(BOOL)lossless; 61 | +(void)setLossless:(BOOL)lossless; 62 | 63 | #if TARGET_OS_IPHONE 64 | +(BOOL)hasUIKitAdditions; 65 | #endif 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/MNCAttributedString.m: -------------------------------------------------------------------------------- 1 | // 2 | // MNAttributedString.m 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/16/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNCAttributedString.h" 31 | 32 | #import "MNASParagraphyStyle.h" 33 | #import "MNASGlyphInfo.h" 34 | #import "MNASCharacterShape.h" 35 | #import "MNASKern.h" 36 | #import "MNASStrokeWidth.h" 37 | #import "MNASLigature.h" 38 | #import "MNASSuperScript.h" 39 | #import "MNASUnderlineStyle.h" 40 | #import "MNASForegroundColor.h" 41 | #import "MNASStrokeColor.h" 42 | #import "MNASUnderlineColor.h" 43 | #import "MNASVerticalForms.h" 44 | #import "MNASFont.h" 45 | 46 | NSString *const kMNAttributedStringAttributeAttributeKey = @"kMNAttributedStringAttributeAttributeKey"; 47 | NSString *const kMNAttributedStringAttributeRangeKey = @"kMNAttributedStringAttributeRangeKey"; 48 | 49 | @interface MNCAttributedString (/* Private Methods */) 50 | -(void)_buildIntermediateRepresentationFromString:(NSAttributedString *)string; 51 | -(NSDictionary *)_dictionaryForAttributes:(NSDictionary *)attrs range:(NSRange)aRange; 52 | +(NSRange)_rangeFromRangeDictionaryItem:(id)rangeItem; 53 | +(NSString *)_rangeStringFromRange:(NSRange)range; 54 | @end 55 | 56 | @implementation MNCAttributedString 57 | @synthesize string = _string, attributes = _attributes; 58 | 59 | #pragma mark - NSCoding Protocol 60 | 61 | -(id)initWithCoder:(NSCoder *)aDecoder { 62 | if ((self = [super init])) { 63 | _string = [[aDecoder decodeObjectForKey:@"string"] copy]; 64 | _attributes = [[aDecoder decodeObjectForKey:@"attributes"] copy]; 65 | __substituteClasses = [[NSMutableSet setWithCapacity:0] retain]; 66 | 67 | [self registerSubstituteClass:[MNASParagraphyStyle class]]; 68 | [self registerSubstituteClass:[MNASGlyphInfo class]]; 69 | [self registerSubstituteClass:[MNASCharacterShape class]]; 70 | [self registerSubstituteClass:[MNASKern class]]; 71 | [self registerSubstituteClass:[MNASLigature class]]; 72 | [self registerSubstituteClass:[MNASStrokeWidth class]]; 73 | [self registerSubstituteClass:[MNASSuperScript class]]; 74 | [self registerSubstituteClass:[MNASUnderlineStyle class]]; 75 | [self registerSubstituteClass:[MNASForegroundColor class]]; 76 | [self registerSubstituteClass:[MNASStrokeColor class]]; 77 | [self registerSubstituteClass:[MNASUnderlineColor class]]; 78 | [self registerSubstituteClass:[MNASVerticalForms class]]; 79 | [self registerSubstituteClass:[MNASFont class]]; 80 | } 81 | return self; 82 | } 83 | 84 | -(void)encodeWithCoder:(NSCoder *)aCoder { 85 | [aCoder encodeObject:self.string forKey:@"string"]; 86 | [aCoder encodeObject:self.attributes forKey:@"attributes"]; 87 | } 88 | 89 | #pragma mark - Platform specific representation 90 | 91 | -(id)initWithAttributedString:(NSAttributedString *)string { 92 | if ((self = [super init])) { 93 | __substituteClasses = [[NSMutableSet setWithCapacity:0] retain]; 94 | 95 | [self registerSubstituteClass:[MNASParagraphyStyle class]]; 96 | [self registerSubstituteClass:[MNASGlyphInfo class]]; 97 | [self registerSubstituteClass:[MNASCharacterShape class]]; 98 | [self registerSubstituteClass:[MNASKern class]]; 99 | [self registerSubstituteClass:[MNASLigature class]]; 100 | [self registerSubstituteClass:[MNASStrokeWidth class]]; 101 | [self registerSubstituteClass:[MNASSuperScript class]]; 102 | [self registerSubstituteClass:[MNASUnderlineStyle class]]; 103 | [self registerSubstituteClass:[MNASForegroundColor class]]; 104 | [self registerSubstituteClass:[MNASStrokeColor class]]; 105 | [self registerSubstituteClass:[MNASUnderlineColor class]]; 106 | [self registerSubstituteClass:[MNASVerticalForms class]]; 107 | [self registerSubstituteClass:[MNASFont class]]; 108 | 109 | [self _buildIntermediateRepresentationFromString:string]; 110 | } 111 | 112 | return self; 113 | } 114 | 115 | -(NSAttributedString *)attributedString { 116 | NSMutableAttributedString *aString = [[NSMutableAttributedString alloc] initWithString:self.string]; 117 | id attributeObj = nil; 118 | id attributeToInsert = nil; 119 | 120 | #if TARGET_OS_IPHONE 121 | NSRange range; 122 | #endif 123 | 124 | for (NSDictionary *dict in self.attributes) { 125 | 126 | attributeObj = [dict objectForKey:kMNAttributedStringAttributeAttributeKey]; 127 | 128 | if ([attributeObj conformsToProtocol:@protocol(MNCAttributedStringAttributeProtocol)]) { 129 | attributeToInsert = [attributeObj platformRepresentation]; 130 | } else { 131 | attributeToInsert = attributeObj; 132 | } 133 | 134 | #if TARGET_OS_IPHONE 135 | // translate for iOS 136 | range = [[self class] _rangeFromRangeDictionaryItem:[dict objectForKey:kMNAttributedStringAttributeRangeKey]]; 137 | CFAttributedStringSetAttributes((CFMutableAttributedStringRef)aString, CFRangeMake(range.location, range.length) , (CFDictionaryRef)attributeToInsert, false); 138 | 139 | #else 140 | // translate for Mac 141 | [aString addAttributes:attributeToInsert range:[[self class] _rangeFromRangeDictionaryItem:[dict objectForKey:kMNAttributedStringAttributeRangeKey]]]; 142 | #endif 143 | } 144 | 145 | return [aString autorelease]; 146 | } 147 | 148 | -(Class)_substituteClassForObject:(void *)object { 149 | for (Class cls in __substituteClasses) { 150 | if ([cls isSubstituteForObject:object]) { 151 | return cls; 152 | } 153 | } 154 | return nil; 155 | } 156 | 157 | -(void)_buildIntermediateRepresentationFromString:(NSAttributedString *)string { 158 | _string = [string.string copy]; 159 | NSMutableArray *attributes = [NSMutableArray arrayWithCapacity:0]; 160 | [attributes addObject:[NSNull null]]; 161 | 162 | [string enumerateAttributesInRange:NSMakeRange(0, [_string length]) options:NSAttributedStringEnumerationReverse usingBlock:^(NSDictionary *attrs, NSRange range, BOOL *stop) { 163 | 164 | Class subsituteClass = nil; 165 | id subsituteObject = nil; 166 | 167 | NSUInteger idx = 0; 168 | 169 | for (NSString *key in attrs) { 170 | subsituteClass = [self _substituteClassForObject:key]; 171 | if (subsituteClass) { 172 | subsituteObject = [[subsituteClass alloc] initWithAttributeName:key value:[attrs objectForKey:key] range:range forAttributedString:string]; 173 | [attributes insertObject:[self _dictionaryForAttributes:subsituteObject range:range] atIndex:([attributes count]-1)]; 174 | [subsituteObject release], subsituteObject = nil; 175 | } else { 176 | NSLog(@"Attribute not translated ->> (%@): %@", key, [attrs objectForKey:key]); 177 | 178 | if (([MNCAttributedString lossless]) && ([[attrs objectForKey:key] conformsToProtocol:@protocol(NSCoding)])) { 179 | [attributes insertObject:[self _dictionaryForAttributes:[NSDictionary dictionaryWithObject:[attrs objectForKey:key] forKey:key] range:range] atIndex:([attributes count]-1)]; 180 | } 181 | } 182 | idx++; 183 | } 184 | }]; 185 | 186 | [attributes removeLastObject]; 187 | [_attributes release], _attributes = nil; 188 | 189 | _attributes = [attributes copy]; 190 | } 191 | 192 | -(void)dealloc { 193 | [__substituteClasses release], __substituteClasses = nil; 194 | [_string release], _string = nil; 195 | [_attributes release], _string = nil; 196 | [super dealloc]; 197 | } 198 | 199 | -(NSDictionary *)_dictionaryForAttributes:(NSDictionary *)attrs range:(NSRange)aRange { 200 | NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:3]; 201 | [dict setObject:[[self class] _rangeStringFromRange:aRange] 202 | forKey:kMNAttributedStringAttributeRangeKey]; 203 | [dict setObject:attrs forKey:kMNAttributedStringAttributeAttributeKey]; 204 | 205 | return dict; 206 | } 207 | 208 | #pragma mark - Deal with NSRange 209 | 210 | +(NSRange)_rangeFromRangeDictionaryItem:(id)rangeItem { 211 | if ([rangeItem isKindOfClass:[NSString class]]) { 212 | return NSRangeFromString(rangeItem); 213 | } else if ([rangeItem isKindOfClass:[NSValue class]]) { 214 | return [rangeItem rangeValue]; 215 | } else { 216 | return NSMakeRange(0, 0); 217 | } 218 | } 219 | 220 | +(NSString *)_rangeStringFromRange:(NSRange)range { 221 | return NSStringFromRange(range); 222 | } 223 | 224 | #pragma mark - Substitute Class Methods 225 | -(void)registerSubstituteClass:(Class)cls { 226 | if ([cls conformsToProtocol:@protocol(MNCAttributedStringAttributeProtocol)]) 227 | [__substituteClasses addObject:cls]; 228 | } 229 | 230 | -(void)unregisterSubtituteClass:(Class)cls { 231 | if ([cls conformsToProtocol:@protocol(MNCAttributedStringAttributeProtocol)]) 232 | [__substituteClasses removeObject:cls]; 233 | } 234 | 235 | #pragma mark - Detection of UIKit Additions 236 | 237 | #if TARGET_OS_IPHONE 238 | +(BOOL)hasUIKitAdditions { 239 | return ([[[UIDevice currentDevice] systemVersion] compare:@"6.0"] != NSOrderedDescending); 240 | } 241 | #endif 242 | 243 | 244 | #pragma mark - Lossy switch 245 | static BOOL _MNAttributedStringLossless = YES; 246 | 247 | +(BOOL)lossless { 248 | return _MNAttributedStringLossless; 249 | } 250 | 251 | +(void)setLossless:(BOOL)lossless { 252 | _MNAttributedStringLossless = lossless; 253 | } 254 | 255 | #pragma mark - MNCIntermediateObject Protocol 256 | 257 | -(id)initWithSubsituteObject:(void *)object { 258 | return [self initWithAttributedString:(id)object]; 259 | } 260 | 261 | +(BOOL)isSubstituteForObject:(void *)object { 262 | return [(id)object isKindOfClass:[NSAttributedString class]]; 263 | } 264 | 265 | 266 | -(id)platformRepresentation { 267 | return [self attributedString]; 268 | } 269 | 270 | @end 271 | -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/MNCColor.h: -------------------------------------------------------------------------------- 1 | // 2 | // MNColor.h 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/7/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #if TARGET_OS_IPHONE 31 | #import 32 | #else 33 | #import 34 | #endif 35 | 36 | #import "MNCIntermediateObjectProtocol.h" 37 | 38 | @interface MNCColor : NSObject { 39 | @private 40 | CGFloat _red; 41 | CGFloat _green; 42 | CGFloat _blue; 43 | CGFloat _alpha; 44 | } 45 | 46 | @property (readonly) CGFloat red; 47 | @property (readonly) CGFloat green; 48 | @property (readonly) CGFloat blue; 49 | @property (readonly) CGFloat alpha; 50 | 51 | #if TARGET_OS_IPHONE 52 | -(id)initWithColor:(UIColor *)color; 53 | -(UIColor *)color; 54 | #else 55 | -(id)initWithColor:(NSColor *)color; 56 | -(NSColor *)color; 57 | #endif 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/MNCColor.m: -------------------------------------------------------------------------------- 1 | // 2 | // MNColor.m 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/7/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNCColor.h" 31 | 32 | @implementation MNCColor 33 | @synthesize red = _red, green = _green, blue = _blue, alpha = _alpha; 34 | 35 | #pragma mark - NSCoding Protocol 36 | 37 | -(id)initWithCoder:(NSCoder *)aDecoder { 38 | if ((self = [super init])) { 39 | _red = [aDecoder decodeFloatForKey:@"red"]; 40 | _green = [aDecoder decodeFloatForKey:@"green"]; 41 | _blue = [aDecoder decodeFloatForKey:@"blue"]; 42 | _alpha = [aDecoder decodeFloatForKey:@"alpha"]; 43 | } 44 | 45 | return self; 46 | } 47 | 48 | -(void)encodeWithCoder:(NSCoder *)aCoder { 49 | [aCoder encodeFloat:self.red forKey:@"red"]; 50 | [aCoder encodeFloat:self.green forKey:@"green"]; 51 | [aCoder encodeFloat:self.blue forKey:@"blue"]; 52 | [aCoder encodeFloat:self.alpha forKey:@"alpha"]; 53 | } 54 | 55 | #pragma mark - Platform specific representation 56 | 57 | #if TARGET_OS_IPHONE 58 | 59 | -(id)initWithColor:(UIColor *)color { 60 | if ((self = [super init])) { 61 | [color getRed:&_red green:&_green blue:&_blue alpha:&_alpha]; 62 | } 63 | return self; 64 | } 65 | 66 | -(UIColor *)color { 67 | return [UIColor colorWithRed:self.red green:self.green blue:self.blue alpha:self.alpha]; 68 | } 69 | 70 | #else 71 | 72 | -(id)initWithColor:(NSColor *)color { 73 | if ((self = [super init])) { 74 | 75 | NSColor *calibratedColor = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; 76 | 77 | _red = [calibratedColor redComponent]; 78 | _green = [calibratedColor greenComponent]; 79 | _blue = [calibratedColor blueComponent]; 80 | _alpha = [calibratedColor alphaComponent]; 81 | } 82 | return self; 83 | } 84 | 85 | -(NSColor *)color { 86 | return [NSColor colorWithCalibratedRed:self.red green:self.green blue:self.blue alpha:self.alpha]; 87 | } 88 | #endif 89 | 90 | -(NSString *)description { 91 | return [NSString stringWithFormat:@"MNColor: red(%f) green(%f) blue(%f) alpha(%f)", self.red, self.green, self.blue, self.alpha]; 92 | } 93 | 94 | #pragma mark - MNCIntermediateObject Protocol 95 | 96 | -(id)initWithSubsituteObject:(void *)object { 97 | return [self initWithColor:object]; 98 | } 99 | 100 | +(BOOL)isSubstituteForObject:(void *)object { 101 | #if TARGET_OS_IPHONE 102 | return [(id)object isKindOfClass:[UIColor class]]; 103 | #else 104 | return [(id)object isKindOfClass:[NSColor class]]; 105 | #endif 106 | } 107 | 108 | -(id)platformRepresentation { 109 | return [self color]; 110 | } 111 | 112 | @end 113 | -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/MNCFont.h: -------------------------------------------------------------------------------- 1 | // 2 | // MNFont.h 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/7/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #if TARGET_OS_IPHONE 31 | #import 32 | #else 33 | #import 34 | #endif 35 | 36 | #import "MNCIntermediateObjectProtocol.h" 37 | 38 | @interface MNCFont : NSObject { 39 | @private 40 | NSString *_fontName; 41 | CGFloat _size; 42 | } 43 | 44 | @property (readonly) NSString *fontName; 45 | @property (readonly) CGFloat size; 46 | 47 | #if TARGET_OS_IPHONE 48 | -(id)initWithFont:(UIFont *)font; 49 | -(UIFont *)font; 50 | #else 51 | -(id)initWithFont:(NSFont *)font; 52 | -(NSFont *)font; 53 | #endif 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/MNCFont.m: -------------------------------------------------------------------------------- 1 | // 2 | // MNFont.m 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/7/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNCFont.h" 31 | 32 | @implementation MNCFont 33 | @synthesize fontName = _fontName, size = _size; 34 | 35 | #pragma mark - NSCoding Protocol 36 | 37 | -(id)initWithCoder:(NSCoder *)aDecoder { 38 | if ((self = [super init])) { 39 | _fontName = [[aDecoder decodeObjectForKey:@"fontName"] copy]; 40 | _size = [aDecoder decodeFloatForKey:@"size"]; 41 | } 42 | 43 | return self; 44 | } 45 | 46 | -(void)encodeWithCoder:(NSCoder *)aCoder { 47 | [aCoder encodeObject:self.fontName forKey:@"fontName"]; 48 | [aCoder encodeFloat:self.size forKey:@"size"]; 49 | } 50 | 51 | -(void)dealloc { 52 | [_fontName release], _fontName = nil; 53 | [super dealloc]; 54 | } 55 | 56 | #pragma mark - Platform specific representation 57 | 58 | #if TARGET_OS_IPHONE 59 | 60 | -(id)initWithFont:(UIFont *)font { 61 | if ((self = [super init])) { 62 | _fontName = [font.fontName copy] ; 63 | _size = font.pointSize; 64 | } 65 | return self; 66 | } 67 | 68 | -(UIFont *)font { 69 | UIFont *test = [UIFont fontWithName:self.fontName size:self.size]; 70 | 71 | if (test) { 72 | return test; 73 | } else { 74 | return [UIFont systemFontOfSize:self.size]; 75 | } 76 | } 77 | 78 | #else 79 | 80 | -(id)initWithFont:(NSFont *)font { 81 | if ((self = [super init])) { 82 | _fontName = [font.fontName copy]; 83 | _size = font.pointSize; 84 | } 85 | return self; 86 | } 87 | 88 | -(NSFont *)font { 89 | NSFont *test = [NSFont fontWithName:self.fontName size:self.size]; 90 | 91 | if (test) { 92 | return test; 93 | } else { 94 | return [NSFont systemFontOfSize:self.size]; 95 | } 96 | } 97 | #endif 98 | 99 | -(NSString *)description { 100 | return [NSString stringWithFormat:@"MNFont: fontName(%@) pointSize(%f)", self.fontName, self.size]; 101 | } 102 | 103 | 104 | #pragma mark - MNCIntermediateObject Protocol 105 | 106 | -(id)initWithSubsituteObject:(void *)object { 107 | return [self initWithFont:(id)object]; 108 | } 109 | 110 | +(BOOL)isSubstituteForObject:(void *)object { 111 | #if TARGET_OS_IPHONE 112 | return [(id)object isKindOfClass:[UIFont class]]; 113 | #else 114 | return [(id)object isKindOfClass:[NSFont class]]; 115 | #endif 116 | } 117 | 118 | -(id)platformRepresentation { 119 | return [self font]; 120 | } 121 | @end 122 | -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/NSAttributedStrings/MNASCharacterShape.h: -------------------------------------------------------------------------------- 1 | // 2 | // MNASCharacterShape.h 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/21/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNCAttributedString.h" 31 | 32 | #import 33 | #if TARGET_OS_IPHONE 34 | #import 35 | #endif 36 | 37 | @interface MNASCharacterShape : NSObject { 38 | @private 39 | NSNumber *_shapeType; 40 | } 41 | 42 | @property (readonly) NSNumber *shapeType; 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/NSAttributedStrings/MNASCharacterShape.m: -------------------------------------------------------------------------------- 1 | // 2 | // MNASCharacterShape.m 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/21/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNASCharacterShape.h" 31 | 32 | @implementation MNASCharacterShape 33 | @synthesize shapeType = _shapeType; 34 | 35 | #pragma mark - NSCoding Protocol 36 | 37 | -(id)initWithCoder:(NSCoder *)aDecoder { 38 | if ((self = [super init])) { 39 | _shapeType = [[aDecoder decodeObjectForKey:@"shapeType"] retain]; 40 | } 41 | 42 | return self; 43 | } 44 | 45 | -(void)encodeWithCoder:(NSCoder *)aCoder { 46 | [aCoder encodeObject:self.shapeType forKey:@"shapeType"]; 47 | } 48 | 49 | #pragma mark - MNAttributedStringAttribute Protocol 50 | 51 | +(BOOL)isSubstituteForObject:(void *)object { 52 | #if TARGET_OS_IPHONE 53 | return [(id)object isEqualToString:(NSString *)kCTGlyphInfoAttributeName]; 54 | #else 55 | return [(id)object isEqualToString:NSGlyphInfoAttributeName]; 56 | #endif 57 | } 58 | 59 | -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range:(NSRange)range forAttributedString:(NSAttributedString *)string { 60 | if ((self = [super init])) { 61 | _shapeType = [(NSNumber *)object retain]; 62 | } 63 | return self; 64 | } 65 | 66 | -(NSDictionary *)platformRepresentation { 67 | #if TARGET_OS_IPHONE 68 | return [NSDictionary dictionaryWithObject:self.shapeType forKey:(NSString *)kCTCharacterShapeAttributeName]; 69 | #else 70 | return [NSDictionary dictionaryWithObject:self.shapeType forKey:NSCharacterShapeAttributeName]; 71 | #endif 72 | } 73 | 74 | -(void)dealloc { 75 | [_shapeType release], _shapeType = nil; 76 | [super dealloc]; 77 | } 78 | 79 | 80 | @end 81 | -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/NSAttributedStrings/MNASFont.h: -------------------------------------------------------------------------------- 1 | // 2 | // MNASFont.h 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/23/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNCAttributedString.h" 31 | 32 | #import 33 | #if TARGET_OS_IPHONE 34 | #import 35 | #endif 36 | 37 | @interface MNASFont : NSObject { 38 | @private; 39 | NSString *_fontName; 40 | CGFloat _size; 41 | NSNumber *_baseLineAdjustment; 42 | NSNumber *_obliqueness; 43 | NSNumber *_expansion; 44 | } 45 | 46 | @property (readonly) NSString *fontName; 47 | @property (readonly) CGFloat size; 48 | @property (readonly) NSNumber *baseLineAdjustment; 49 | @property (readonly) NSNumber *obliqueness; 50 | @property (readonly) NSNumber *expansion; 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/NSAttributedStrings/MNASFont.m: -------------------------------------------------------------------------------- 1 | // 2 | // MNASFont.m 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/23/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNASFont.h" 31 | 32 | @implementation MNASFont 33 | @synthesize fontName = _fontName, size = _size, baseLineAdjustment = _baseLineAdjustment, obliqueness = _obliqueness, expansion = _expansion; 34 | 35 | #pragma mark - NSCoding Protocol 36 | 37 | -(id)initWithCoder:(NSCoder *)aDecoder { 38 | if ((self = [super init])) { 39 | _fontName = [[aDecoder decodeObjectForKey:@"fontName"] retain]; 40 | _size = [[aDecoder decodeObjectForKey:@"size"] floatValue]; 41 | _baseLineAdjustment = [[aDecoder decodeObjectForKey:@"baselineAdjustment"] retain]; 42 | _obliqueness = [[aDecoder decodeObjectForKey:@"obliqueness"] retain]; 43 | _expansion = [[aDecoder decodeObjectForKey:@"expansion"] retain]; 44 | 45 | } 46 | 47 | return self; 48 | } 49 | 50 | -(void)encodeWithCoder:(NSCoder *)aCoder { 51 | [aCoder encodeObject:self.fontName forKey:@"fontName"]; 52 | [aCoder encodeObject:[NSNumber numberWithFloat:self.size] forKey:@"size"]; 53 | [aCoder encodeObject:self.baseLineAdjustment forKey:@"baselineAdjustment"]; 54 | [aCoder encodeObject:self.obliqueness forKey:@"obliqueness"]; 55 | [aCoder encodeObject:self.expansion forKey:@"expansion"]; 56 | } 57 | 58 | #pragma mark - MNAttributedStringAttribute Protocol 59 | 60 | +(BOOL)isSubstituteForObject:(void *)object { 61 | #if TARGET_OS_IPHONE 62 | return (([(id)object isEqualToString:(NSString *)kCTFontAttributeName]) || ([(id)object isEqualToString:NSFontAttributeName])); 63 | #else 64 | return [(id)object isEqualToString:NSFontAttributeName]; 65 | #endif 66 | } 67 | 68 | -(id)_valueForAttribute:(NSString *)attributeName atRange:(NSRange)theRange forAttributedString:(NSAttributedString *)string { 69 | __block id retValue = nil; 70 | 71 | [string enumerateAttribute:attributeName inRange:theRange options:NSAttributedStringEnumerationReverse usingBlock:^(id value, NSRange range, BOOL *stop) { 72 | if (NSEqualRanges(range, theRange)) { 73 | retValue = value; 74 | *stop = YES; 75 | } 76 | }]; 77 | 78 | return retValue; 79 | } 80 | 81 | -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range:(NSRange)range forAttributedString:(NSAttributedString *)string { 82 | if ((self = [super init])) { 83 | #if TARGET_OS_IPHONE 84 | 85 | CTFontDescriptorRef fontDesc; 86 | 87 | if ([MNCAttributedString hasUIKitAdditions]) { 88 | if ([attributeName isEqualToString:NSFontAttributeName]) { 89 | UIFont *theFont = (UIFont *)object; 90 | 91 | CFStringRef desckeys[] = { kCTFontNameAttribute, kCTFontSizeAttribute }; 92 | CFTypeRef descvalues[] = { (CFStringRef)theFont.fontName, (CFNumberRef)[NSNumber numberWithFloat:theFont.pointSize] }; 93 | CFDictionaryRef descDict = CFDictionaryCreate(kCFAllocatorDefault, (const void **)&desckeys , (const void **)&descvalues, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); 94 | 95 | fontDesc = CTFontDescriptorCreateWithAttributes(descDict); 96 | CFRelease(descDict); 97 | 98 | } else { 99 | fontDesc = CTFontCopyFontDescriptor(object); 100 | } 101 | } else { 102 | fontDesc = CTFontCopyFontDescriptor(object); 103 | } 104 | 105 | _fontName = CTFontDescriptorCopyAttribute(fontDesc, kCTFontNameAttribute); 106 | 107 | _baseLineAdjustment = CTFontDescriptorCopyAttribute(fontDesc, kCTFontBaselineAdjustAttribute); 108 | 109 | CFNumberRef pointSize = CTFontDescriptorCopyAttribute(fontDesc, kCTFontSizeAttribute); 110 | _size = [(NSNumber *)pointSize floatValue]; 111 | CFRelease(pointSize); 112 | 113 | CFDictionaryRef traits = CTFontDescriptorCopyAttribute(fontDesc, kCTFontTraitsAttribute); 114 | _obliqueness = CFDictionaryGetValue(traits, kCTFontSlantTrait); 115 | _expansion = CFDictionaryGetValue(traits, kCTFontWidthTrait); 116 | 117 | CFRetain(_obliqueness); 118 | CFRetain(_expansion); 119 | 120 | CFRelease(traits); 121 | CFRelease(fontDesc); 122 | 123 | #else 124 | 125 | _fontName = (NSString *)CTFontCopyPostScriptName(object); 126 | 127 | _size = ((NSFont *)object).pointSize; 128 | 129 | _baseLineAdjustment = [[self _valueForAttribute:NSBaselineOffsetAttributeName atRange:range forAttributedString:string] copy]; 130 | _obliqueness = [[self _valueForAttribute:NSObliquenessAttributeName atRange:range forAttributedString:string] copy]; 131 | _expansion = [[self _valueForAttribute:NSExpansionAttributeName atRange:range forAttributedString:string] copy]; 132 | 133 | #endif 134 | // set default values if they are not filled in 135 | 136 | if (!_baseLineAdjustment) 137 | _baseLineAdjustment = [[NSNumber numberWithFloat:0.0] retain]; 138 | 139 | if (!_obliqueness) 140 | _obliqueness = [[NSNumber numberWithFloat:0.0] retain]; 141 | 142 | if (!_expansion) 143 | _expansion = [[NSNumber numberWithFloat:0.0] retain]; 144 | 145 | } 146 | return self; 147 | } 148 | 149 | -(NSDictionary *)platformRepresentation { 150 | #if TARGET_OS_IPHONE 151 | 152 | CFStringRef traitskeys[] = { kCTFontSlantTrait, kCTFontWidthTrait }; 153 | CFTypeRef traitsvalues[] = { (CFNumberRef)self.obliqueness, (CFNumberRef)self.expansion }; 154 | 155 | CFDictionaryRef traitsDict = CFDictionaryCreate(kCFAllocatorDefault, (const void **)&traitskeys , (const void **)&traitsvalues, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); 156 | 157 | CFStringRef desckeys[] = { kCTFontNameAttribute, kCTFontBaselineAdjustAttribute, kCTFontTraitsAttribute }; 158 | CFTypeRef descvalues[] = { (CFStringRef)self.fontName, (CFNumberRef)self.baseLineAdjustment, traitsDict }; 159 | 160 | CFDictionaryRef descDict = CFDictionaryCreate(kCFAllocatorDefault, (const void **)&desckeys , (const void **)&descvalues, 3, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); 161 | CTFontDescriptorRef descriptor = CTFontDescriptorCreateWithAttributes(descDict); 162 | CFRelease(traitsDict); 163 | CFRelease(descDict); 164 | 165 | CTFontRef font = CTFontCreateWithFontDescriptor(descriptor, self.size, NULL); 166 | 167 | CFStringRef keys[] = { kCTFontAttributeName }; 168 | CFTypeRef values[] = { font }; 169 | 170 | NSDictionary *platformRepresentation = (NSDictionary *)CFDictionaryCreate(kCFAllocatorDefault, (const void **)&keys , (const void **)&values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); 171 | CFRelease(descriptor); 172 | CFRelease(font); 173 | 174 | return [platformRepresentation autorelease]; 175 | 176 | #else 177 | NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:4]; 178 | if (self.baseLineAdjustment) 179 | [dict setObject:self.baseLineAdjustment forKey:NSBaselineOffsetAttributeName]; 180 | if (self.obliqueness) 181 | [dict setObject:self.obliqueness forKey:NSObliquenessAttributeName]; 182 | if (self.expansion) 183 | [dict setObject:self.expansion forKey:NSExpansionAttributeName]; 184 | 185 | CFStringRef desckeys[] = { kCTFontNameAttribute }; 186 | CFTypeRef descvalues[] = { (CFStringRef)self.fontName }; 187 | 188 | CFDictionaryRef descDict = CFDictionaryCreate(kCFAllocatorDefault, (const void **)&desckeys , (const void **)&descvalues, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); 189 | CTFontDescriptorRef descriptor = CTFontDescriptorCreateWithAttributes(descDict); 190 | CFRelease(descDict); 191 | 192 | CTFontRef font = CTFontCreateWithFontDescriptor(descriptor, self.size, NULL); 193 | CFRelease(descriptor); 194 | 195 | [dict setObject:(NSFont *)font forKey:NSFontAttributeName]; 196 | CFRelease(font); 197 | 198 | return dict; 199 | 200 | #endif 201 | } 202 | 203 | -(void)dealloc { 204 | [_fontName release], _fontName = nil; 205 | [_baseLineAdjustment release], _baseLineAdjustment = nil; 206 | [_obliqueness release], _obliqueness = nil; 207 | [_expansion release], _expansion = nil; 208 | [super dealloc]; 209 | } 210 | 211 | 212 | @end -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/NSAttributedStrings/MNASForegroundColor.h: -------------------------------------------------------------------------------- 1 | // 2 | // MNASForegroundColor.h 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/23/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNCAttributedString.h" 31 | #import "MNCColor.h" 32 | 33 | #import 34 | #if TARGET_OS_IPHONE 35 | #import 36 | #endif 37 | 38 | @interface MNASForegroundColor : NSObject { 39 | @private 40 | 41 | #if TARGET_OS_IPHONE 42 | UIColor *_color; 43 | #else 44 | NSColor *_color; 45 | #endif 46 | } 47 | 48 | #if TARGET_OS_IPHONE 49 | @property (readonly) UIColor *color; 50 | #else 51 | @property (readonly) NSColor *color; 52 | #endif 53 | 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/NSAttributedStrings/MNASForegroundColor.m: -------------------------------------------------------------------------------- 1 | // 2 | // MNASForegroundColor.m 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/23/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNASForegroundColor.h" 31 | 32 | @implementation MNASForegroundColor 33 | @synthesize color = _color; 34 | 35 | #pragma mark - NSCoding Protocol 36 | 37 | -(id)initWithCoder:(NSCoder *)aDecoder { 38 | if ((self = [super init])) { 39 | _color = [[aDecoder decodeObjectForKey:@"color"] retain]; 40 | } 41 | 42 | return self; 43 | } 44 | 45 | -(void)encodeWithCoder:(NSCoder *)aCoder { 46 | [aCoder encodeObject:self.color forKey:@"color"]; 47 | } 48 | 49 | #pragma mark - MNAttributedStringAttribute Protocol 50 | 51 | +(BOOL)isSubstituteForObject:(void *)object { 52 | #if TARGET_OS_IPHONE 53 | return (([(id)object isEqualToString:(NSString *)kCTForegroundColorAttributeName]) || ([(id)object isEqualToString:NSForegroundColorAttributeName])); 54 | #else 55 | return [(id)object isEqualToString:NSForegroundColorAttributeName]; 56 | #endif 57 | } 58 | 59 | -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range:(NSRange)range forAttributedString:(NSAttributedString *)string { 60 | if ((self = [super init])) { 61 | #if TARGET_OS_IPHONE 62 | if ([attributeName isEqualToString:(NSString *)kCTForegroundColorAttributeName]) { 63 | _color = [[UIColor colorWithCGColor:object] retain]; 64 | 65 | } else { 66 | _color = object; 67 | } 68 | 69 | #else 70 | _color = [(id)object retain]; 71 | #endif 72 | } 73 | return self; 74 | } 75 | 76 | -(NSDictionary *)platformRepresentation { 77 | #if TARGET_OS_IPHONE 78 | CFStringRef keys[] = { kCTForegroundColorAttributeName }; 79 | CFTypeRef values[] = { [self.color CGColor] }; 80 | 81 | return [(NSDictionary *)CFDictionaryCreate(kCFAllocatorDefault, (const void **)&keys , (const void **)&values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks) autorelease]; 82 | #else 83 | return [NSDictionary dictionaryWithObject:self.color forKey:NSForegroundColorAttributeName]; 84 | #endif 85 | } 86 | 87 | -(void)dealloc { 88 | [_color release], _color = nil; 89 | [super dealloc]; 90 | } 91 | 92 | 93 | @end -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/NSAttributedStrings/MNASGlyphInfo.h: -------------------------------------------------------------------------------- 1 | // 2 | // MNASGlyphInfo.h 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/16/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNCAttributedString.h" 31 | 32 | #import 33 | #if TARGET_OS_IPHONE 34 | #import 35 | #endif 36 | 37 | @interface MNASGlyphInfo : NSObject { 38 | @private 39 | NSUInteger _characterCollection; 40 | NSUInteger _characterIdentifier; 41 | NSString *_baseString; 42 | } 43 | 44 | @property (readonly) NSUInteger characterCollection; 45 | @property (readonly) NSUInteger characterIdentifier; 46 | @property (readonly) NSString *baseString; 47 | 48 | 49 | #if TARGET_OS_IPHONE 50 | -(id)initWithGlyph:(CTGlyphInfoRef)glyph baseString:(NSString *)baseString; 51 | #else 52 | -(id)initWithGlyph:(NSGlyphInfo *)glyph baseString:(NSString *)baseString; 53 | #endif 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/NSAttributedStrings/MNASGlyphInfo.m: -------------------------------------------------------------------------------- 1 | // 2 | // MNASGlyphInfo.m 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/16/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNASGlyphInfo.h" 31 | 32 | @implementation MNASGlyphInfo 33 | @synthesize characterCollection = _characterCollection, characterIdentifier = _characterIdentifier, baseString = _baseString; 34 | 35 | #pragma mark - NSCoding Protocol 36 | 37 | -(id)initWithCoder:(NSCoder *)aDecoder { 38 | if ((self = [super init])) { 39 | _characterCollection = [[aDecoder decodeObjectForKey:@"characterCollection"] unsignedIntegerValue]; 40 | _characterIdentifier = [[aDecoder decodeObjectForKey:@"characterIdentifier"] unsignedIntegerValue]; 41 | _baseString = [[aDecoder decodeObjectForKey:@"baseString"] copy]; 42 | } 43 | return self; 44 | } 45 | 46 | -(void)encodeWithCoder:(NSCoder *)aCoder { 47 | [aCoder encodeObject:self.baseString forKey:@"baseString"]; 48 | [aCoder encodeObject:[NSNumber numberWithUnsignedInteger:self.characterCollection] forKey:@"characterCollection"]; 49 | [aCoder encodeObject:[NSNumber numberWithUnsignedInteger:self.characterIdentifier] forKey:@"characterIdentifier"]; 50 | } 51 | 52 | #pragma mark - Object Life Cycle 53 | 54 | #if TARGET_OS_IPHONE 55 | 56 | -(id)initWithGlyph:(CTGlyphInfoRef)glyph baseString:(NSString *)baseString { 57 | if ((self = [super init])) { 58 | _characterIdentifier = (NSUInteger)CTGlyphInfoGetCharacterIdentifier(glyph); 59 | _characterCollection = (NSUInteger)CTGlyphInfoGetCharacterCollection(glyph); 60 | _baseString = [baseString copy]; 61 | } 62 | return self; 63 | } 64 | 65 | #else 66 | 67 | -(id)initWithGlyph:(NSGlyphInfo *)glyph baseString:(NSString *)baseString { 68 | if ((self = [super init])) { 69 | _characterCollection = glyph.characterCollection; 70 | _characterIdentifier = glyph.characterIdentifier; 71 | _baseString = [baseString copy]; 72 | } 73 | return self; 74 | } 75 | 76 | #endif 77 | 78 | -(void)dealloc { 79 | [_baseString release], _baseString = nil; 80 | [super dealloc]; 81 | } 82 | 83 | #if TARGET_OS_IPHONE 84 | 85 | -(NSDictionary *)platformRepresentation { 86 | CTGlyphInfoRef glyphinfo = CTGlyphInfoCreateWithCharacterIdentifier(self.characterIdentifier, self.characterCollection, (CFStringRef)self.baseString); 87 | 88 | CFStringRef keys[] = { kCTGlyphInfoAttributeName }; 89 | CFTypeRef values[] = { glyphinfo }; 90 | 91 | CFDictionaryRef dict = CFDictionaryCreate(kCFAllocatorDefault, (const void **)&keys , (const void **)&values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); 92 | CFRelease(glyphinfo); 93 | 94 | return [(NSDictionary *)dict autorelease]; 95 | } 96 | 97 | #else 98 | 99 | -(NSDictionary *)platformRepresentation { 100 | return [NSDictionary dictionaryWithObject:[NSGlyphInfo glyphInfoWithCharacterIdentifier:self.characterIdentifier collection:self.characterCollection baseString:self.baseString] forKey:NSGlyphInfoAttributeName]; 101 | } 102 | 103 | #endif 104 | 105 | #pragma mark - MNCIntermediateObject Protocl 106 | 107 | +(BOOL)isSubstituteForObject:(void *)object { 108 | #if TARGET_OS_IPHONE 109 | return [(id)object isEqualToString:(NSString *)kCTGlyphInfoAttributeName]; 110 | #else 111 | return [(id)object isEqualToString:NSGlyphInfoAttributeName]; 112 | #endif 113 | } 114 | 115 | -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range:(NSRange)range forAttributedString:(NSAttributedString *)string { 116 | #if TARGET_OS_IPHONE 117 | 118 | return [self initWithGlyph:(CTGlyphInfoRef)object baseString:[string.string substringWithRange:range]]; 119 | #else 120 | return [self initWithGlyph:object baseString:[string.string substringWithRange:range]]; 121 | #endif 122 | } 123 | 124 | @end 125 | -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/NSAttributedStrings/MNASKern.h: -------------------------------------------------------------------------------- 1 | // 2 | // MNASKern.h 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/22/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNCAttributedString.h" 31 | 32 | #import 33 | #if TARGET_OS_IPHONE 34 | #import 35 | #endif 36 | 37 | @interface MNASKern : NSObject { 38 | @private 39 | NSNumber *_kern; 40 | } 41 | 42 | @property (readonly) NSNumber *kern; 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/NSAttributedStrings/MNASKern.m: -------------------------------------------------------------------------------- 1 | // 2 | // MNASKern.m 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/22/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNASKern.h" 31 | 32 | @implementation MNASKern 33 | @synthesize kern = _kern; 34 | 35 | #pragma mark - NSCoding Protocol 36 | 37 | -(id)initWithCoder:(NSCoder *)aDecoder { 38 | if ((self = [super init])) { 39 | _kern = [[aDecoder decodeObjectForKey:@"kern"] retain]; 40 | } 41 | 42 | return self; 43 | } 44 | 45 | -(void)encodeWithCoder:(NSCoder *)aCoder { 46 | [aCoder encodeObject:self.kern forKey:@"kern"]; 47 | } 48 | 49 | #pragma mark - MNAttributedStringAttribute Protocol 50 | 51 | +(BOOL)isSubstituteForObject:(void *)object { 52 | #if TARGET_OS_IPHONE 53 | return (([(id)object isEqualToString:(NSString *)kCTKernAttributeName]) || ([(id)object isEqualToString:NSKernAttributeName])); 54 | #else 55 | return [(id)object isEqualToString:NSKernAttributeName]; 56 | #endif 57 | } 58 | 59 | -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range:(NSRange)range forAttributedString:(NSAttributedString *)string { 60 | if ((self = [super init])) { 61 | _kern = [(NSNumber *)object retain]; 62 | } 63 | return self; 64 | } 65 | 66 | -(NSDictionary *)platformRepresentation { 67 | #if TARGET_OS_IPHONE 68 | if ([MNCAttributedString hasUIKitAdditions]) { 69 | return [NSDictionary dictionaryWithObject:self.kern forKey:NSKernAttributeName]; 70 | 71 | } else { 72 | return [NSDictionary dictionaryWithObject:self.kern forKey:(NSString *)kCTKernAttributeName]; 73 | 74 | } 75 | #else 76 | return [NSDictionary dictionaryWithObject:self.kern forKey:NSKernAttributeName]; 77 | #endif 78 | } 79 | 80 | -(void)dealloc { 81 | [_kern release], _kern = nil; 82 | [super dealloc]; 83 | } 84 | 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/NSAttributedStrings/MNASLigature.h: -------------------------------------------------------------------------------- 1 | // 2 | // MNASLigature.h 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/22/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNCAttributedString.h" 31 | 32 | #import 33 | #if TARGET_OS_IPHONE 34 | #import 35 | #endif 36 | 37 | @interface MNASLigature : NSObject { 38 | @private 39 | NSNumber *_type; 40 | 41 | } 42 | 43 | @property (readonly) NSNumber *type; 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/NSAttributedStrings/MNASLigature.m: -------------------------------------------------------------------------------- 1 | // 2 | // MNASLigature.m 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/22/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNASLigature.h" 31 | 32 | @implementation MNASLigature 33 | @synthesize type = _type; 34 | 35 | #pragma mark - NSCoding Protocol 36 | 37 | -(id)initWithCoder:(NSCoder *)aDecoder { 38 | if ((self = [super init])) { 39 | _type = [[aDecoder decodeObjectForKey:@"type"] retain]; 40 | } 41 | 42 | return self; 43 | } 44 | 45 | -(void)encodeWithCoder:(NSCoder *)aCoder { 46 | [aCoder encodeObject:self.type forKey:@"type"]; 47 | } 48 | 49 | #pragma mark - MNAttributedStringAttribute Protocol 50 | 51 | +(BOOL)isSubstituteForObject:(void *)object { 52 | #if TARGET_OS_IPHONE 53 | return (([(id)object isEqualToString:(NSString *)kCTLigatureAttributeName]) || ([(id)object isEqualToString:NSLigatureAttributeName])); 54 | #else 55 | return [(id)object isEqualToString:NSLigatureAttributeName]; 56 | #endif 57 | } 58 | 59 | -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range:(NSRange)range forAttributedString:(NSAttributedString *)string { 60 | if ((self = [super init])) { 61 | _type = [(NSNumber *)object retain]; 62 | } 63 | return self; 64 | } 65 | 66 | -(NSDictionary *)platformRepresentation { 67 | #if TARGET_OS_IPHONE 68 | if ([MNCAttributedString hasUIKitAdditions]) { 69 | return [NSDictionary dictionaryWithObject:self.type forKey:NSLigatureAttributeName]; 70 | 71 | } else { 72 | return [NSDictionary dictionaryWithObject:self.type forKey:(NSString *)kCTLigatureAttributeName]; 73 | 74 | } 75 | #else 76 | return [NSDictionary dictionaryWithObject:self.type forKey:NSLigatureAttributeName]; 77 | #endif 78 | } 79 | 80 | -(void)dealloc { 81 | [_type release], _type = nil; 82 | [super dealloc]; 83 | } 84 | 85 | 86 | @end -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/NSAttributedStrings/MNASParagraphyStyle.h: -------------------------------------------------------------------------------- 1 | // 2 | // MNASParagraphyStyle.h 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/16/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import 31 | #if TARGET_OS_IPHONE 32 | #import 33 | #endif 34 | 35 | #import "MNCAttributedString.h" 36 | 37 | @interface MNASParagraphyStyle : NSObject { 38 | @private 39 | NSUInteger _alignment; 40 | CGFloat _firstLineHeadIndent; 41 | CGFloat _headIndent; 42 | CGFloat _tailIndent; 43 | NSArray *_tabStops; 44 | CGFloat _defaultTabInterval; 45 | CGFloat _lineHeightMultiple; 46 | CGFloat _maximumLineHeight; 47 | CGFloat _minimumLineHeight; 48 | CGFloat _lineSpacing; 49 | CGFloat _paragraphSpacing; 50 | CGFloat _paragraphSpacingBefore; 51 | 52 | NSUInteger _lineBreakMode; 53 | CGFloat _hyphenationFactor; 54 | NSInteger _baseWritingDirection; 55 | 56 | } 57 | 58 | @property (readonly) NSUInteger alignment; 59 | @property (readonly) CGFloat firstLineHeadIndent; 60 | @property (readonly) CGFloat headIndent; 61 | @property (readonly) CGFloat tailIndent; 62 | @property (readonly) NSArray *tabStops; 63 | @property (readonly) CGFloat defaultTabInterval; 64 | @property (readonly) CGFloat lineHeightMultiple; 65 | @property (readonly) CGFloat maximumLineHeight; 66 | @property (readonly) CGFloat minimumLineHeight; 67 | @property (readonly) CGFloat lineSpacing; 68 | @property (readonly) CGFloat paragraphSpacing; 69 | @property (readonly) CGFloat paragraphSpacingBefore; 70 | 71 | // ADD Text Blocks 72 | 73 | @property (readonly) NSUInteger lineBreakMode; 74 | @property (readonly) CGFloat hyphenationFactor; 75 | 76 | // ADD tighteningFactorForTruncation 77 | 78 | @property (readonly) NSInteger baseWritingDirection; 79 | 80 | @end 81 | -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/NSAttributedStrings/MNASParagraphyStyle.m: -------------------------------------------------------------------------------- 1 | // 2 | // MNASParagraphyStyle.m 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/16/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNASParagraphyStyle.h" 31 | #import "MNASTextTab.h" 32 | 33 | @implementation MNASParagraphyStyle 34 | @synthesize alignment = _alignment, firstLineHeadIndent = _firstLineHeadIndent, headIndent = _headIndent; 35 | @synthesize tailIndent = _tailIndent, tabStops = _tabStops, defaultTabInterval = _defaultTabInterval, lineHeightMultiple = _lineHeightMultiple; 36 | @synthesize maximumLineHeight = _maximumLineHeight, minimumLineHeight = _minimumLineHeight, lineSpacing = _lineSpacing; 37 | @synthesize paragraphSpacing = _paragraphSpacing, paragraphSpacingBefore = _paragraphSpacingBefore; 38 | @synthesize lineBreakMode = _lineBreakMode, hyphenationFactor = _hyphenationFactor,baseWritingDirection = _baseWritingDirection; 39 | 40 | #pragma mark - NSCoding Protocol 41 | 42 | -(id)initWithCoder:(NSCoder *)aDecoder { 43 | if ((self = [super init])) { 44 | _tabStops = [[aDecoder decodeObjectForKey:@"tabStops"] copy]; 45 | _alignment = [[aDecoder decodeObjectForKey:@"alignment"] unsignedIntegerValue]; 46 | _lineBreakMode = [[aDecoder decodeObjectForKey:@"lineBreakMode"] unsignedIntegerValue]; 47 | _hyphenationFactor = [aDecoder decodeFloatForKey:@"hyphenationFactor"]; 48 | _baseWritingDirection = [[aDecoder decodeObjectForKey:@"baseWritingDirection"] unsignedIntegerValue]; 49 | 50 | _firstLineHeadIndent = [aDecoder decodeFloatForKey:@"firstLineHeadIdent"]; 51 | _headIndent = [aDecoder decodeFloatForKey:@"headIndent"]; 52 | _tailIndent = [aDecoder decodeFloatForKey:@"tailIndent"]; 53 | _defaultTabInterval = [aDecoder decodeFloatForKey:@"defaultTabInterval"]; 54 | _lineHeightMultiple = [aDecoder decodeFloatForKey:@"lineHeightMultiple"]; 55 | _maximumLineHeight = [aDecoder decodeFloatForKey:@"maximumLineHeight"]; 56 | _minimumLineHeight = [aDecoder decodeFloatForKey:@"minimumLineHeight"]; 57 | _lineSpacing = [aDecoder decodeFloatForKey:@"lineSpacing"]; 58 | _paragraphSpacing = [aDecoder decodeFloatForKey:@"paragraphSpacing"]; 59 | _paragraphSpacingBefore = [aDecoder decodeFloatForKey:@"paragraphSpacingBefore"]; 60 | } 61 | return self; 62 | } 63 | 64 | -(void)encodeWithCoder:(NSCoder *)aCoder { 65 | [aCoder encodeObject:self.tabStops forKey:@"tabStops"]; 66 | [aCoder encodeObject:[NSNumber numberWithUnsignedInteger:self.alignment] forKey:@"alignment"]; 67 | 68 | [aCoder encodeObject:[NSNumber numberWithUnsignedInteger:self.lineBreakMode] forKey:@"lineBreakMode"]; 69 | [aCoder encodeFloat:self.hyphenationFactor forKey:@"hyphenationFactor"]; 70 | [aCoder encodeObject:[NSNumber numberWithUnsignedInteger:self.baseWritingDirection] forKey:@"baseWritingDirection"]; 71 | 72 | [aCoder encodeFloat:self.firstLineHeadIndent forKey:@"firstLineHeadIdent"]; 73 | [aCoder encodeFloat:self.headIndent forKey:@"headIndent"]; 74 | [aCoder encodeFloat:self.tailIndent forKey:@"tailIndent"]; 75 | [aCoder encodeFloat:self.defaultTabInterval forKey:@"defaultTabInterval"]; 76 | [aCoder encodeFloat:self.lineHeightMultiple forKey:@"lineHeightMultiple"]; 77 | [aCoder encodeFloat:self.maximumLineHeight forKey:@"maximumLineHeight"]; 78 | [aCoder encodeFloat:self.minimumLineHeight forKey:@"minimumLineHeight"]; 79 | [aCoder encodeFloat:self.lineSpacing forKey:@"lineSpacing"]; 80 | [aCoder encodeFloat:self.paragraphSpacing forKey:@"paragraphSpacing"]; 81 | [aCoder encodeFloat:self.paragraphSpacingBefore forKey:@"paragraphSpacingBefore"]; 82 | 83 | } 84 | 85 | 86 | -(NSDictionary *)platformRepresentation { 87 | #if TARGET_OS_IPHONE 88 | 89 | if ([MNCAttributedString hasUIKitAdditions]) { 90 | NSMutableParagraphStyle *platRep = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; 91 | 92 | platRep.alignment = self.alignment; 93 | platRep.lineBreakMode = self.lineBreakMode; 94 | platRep.hyphenationFactor = self.hyphenationFactor; 95 | platRep.baseWritingDirection = self.baseWritingDirection; 96 | 97 | platRep.firstLineHeadIndent = self.firstLineHeadIndent; 98 | platRep.headIndent = self.headIndent; 99 | platRep.tailIndent = self.tailIndent; 100 | platRep.lineHeightMultiple = self.lineHeightMultiple; 101 | platRep.maximumLineHeight = self.maximumLineHeight; 102 | platRep.minimumLineHeight = self.minimumLineHeight; 103 | platRep.lineSpacing = self.lineSpacing; 104 | platRep.paragraphSpacing = self.paragraphSpacing; 105 | platRep.paragraphSpacingBefore = self.paragraphSpacingBefore; 106 | 107 | NSDictionary *platformDict = [NSDictionary dictionaryWithObject:platRep forKey:NSParagraphStyleAttributeName]; 108 | [platRep release]; 109 | 110 | return platformDict; 111 | } 112 | 113 | NSMutableArray *tempTabStops = [NSMutableArray arrayWithCapacity:[self.tabStops count]]; 114 | CTTextTabRef cttexttab; 115 | 116 | for (MNASTextTab *textTab in self.tabStops) { 117 | cttexttab = [textTab platformRepresentation]; 118 | 119 | CFArrayAppendValue((CFMutableArrayRef)tempTabStops, cttexttab); 120 | CFRelease(cttexttab); 121 | } 122 | 123 | CTParagraphStyleSetting settings[] = { 124 | { kCTParagraphStyleSpecifierAlignment, sizeof(CTTextAlignment), &_alignment }, 125 | { kCTParagraphStyleSpecifierLineBreakMode, sizeof(NSUInteger), &_lineBreakMode }, 126 | { kCTParagraphStyleSpecifierBaseWritingDirection, sizeof(NSUInteger), &_baseWritingDirection }, 127 | { kCTParagraphStyleSpecifierTabStops, sizeof(CFArrayRef), &tempTabStops }, 128 | { kCTParagraphStyleSpecifierFirstLineHeadIndent, sizeof(CGFloat), &_firstLineHeadIndent }, 129 | { kCTParagraphStyleSpecifierHeadIndent, sizeof(CGFloat), &_headIndent }, 130 | { kCTParagraphStyleSpecifierTailIndent, sizeof(CGFloat), &_tailIndent }, 131 | { kCTParagraphStyleSpecifierDefaultTabInterval, sizeof(CGFloat), &_defaultTabInterval }, 132 | { kCTParagraphStyleSpecifierLineHeightMultiple, sizeof(CGFloat), &_lineHeightMultiple }, 133 | { kCTParagraphStyleSpecifierMaximumLineHeight, sizeof(CGFloat), &_maximumLineHeight }, 134 | { kCTParagraphStyleSpecifierMinimumLineHeight, sizeof(CGFloat), &_minimumLineHeight }, 135 | { kCTParagraphStyleSpecifierLineSpacing, sizeof(CGFloat), &_lineSpacing }, 136 | { kCTParagraphStyleSpecifierParagraphSpacing, sizeof(CGFloat), &_paragraphSpacing }, 137 | { kCTParagraphStyleSpecifierParagraphSpacingBefore, sizeof(CGFloat), &_paragraphSpacingBefore } 138 | 139 | }; 140 | 141 | CTParagraphStyleRef paragraphStyle = CTParagraphStyleCreate(settings, sizeof(settings) / sizeof(CTParagraphStyleSetting)); 142 | 143 | CFStringRef keys[] = { kCTParagraphStyleAttributeName }; 144 | CFTypeRef values[] = { paragraphStyle }; 145 | 146 | CFDictionaryRef dict = CFDictionaryCreate(kCFAllocatorDefault, (const void **)&keys , (const void **)&values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); 147 | CFRelease(paragraphStyle); 148 | 149 | return [(NSDictionary *)dict autorelease]; 150 | #else 151 | NSMutableParagraphStyle *platRep = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; 152 | 153 | platRep.alignment = self.alignment; 154 | platRep.lineBreakMode = self.lineBreakMode; 155 | platRep.hyphenationFactor = self.hyphenationFactor; 156 | platRep.baseWritingDirection = self.baseWritingDirection; 157 | 158 | NSMutableArray *tempTabStops = [NSMutableArray arrayWithCapacity:[self.tabStops count]]; 159 | for (MNASTextTab *textTab in self.tabStops) { 160 | [tempTabStops addObject:[textTab platformRepresentation]]; 161 | } 162 | 163 | platRep.tabStops = tempTabStops; 164 | 165 | platRep.firstLineHeadIndent = self.firstLineHeadIndent; 166 | platRep.headIndent = self.headIndent; 167 | platRep.tailIndent = self.tailIndent; 168 | platRep.defaultTabInterval = self.defaultTabInterval; 169 | platRep.lineHeightMultiple = self.lineHeightMultiple; 170 | platRep.maximumLineHeight = self.maximumLineHeight; 171 | platRep.minimumLineHeight = self.minimumLineHeight; 172 | platRep.lineSpacing = self.lineSpacing; 173 | platRep.paragraphSpacing = self.paragraphSpacing; 174 | platRep.paragraphSpacingBefore = self.paragraphSpacingBefore; 175 | 176 | NSDictionary *platformDict = [NSDictionary dictionaryWithObject:platRep forKey:NSParagraphStyleAttributeName]; 177 | [platRep release]; 178 | 179 | return platformDict; 180 | 181 | #endif 182 | } 183 | 184 | -(void)dealloc { 185 | [_tabStops release], _tabStops = nil; 186 | [super dealloc]; 187 | } 188 | 189 | #pragma mark - MNCIntermediateObject Protocl 190 | 191 | +(BOOL)isSubstituteForObject:(void *)object { 192 | #if TARGET_OS_IPHONE 193 | return (([(id)object isEqualToString:(NSString *)kCTParagraphStyleAttributeName]) || ([(id)object isEqualToString:NSParagraphStyleAttributeName])); 194 | #else 195 | return [(id)object isEqualToString:NSParagraphStyleAttributeName]; 196 | #endif 197 | } 198 | 199 | -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range:(NSRange)range forAttributedString:(NSAttributedString *)string { 200 | if ((self = [super init])) { 201 | #if TARGET_OS_IPHONE 202 | 203 | if ([attributeName isEqualToString:(NSString *)kCTParagraphStyleAttributeName]) { 204 | CTParagraphStyleRef paragraphStyle = (CTParagraphStyleRef)object; 205 | 206 | CTParagraphStyleGetValueForSpecifier(paragraphStyle, kCTParagraphStyleSpecifierAlignment, sizeof(CTTextAlignment), &_alignment); 207 | CTParagraphStyleGetValueForSpecifier(paragraphStyle, kCTParagraphStyleSpecifierLineBreakMode, sizeof(NSUInteger), &_lineBreakMode); 208 | CTParagraphStyleGetValueForSpecifier(paragraphStyle, kCTParagraphStyleSpecifierBaseWritingDirection, sizeof(NSUInteger), &_baseWritingDirection); 209 | 210 | NSArray *tempTabStops; 211 | 212 | CTParagraphStyleGetValueForSpecifier(paragraphStyle, kCTParagraphStyleSpecifierTabStops, sizeof(CFArrayRef), &tempTabStops); 213 | 214 | NSMutableArray *mntexttabs = [NSMutableArray arrayWithCapacity:[tempTabStops count]]; 215 | for (id tabStop in tempTabStops) { 216 | [mntexttabs addObject:[MNASTextTab textTabWithTabStop:(CTTextTabRef)tabStop]]; 217 | } 218 | _tabStops = [mntexttabs copy]; 219 | 220 | CTParagraphStyleGetValueForSpecifier(paragraphStyle, kCTParagraphStyleSpecifierFirstLineHeadIndent, sizeof(CGFloat), &_firstLineHeadIndent); 221 | CTParagraphStyleGetValueForSpecifier(paragraphStyle, kCTParagraphStyleSpecifierHeadIndent, sizeof(CGFloat), &_headIndent); 222 | CTParagraphStyleGetValueForSpecifier(paragraphStyle, kCTParagraphStyleSpecifierTailIndent, sizeof(CGFloat), &_tailIndent); 223 | CTParagraphStyleGetValueForSpecifier(paragraphStyle, kCTParagraphStyleSpecifierDefaultTabInterval, sizeof(CGFloat), &_defaultTabInterval); 224 | CTParagraphStyleGetValueForSpecifier(paragraphStyle, kCTParagraphStyleSpecifierLineHeightMultiple, sizeof(CGFloat), &_lineHeightMultiple); 225 | CTParagraphStyleGetValueForSpecifier(paragraphStyle, kCTParagraphStyleSpecifierMaximumLineHeight, sizeof(CGFloat), &_maximumLineHeight); 226 | CTParagraphStyleGetValueForSpecifier(paragraphStyle, kCTParagraphStyleSpecifierMinimumLineHeight, sizeof(CGFloat), &_minimumLineHeight); 227 | CTParagraphStyleGetValueForSpecifier(paragraphStyle, kCTParagraphStyleSpecifierLineSpacing, sizeof(CGFloat), &_lineSpacing); 228 | CTParagraphStyleGetValueForSpecifier(paragraphStyle, kCTParagraphStyleSpecifierParagraphSpacing, sizeof(CGFloat), &_paragraphSpacing); 229 | CTParagraphStyleGetValueForSpecifier(paragraphStyle, kCTParagraphStyleSpecifierParagraphSpacingBefore, sizeof(CGFloat), &_paragraphSpacingBefore); 230 | _hyphenationFactor = 0.0; 231 | 232 | } else { 233 | NSParagraphStyle *paragraphStyle = object; 234 | 235 | _alignment = paragraphStyle.alignment; 236 | _lineBreakMode = paragraphStyle.lineBreakMode; 237 | _hyphenationFactor = paragraphStyle.hyphenationFactor; 238 | _baseWritingDirection = paragraphStyle.baseWritingDirection; 239 | 240 | _tabStops = [[NSArray array] retain]; 241 | 242 | _firstLineHeadIndent = paragraphStyle.firstLineHeadIndent; 243 | _headIndent = paragraphStyle.headIndent; 244 | _tailIndent = paragraphStyle.tailIndent; 245 | _lineHeightMultiple = paragraphStyle.lineHeightMultiple; 246 | _maximumLineHeight = paragraphStyle.maximumLineHeight; 247 | _minimumLineHeight = paragraphStyle.minimumLineHeight; 248 | _lineSpacing = paragraphStyle.lineSpacing; 249 | _paragraphSpacing = paragraphStyle.paragraphSpacing; 250 | _paragraphSpacingBefore = paragraphStyle.paragraphSpacingBefore; 251 | } 252 | 253 | #else 254 | NSParagraphStyle *paragraphStyle = object; 255 | 256 | _alignment = paragraphStyle.alignment; 257 | _lineBreakMode = paragraphStyle.lineBreakMode; 258 | _hyphenationFactor = paragraphStyle.hyphenationFactor; 259 | _baseWritingDirection = paragraphStyle.baseWritingDirection; 260 | 261 | NSMutableArray *mntexttabs = [NSMutableArray arrayWithCapacity:[paragraphStyle.tabStops count]]; 262 | for (NSTextTab *tabStop in paragraphStyle.tabStops) { 263 | [mntexttabs addObject:[MNASTextTab textTabWithTabStop:tabStop]]; 264 | } 265 | _tabStops = [mntexttabs copy]; 266 | 267 | _firstLineHeadIndent = paragraphStyle.firstLineHeadIndent; 268 | _headIndent = paragraphStyle.headIndent; 269 | _tailIndent = paragraphStyle.tailIndent; 270 | _defaultTabInterval = paragraphStyle.defaultTabInterval; 271 | _lineHeightMultiple = paragraphStyle.lineHeightMultiple; 272 | _maximumLineHeight = paragraphStyle.maximumLineHeight; 273 | _minimumLineHeight = paragraphStyle.minimumLineHeight; 274 | _lineSpacing = paragraphStyle.lineSpacing; 275 | _paragraphSpacing = paragraphStyle.paragraphSpacing; 276 | _paragraphSpacingBefore = paragraphStyle.paragraphSpacingBefore; 277 | #endif 278 | 279 | } 280 | 281 | return self; 282 | } 283 | 284 | @end 285 | -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/NSAttributedStrings/MNASStrokeColor.h: -------------------------------------------------------------------------------- 1 | // 2 | // MNASStrokeColor.h 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/23/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNCAttributedString.h" 31 | #import "MNCColor.h" 32 | 33 | #import 34 | #if TARGET_OS_IPHONE 35 | #import 36 | #endif 37 | 38 | @interface MNASStrokeColor : NSObject { 39 | @private 40 | #if TARGET_OS_IPHONE 41 | UIColor *_color; 42 | #else 43 | NSColor *_color; 44 | #endif 45 | } 46 | #if TARGET_OS_IPHONE 47 | @property (readonly) UIColor *color; 48 | #else 49 | @property (readonly) NSColor *color; 50 | #endif 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/NSAttributedStrings/MNASStrokeColor.m: -------------------------------------------------------------------------------- 1 | // 2 | // MNASStrokeColor.m 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/23/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNASStrokeColor.h" 31 | 32 | @implementation MNASStrokeColor 33 | @synthesize color = _color; 34 | 35 | #pragma mark - NSCoding Protocol 36 | 37 | -(id)initWithCoder:(NSCoder *)aDecoder { 38 | if ((self = [super init])) { 39 | _color = [[aDecoder decodeObjectForKey:@"color"] retain]; 40 | } 41 | 42 | return self; 43 | } 44 | 45 | -(void)encodeWithCoder:(NSCoder *)aCoder { 46 | [aCoder encodeObject:self.color forKey:@"color"]; 47 | } 48 | 49 | #pragma mark - MNAttributedStringAttribute Protocol 50 | 51 | +(BOOL)isSubstituteForObject:(void *)object { 52 | #if TARGET_OS_IPHONE 53 | return (([(id)object isEqualToString:(NSString *)kCTStrokeColorAttributeName]) || ([(id)object isEqualToString:NSStrokeColorAttributeName])); 54 | #else 55 | return [(id)object isEqualToString:NSStrokeColorAttributeName]; 56 | #endif 57 | } 58 | 59 | -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range:(NSRange)range forAttributedString:(NSAttributedString *)string { 60 | if ((self = [super init])) { 61 | #if TARGET_OS_IPHONE 62 | if ([attributeName isEqualToString:(NSString *)kCTStrokeColorAttributeName]) { 63 | _color = [[UIColor colorWithCGColor:object] retain]; 64 | 65 | } else { 66 | _color = [(id)object retain]; 67 | } 68 | #else 69 | _color = [(id)object retain]; 70 | #endif 71 | } 72 | return self; 73 | } 74 | 75 | -(NSDictionary *)platformRepresentation { 76 | #if TARGET_OS_IPHONE 77 | if ([MNCAttributedString hasUIKitAdditions]) { 78 | return [NSDictionary dictionaryWithObject:self.color forKey:NSStrokeColorAttributeName]; 79 | 80 | } else { 81 | CFStringRef keys[] = { kCTStrokeColorAttributeName }; 82 | CFTypeRef values[] = { [self.color CGColor] }; 83 | 84 | return [(NSDictionary *)CFDictionaryCreate(kCFAllocatorDefault, (const void **)&keys , (const void **)&values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks) autorelease]; 85 | 86 | } 87 | #else 88 | return [NSDictionary dictionaryWithObject:self.color forKey:NSStrokeColorAttributeName]; 89 | #endif 90 | } 91 | 92 | -(void)dealloc { 93 | [_color release], _color = nil; 94 | [super dealloc]; 95 | } 96 | 97 | 98 | @end -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/NSAttributedStrings/MNASStrokeWidth.h: -------------------------------------------------------------------------------- 1 | // 2 | // MNASStrokeWidth.h 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/22/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNCAttributedString.h" 31 | 32 | #import 33 | #if TARGET_OS_IPHONE 34 | #import 35 | #endif 36 | 37 | @interface MNASStrokeWidth : NSObject { 38 | @private 39 | NSNumber *_width; 40 | 41 | } 42 | 43 | @property (readonly) NSNumber *width; 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/NSAttributedStrings/MNASStrokeWidth.m: -------------------------------------------------------------------------------- 1 | // 2 | // MNASStrokeWidth.m 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/22/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNASStrokeWidth.h" 31 | 32 | @implementation MNASStrokeWidth 33 | @synthesize width = _width; 34 | 35 | #pragma mark - NSCoding Protocol 36 | 37 | -(id)initWithCoder:(NSCoder *)aDecoder { 38 | if ((self = [super init])) { 39 | _width = [[aDecoder decodeObjectForKey:@"width"] retain]; 40 | } 41 | 42 | return self; 43 | } 44 | 45 | -(void)encodeWithCoder:(NSCoder *)aCoder { 46 | [aCoder encodeObject:self.width forKey:@"width"]; 47 | } 48 | 49 | #pragma mark - MNAttributedStringAttribute Protocol 50 | 51 | +(BOOL)isSubstituteForObject:(void *)object { 52 | #if TARGET_OS_IPHONE 53 | return (([(id)object isEqualToString:(NSString *)kCTStrokeWidthAttributeName]) || ([(id)object isEqualToString:NSStrokeWidthAttributeName])); 54 | #else 55 | return [(id)object isEqualToString:NSStrokeWidthAttributeName]; 56 | #endif 57 | } 58 | 59 | -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range:(NSRange)range forAttributedString:(NSAttributedString *)string { 60 | if ((self = [super init])) { 61 | _width = [(NSNumber *)object retain]; 62 | } 63 | return self; 64 | } 65 | 66 | -(NSDictionary *)platformRepresentation { 67 | #if TARGET_OS_IPHONE 68 | if ([MNCAttributedString hasUIKitAdditions]) { 69 | return [NSDictionary dictionaryWithObject:self.width forKey:NSStrokeWidthAttributeName]; 70 | 71 | } else { 72 | return [NSDictionary dictionaryWithObject:self.width forKey:(NSString *)kCTStrokeWidthAttributeName]; 73 | 74 | } 75 | #else 76 | return [NSDictionary dictionaryWithObject:self.width forKey:NSStrokeWidthAttributeName]; 77 | #endif 78 | } 79 | 80 | -(void)dealloc { 81 | [_width release], _width = nil; 82 | [super dealloc]; 83 | } 84 | 85 | 86 | @end -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/NSAttributedStrings/MNASSuperScript.h: -------------------------------------------------------------------------------- 1 | // 2 | // MNASSuperScript.h 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/23/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNCAttributedString.h" 31 | 32 | #import 33 | #if TARGET_OS_IPHONE 34 | #import 35 | #endif 36 | 37 | @interface MNASSuperScript : NSObject { 38 | @private 39 | NSNumber *_textPosition; 40 | 41 | } 42 | 43 | @property (readonly) NSNumber *textPosition; 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/NSAttributedStrings/MNASSuperScript.m: -------------------------------------------------------------------------------- 1 | // 2 | // MNASSuperScript.m 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/23/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNASSuperScript.h" 31 | 32 | @implementation MNASSuperScript 33 | @synthesize textPosition = _textPosition; 34 | 35 | #pragma mark - NSCoding Protocol 36 | 37 | -(id)initWithCoder:(NSCoder *)aDecoder { 38 | if ((self = [super init])) { 39 | _textPosition = [[aDecoder decodeObjectForKey:@"textPosition"] retain]; 40 | } 41 | 42 | return self; 43 | } 44 | 45 | -(void)encodeWithCoder:(NSCoder *)aCoder { 46 | [aCoder encodeObject:self.textPosition forKey:@"textPosition"]; 47 | } 48 | 49 | #pragma mark - MNAttributedStringAttribute Protocol 50 | 51 | +(BOOL)isSubstituteForObject:(void *)object { 52 | #if TARGET_OS_IPHONE 53 | return [(id)object isEqualToString:(NSString *)kCTSuperscriptAttributeName]; 54 | #else 55 | return [(id)object isEqualToString:NSSuperscriptAttributeName]; 56 | #endif 57 | } 58 | 59 | -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range:(NSRange)range forAttributedString:(NSAttributedString *)string { 60 | if ((self = [super init])) { 61 | _textPosition = [(NSNumber *)object retain]; 62 | } 63 | return self; 64 | } 65 | 66 | -(NSDictionary *)platformRepresentation { 67 | #if TARGET_OS_IPHONE 68 | return [NSDictionary dictionaryWithObject:self.textPosition forKey:(NSString *)kCTSuperscriptAttributeName]; 69 | #else 70 | return [NSDictionary dictionaryWithObject:self.textPosition forKey:NSSuperscriptAttributeName]; 71 | #endif 72 | } 73 | 74 | -(void)dealloc { 75 | [_textPosition release], _textPosition = nil; 76 | [super dealloc]; 77 | } 78 | 79 | 80 | @end -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/NSAttributedStrings/MNASTextTab.h: -------------------------------------------------------------------------------- 1 | // 2 | // MNASTextTab.h 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/16/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import 31 | #if TARGET_OS_IPHONE 32 | #import 33 | #endif 34 | 35 | @interface MNASTextTab : NSObject { 36 | @private 37 | NSUInteger _alignment; 38 | CGFloat _location; 39 | NSDictionary *_options; 40 | } 41 | 42 | @property (readonly) NSUInteger alignment; 43 | @property (readonly) CGFloat location; 44 | @property (readonly) NSDictionary *options; 45 | 46 | #if TARGET_OS_IPHONE 47 | +(id)textTabWithTabStop:(CTTextTabRef)tab; 48 | -(id)initWithTabStop:(CTTextTabRef)tab; 49 | -(CTTextTabRef)platformRepresentation; 50 | #else 51 | +(id)textTabWithTabStop:(NSTextTab *)tab; 52 | -(id)initWithTabStop:(NSTextTab *)tab; 53 | -(NSTextTab *)platformRepresentation; 54 | #endif 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/NSAttributedStrings/MNASTextTab.m: -------------------------------------------------------------------------------- 1 | // 2 | // MNASTextTab.m 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/16/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNASTextTab.h" 31 | 32 | @implementation MNASTextTab 33 | @synthesize alignment = _alignment, location = _location, options = _options; 34 | 35 | #pragma mark - NSCoding Protocol 36 | 37 | -(id)initWithCoder:(NSCoder *)aDecoder { 38 | if ((self = [super init])) { 39 | _alignment = [[aDecoder decodeObjectForKey:@"alignment"] unsignedIntegerValue]; 40 | _location = [aDecoder decodeFloatForKey:@"location"]; 41 | _options = [[aDecoder decodeObjectForKey:@"options"] copy]; 42 | } 43 | return self; 44 | } 45 | 46 | -(void)encodeWithCoder:(NSCoder *)aCoder { 47 | [aCoder encodeObject:[NSNumber numberWithUnsignedInteger:self.alignment] forKey:@"alignment"]; 48 | [aCoder encodeFloat:self.location forKey:@"location"]; 49 | [aCoder encodeObject:self.options forKey:@"options"]; 50 | } 51 | 52 | #pragma mark - Object Life Cycle 53 | 54 | #if TARGET_OS_IPHONE 55 | 56 | +(id)textTabWithTabStop:(CTTextTabRef)tab { 57 | return [[[self alloc] initWithTabStop:tab] autorelease]; 58 | } 59 | 60 | -(id)initWithTabStop:(CTTextTabRef)tab { 61 | if ((self = [super init])) { 62 | _alignment = CTTextTabGetAlignment(tab); 63 | _location = CTTextTabGetLocation(tab); 64 | _options = [((NSDictionary *)CTTextTabGetOptions(tab)) copy]; 65 | } 66 | return self; 67 | } 68 | 69 | #else 70 | 71 | +(id)textTabWithTabStop:(NSTextTab *)tab { 72 | return [[[self alloc] initWithTabStop:tab] autorelease]; 73 | } 74 | 75 | -(id)initWithTabStop:(NSTextTab *)tab { 76 | if ((self = [super init])) { 77 | _alignment = tab.alignment; 78 | _location = tab.location; 79 | _options = [tab.options copy]; 80 | } 81 | return self; 82 | } 83 | 84 | #endif 85 | 86 | -(void)dealloc { 87 | [_options release], _options = nil; 88 | [super dealloc]; 89 | } 90 | 91 | #if TARGET_OS_IPHONE 92 | 93 | -(CTTextTabRef)platformRepresentation { 94 | return CTTextTabCreate(self.alignment, self.location, (CFDictionaryRef)self.options); 95 | } 96 | 97 | #else 98 | 99 | -(NSTextTab *)platformRepresentation { 100 | return [[[NSTextTab alloc] initWithTextAlignment:self.alignment location:self.location options:self.options] autorelease]; 101 | } 102 | 103 | #endif 104 | 105 | @end 106 | -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/NSAttributedStrings/MNASUnderlineColor.h: -------------------------------------------------------------------------------- 1 | // 2 | // MNASUnderlineColor.h 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/23/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNCAttributedString.h" 31 | #import "MNCColor.h" 32 | 33 | #import 34 | #if TARGET_OS_IPHONE 35 | #import 36 | #endif 37 | 38 | @interface MNASUnderlineColor : NSObject { 39 | @private 40 | #if TARGET_OS_IPHONE 41 | UIColor *_color; 42 | #else 43 | NSColor *_color; 44 | #endif 45 | } 46 | 47 | #if TARGET_OS_IPHONE 48 | @property (readonly) UIColor *color; 49 | #else 50 | @property (readonly) NSColor *color; 51 | #endif 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/NSAttributedStrings/MNASUnderlineColor.m: -------------------------------------------------------------------------------- 1 | // 2 | // MNASUnderlineColor.m 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/23/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNASUnderlineColor.h" 31 | 32 | @implementation MNASUnderlineColor 33 | @synthesize color = _color; 34 | 35 | #pragma mark - NSCoding Protocol 36 | 37 | -(id)initWithCoder:(NSCoder *)aDecoder { 38 | if ((self = [super init])) { 39 | _color = [[aDecoder decodeObjectForKey:@"color"] retain]; 40 | } 41 | 42 | return self; 43 | } 44 | 45 | -(void)encodeWithCoder:(NSCoder *)aCoder { 46 | [aCoder encodeObject:self.color forKey:@"color"]; 47 | } 48 | 49 | #pragma mark - MNAttributedStringAttribute Protocol 50 | 51 | +(BOOL)isSubstituteForObject:(void *)object { 52 | #if TARGET_OS_IPHONE 53 | return [(id)object isEqualToString:(NSString *)kCTUnderlineColorAttributeName]; 54 | #else 55 | return [(id)object isEqualToString:NSUnderlineColorAttributeName]; 56 | #endif 57 | } 58 | 59 | -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range:(NSRange)range forAttributedString:(NSAttributedString *)string { 60 | if ((self = [super init])) { 61 | #if TARGET_OS_IPHONE 62 | _color = [[UIColor colorWithCGColor:object] retain]; 63 | #else 64 | _color = [(id)object retain]; 65 | #endif 66 | 67 | } 68 | return self; 69 | } 70 | 71 | -(NSDictionary *)platformRepresentation { 72 | #if TARGET_OS_IPHONE 73 | CFStringRef keys[] = { kCTUnderlineColorAttributeName }; 74 | CFTypeRef values[] = { [self.color CGColor] }; 75 | 76 | return [(NSDictionary *)CFDictionaryCreate(kCFAllocatorDefault, (const void **)&keys , (const void **)&values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks) autorelease]; 77 | #else 78 | return [NSDictionary dictionaryWithObject:self.color forKey:NSUnderlineColorAttributeName]; 79 | #endif 80 | } 81 | 82 | -(void)dealloc { 83 | [_color release], _color = nil; 84 | [super dealloc]; 85 | } 86 | 87 | 88 | @end -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/NSAttributedStrings/MNASUnderlineStyle.h: -------------------------------------------------------------------------------- 1 | // 2 | // MNASUnderlineStyle.h 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/23/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNCAttributedString.h" 31 | 32 | #import 33 | #if TARGET_OS_IPHONE 34 | #import 35 | #endif 36 | 37 | @interface MNASUnderlineStyle : NSObject { 38 | @private 39 | NSNumber *_styleMask; 40 | 41 | } 42 | 43 | @property (readonly) NSNumber *styleMask; 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/NSAttributedStrings/MNASUnderlineStyle.m: -------------------------------------------------------------------------------- 1 | // 2 | // MNASUnderlineStyle.m 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/23/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNASUnderlineStyle.h" 31 | 32 | @implementation MNASUnderlineStyle 33 | @synthesize styleMask = _styleMask; 34 | 35 | #pragma mark - NSCoding Protocol 36 | 37 | -(id)initWithCoder:(NSCoder *)aDecoder { 38 | if ((self = [super init])) { 39 | _styleMask = [[aDecoder decodeObjectForKey:@"styleMask"] retain]; 40 | } 41 | 42 | return self; 43 | } 44 | 45 | -(void)encodeWithCoder:(NSCoder *)aCoder { 46 | [aCoder encodeObject:self.styleMask forKey:@"styleMask"]; 47 | } 48 | 49 | #pragma mark - MNAttributedStringAttribute Protocol 50 | 51 | +(BOOL)isSubstituteForObject:(void *)object { 52 | #if TARGET_OS_IPHONE 53 | return (([(id)object isEqualToString:(NSString *)kCTUnderlineStyleAttributeName]) || ([(id)object isEqualToString:NSUnderlineStyleAttributeName])); 54 | #else 55 | return [(id)object isEqualToString:NSUnderlineStyleAttributeName]; 56 | #endif 57 | } 58 | 59 | -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range:(NSRange)range forAttributedString:(NSAttributedString *)string { 60 | if ((self = [super init])) { 61 | _styleMask = [(NSNumber *)object retain]; 62 | } 63 | return self; 64 | } 65 | 66 | -(NSDictionary *)platformRepresentation { 67 | #if TARGET_OS_IPHONE 68 | return [NSDictionary dictionaryWithObject:self.styleMask forKey:(NSString *)kCTUnderlineStyleAttributeName]; 69 | #else 70 | return [NSDictionary dictionaryWithObject:self.styleMask forKey:NSUnderlineStyleAttributeName]; 71 | #endif 72 | } 73 | 74 | -(void)dealloc { 75 | [_styleMask release], _styleMask = nil; 76 | [super dealloc]; 77 | } 78 | 79 | 80 | @end -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/NSAttributedStrings/MNASVerticalForms.h: -------------------------------------------------------------------------------- 1 | // 2 | // MNASVerticalForms.h 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/23/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNCAttributedString.h" 31 | 32 | #import 33 | #if TARGET_OS_IPHONE 34 | #import 35 | #endif 36 | 37 | @interface MNASVerticalForms : NSObject { 38 | @private 39 | BOOL _enabled; 40 | } 41 | 42 | @property (readonly) BOOL enabled; 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /MNCoder/IntermediateObjects/NSAttributedStrings/MNASVerticalForms.m: -------------------------------------------------------------------------------- 1 | // 2 | // MNASVerticalForms.m 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/23/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNASVerticalForms.h" 31 | 32 | @implementation MNASVerticalForms 33 | @synthesize enabled = _enabled; 34 | 35 | #pragma mark - NSCoding Protocol 36 | 37 | -(id)initWithCoder:(NSCoder *)aDecoder { 38 | if ((self = [super init])) { 39 | _enabled = [aDecoder decodeBoolForKey:@"enabled"]; 40 | } 41 | 42 | return self; 43 | } 44 | 45 | -(void)encodeWithCoder:(NSCoder *)aCoder { 46 | [aCoder encodeBool:self.enabled forKey:@"enabled"]; 47 | } 48 | 49 | #pragma mark - MNAttributedStringAttribute Protocol 50 | 51 | +(BOOL)isSubstituteForObject:(void *)object { 52 | #if TARGET_OS_IPHONE 53 | return (([(id)object isEqualToString:(NSString *)kCTVerticalFormsAttributeName]) || ([(id)object isEqualToString:NSVerticalGlyphFormAttributeName])); 54 | #else 55 | return [(id)object isEqualToString:NSVerticalGlyphFormAttributeName]; 56 | #endif 57 | } 58 | 59 | -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range:(NSRange)range forAttributedString:(NSAttributedString *)string { 60 | if ((self = [super init])) { 61 | #if TARGET_OS_IPHONE 62 | if ([attributeName isEqualToString:(NSString *)kCTVerticalFormsAttributeName]) { 63 | if ((CFBooleanRef)object == kCFBooleanTrue) { 64 | _enabled = YES; 65 | } else { 66 | _enabled = NO; 67 | } 68 | } else { 69 | _enabled = [(NSNumber *)object boolValue]; 70 | } 71 | 72 | #else 73 | _enabled = [(NSNumber *)object boolValue]; 74 | 75 | #endif 76 | } 77 | return self; 78 | } 79 | 80 | -(NSDictionary *)platformRepresentation { 81 | #if TARGET_OS_IPHONE 82 | 83 | if ([MNCAttributedString hasUIKitAdditions]) { 84 | return [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:self.enabled] forKey:NSVerticalGlyphFormAttributeName]; 85 | } else { 86 | CFBooleanRef verticalFormsEnabled; 87 | if (_enabled) { 88 | verticalFormsEnabled = kCFBooleanTrue; 89 | } else { 90 | verticalFormsEnabled = kCFBooleanFalse; 91 | } 92 | 93 | CFStringRef keys[] = { kCTVerticalFormsAttributeName }; 94 | CFTypeRef values[] = { verticalFormsEnabled }; 95 | 96 | return [(NSDictionary *)CFDictionaryCreate(kCFAllocatorDefault, (const void **)&keys , (const void **)&values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks) autorelease]; 97 | } 98 | 99 | #else 100 | return [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:self.enabled] forKey:NSVerticalGlyphFormAttributeName]; 101 | 102 | #endif 103 | 104 | } 105 | 106 | 107 | @end -------------------------------------------------------------------------------- /MNCoder/MNArchiver.h: -------------------------------------------------------------------------------- 1 | // 2 | // MNArchiver.h 3 | // Mac 4 | // 5 | // Created by Jeremy Foo on 1/7/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import 31 | #import "MNCoder.h" 32 | 33 | @interface MNArchiver : MNCoder { 34 | @private 35 | NSKeyedArchiver *__archiver; 36 | BOOL encoded; 37 | } 38 | @property (nonatomic, readwrite) NSPropertyListFormat outputFormat; 39 | 40 | +(NSData *)archivedDataWithRootObject:(id)object; 41 | +(BOOL)archiveRootObject:(id)object toFile:(NSString *)path; 42 | 43 | -(id)initForWritingWithMutableData:(NSMutableData *)data; 44 | -(void)encodeRootObject:(id)object; 45 | @end 46 | -------------------------------------------------------------------------------- /MNCoder/MNArchiver.m: -------------------------------------------------------------------------------- 1 | // 2 | // MNArchiver.m 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/7/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNArchiver.h" 31 | #import "MNCIntermediateObjectProtocol.h" 32 | 33 | #import "MNCFont.h" 34 | #import "MNCColor.h" 35 | #import "MNCAttributedString.h" 36 | 37 | @implementation MNArchiver 38 | 39 | #pragma mark - Object Life Cycle 40 | 41 | -(id)init { 42 | NSAssert(YES, @"Use initForWritingWithMutableData: instead of init", nil); 43 | return nil; 44 | } 45 | 46 | -(id)initForWritingWithMutableData:(NSMutableData *)data { 47 | if ((self = [super init])) { 48 | __archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data]; 49 | __archiver.delegate = self; 50 | encoded = NO; 51 | } 52 | 53 | return self; 54 | } 55 | 56 | -(void)dealloc { 57 | __archiver.delegate = nil; 58 | [__archiver release], __archiver = nil; 59 | [super dealloc]; 60 | } 61 | 62 | #pragma mark - Override Accessors 63 | 64 | -(void)setOutputFormat:(NSPropertyListFormat)_outputFormat { 65 | [__archiver setOutputFormat:_outputFormat]; 66 | } 67 | 68 | -(NSPropertyListFormat)outputFormat { 69 | return __archiver.outputFormat; 70 | } 71 | 72 | #pragma mark - Instance Methods 73 | 74 | -(void)encodeRootObject:(id)object { 75 | if (!encoded) { 76 | [__archiver encodeObject:object forKey:MNCoderRootObjectName]; 77 | [__archiver finishEncoding]; 78 | encoded = YES; 79 | } 80 | } 81 | 82 | #pragma mark - Static Methods 83 | 84 | +(NSData *)archivedDataWithRootObject:(id)object { 85 | NSMutableData *resultData = [NSMutableData dataWithCapacity:0]; 86 | 87 | MNArchiver *archiver = [[[MNArchiver alloc] initForWritingWithMutableData:resultData] autorelease]; 88 | archiver.outputFormat = NSPropertyListBinaryFormat_v1_0; 89 | [archiver registerSubstituteClass:[MNCFont class]]; 90 | [archiver registerSubstituteClass:[MNCColor class]]; 91 | [archiver registerSubstituteClass:[MNCAttributedString class]]; 92 | 93 | [archiver encodeRootObject:object]; 94 | 95 | return resultData; 96 | } 97 | 98 | +(BOOL)archiveRootObject:(id)object toFile:(NSString *)path { 99 | NSData *serializedData = [MNArchiver archivedDataWithRootObject:object]; 100 | 101 | NSFileManager *fileManager = [NSFileManager defaultManager]; 102 | 103 | if ([fileManager fileExistsAtPath:path]) { 104 | if (![fileManager isWritableFileAtPath:path]) 105 | return NO; 106 | } 107 | 108 | return [serializedData writeToFile:path atomically:YES]; 109 | } 110 | 111 | #pragma mark - NSKeyedArchiver Delegate Methods 112 | 113 | -(id)archiver:(NSKeyedArchiver *)archiver willEncodeObject:(id)object { 114 | // NSLog(@"Object(%@): %@", NSStringFromClass([object class]), object); 115 | 116 | for (Class cls in __subsituteClasses) { 117 | 118 | if ([cls isSubstituteForObject:object]) { 119 | return [[[cls alloc] initWithSubsituteObject:object] autorelease]; 120 | } 121 | } 122 | 123 | return object; 124 | } 125 | 126 | @end 127 | -------------------------------------------------------------------------------- /MNCoder/MNCIntermediateObjectProtocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // MNCIntermediateObjectProtocol.h 3 | // 4 | // Created by Jeremy Foo on 1/7/12. 5 | // Copyright (c) 2012 Jeremy Foo 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining 8 | // a copy of this software and associated documentation files (the 9 | // "Software"), to deal in the Software without restriction, including 10 | // without limitation the rights to use, copy, modify, merge, publish, 11 | // distribute, sublicense, and/or sell copies of the Software, and to 12 | // permit persons to whom the Software is furnished to do so, subject to 13 | // the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be 16 | // included in all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | // 28 | 29 | #import 30 | 31 | @protocol MNCIntermediateObjectProtocol 32 | @required 33 | +(BOOL)isSubstituteForObject:(void *)object; 34 | -(id)initWithSubsituteObject:(void *)object; 35 | -(id)platformRepresentation; 36 | @end -------------------------------------------------------------------------------- /MNCoder/MNCoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // MNCoder.h 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 9/1/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import 31 | 32 | extern NSString *const MNCoderRootObjectName; 33 | 34 | @interface MNCoder : NSObject { 35 | NSMutableSet *__subsituteClasses; 36 | } 37 | -(void)registerSubstituteClass:(Class)cls; 38 | -(void)unregisterSubtituteClass:(Class)cls; 39 | @end -------------------------------------------------------------------------------- /MNCoder/MNCoder.m: -------------------------------------------------------------------------------- 1 | // 2 | // MNCoder.m 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 9/1/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNCoder.h" 31 | #import "MNCIntermediateObjectProtocol.h" 32 | 33 | NSString *const MNCoderRootObjectName = @"MNC0derRootObject"; 34 | 35 | @implementation MNCoder 36 | 37 | #pragma mark - Object Life Cycle 38 | 39 | -(id)init { 40 | if ((self = [super init])) { 41 | __subsituteClasses = [[NSMutableSet setWithCapacity:0] retain]; 42 | } 43 | return self; 44 | } 45 | 46 | -(void)dealloc { 47 | [__subsituteClasses release], __subsituteClasses = nil; 48 | [super dealloc]; 49 | } 50 | 51 | #pragma mark - Instance Methods 52 | -(void)registerSubstituteClass:(Class)cls { 53 | if ([cls conformsToProtocol:@protocol(MNCIntermediateObjectProtocol)]) 54 | [__subsituteClasses addObject:cls]; 55 | } 56 | 57 | -(void)unregisterSubtituteClass:(Class)cls { 58 | if ([cls conformsToProtocol:@protocol(MNCIntermediateObjectProtocol)]) 59 | [__subsituteClasses removeObject:cls]; 60 | } 61 | 62 | @end -------------------------------------------------------------------------------- /MNCoder/MNUnarchiver.h: -------------------------------------------------------------------------------- 1 | // 2 | // MNUnarchiver.h 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/7/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import 31 | #import "MNCoder.h" 32 | 33 | @interface MNUnarchiver : MNCoder { 34 | @private 35 | NSKeyedUnarchiver *__unarchiver; 36 | id _decodedRootObject; 37 | } 38 | @property (readonly) id decodedRootObject; 39 | 40 | +(id)unarchiveObjectWithData:(NSData *)data; 41 | +(id)unarchiveObjectWithFile:(NSString *)path; 42 | 43 | -(id)initForReadingWithData:(NSData *)data; 44 | @end 45 | -------------------------------------------------------------------------------- /MNCoder/MNUnarchiver.m: -------------------------------------------------------------------------------- 1 | // 2 | // MNUnarchiver.m 3 | // MNCoder 4 | // 5 | // Created by Jeremy Foo on 1/7/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #ifndef __has_feature 31 | #define __has_feature(x) 0 // Compatibility with non-clang compilers. 32 | #endif 33 | 34 | #ifndef NS_RETURNS_RETAINED 35 | #if __has_feature(attribute_ns_returns_retained) 36 | #define NS_RETURNS_RETAINED __attribute__((ns_returns_retained)) 37 | #else 38 | #define NS_RETURNS_RETAINED 39 | #endif 40 | #endif 41 | 42 | #import "MNUnarchiver.h" 43 | #import "MNCIntermediateObjectProtocol.h" 44 | 45 | // preconfigured intermediate objects 46 | #import "MNCFont.h" 47 | #import "MNCColor.h" 48 | #import "MNCAttributedString.h" 49 | 50 | @implementation MNUnarchiver 51 | @synthesize decodedRootObject=_decodedRootObject; 52 | 53 | #pragma mark - Object Life Cycle 54 | 55 | -(id)init { 56 | NSAssert(YES, @"Use initForReadingWithData: instead of init", nil); 57 | return nil; 58 | } 59 | 60 | -(id)initForReadingWithData:(NSData *)data { 61 | if ((self = [super init])) { 62 | __unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data]; 63 | __unarchiver.delegate = self; 64 | _decodedRootObject = nil; 65 | } 66 | return self; 67 | } 68 | 69 | -(void)dealloc { 70 | [_decodedRootObject release], _decodedRootObject = nil; 71 | [__unarchiver release], __unarchiver = nil; 72 | [super dealloc]; 73 | } 74 | 75 | #pragma mark - Instance Methods 76 | -(id)decodedRootObject { 77 | if (!_decodedRootObject) { 78 | _decodedRootObject = [[__unarchiver decodeObjectForKey:MNCoderRootObjectName] retain]; 79 | 80 | // after finishing the decode, the unarchiver can't be used anymore, 81 | // lets proactively release it to reclaim memory. 82 | [__unarchiver finishDecoding]; 83 | [__unarchiver release], __unarchiver = nil; 84 | } 85 | 86 | id test = [[_decodedRootObject retain] autorelease]; 87 | 88 | return test; 89 | } 90 | 91 | #pragma mark - Static Methods 92 | 93 | +(id)unarchiveObjectWithData:(NSData *)data { 94 | MNUnarchiver *unarchiver = [[[MNUnarchiver alloc] initForReadingWithData:data] autorelease]; 95 | [unarchiver registerSubstituteClass:[MNCFont class]]; 96 | [unarchiver registerSubstituteClass:[MNCColor class]]; 97 | [unarchiver registerSubstituteClass:[MNCAttributedString class]]; 98 | 99 | return [[[unarchiver decodedRootObject] retain] autorelease]; 100 | } 101 | 102 | +(id)unarchiveObjectWithFile:(NSString *)path { 103 | NSFileManager *fileManager = [NSFileManager defaultManager]; 104 | 105 | if (![fileManager fileExistsAtPath:path]) 106 | return nil; 107 | 108 | NSData *data = [NSData dataWithContentsOfFile:path]; 109 | 110 | id unarchivedObj = [MNUnarchiver unarchiveObjectWithData:data]; 111 | 112 | return [[unarchivedObj retain] autorelease]; 113 | } 114 | 115 | #pragma mark - NSKeyedUnarchiver Delegate Methods 116 | 117 | -(Class)unarchiver:(NSKeyedUnarchiver *)unarchiver cannotDecodeObjectOfClassName:(NSString *)name originalClasses:(NSArray *)classNames { 118 | NSString *platformName; 119 | 120 | #if TARGET_OS_IPHONE 121 | platformName = @"TARGET_OS_IPHONE"; 122 | #else 123 | platformName = @"TARGET_OS_MAC"; 124 | #endif 125 | 126 | NSLog(@"Class %@ does not exist for this platform (%@) -> %@", name, platformName, classNames); 127 | return nil; 128 | } 129 | 130 | -(id)unarchiver:(NSKeyedUnarchiver *)unarchiver didDecodeObject:(id)object NS_RETURNS_RETAINED { 131 | 132 | for (Class cls in __subsituteClasses) { 133 | 134 | if ([object isKindOfClass:cls]) { 135 | id platformRepresentation = [[object platformRepresentation] retain]; 136 | [object release]; 137 | 138 | // NSKeyedUnarchiver does not retain the replacement object thus a temp workaround with analyzer warning 139 | // is not to autorelease it. 140 | // 141 | // Checking Instruments using the leaks profiler shows that this does not leak at all. Adding the 142 | // "autorelease" prior to returning will show you a nice backtrace in Instruments that will allow 143 | // inference that this is not retained upon the return. 144 | // 145 | // Will be filing a radar for this issue. (http://openradar.appspot.com/radar?id=1517414) 146 | return platformRepresentation; 147 | } 148 | } 149 | 150 | return object; 151 | } 152 | 153 | @end 154 | -------------------------------------------------------------------------------- /Mac/Mac.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 3F18E3FE14B7D6EE00303392 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3F18E3FD14B7D6EE00303392 /* Cocoa.framework */; }; 11 | 3F18E40814B7D6EE00303392 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 3F18E40614B7D6EE00303392 /* InfoPlist.strings */; }; 12 | 3F18E40A14B7D6EE00303392 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F18E40914B7D6EE00303392 /* main.m */; }; 13 | 3F18E40E14B7D6EE00303392 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 3F18E40C14B7D6EE00303392 /* Credits.rtf */; }; 14 | 3F18E41114B7D6EE00303392 /* MNAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F18E41014B7D6EE00303392 /* MNAppDelegate.m */; }; 15 | 3F18E41414B7D6EE00303392 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3F18E41214B7D6EE00303392 /* MainMenu.xib */; }; 16 | 3F18E44914B7D79700303392 /* MNArchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F18E44814B7D79700303392 /* MNArchiver.m */; }; 17 | 3F18E45014B7D8B900303392 /* MNUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F18E44F14B7D8B900303392 /* MNUnarchiver.m */; }; 18 | 3F18E46014B7DB4600303392 /* MNCFont.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F18E45F14B7DB4600303392 /* MNCFont.m */; }; 19 | 3F18E46314B7DB5300303392 /* MNCColor.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F18E46214B7DB5300303392 /* MNCColor.m */; }; 20 | 3F54A0AC14C3535D003D5928 /* MNCAttributedString.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F54A0AB14C3535D003D5928 /* MNCAttributedString.m */; }; 21 | 3F54A0C214C357AC003D5928 /* MNASParagraphyStyle.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F54A0C114C357AC003D5928 /* MNASParagraphyStyle.m */; }; 22 | 3F54A0C514C357B8003D5928 /* MNASGlyphInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F54A0C414C357B8003D5928 /* MNASGlyphInfo.m */; }; 23 | 3F54A0D814C36BD2003D5928 /* MNASTextTab.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F54A0D714C36BD2003D5928 /* MNASTextTab.m */; }; 24 | 3F8561BE14CAB97800B7FE8D /* MNASCharacterShape.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F8561BD14CAB97800B7FE8D /* MNASCharacterShape.m */; }; 25 | 3F8561C614CAC67C00B7FE8D /* MNCoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F8561C514CAC67C00B7FE8D /* MNCoder.m */; }; 26 | 3F8561DE14CB705100B7FE8D /* MNASKern.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F8561DD14CB705100B7FE8D /* MNASKern.m */; }; 27 | 3F8561E414CB708500B7FE8D /* MNASLigature.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F8561E314CB708500B7FE8D /* MNASLigature.m */; }; 28 | 3F8561E714CB711300B7FE8D /* MNASStrokeWidth.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F8561E614CB711300B7FE8D /* MNASStrokeWidth.m */; }; 29 | 3FD4555714CC6D8700D2AABF /* MNASSuperScript.m in Sources */ = {isa = PBXBuildFile; fileRef = 3FD4555614CC6D8700D2AABF /* MNASSuperScript.m */; }; 30 | 3FD4555F14CC6E5700D2AABF /* MNASUnderlineStyle.m in Sources */ = {isa = PBXBuildFile; fileRef = 3FD4555E14CC6E5700D2AABF /* MNASUnderlineStyle.m */; }; 31 | 3FD4556514CC6F7300D2AABF /* MNASForegroundColor.m in Sources */ = {isa = PBXBuildFile; fileRef = 3FD4556414CC6F7300D2AABF /* MNASForegroundColor.m */; }; 32 | 3FD4556B14CC746D00D2AABF /* MNASStrokeColor.m in Sources */ = {isa = PBXBuildFile; fileRef = 3FD4556A14CC746D00D2AABF /* MNASStrokeColor.m */; }; 33 | 3FD4556E14CC74D600D2AABF /* MNASUnderlineColor.m in Sources */ = {isa = PBXBuildFile; fileRef = 3FD4556D14CC74D600D2AABF /* MNASUnderlineColor.m */; }; 34 | 3FD4557714CC7A4600D2AABF /* MNASVerticalForms.m in Sources */ = {isa = PBXBuildFile; fileRef = 3FD4557614CC7A4500D2AABF /* MNASVerticalForms.m */; }; 35 | 3FD4557D14CC7F2B00D2AABF /* MNASFont.m in Sources */ = {isa = PBXBuildFile; fileRef = 3FD4557C14CC7F2A00D2AABF /* MNASFont.m */; }; 36 | 3FE9DD7B14BAF36D00261727 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3F18E40214B7D6EE00303392 /* Foundation.framework */; }; 37 | /* End PBXBuildFile section */ 38 | 39 | /* Begin PBXFileReference section */ 40 | 3F18E3F914B7D6EE00303392 /* Mac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Mac.app; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | 3F18E3FD14B7D6EE00303392 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; 42 | 3F18E40014B7D6EE00303392 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; 43 | 3F18E40114B7D6EE00303392 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; 44 | 3F18E40214B7D6EE00303392 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 45 | 3F18E40514B7D6EE00303392 /* Mac-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Mac-Info.plist"; sourceTree = ""; }; 46 | 3F18E40714B7D6EE00303392 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 47 | 3F18E40914B7D6EE00303392 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = main.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 48 | 3F18E40B14B7D6EE00303392 /* Mac-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Mac-Prefix.pch"; sourceTree = ""; }; 49 | 3F18E40D14B7D6EE00303392 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = en; path = en.lproj/Credits.rtf; sourceTree = ""; }; 50 | 3F18E40F14B7D6EE00303392 /* MNAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = MNAppDelegate.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 51 | 3F18E41014B7D6EE00303392 /* MNAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = MNAppDelegate.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 52 | 3F18E41314B7D6EE00303392 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = ""; }; 53 | 3F18E44714B7D79700303392 /* MNArchiver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = MNArchiver.h; path = ../MNCoder/MNArchiver.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 54 | 3F18E44814B7D79700303392 /* MNArchiver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = MNArchiver.m; path = ../MNCoder/MNArchiver.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 55 | 3F18E44E14B7D8B900303392 /* MNUnarchiver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MNUnarchiver.h; path = ../MNCoder/MNUnarchiver.h; sourceTree = ""; }; 56 | 3F18E44F14B7D8B900303392 /* MNUnarchiver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MNUnarchiver.m; path = ../MNCoder/MNUnarchiver.m; sourceTree = ""; }; 57 | 3F18E45E14B7DB4600303392 /* MNCFont.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MNCFont.h; path = ../MNCoder/IntermediateObjects/MNCFont.h; sourceTree = ""; }; 58 | 3F18E45F14B7DB4600303392 /* MNCFont.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MNCFont.m; path = ../MNCoder/IntermediateObjects/MNCFont.m; sourceTree = ""; }; 59 | 3F18E46114B7DB5300303392 /* MNCColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MNCColor.h; path = ../MNCoder/IntermediateObjects/MNCColor.h; sourceTree = ""; }; 60 | 3F18E46214B7DB5300303392 /* MNCColor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MNCColor.m; path = ../MNCoder/IntermediateObjects/MNCColor.m; sourceTree = ""; }; 61 | 3F2E56DB14B82A3800B9A12E /* MNCIntermediateObjectProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MNCIntermediateObjectProtocol.h; path = ../MNCoder/MNCIntermediateObjectProtocol.h; sourceTree = ""; }; 62 | 3F54A0AA14C3535D003D5928 /* MNCAttributedString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MNCAttributedString.h; path = ../MNCoder/IntermediateObjects/MNCAttributedString.h; sourceTree = ""; }; 63 | 3F54A0AB14C3535D003D5928 /* MNCAttributedString.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MNCAttributedString.m; path = ../MNCoder/IntermediateObjects/MNCAttributedString.m; sourceTree = ""; }; 64 | 3F54A0C014C357AC003D5928 /* MNASParagraphyStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = MNASParagraphyStyle.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 65 | 3F54A0C114C357AC003D5928 /* MNASParagraphyStyle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = MNASParagraphyStyle.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 66 | 3F54A0C314C357B8003D5928 /* MNASGlyphInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = MNASGlyphInfo.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 67 | 3F54A0C414C357B8003D5928 /* MNASGlyphInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = MNASGlyphInfo.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 68 | 3F54A0D614C36BD2003D5928 /* MNASTextTab.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MNASTextTab.h; sourceTree = ""; }; 69 | 3F54A0D714C36BD2003D5928 /* MNASTextTab.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MNASTextTab.m; sourceTree = ""; }; 70 | 3F8561BC14CAB97800B7FE8D /* MNASCharacterShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = MNASCharacterShape.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 71 | 3F8561BD14CAB97800B7FE8D /* MNASCharacterShape.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = MNASCharacterShape.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 72 | 3F8561C414CAC67C00B7FE8D /* MNCoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MNCoder.h; path = ../MNCoder/MNCoder.h; sourceTree = ""; }; 73 | 3F8561C514CAC67C00B7FE8D /* MNCoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MNCoder.m; path = ../MNCoder/MNCoder.m; sourceTree = ""; }; 74 | 3F8561DC14CB705100B7FE8D /* MNASKern.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = MNASKern.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 75 | 3F8561DD14CB705100B7FE8D /* MNASKern.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = MNASKern.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 76 | 3F8561E214CB708500B7FE8D /* MNASLigature.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = MNASLigature.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 77 | 3F8561E314CB708500B7FE8D /* MNASLigature.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = MNASLigature.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 78 | 3F8561E514CB711300B7FE8D /* MNASStrokeWidth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = MNASStrokeWidth.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 79 | 3F8561E614CB711300B7FE8D /* MNASStrokeWidth.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = MNASStrokeWidth.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 80 | 3FD4555514CC6D8700D2AABF /* MNASSuperScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = MNASSuperScript.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 81 | 3FD4555614CC6D8700D2AABF /* MNASSuperScript.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = MNASSuperScript.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 82 | 3FD4555D14CC6E5700D2AABF /* MNASUnderlineStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MNASUnderlineStyle.h; sourceTree = ""; }; 83 | 3FD4555E14CC6E5700D2AABF /* MNASUnderlineStyle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MNASUnderlineStyle.m; sourceTree = ""; }; 84 | 3FD4556314CC6F7300D2AABF /* MNASForegroundColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = MNASForegroundColor.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 85 | 3FD4556414CC6F7300D2AABF /* MNASForegroundColor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = MNASForegroundColor.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 86 | 3FD4556914CC746C00D2AABF /* MNASStrokeColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = MNASStrokeColor.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 87 | 3FD4556A14CC746D00D2AABF /* MNASStrokeColor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = MNASStrokeColor.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 88 | 3FD4556C14CC74D600D2AABF /* MNASUnderlineColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MNASUnderlineColor.h; sourceTree = ""; }; 89 | 3FD4556D14CC74D600D2AABF /* MNASUnderlineColor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MNASUnderlineColor.m; sourceTree = ""; }; 90 | 3FD4557514CC7A4500D2AABF /* MNASVerticalForms.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MNASVerticalForms.h; sourceTree = ""; }; 91 | 3FD4557614CC7A4500D2AABF /* MNASVerticalForms.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MNASVerticalForms.m; sourceTree = ""; }; 92 | 3FD4557B14CC7F2A00D2AABF /* MNASFont.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = MNASFont.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 93 | 3FD4557C14CC7F2A00D2AABF /* MNASFont.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = MNASFont.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 94 | /* End PBXFileReference section */ 95 | 96 | /* Begin PBXFrameworksBuildPhase section */ 97 | 3F18E3F614B7D6EE00303392 /* Frameworks */ = { 98 | isa = PBXFrameworksBuildPhase; 99 | buildActionMask = 2147483647; 100 | files = ( 101 | 3FE9DD7B14BAF36D00261727 /* Foundation.framework in Frameworks */, 102 | 3F18E3FE14B7D6EE00303392 /* Cocoa.framework in Frameworks */, 103 | ); 104 | runOnlyForDeploymentPostprocessing = 0; 105 | }; 106 | /* End PBXFrameworksBuildPhase section */ 107 | 108 | /* Begin PBXGroup section */ 109 | 3F18E3EE14B7D6ED00303392 = { 110 | isa = PBXGroup; 111 | children = ( 112 | 3F18E44614B7D77700303392 /* MNCoder */, 113 | 3F18E40314B7D6EE00303392 /* Mac */, 114 | 3F18E3FC14B7D6EE00303392 /* Frameworks */, 115 | 3F18E3FA14B7D6EE00303392 /* Products */, 116 | ); 117 | sourceTree = ""; 118 | }; 119 | 3F18E3FA14B7D6EE00303392 /* Products */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | 3F18E3F914B7D6EE00303392 /* Mac.app */, 123 | ); 124 | name = Products; 125 | sourceTree = ""; 126 | }; 127 | 3F18E3FC14B7D6EE00303392 /* Frameworks */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | 3F18E3FD14B7D6EE00303392 /* Cocoa.framework */, 131 | 3F18E3FF14B7D6EE00303392 /* Other Frameworks */, 132 | ); 133 | name = Frameworks; 134 | sourceTree = ""; 135 | }; 136 | 3F18E3FF14B7D6EE00303392 /* Other Frameworks */ = { 137 | isa = PBXGroup; 138 | children = ( 139 | 3F18E40014B7D6EE00303392 /* AppKit.framework */, 140 | 3F18E40114B7D6EE00303392 /* CoreData.framework */, 141 | 3F18E40214B7D6EE00303392 /* Foundation.framework */, 142 | ); 143 | name = "Other Frameworks"; 144 | sourceTree = ""; 145 | }; 146 | 3F18E40314B7D6EE00303392 /* Mac */ = { 147 | isa = PBXGroup; 148 | children = ( 149 | 3F18E40F14B7D6EE00303392 /* MNAppDelegate.h */, 150 | 3F18E41014B7D6EE00303392 /* MNAppDelegate.m */, 151 | 3F18E41214B7D6EE00303392 /* MainMenu.xib */, 152 | 3F18E40414B7D6EE00303392 /* Supporting Files */, 153 | ); 154 | path = Mac; 155 | sourceTree = ""; 156 | }; 157 | 3F18E40414B7D6EE00303392 /* Supporting Files */ = { 158 | isa = PBXGroup; 159 | children = ( 160 | 3F18E40514B7D6EE00303392 /* Mac-Info.plist */, 161 | 3F18E40614B7D6EE00303392 /* InfoPlist.strings */, 162 | 3F18E40914B7D6EE00303392 /* main.m */, 163 | 3F18E40B14B7D6EE00303392 /* Mac-Prefix.pch */, 164 | 3F18E40C14B7D6EE00303392 /* Credits.rtf */, 165 | ); 166 | name = "Supporting Files"; 167 | sourceTree = ""; 168 | }; 169 | 3F18E44614B7D77700303392 /* MNCoder */ = { 170 | isa = PBXGroup; 171 | children = ( 172 | 3F2E56DB14B82A3800B9A12E /* MNCIntermediateObjectProtocol.h */, 173 | 3F18E45C14B7DB2C00303392 /* Intermediate Objects */, 174 | 3F18E44714B7D79700303392 /* MNArchiver.h */, 175 | 3F18E44814B7D79700303392 /* MNArchiver.m */, 176 | 3F18E44E14B7D8B900303392 /* MNUnarchiver.h */, 177 | 3F18E44F14B7D8B900303392 /* MNUnarchiver.m */, 178 | 3F8561C414CAC67C00B7FE8D /* MNCoder.h */, 179 | 3F8561C514CAC67C00B7FE8D /* MNCoder.m */, 180 | ); 181 | name = MNCoder; 182 | sourceTree = ""; 183 | }; 184 | 3F18E45C14B7DB2C00303392 /* Intermediate Objects */ = { 185 | isa = PBXGroup; 186 | children = ( 187 | 3F54A0AA14C3535D003D5928 /* MNCAttributedString.h */, 188 | 3F54A0AB14C3535D003D5928 /* MNCAttributedString.m */, 189 | 3F54A0A914C3535D003D5928 /* NSAttributedStrings */, 190 | 3F18E45E14B7DB4600303392 /* MNCFont.h */, 191 | 3F18E45F14B7DB4600303392 /* MNCFont.m */, 192 | 3F18E46114B7DB5300303392 /* MNCColor.h */, 193 | 3F18E46214B7DB5300303392 /* MNCColor.m */, 194 | ); 195 | name = "Intermediate Objects"; 196 | sourceTree = ""; 197 | }; 198 | 3F54A0A914C3535D003D5928 /* NSAttributedStrings */ = { 199 | isa = PBXGroup; 200 | children = ( 201 | 3F54A0C014C357AC003D5928 /* MNASParagraphyStyle.h */, 202 | 3F54A0C114C357AC003D5928 /* MNASParagraphyStyle.m */, 203 | 3F54A0C314C357B8003D5928 /* MNASGlyphInfo.h */, 204 | 3F54A0C414C357B8003D5928 /* MNASGlyphInfo.m */, 205 | 3F54A0D614C36BD2003D5928 /* MNASTextTab.h */, 206 | 3F54A0D714C36BD2003D5928 /* MNASTextTab.m */, 207 | 3F8561BC14CAB97800B7FE8D /* MNASCharacterShape.h */, 208 | 3F8561BD14CAB97800B7FE8D /* MNASCharacterShape.m */, 209 | 3F8561DC14CB705100B7FE8D /* MNASKern.h */, 210 | 3F8561DD14CB705100B7FE8D /* MNASKern.m */, 211 | 3F8561E214CB708500B7FE8D /* MNASLigature.h */, 212 | 3F8561E314CB708500B7FE8D /* MNASLigature.m */, 213 | 3F8561E514CB711300B7FE8D /* MNASStrokeWidth.h */, 214 | 3F8561E614CB711300B7FE8D /* MNASStrokeWidth.m */, 215 | 3FD4555514CC6D8700D2AABF /* MNASSuperScript.h */, 216 | 3FD4555614CC6D8700D2AABF /* MNASSuperScript.m */, 217 | 3FD4555D14CC6E5700D2AABF /* MNASUnderlineStyle.h */, 218 | 3FD4555E14CC6E5700D2AABF /* MNASUnderlineStyle.m */, 219 | 3FD4556314CC6F7300D2AABF /* MNASForegroundColor.h */, 220 | 3FD4556414CC6F7300D2AABF /* MNASForegroundColor.m */, 221 | 3FD4556914CC746C00D2AABF /* MNASStrokeColor.h */, 222 | 3FD4556A14CC746D00D2AABF /* MNASStrokeColor.m */, 223 | 3FD4556C14CC74D600D2AABF /* MNASUnderlineColor.h */, 224 | 3FD4556D14CC74D600D2AABF /* MNASUnderlineColor.m */, 225 | 3FD4557514CC7A4500D2AABF /* MNASVerticalForms.h */, 226 | 3FD4557614CC7A4500D2AABF /* MNASVerticalForms.m */, 227 | 3FD4557B14CC7F2A00D2AABF /* MNASFont.h */, 228 | 3FD4557C14CC7F2A00D2AABF /* MNASFont.m */, 229 | ); 230 | name = NSAttributedStrings; 231 | path = ../MNCoder/IntermediateObjects/NSAttributedStrings; 232 | sourceTree = ""; 233 | }; 234 | /* End PBXGroup section */ 235 | 236 | /* Begin PBXNativeTarget section */ 237 | 3F18E3F814B7D6EE00303392 /* Mac */ = { 238 | isa = PBXNativeTarget; 239 | buildConfigurationList = 3F18E41714B7D6EE00303392 /* Build configuration list for PBXNativeTarget "Mac" */; 240 | buildPhases = ( 241 | 3F18E3F514B7D6EE00303392 /* Sources */, 242 | 3F18E3F614B7D6EE00303392 /* Frameworks */, 243 | 3F18E3F714B7D6EE00303392 /* Resources */, 244 | ); 245 | buildRules = ( 246 | ); 247 | dependencies = ( 248 | ); 249 | name = Mac; 250 | productName = Mac; 251 | productReference = 3F18E3F914B7D6EE00303392 /* Mac.app */; 252 | productType = "com.apple.product-type.application"; 253 | }; 254 | /* End PBXNativeTarget section */ 255 | 256 | /* Begin PBXProject section */ 257 | 3F18E3F014B7D6ED00303392 /* Project object */ = { 258 | isa = PBXProject; 259 | attributes = { 260 | LastUpgradeCheck = 0430; 261 | }; 262 | buildConfigurationList = 3F18E3F314B7D6ED00303392 /* Build configuration list for PBXProject "Mac" */; 263 | compatibilityVersion = "Xcode 3.2"; 264 | developmentRegion = English; 265 | hasScannedForEncodings = 0; 266 | knownRegions = ( 267 | en, 268 | ); 269 | mainGroup = 3F18E3EE14B7D6ED00303392; 270 | productRefGroup = 3F18E3FA14B7D6EE00303392 /* Products */; 271 | projectDirPath = ""; 272 | projectRoot = ""; 273 | targets = ( 274 | 3F18E3F814B7D6EE00303392 /* Mac */, 275 | ); 276 | }; 277 | /* End PBXProject section */ 278 | 279 | /* Begin PBXResourcesBuildPhase section */ 280 | 3F18E3F714B7D6EE00303392 /* Resources */ = { 281 | isa = PBXResourcesBuildPhase; 282 | buildActionMask = 2147483647; 283 | files = ( 284 | 3F18E40814B7D6EE00303392 /* InfoPlist.strings in Resources */, 285 | 3F18E40E14B7D6EE00303392 /* Credits.rtf in Resources */, 286 | 3F18E41414B7D6EE00303392 /* MainMenu.xib in Resources */, 287 | ); 288 | runOnlyForDeploymentPostprocessing = 0; 289 | }; 290 | /* End PBXResourcesBuildPhase section */ 291 | 292 | /* Begin PBXSourcesBuildPhase section */ 293 | 3F18E3F514B7D6EE00303392 /* Sources */ = { 294 | isa = PBXSourcesBuildPhase; 295 | buildActionMask = 2147483647; 296 | files = ( 297 | 3F18E40A14B7D6EE00303392 /* main.m in Sources */, 298 | 3F18E41114B7D6EE00303392 /* MNAppDelegate.m in Sources */, 299 | 3F18E44914B7D79700303392 /* MNArchiver.m in Sources */, 300 | 3F18E45014B7D8B900303392 /* MNUnarchiver.m in Sources */, 301 | 3F18E46014B7DB4600303392 /* MNCFont.m in Sources */, 302 | 3F18E46314B7DB5300303392 /* MNCColor.m in Sources */, 303 | 3F54A0AC14C3535D003D5928 /* MNCAttributedString.m in Sources */, 304 | 3F54A0C214C357AC003D5928 /* MNASParagraphyStyle.m in Sources */, 305 | 3F54A0C514C357B8003D5928 /* MNASGlyphInfo.m in Sources */, 306 | 3F54A0D814C36BD2003D5928 /* MNASTextTab.m in Sources */, 307 | 3F8561BE14CAB97800B7FE8D /* MNASCharacterShape.m in Sources */, 308 | 3F8561C614CAC67C00B7FE8D /* MNCoder.m in Sources */, 309 | 3F8561DE14CB705100B7FE8D /* MNASKern.m in Sources */, 310 | 3F8561E414CB708500B7FE8D /* MNASLigature.m in Sources */, 311 | 3F8561E714CB711300B7FE8D /* MNASStrokeWidth.m in Sources */, 312 | 3FD4555714CC6D8700D2AABF /* MNASSuperScript.m in Sources */, 313 | 3FD4555F14CC6E5700D2AABF /* MNASUnderlineStyle.m in Sources */, 314 | 3FD4556514CC6F7300D2AABF /* MNASForegroundColor.m in Sources */, 315 | 3FD4556B14CC746D00D2AABF /* MNASStrokeColor.m in Sources */, 316 | 3FD4556E14CC74D600D2AABF /* MNASUnderlineColor.m in Sources */, 317 | 3FD4557714CC7A4600D2AABF /* MNASVerticalForms.m in Sources */, 318 | 3FD4557D14CC7F2B00D2AABF /* MNASFont.m in Sources */, 319 | ); 320 | runOnlyForDeploymentPostprocessing = 0; 321 | }; 322 | /* End PBXSourcesBuildPhase section */ 323 | 324 | /* Begin PBXVariantGroup section */ 325 | 3F18E40614B7D6EE00303392 /* InfoPlist.strings */ = { 326 | isa = PBXVariantGroup; 327 | children = ( 328 | 3F18E40714B7D6EE00303392 /* en */, 329 | ); 330 | name = InfoPlist.strings; 331 | sourceTree = ""; 332 | }; 333 | 3F18E40C14B7D6EE00303392 /* Credits.rtf */ = { 334 | isa = PBXVariantGroup; 335 | children = ( 336 | 3F18E40D14B7D6EE00303392 /* en */, 337 | ); 338 | name = Credits.rtf; 339 | sourceTree = ""; 340 | }; 341 | 3F18E41214B7D6EE00303392 /* MainMenu.xib */ = { 342 | isa = PBXVariantGroup; 343 | children = ( 344 | 3F18E41314B7D6EE00303392 /* en */, 345 | ); 346 | name = MainMenu.xib; 347 | sourceTree = ""; 348 | }; 349 | /* End PBXVariantGroup section */ 350 | 351 | /* Begin XCBuildConfiguration section */ 352 | 3F18E41514B7D6EE00303392 /* Debug */ = { 353 | isa = XCBuildConfiguration; 354 | buildSettings = { 355 | ALWAYS_SEARCH_USER_PATHS = NO; 356 | ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; 357 | COPY_PHASE_STRIP = NO; 358 | GCC_C_LANGUAGE_STANDARD = gnu99; 359 | GCC_DYNAMIC_NO_PIC = NO; 360 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 361 | GCC_OPTIMIZATION_LEVEL = 0; 362 | GCC_PREPROCESSOR_DEFINITIONS = ( 363 | "DEBUG=1", 364 | "$(inherited)", 365 | ); 366 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 367 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 368 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 369 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; 370 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 371 | GCC_WARN_UNUSED_VARIABLE = YES; 372 | MACOSX_DEPLOYMENT_TARGET = 10.7; 373 | ONLY_ACTIVE_ARCH = YES; 374 | SDKROOT = macosx; 375 | }; 376 | name = Debug; 377 | }; 378 | 3F18E41614B7D6EE00303392 /* Release */ = { 379 | isa = XCBuildConfiguration; 380 | buildSettings = { 381 | ALWAYS_SEARCH_USER_PATHS = NO; 382 | ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; 383 | COPY_PHASE_STRIP = YES; 384 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 385 | GCC_C_LANGUAGE_STANDARD = gnu99; 386 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 387 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 388 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 389 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; 390 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 391 | GCC_WARN_UNUSED_VARIABLE = YES; 392 | MACOSX_DEPLOYMENT_TARGET = 10.7; 393 | SDKROOT = macosx; 394 | }; 395 | name = Release; 396 | }; 397 | 3F18E41814B7D6EE00303392 /* Debug */ = { 398 | isa = XCBuildConfiguration; 399 | buildSettings = { 400 | ARCHS = "$(ARCHS_STANDARD_64_BIT)"; 401 | GCC_OPTIMIZATION_LEVEL = s; 402 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 403 | GCC_PREFIX_HEADER = "Mac/Mac-Prefix.pch"; 404 | INFOPLIST_FILE = "Mac/Mac-Info.plist"; 405 | PRODUCT_NAME = "$(TARGET_NAME)"; 406 | VALID_ARCHS = x86_64; 407 | WRAPPER_EXTENSION = app; 408 | }; 409 | name = Debug; 410 | }; 411 | 3F18E41914B7D6EE00303392 /* Release */ = { 412 | isa = XCBuildConfiguration; 413 | buildSettings = { 414 | ARCHS = "$(ARCHS_STANDARD_64_BIT)"; 415 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 416 | GCC_PREFIX_HEADER = "Mac/Mac-Prefix.pch"; 417 | INFOPLIST_FILE = "Mac/Mac-Info.plist"; 418 | PRODUCT_NAME = "$(TARGET_NAME)"; 419 | VALID_ARCHS = x86_64; 420 | WRAPPER_EXTENSION = app; 421 | }; 422 | name = Release; 423 | }; 424 | /* End XCBuildConfiguration section */ 425 | 426 | /* Begin XCConfigurationList section */ 427 | 3F18E3F314B7D6ED00303392 /* Build configuration list for PBXProject "Mac" */ = { 428 | isa = XCConfigurationList; 429 | buildConfigurations = ( 430 | 3F18E41514B7D6EE00303392 /* Debug */, 431 | 3F18E41614B7D6EE00303392 /* Release */, 432 | ); 433 | defaultConfigurationIsVisible = 0; 434 | defaultConfigurationName = Release; 435 | }; 436 | 3F18E41714B7D6EE00303392 /* Build configuration list for PBXNativeTarget "Mac" */ = { 437 | isa = XCConfigurationList; 438 | buildConfigurations = ( 439 | 3F18E41814B7D6EE00303392 /* Debug */, 440 | 3F18E41914B7D6EE00303392 /* Release */, 441 | ); 442 | defaultConfigurationIsVisible = 0; 443 | defaultConfigurationName = Release; 444 | }; 445 | /* End XCConfigurationList section */ 446 | }; 447 | rootObject = 3F18E3F014B7D6ED00303392 /* Project object */; 448 | } 449 | -------------------------------------------------------------------------------- /Mac/Mac.xcodeproj/xcshareddata/xcschemes/Mac.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 52 | 53 | 59 | 60 | 61 | 62 | 66 | 67 | 68 | 69 | 73 | 74 | 75 | 76 | 82 | 83 | 89 | 90 | 91 | 92 | 94 | 95 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /Mac/Mac/MNAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // MNAppDelegate.h 3 | // Mac 4 | // 5 | // Created by Jeremy Foo on 1/7/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import 31 | 32 | @interface MNAppDelegate : NSObject { 33 | NSColorWell *_colorWell; 34 | } 35 | 36 | 37 | @property (assign) IBOutlet NSWindow *window; 38 | 39 | @property (assign) IBOutlet NSTextView *textView; 40 | @property (assign) IBOutlet NSTextView *unarchiveTextView; 41 | - (IBAction)archiveTapped:(id)sender; 42 | - (IBAction)unarchiveTapped:(id)sender; 43 | @end 44 | -------------------------------------------------------------------------------- /Mac/Mac/MNAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // MNAppDelegate.m 3 | // Mac 4 | // 5 | // Created by Jeremy Foo on 1/7/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNAppDelegate.h" 31 | #import "MNArchiver.h" 32 | #import "MNUnarchiver.h" 33 | 34 | /* 35 | #import "MNFont.h" 36 | #import "MNColor.h" 37 | #import "MNAttributedString.h" 38 | */ 39 | 40 | @implementation MNAppDelegate 41 | 42 | @synthesize window = _window; 43 | @synthesize textView; 44 | @synthesize unarchiveTextView; 45 | 46 | - (void)dealloc 47 | { 48 | [super dealloc]; 49 | } 50 | 51 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification 52 | { 53 | // Insert code here to initialize your application 54 | 55 | } 56 | 57 | -(IBAction)archiveTapped:(id)sender { 58 | NSAttributedString *astring = (NSMutableAttributedString *)[textView textStorage]; 59 | [MNArchiver archiveRootObject:astring toFile:[NSString stringWithFormat:@"%@MNCoderTest.plist", @"/tmp/"]]; 60 | } 61 | 62 | -(IBAction)unarchiveTapped:(id)sender { 63 | 64 | /* 65 | NSData *data = [NSData dataWithContentsOfFile:[NSString stringWithFormat:@"%@MNCoderTest.plist", NSTemporaryDirectory()]]; 66 | 67 | MNUnarchiver *unarchiver = [[MNUnarchiver alloc] initForReadingWithData:data]; 68 | [unarchiver registerSubstituteClass:[MNFont class]]; 69 | [unarchiver registerSubstituteClass:[MNColor class]]; 70 | [unarchiver registerSubstituteClass:[MNAttributedString class]]; 71 | 72 | id test = [unarchiver decodedRootObject]; 73 | NSLog(@"test: %lu", [test retainCount]); 74 | 75 | id test2 = [unarchiver decodedRootObject]; 76 | NSLog(@"test2: %lu", [test2 retainCount]); 77 | NSLog(@"test: %lu", [test retainCount]); 78 | 79 | [unarchiver release]; 80 | NSLog(@"test2: %lu", [test2 retainCount]); 81 | NSLog(@"test: %lu", [test retainCount]); 82 | 83 | [[unarchiveTextView textStorage] setAttributedString:test]; 84 | */ 85 | 86 | NSAttributedString *test = [MNUnarchiver unarchiveObjectWithFile:[NSString stringWithFormat:@"%@MNCoderTest.plist", @"/tmp/"]]; 87 | [[unarchiveTextView textStorage] setAttributedString:test]; 88 | } 89 | 90 | @end 91 | -------------------------------------------------------------------------------- /Mac/Mac/Mac-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.mindnode.mncoder.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSHumanReadableCopyright 28 | Copyright © 2012 __MyCompanyName__. All rights reserved. 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /Mac/Mac/Mac-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'Mac' target in the 'Mac' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /Mac/Mac/en.lproj/Credits.rtf: -------------------------------------------------------------------------------- 1 | {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;} 2 | {\colortbl;\red255\green255\blue255;} 3 | \paperw9840\paperh8400 4 | \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural 5 | 6 | \f0\b\fs24 \cf0 Engineering: 7 | \b0 \ 8 | Some people\ 9 | \ 10 | 11 | \b Human Interface Design: 12 | \b0 \ 13 | Some other people\ 14 | \ 15 | 16 | \b Testing: 17 | \b0 \ 18 | Hopefully not nobody\ 19 | \ 20 | 21 | \b Documentation: 22 | \b0 \ 23 | Whoever\ 24 | \ 25 | 26 | \b With special thanks to: 27 | \b0 \ 28 | Mom\ 29 | } 30 | -------------------------------------------------------------------------------- /Mac/Mac/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Mac/Mac/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Mac 4 | // 5 | // Created by Jeremy Foo on 1/7/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import 31 | 32 | int main(int argc, char *argv[]) 33 | { 34 | return NSApplicationMain(argc, (const char **)argv); 35 | } 36 | -------------------------------------------------------------------------------- /NSAttributedStringsMappingModel.csv: -------------------------------------------------------------------------------- 1 | ,iOS,Mac,iOS,Mac,,,,,,, 2 | MAPPED,const CFStringRef kCTCharacterShapeAttributeName;,NSString *NSCharacterShapeAttributeName;,CFNumber,integer value,,,,,,, 3 | MAPPED,const CFStringRef kCTFontAttributeName;,NSString *NSFontAttributeName;,CTFont,NSFont,,,,,,, 4 | MAPPED,const CFStringRef kCTKernAttributeName;,NSString *NSKernAttributeName;,CFNumber,NSNumber,,,,,,, 5 | MAPPED,const CFStringRef kCTLigatureAttributeName;,NSString *NSLigatureAttributeName;,CFNumber,NSNumber,,,,,,, 6 | MAPPED,const CFStringRef kCTForegroundColorAttributeName;,NSString *NSForegroundColorAttributeName;,CGColor,NSColor,,,,,,, 7 | ,const CFStringRef kCTForegroundColorFromContextAttributeName;,,CFBoolean,,,,,,,, 8 | MAPPED,const CFStringRef kCTParagraphStyleAttributeName;,NSString *NSParagraphStyleAttributeName;,CTParagraphStyle,NSParagraphStyle,,,,,,, 9 | MAPPED,const CFStringRef kCTStrokeWidthAttributeName;,NSString *NSStrokeWidthAttributeName;,CFNumber,NSNumber,,,,,,, 10 | MAPPED,const CFStringRef kCTStrokeColorAttributeName;,NSString *NSStrokeColorAttributeName;,CGColor,NSColor,,,,,,, 11 | MAPPED,const CFStringRef kCTSuperscriptAttributeName;,NSString *NSSuperscriptAttributeName;,CFNumber,NSNumber,,,,,,, 12 | MAPPED,const CFStringRef kCTUnderlineColorAttributeName;,NSString *NSUnderlineColorAttributeName;,CGColor,NSColor,,,,,,, 13 | MAPPED,const CFStringRef kCTUnderlineStyleAttributeName;,NSString *NSUnderlineStyleAttributeName;,bitmask,bitmask,,,,,,, 14 | MAPPED,const CFStringRef kCTVerticalFormsAttributeName;,NSString *NSVerticalGlyphFormAttributeName;,CGBoolean,"NSNumber (1 = true, 0 = false)",,,,,,, 15 | MAPPED,const CFStringRef kCTGlyphInfoAttributeName;,NSString *NSGlyphInfoAttributeName;,CTGlyphInfo,NSGlyphInfo,,,,,,, 16 | ,const CFStringRef kCTRunDelegateAttributeName,,CTRunDelegate,,,,,,,, 17 | ,,NSString *NSBackgroundColorAttributeName;,,NSColor,,,,,,, 18 | ,,NSString *NSAttachmentAttributeName;,,NSTextAttachment,,,,,,, 19 | MAPPED,,NSString *NSBaselineOffsetAttributeName;,kCTFontBaselineAdjustAttribute in CTFontDescriptor,NSNumber,,,,,,, 20 | ,,NSString *NSLinkAttributeName;,"doesn’t exist, must implement ourselves by drawing and checking location",NSURL or NSString,,,,,,, 21 | ,,NSString *NSStrikethroughStyleAttributeName;,"doesn’t exist, must implement ourselves by drawing",NSNumber,,,,,,, 22 | ,,NSString *NSStrikethroughColorAttributeName;,"doesn’t exist, must implement ourselves by drawing",NScolor,,,,,,, 23 | ,,NSString *NSShadowAttributeName;,"doesn’t exist, must implement ourselves by drawing",NSShadow,,,,,,, 24 | MAPPED,,NSString *NSObliquenessAttributeName;,kCTFontSlantTrait in CTFontDescriptor,NSNumber (skew to apply),,,,,,, 25 | MAPPED,,NSString *NSExpansionAttributeName;,kCTFontWidthTrait in CTFontDescriptor,NSNumber (log of expansion factor to apply to glphys),,,,,,, 26 | ,,NSString *NSCursorAttributeName;,really specific to the Mac,NSCursor,,,,,,, 27 | ,,NSString *NSToolTipAttributeName;,really specific to the Mac,NSString,,,,,,, 28 | ,,NSString *NSMarkedClauseSegmentAttributeName;,,NSnumber (index marking clause segments),,,,,,, 29 | ,,NSString *NSWritingDirectionAttributeName;,,NSArray of numbers (for overriding bidi algorithm),,,,,,, 30 | ,,,,,,,,,,, 31 | ,,,,,,,,,,, 32 | ,,,,,,,,,,, 33 | ,,,,,,,,,,, 34 | ,,,,,,,,,,, 35 | ,,,,,,,,,,, 36 | ,,,,,,,,,,, 37 | ,,,,,,,,,,, 38 | ,,,,,,,,,,, 39 | ,,,,,,,,,,, 40 | ,,,,,,,,,,, 41 | ,,,,,,,,,,, 42 | ,,,,,,,,,,, 43 | ,,,,,,,,,,, 44 | ,,,,,,,,,,, 45 | ,,,,,,,,,,, 46 | ,,,,,,,,,,, 47 | ,,,,,,,,,,, -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Serializer composition of NSKeyedArchvier/NSKeyedUnarchiver that primarily deals with creating portable seralized plists of objects for use on both the Mac and iOS. 2 | 3 | The current version only deals with portability of NSAttributedString and its components that are perhaps not present on iOS. This includes the following but may ahve more, 4 | 5 | - NSFont to UIFont 6 | - NSColor to UIColor 7 | - NSAttributedString to close to 1-to-1 mapping of NSAttributedString on relevant platforms 8 | 9 | #### How 10 | MNCoder works by having intermediate objects that are actually serializable that when unarchived on various platforms will have platform specific representations generated. This currently only works for the fonts and colors. NSParagraphStyles may require regeneration of the entire Attributed string and is currently under investigation as it seems to require explicit setting of Alignments via CoreText. 11 | 12 | #### So now what? 13 | It is fairly easy to implement the intermediate objects that will handle the translation between the different platforms. All that is needed is for any object to implement the `MNCIntermediateObjectProtocol` which consists of the following. 14 | 15 | `+(NSArray *)subsituteClasses;` Basically returns an NSArray of NSString class names that the Intermediate object negotiates for. In the case of `NSFont`/`UIFont`, the NSArray basically will contain NSString values of `NSFont` and `UIFont` respectively. 16 | 17 | `-(id)initWithSubsituteObject:(id)object;` is the initializer that is used when initializing the intermediate object for serialization. 18 | 19 | `-(id)platformRepresentation;` returns the object that is to be represented for the current platform that the serialzied version is decoded for. 20 | 21 | In addition to these methods, the intermediate object protocol also requires that the NSCoding protocol be implemented such that these intermediate objects can be serialized by the Archiver. 22 | 23 | Attributed strings have their own internal intermediate objects to handle the various features that iOS/Mac supports and will reduce the current working set to the lowest common denominator by rejecting attributes it doesn't understand (sadly NSLinkAttributeName for links on Mac OS X). Further work can be made to enhnace this system that will provide a way to revive attachments and links. 24 | 25 | Specifically for Attributed strings, you can set whether it will be a lossless translation (by preserving attributes that can't be translated) or one that is not by setting the lossless BOOL via a static method `[MNAttributedString setLossless:(BOOL)]`. 26 | 27 | #### Cavets 28 | - Doesn't do TextLists and TextBlocks 29 | - Doesn't do certain portions of the Mac's Attributed String (ie. hypenation factor, etc.) 30 | - Doesn't do certain portions of the iOS's Attributed String (ie. background color, etc.) 31 | - Links 32 | - Text attachments 33 | 34 | ##### iOS 6 35 | iOS 6 introduces the NSAttributedString UIKit additions. While welcomed, there are only a handful of attributes compared to the OS X counter parts. And even then, of the handful, only some are implemented because there is a need to maintain some sort of parity between the CoreText and UIKit additions. As such, these attributes are not implemented. 36 | 37 | - NSBackgroundColorAttributeName 38 | - NSBaselineOffsetAttributeName: Dealt with in ParagraphStyle 39 | - NSStrikethroughStyleAttributeName 40 | - NSShadowAttributeName 41 | 42 | Additionally, to be as lossless as possible, platform representation of the various attributes will default to the ones that contain the most information. Sometimes this may be coretext sometimes the UIKit additions provide more information. 43 | 44 | #### Sample Project 45 | The same project provided opens as a workspace, MNcoder.xcworkspace and contain 2 projects, one for iOS and one for Mac OS X for testing. All archivng and unarchiving does so in the NSTemporaryDirectory() under the file name MNCoderTest.plist or whatever is set in the #define in the MNCoder.h file. 46 | 47 | This project makes use of git submodules for EGOTextView. 48 | 49 | Remember to do `git submodule init` and `git submodule update` after cloning the project. -------------------------------------------------------------------------------- /iOS/iOS.xcodeproj/xcshareddata/xcschemes/iOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 52 | 53 | 59 | 60 | 61 | 62 | 66 | 67 | 71 | 72 | 73 | 74 | 80 | 81 | 87 | 88 | 89 | 90 | 92 | 93 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /iOS/iOS/MNAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // MNAppDelegate.h 3 | // iOS 4 | // 5 | // Created by Jeremy Foo on 1/7/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import 31 | 32 | @class MNViewController; 33 | 34 | @interface MNAppDelegate : UIResponder 35 | 36 | @property (strong, nonatomic) UIWindow *window; 37 | 38 | @property (strong, nonatomic) MNViewController *viewController; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /iOS/iOS/MNAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // MNAppDelegate.m 3 | // iOS 4 | // 5 | // Created by Jeremy Foo on 1/7/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNAppDelegate.h" 31 | 32 | #import "MNViewController.h" 33 | 34 | @implementation MNAppDelegate 35 | 36 | @synthesize window = _window; 37 | @synthesize viewController = _viewController; 38 | 39 | - (void)dealloc 40 | { 41 | [_window release]; 42 | [_viewController release]; 43 | [super dealloc]; 44 | } 45 | 46 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 47 | { 48 | self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; 49 | // Override point for customization after application launch. 50 | self.viewController = [[[MNViewController alloc] initWithNibName:@"MNViewController" bundle:nil] autorelease]; 51 | 52 | UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:self.viewController]; 53 | self.window.rootViewController = nav; 54 | [nav release]; 55 | 56 | [self.window makeKeyAndVisible]; 57 | return YES; 58 | } 59 | 60 | - (void)applicationWillResignActive:(UIApplication *)application 61 | { 62 | /* 63 | Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 64 | Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 65 | */ 66 | } 67 | 68 | - (void)applicationDidEnterBackground:(UIApplication *)application 69 | { 70 | /* 71 | Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 72 | If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 73 | */ 74 | } 75 | 76 | - (void)applicationWillEnterForeground:(UIApplication *)application 77 | { 78 | /* 79 | Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 80 | */ 81 | } 82 | 83 | - (void)applicationDidBecomeActive:(UIApplication *)application 84 | { 85 | /* 86 | Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 87 | */ 88 | } 89 | 90 | - (void)applicationWillTerminate:(UIApplication *)application 91 | { 92 | /* 93 | Called when the application is about to terminate. 94 | Save data if appropriate. 95 | See also applicationDidEnterBackground:. 96 | */ 97 | } 98 | 99 | @end 100 | -------------------------------------------------------------------------------- /iOS/iOS/MNViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MNViewController.h 3 | // iOS 4 | // 5 | // Created by Jeremy Foo on 1/7/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import 31 | #import "EGOTextView.h" 32 | 33 | @interface MNViewController : UIViewController 34 | @property (retain, nonatomic) IBOutlet EGOTextView *textView; 35 | @property (retain, nonatomic) IBOutlet UISegmentedControl *segmentedButtons; 36 | @property (retain, nonatomic) IBOutlet UIBarButtonItem *actionButton; 37 | - (IBAction)actionButtonTapped:(id)sender; 38 | - (IBAction)segmentedValueChanged:(id)sender; 39 | @end 40 | -------------------------------------------------------------------------------- /iOS/iOS/MNViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MNViewController.m 3 | // iOS 4 | // 5 | // Created by Jeremy Foo on 1/7/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import "MNViewController.h" 31 | #import "MNUnarchiver.h" 32 | #import "MNArchiver.h" 33 | 34 | /* 35 | #import "MNFont.h" 36 | #import "MNColor.h" 37 | #import "MNAttributedString.h" 38 | */ 39 | 40 | @implementation MNViewController 41 | @synthesize textView; 42 | @synthesize segmentedButtons; 43 | @synthesize actionButton; 44 | 45 | - (void)didReceiveMemoryWarning 46 | { 47 | [super didReceiveMemoryWarning]; 48 | // Release any cached data, images, etc that aren't in use. 49 | } 50 | 51 | #pragma mark - View lifecycle 52 | 53 | - (void)viewDidLoad 54 | { 55 | [super viewDidLoad]; 56 | // Do any additional setup after loading the view, typically from a nib. 57 | [textView becomeFirstResponder]; 58 | self.navigationController.navigationBarHidden = NO; 59 | 60 | self.navigationItem.titleView = self.segmentedButtons; 61 | self.navigationItem.rightBarButtonItem = self.actionButton; 62 | 63 | } 64 | 65 | - (void)viewDidUnload 66 | { 67 | [self setTextView:nil]; 68 | [self setSegmentedButtons:nil]; 69 | [self setActionButton:nil]; 70 | [super viewDidUnload]; 71 | // Release any retained subviews of the main view. 72 | // e.g. self.myOutlet = nil; 73 | } 74 | 75 | - (void)viewWillAppear:(BOOL)animated 76 | { 77 | [super viewWillAppear:animated]; 78 | } 79 | 80 | - (void)viewDidAppear:(BOOL)animated 81 | { 82 | [super viewDidAppear:animated]; 83 | } 84 | 85 | - (void)viewWillDisappear:(BOOL)animated 86 | { 87 | [super viewWillDisappear:animated]; 88 | } 89 | 90 | - (void)viewDidDisappear:(BOOL)animated 91 | { 92 | [super viewDidDisappear:animated]; 93 | } 94 | 95 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 96 | { 97 | // Return YES for supported orientations 98 | return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); 99 | } 100 | 101 | - (void)dealloc { 102 | [textView release]; 103 | [segmentedButtons release]; 104 | [actionButton release]; 105 | [super dealloc]; 106 | } 107 | 108 | - (IBAction)actionButtonTapped:(id)sender { 109 | if (self.segmentedButtons.selectedSegmentIndex == 0) { 110 | // do archive 111 | NSAttributedString *astring = self.textView.attributedString; 112 | [MNArchiver archiveRootObject:astring toFile:[NSString stringWithFormat:@"%@MNCoderTest.plist", @"/tmp/"]]; 113 | } else { 114 | // do unarchive 115 | /* 116 | NSData *data = [NSData dataWithContentsOfFile:[NSString stringWithFormat:@"%@MNCoderTest.plist", NSTemporaryDirectory()]]; 117 | 118 | MNUnarchiver *unarchiver = [[MNUnarchiver alloc] initForReadingWithData:data]; 119 | [unarchiver registerSubstituteClass:[MNFont class]]; 120 | [unarchiver registerSubstituteClass:[MNColor class]]; 121 | [unarchiver registerSubstituteClass:[MNAttributedString class]]; 122 | 123 | id test = [unarchiver decodedRootObject]; 124 | NSLog(@"test: %lu", [test retainCount]); 125 | 126 | id test2 = [unarchiver decodedRootObject]; 127 | NSLog(@"test2: %lu", [test2 retainCount]); 128 | NSLog(@"test: %lu", [test retainCount]); 129 | 130 | [unarchiver release]; 131 | NSLog(@"test2: %lu", [test2 retainCount]); 132 | NSLog(@"test: %lu", [test retainCount]); 133 | 134 | [self.textView setAttributedString:test]; 135 | */ 136 | 137 | NSAttributedString *test = [MNUnarchiver unarchiveObjectWithFile:[NSString stringWithFormat:@"%@MNCoderTest.plist", @"/tmp/"]]; 138 | [self.textView setAttributedString:test]; 139 | } 140 | 141 | } 142 | 143 | - (IBAction)segmentedValueChanged:(id)sender { 144 | if (self.segmentedButtons.selectedSegmentIndex == 0) { 145 | self.actionButton.title = @"Archive"; 146 | self.textView.editable = YES; 147 | [self.textView setText:@""]; 148 | } else { 149 | self.actionButton.title = @"Unarchive"; 150 | self.textView.editable = NO; 151 | [self.textView setText:@""]; 152 | } 153 | } 154 | @end 155 | -------------------------------------------------------------------------------- /iOS/iOS/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /iOS/iOS/en.lproj/MNViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1280 5 | 11C74 6 | 1938 7 | 1138.23 8 | 567.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 933 12 | 13 | 14 | IBUIBarButtonItem 15 | IBUISegmentedControl 16 | IBUIView 17 | IBUIScrollView 18 | IBProxyObject 19 | 20 | 21 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 22 | 23 | 24 | PluginDependencyRecalculationVersion 25 | 26 | 27 | 28 | 29 | IBFilesOwner 30 | IBCocoaTouchFramework 31 | 32 | 33 | IBFirstResponder 34 | IBCocoaTouchFramework 35 | 36 | 37 | 38 | 274 39 | 40 | 41 | 42 | 274 43 | {320, 202} 44 | 45 | 46 | 47 | _NS:190 48 | YES 49 | YES 50 | IBCocoaTouchFramework 51 | 52 | 53 | {{0, 64}, {320, 416}} 54 | 55 | 56 | 57 | 58 | 3 59 | MC43NQA 60 | 61 | 2 62 | 63 | 64 | NO 65 | 66 | 67 | NO 68 | 69 | IBCocoaTouchFramework 70 | 71 | 72 | 73 | 292 74 | {207, 30} 75 | 76 | 77 | 78 | _NS:273 79 | NO 80 | IBCocoaTouchFramework 81 | 2 82 | 2 83 | 0 84 | 85 | Archive 86 | Unarchive 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | {0, 0} 98 | {0, 0} 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | Archive 107 | IBCocoaTouchFramework 108 | 2 109 | 110 | 111 | 112 | 113 | 114 | 115 | view 116 | 117 | 118 | 119 | 7 120 | 121 | 122 | 123 | textView 124 | 125 | 126 | 127 | 12 128 | 129 | 130 | 131 | segmentedButtons 132 | 133 | 134 | 135 | 18 136 | 137 | 138 | 139 | actionButton 140 | 141 | 142 | 143 | 20 144 | 145 | 146 | 147 | segmentedValueChanged: 148 | 149 | 150 | 13 151 | 152 | 22 153 | 154 | 155 | 156 | actionButtonTapped: 157 | 158 | 159 | 160 | 21 161 | 162 | 163 | 164 | 165 | 166 | 0 167 | 168 | 169 | 170 | 171 | 172 | -1 173 | 174 | 175 | File's Owner 176 | 177 | 178 | -2 179 | 180 | 181 | 182 | 183 | 6 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 9 192 | 193 | 194 | 195 | 196 | 17 197 | 198 | 199 | 200 | 201 | 19 202 | 203 | 204 | 205 | 206 | 207 | 208 | MNViewController 209 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 210 | UIResponder 211 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 212 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 213 | 214 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 215 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 216 | EGOTextView 217 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 218 | 219 | 220 | 221 | 222 | 223 | 22 224 | 225 | 226 | 227 | 228 | EGOTextView 229 | UIScrollView 230 | 231 | IBProjectSource 232 | ./Classes/EGOTextView.h 233 | 234 | 235 | 236 | MNViewController 237 | UIViewController 238 | 239 | actionButtonTapped: 240 | id 241 | 242 | 243 | actionButtonTapped: 244 | 245 | actionButtonTapped: 246 | id 247 | 248 | 249 | 250 | UIBarButtonItem 251 | UISegmentedControl 252 | EGOTextView 253 | 254 | 255 | 256 | actionButton 257 | UIBarButtonItem 258 | 259 | 260 | segmentedButtons 261 | UISegmentedControl 262 | 263 | 264 | textView 265 | EGOTextView 266 | 267 | 268 | 269 | IBProjectSource 270 | ./Classes/MNViewController.h 271 | 272 | 273 | 274 | 275 | 0 276 | IBCocoaTouchFramework 277 | YES 278 | 3 279 | 933 280 | 281 | 282 | -------------------------------------------------------------------------------- /iOS/iOS/iOS-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFiles 12 | 13 | CFBundleIdentifier 14 | com.mindnode.mncoder.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.0 23 | CFBundleSignature 24 | ???? 25 | CFBundleVersion 26 | 1.0 27 | LSRequiresIPhoneOS 28 | 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /iOS/iOS/iOS-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'iOS' target in the 'iOS' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_4_0 8 | #warning "This project uses features only available in iOS SDK 4.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /iOS/iOS/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // iOS 4 | // 5 | // Created by Jeremy Foo on 1/7/12. 6 | // Copyright (c) 2012 Jeremy Foo 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // 29 | 30 | #import 31 | 32 | #import "MNAppDelegate.h" 33 | 34 | int main(int argc, char *argv[]) 35 | { 36 | @autoreleasepool { 37 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([MNAppDelegate class])); 38 | } 39 | } 40 | --------------------------------------------------------------------------------