NSFont Pfad

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Folgendes funktioniert bei mir:

    Quellcode

    1. // returns font file URL for font or nil if not available
    2. - (NSURL*) fontFileURL
    3. {
    4. // get core text font
    5. CTFontRef aFont = CTFontCreateWithName((CFStringRef) [self fontName], 0.0, NULL);
    6. // get attribute
    7. CFTypeRef attribute = CTFontCopyAttribute(aFont, kCTFontURLAttribute);
    8. if(!attribute)
    9. return nil;
    10. NSURL *fontFileURL = [(NSURL*) attribute autorelease];
    11. return fontFileURL;
    12. }
    Alles anzeigen
    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

    1. // returns font file URL for font or nil if not available
    2. - (NSURL*) fontFileURL
    3. {
    4. // get core text font
    5. CTFontRef aFont = CTFontCreateWithName((CFStringRef) [self fontName], 0.0, NULL);
    6. // get attribute
    7. CFTypeRef attribute = CTFontCopyAttribute(aFont, kCTFontURLAttribute);
    8. if(!attribute)
    9. return nil;
    10. NSURL *fontFileURL = [(NSURL*) attribute autorelease];
    11. return fontFileURL;
    12. }
    Alles anzeigen


    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)