2016-09-04 11 views
0

우르두 기반 앱 중 하나의 글꼴은 "Jameel Noori Nastaleeq Kasheeda"입니다. 우리는 HTML 텍스트를 NSString으로 변환 한 후 UILabel에 내용을 표시해야합니다. 있는 NSString에 HTML로 변환하는Nastaleeq Urdu 글꼴을 사용하여 콘텐츠를 NSString으로 변환하는 HTML 텍스트

, 우리는

-(NSString *)styledHTMLwithHTML:(NSString *)HTML{ 
    NSString *style = @"<meta charset=\"UTF-8\"><style> body { font-family: 'Jameel-Noori-Nastaleeq'; font-size: 20px; } b {font-family: 'Jameel-Noori-Nastaleeq'; }</style>"; 
    return [NSString stringWithFormat:@"%@%@", style, HTML]; 
} 

- (NSAttributedString *)attributedStringWithHTML:(NSString *)HTML { 
    NSDictionary *options = @{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType }; 
    return [[NSAttributedString alloc] initWithData:[HTML dataUsingEncoding:NSUTF16StringEncoding] options:options documentAttributes:NULL error:NULL]; 
} 

그런 다음 우리가 UILabel의의 attributedText 속성이 제대로 HTML 텍스트를 기반으로있는 NSString 형식 얻을 설정하고, 다음과 같은 기능을 구현했습니다.

NSString *styledHtml = [self.novel.article styledHTMLwithHTML:self.novel.article]; 
NSAttributedString *attributedText = [self.novel.article attributedStringWithHTML:styledHtml]; 
self.articleView.articleContent.attributedText = attributedText; 

이 구현은 굴림 또는 헬 베티 같은 기본 아이폰 OS 글꼴의 기대에 따라 노력하고 있지만, 우리는 사용자 정의 우르두어 글꼴 즉 Nastaleeq을 적용 할 때 텍스트가 중복됩니다. 이와 관련하여 도움이된다면 크게 감사하겠습니다.

enter image description here

답변

0

당신은 당신이 html string처럼로드 웹보기를 구현할 수

NSString* htmlString = @"your html string here"; 
    [webView loadHTMLString:htmlString baseURL: nil]; //webView is `UIWebView` object