Created
September 12, 2014 14:22
-
-
Save sonsongithub/44768b95a6175c836886 to your computer and use it in GitHub Desktop.
debug NSAttriutedString and CoreText
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (self.attributedString != nil && [self.attributedString.string rangeOfString:@"これになる不思議"].location != NSNotFound) { | |
DNSLog(@"%@", self.attributedString); | |
UniChar *p = (UniChar*)malloc(sizeof(UniChar) * self.attributedString.string.length); | |
[self.attributedString.string getCharacters:p]; | |
FILE *fp = fopen("/Users/sonson/bug_data.bin", "wb"); | |
fwrite(p, sizeof(UniChar), self.attributedString.string.length, fp); | |
fclose(fp); | |
free(p); | |
CGFloat fontSize = 14; | |
NSString *temp = [self.attributedString.string stringByAppendingString:@"\n"]; | |
NSParagraphStyle *paragraphStyle = [NSParagraphStyle defaultParagraphStyleWithFontSize:fontSize]; | |
NSDictionary *attributes = @{NSParagraphStyleAttributeName:paragraphStyle, NSFontAttributeName:[UIFont systemFontOfSize:fontSize]}; | |
_attributedString = [[NSAttributedString alloc] initWithString:temp attributes:attributes]; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment