2014-03-25 11 views
1

NSAttributedString에서 개별 문자의 글리프를 가져온 다음 appendBezierPathWithGlyphs:count:inFont:으로 NSBezierPath를 얻고 마지막으로 NSArray (아래 코드 참조)에 병합 경로 점을 출력하여 표시합니다. Quartz Composer의 OpenGL.NSString to NSBezierPath 이상한 글자 일부 표준 글꼴

표준 타자기 (American Typewriter, Baskerville, ...)를 포함한 일부 NSFont의 경우 글자가 완전히 잘못되었습니다 (아래 이미지 참조).

나는 프랑스 키보드와 언어으로 일하고 있다고 말하는 것이 중요 할 수 있습니다.

NSBezierPath* path = [NSBezierPath bezierPath]; 

NSTextStorage *storage = [[[NSTextStorage alloc] initWithString:character] autorelease]; 
NSLayoutManager *manager = [[[NSLayoutManager alloc] init] autorelease]; 
NSTextContainer *container = [[[NSTextContainer alloc] init] autorelease]; 

[storage addLayoutManager:manager]; 
[manager addTextContainer:container]; 


NSRange glyphRange = [manager glyphRangeForTextContainer:container]; 
NSGlyph glyphArray[glyphRange.length]; 
NSUInteger glyphCount = [manager getGlyphs:glyphArray range:glyphRange]; 

[manager getGlyphs:glyphArray range:glyphRange]; 

// ---- Necesary 
[path moveToPoint: NSMakePoint(0, 0)]; 


// STRANGE CHARACTERS 
[path appendBezierPathWithGlyphs:glyphArray count:glyphCount inFont:selectedFont]; 

With Arial With Baskerville 사람이 동작의 설명을 알고 있습니까? 에 대한 해결책이 있습니까? 이러한 글꼴로 올바른 경로를 찾으십니까?

답변

2

-appendBezierPathWithGlyphs:count:inFont:에서 사용하는 글꼴의 글리프가 생성되지 않는 것이 문제입니다. NSTextStorageNSFontAttributeName 속성을 설정하지 않으면 글리프가 기본 글꼴로 생성됩니다.

올바른 글꼴로 NSTextStorage을 작성하고 문제가 해결됩니다

NSTextStorage *storage = [[[NSTextStorage alloc] initWithString:character 
                attributes:@{NSFontAttributeName : selectedFont}] autorelease];