Gibt's ne Möglichkeit den Dateipfad eines NSFont zu bekommen? Ich will eine ausgewählte Schrift (Font) in einen Ordner Kopieren
NSFont Pfad
Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen
-
-
ja, aber keinen offiziellen
edit: ich weiß ja nicht ob "toll-free bridging" auch in die andere richtung geht. also NSFont -> CTFont, denn dann könntest du CTFontGetPlatformFont verwenden. ansonsten bleibt dir nur "- (unsigned int)_atsFontID;" -
Folgendes funktioniert bei mir:
Quellcode
- // returns font file URL for font or nil if not available
- - (NSURL*) fontFileURL
- {
- // get core text font
- CTFontRef aFont = CTFontCreateWithName((CFStringRef) [self fontName], 0.0, NULL);
- // get attribute
- CFTypeRef attribute = CTFontCopyAttribute(aFont, kCTFontURLAttribute);
- if(!attribute)
- return nil;
- NSURL *fontFileURL = [(NSURL*) attribute autorelease];
- return fontFileURL;
- }
Xcode 4 sucks – „,Multiple exclamation marks‘, he went on, shaking his head, are a sure sign of a diseased mind.‘“ (Terry Pratchett 1992: Eric)
"Wir ordnen und befehlen hiermit allen Ernstes, dass die Advocati wollene schwarze Mäntel, welche bis unter das Knie gehen, unserer Verordnung gemäß zu tragen haben, damit man die Spitzbuben schon von weitem erkennt." (Friedrich Wilhelm I., Soldatenkönig) -
mika schrieb:
Folgendes funktioniert bei mir:
Quellcode
- // returns font file URL for font or nil if not available
- - (NSURL*) fontFileURL
- {
- // get core text font
- CTFontRef aFont = CTFontCreateWithName((CFStringRef) [self fontName], 0.0, NULL);
- // get attribute
- CFTypeRef attribute = CTFontCopyAttribute(aFont, kCTFontURLAttribute);
- if(!attribute)
- return nil;
- NSURL *fontFileURL = [(NSURL*) attribute autorelease];
- return fontFileURL;
- }
der name ist aber nicht eindeutig. somit bekommst du vielleicht eine CTFont instanz für eine andere font als in NSFont. -
gritsch schrieb:
der name ist aber nicht eindeutig. somit bekommst du vielleicht eine CTFont instanz für eine andere font als in NSFont.
Es ist der PostScript Name, wenn der nicht eindeutig ist, funktioniert nichts mehr richtig.Xcode 4 sucks – „,Multiple exclamation marks‘, he went on, shaking his head, are a sure sign of a diseased mind.‘“ (Terry Pratchett 1992: Eric)
"Wir ordnen und befehlen hiermit allen Ernstes, dass die Advocati wollene schwarze Mäntel, welche bis unter das Knie gehen, unserer Verordnung gemäß zu tragen haben, damit man die Spitzbuben schon von weitem erkennt." (Friedrich Wilhelm I., Soldatenkönig) -
mika schrieb:
gritsch schrieb:
der name ist aber nicht eindeutig. somit bekommst du vielleicht eine CTFont instanz für eine andere font als in NSFont.
Es ist der PostScript Name, wenn der nicht eindeutig ist, funktioniert nichts mehr richtig.
und genau der ist nicht zwingend eindeutig (aber meistens). -
Danke werd ich mal testen.