Re: NSTextView Linked Text Font Attribute Issues

  • On Dec 28, 2007, at 12:01 PM, <cocoa-dev-request...> wrote:

    > I'm having issued with a subclassed NSTextView displaying linked text
    > as I'd like it to.  The link text attributes I specify are working,
    > except for the font name attribute.  The link text appears to be
    > rendered in the Helvetica font, while my default attributes call for
    > Monaco.
    >
    > <snip>
    >
    >
    > myDefaultLinkTextAttributes =
    > [[NSDictionary alloc] initWithObjectsAndKeys:
    > [NSFont fontWithName: @"Monaco" size: 12.0], NSFontNameAttribute,
    > [NSColor lightGrayColor], NSForegroundColorAttributeName,
    > [NSColor clearColor], NSBackgroundColorAttributeName,
    > [NSNumber numberWithInt: NSUnderlineStyleNone],
    > NSUnderlineStyleAttributeName,
    > [NSCursor pointingHandCursor], NSCursorAttributeName,
    > nil];
    >

    The key "NSFontNameAttribute" should be set to an NSString instance
    (the font name), not an NSFont instance.

    So, for the first attribute key, instead of:

    >> [NSFont fontWithName: @"Monaco" size: 12.0], NSFontNameAttribute,

    use:

    @"Monaco", NSFontNameAttribute,

    >
    > Any help would be greatly appreciated!

    hope this helps.

    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    robb albright
    software engineer – Macintosh and cross-platform
    <ralbright...>
    Vernier Software & Technology
    beaverton, or
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    A: Because it messes up the order in which people normally read text.
    Q: Why is top-posting such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing in e-mail?
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  • On Dec 29, 2007, at 4:05 PM, Robb Albright wrote:

    > On Dec 28, 2007, at 12:01 PM, <cocoa-dev-request...> wrote:
    >
    >> I'm having issued with a subclassed NSTextView displaying linked text
    >> as I'd like it to.  The link text attributes I specify are working,
    >> except for the font name attribute.  The link text appears to be
    >> rendered in the Helvetica font, while my default attributes call for
    >> Monaco.
    >>
    >> <snip>
    >>
    >>
    >> myDefaultLinkTextAttributes =
    >> [[NSDictionary alloc] initWithObjectsAndKeys:
    >> [NSFont fontWithName: @"Monaco" size: 12.0], NSFontNameAttribute,
    >> [NSColor lightGrayColor], NSForegroundColorAttributeName,
    >> [NSColor clearColor], NSBackgroundColorAttributeName,
    >> [NSNumber numberWithInt: NSUnderlineStyleNone],
    >> NSUnderlineStyleAttributeName,
    >> [NSCursor pointingHandCursor], NSCursorAttributeName,
    >> nil];
    >>
    >
    > The key "NSFontNameAttribute" should be set to an NSString instance
    > (the font name), not an NSFont instance.
    >
    > So, for the first attribute key, instead of:
    >
    >>> [NSFont fontWithName: @"Monaco" size: 12.0], NSFontNameAttribute,
    >
    >
    > use:
    >
    > @"Monaco", NSFontNameAttribute,

    NSFontNameAttribute (and others that have a pattern of
    NSFont*Attribute] are for working with NSFontDescriptor.

    The original code was almost correct; just change the key name to
    NSFontAttributeName.  As with other keys that can be used, the pattern
    is NS*AttributeName.  And, for this particular key, you do in fact
    want to provide the actual font instance.

    ___________________________________________________________
    Ricky A. Sharp        mailto:<rsharp...>
    Instant Interactive(tm)  http://www.instantinteractive.com
  • On Dec 29, 2007, at 2:19 PM, Ricky Sharp wrote:

    >
    > On Dec 29, 2007, at 4:05 PM, Robb Albright wrote:
    >
    >> On Dec 28, 2007, at 12:01 PM, <cocoa-dev-request...>
    >> wrote:
    >>
    >>> I'm having issued with a subclassed NSTextView displaying linked
    >>> text
    >>> as I'd like it to.  The link text attributes I specify are working,
    >>> except for the font name attribute.  The link text appears to be
    >>> rendered in the Helvetica font, while my default attributes call for
    >>> Monaco.
    >>>
    >>> <snip>
    >>>
    >>>
    >>> myDefaultLinkTextAttributes =
    >>> [[NSDictionary alloc] initWithObjectsAndKeys:
    >>> [NSFont fontWithName: @"Monaco" size: 12.0], NSFontNameAttribute,
    >>> [NSColor lightGrayColor], NSForegroundColorAttributeName,
    >>> [NSColor clearColor], NSBackgroundColorAttributeName,
    >>> [NSNumber numberWithInt: NSUnderlineStyleNone],
    >>> NSUnderlineStyleAttributeName,
    >>> [NSCursor pointingHandCursor], NSCursorAttributeName,
    >>> nil];
    >>>
    >>
    >> <snip incorrect advice>
    >
    > NSFontNameAttribute (and others that have a pattern of
    > NSFont*Attribute] are for working with NSFontDescriptor.
    >
    > The original code was almost correct; just change the key name to
    > NSFontAttributeName.  As with other keys that can be used, the
    > pattern is NS*AttributeName.  And, for this particular key, you do
    > in fact want to provide the actual font instance.

    D'oh! Thanks for the correction... guess I jumped in too quickly
    without checking my work.

    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    robb albright
    software engineer – Macintosh and cross-platform
    Vernier Software & Technology
previous month december 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Go to today