जबकि अन्य तरीकों से हो सकता है, इसे पूरा करने का एक तरीका है स्ट्रिंग को केवल स्ट्रोक के साथ खींचना, फिर स्ट्रिंग को केवल एक भरने के साथ खींचें, जो पहले खींचा गया था, सीधे ऊपर की ओर। (एडोब इनडिज़ीन में वास्तव में यह अंतर्निहित है, जहां यह केवल स्ट्रोक को अक्षर के बाहर लागू करने के लिए दिखाई देगा, जो पठनीयता के साथ मदद करता है)।
यह एक उदाहरण मात्र दृश्य यह कैसे पूरा करने के लिए पता चलता है कि (http://developer.apple.com/library/mac/#qa/qa2008/qa1531.html से प्रेरित) है:
:
@implementation MDInDesignTextView
static NSMutableDictionary *regularAttributes = nil;
static NSMutableDictionary *indesignBackgroundAttributes = nil;
static NSMutableDictionary *indesignForegroundAttributes = nil;
- (void)drawRect:(NSRect)frame {
NSString *string = @"Got stroke?";
if (regularAttributes == nil) {
regularAttributes = [[NSMutableDictionary
dictionaryWithObjectsAndKeys:
[NSFont systemFontOfSize:64.0],NSFontAttributeName,
[NSColor whiteColor],NSForegroundColorAttributeName,
[NSNumber numberWithFloat:-5.0],NSStrokeWidthAttributeName,
[NSColor blackColor],NSStrokeColorAttributeName, nil] retain];
}
if (indesignBackgroundAttributes == nil) {
indesignBackgroundAttributes = [[NSMutableDictionary
dictionaryWithObjectsAndKeys:
[NSFont systemFontOfSize:64.0],NSFontAttributeName,
[NSNumber numberWithFloat:-5.0],NSStrokeWidthAttributeName,
[NSColor blackColor],NSStrokeColorAttributeName, nil] retain];
}
if (indesignForegroundAttributes == nil) {
indesignForegroundAttributes = [[NSMutableDictionary
dictionaryWithObjectsAndKeys:
[NSFont systemFontOfSize:64.0],NSFontAttributeName,
[NSColor whiteColor],NSForegroundColorAttributeName, nil] retain];
}
[[NSColor grayColor] set];
[NSBezierPath fillRect:frame];
// draw top string
[string drawAtPoint:
NSMakePoint(frame.origin.x + 200.0, frame.origin.y + 200.0)
withAttributes:regularAttributes];
// draw bottom string in two passes
[string drawAtPoint:
NSMakePoint(frame.origin.x + 200.0, frame.origin.y + 140.0)
withAttributes:indesignBackgroundAttributes];
[string drawAtPoint:
NSMakePoint(frame.origin.x + 200.0, frame.origin.y + 140.0)
withAttributes:indesignForegroundAttributes];
}
@end
यह निम्न उत्पादन का उत्पादन:
पहले विशेषताएं सेट
अब, यह सही नहीं है, क्योंकि ग्लाइफ कभी-कभी आंशिक सीमाओं पर पड़ते हैं, लेकिन, यह निश्चित रूप से डिफ़ॉल्ट से बेहतर दिखता है।
यदि प्रदर्शन एक मुद्दा है, तो आप हमेशा कोरग्राफिक्स या कोरटेक्स्ट जैसे थोड़ा निम्न स्तर पर गिरने लग सकते हैं।
धन्यवाद। एक इलाज करता है। –
महान, विस्तृत उत्तर। समय में डालने के लिए धन्यवाद! – epologee
सरल। प्रतिभाशाली। ... और पूरी तरह से अनावश्यक होना चाहिए ... (इस के लिए समर्थन पहले से मौजूद होना चाहिए) – u2Fan