• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: text to bezier path
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: text to bezier path


  • Subject: Re: text to bezier path
  • From: "Chase" <email@hidden>
  • Date: Tue, 05 Jun 2007 19:39:30 +0000

Paul, you nailed it.  That's exactly what I meant.  Ultimately, this is for a text-over-video type of thing.

Okay, I've got a little code that works great **without** video underneath it, but if I try to draw the video frame first and THEN draw the text, i can see only the video... no text:

// HERE IT IS ALL BY ITSELF WITH NO VIDEO CODE.  THIS IS IN A SUBCLASS OF NSOPENGLVIEW:
- (void)drawRect:(NSRect)theRect
{
        NSRect bounds = [self bounds];
        NSDictionary *attrs1 = [NSDictionary dictionaryWithObjectsAndKeys:
            [NSFont fontWithName:@"Lucida Grande" size:72.0],    NSFontAttributeName,
            [NSColor blackColor],                                NSForegroundColorAttributeName,
            [NSColor blackColor],                                NSStrokeColorAttributeName,
            [NSNumber numberWithFloat:8.0],                      NSStrokeWidthAttributeName,
            nil];
        NSAttributedString * string1 = [[NSAttributedString alloc] initWithString:@"Now is the time..." attributes:attrs1];
        NSSize size = [string1 size];
        [string1 drawAtPoint:NSMakePoint((bounds.size.width - size.width) / 2, ((bounds.size.height - size.height) / 2) + (size.height / 15))];
        [string1 release];

        NSDictionary *attrs2 = [NSDictionary dictionaryWithObjectsAndKeys:
            [NSFont fontWithName:@"Lucida Grande" size:72.0],    NSFontAttributeName,
            [NSColor whiteColor],                                NSForegroundColorAttributeName,
            nil];
        NSAttributedString * string2 = [[NSAttributedString alloc] initWithString:@"Now is the time..." attributes:attrs2];
        size = [string2 size];
        [string2 drawAtPoint:NSMakePoint(((bounds.size.width - size.width) / 2) + 1, ((bounds.size.height - size.height) / 2) + (size.height / 15))];
        [string2 release];
}



// THIS IS WITH THE VIDEO CODE (EXECUTED FIRST AT THE TOP OF THE METHOD)
- (void)drawRect:(NSRect)theRect
{
        [lock lock];
        NSRect frame = [self frame];
        NSRect bounds = [self bounds];

        [[self openGLContext] makeCurrentContext];
        if(needsReshape)
        {
            GLfloat 	minX, minY, maxX, maxY;

            minX = NSMinX(bounds);
            minY = NSMinY(bounds);
            maxX = NSMaxX(bounds);
            maxY = NSMaxY(bounds);

            [self update];

            if(NSIsEmptyRect([self visibleRect]))
            {
                glViewport(0, 0, 1, 1);
            } else {
                glViewport(0, 0,  frame.size.width ,frame.size.height);
            }
            glMatrixMode(GL_MODELVIEW);
            glLoadIdentity();
            glMatrixMode(GL_PROJECTION);
            glLoadIdentity();
            glOrtho(minX, maxX, minY, maxY, -1.0, 1.0);

            needsReshape = NO;
        }
        glClearColor(0.0, 0.0, 0.0, 0.0);

        glClear(GL_COLOR_BUFFER_BIT);

        if(!currentFrame)
        {
            [self updateCurrentFrame];
        }
        [self renderCurrentFrame];

        glFlush();



        // HERE'S THE EXACT SAME KNOWN-GOOD TEXT SNIPPET FROM BEFORE...

        NSDictionary *attrs1 = [NSDictionary dictionaryWithObjectsAndKeys:
            [NSFont fontWithName:@"Lucida Grande" size:72.0],    NSFontAttributeName,
            [NSColor blackColor],                                NSForegroundColorAttributeName,
            [NSColor blackColor],                                NSStrokeColorAttributeName,
            [NSNumber numberWithFloat:8.0],                      NSStrokeWidthAttributeName,
            nil];
        NSAttributedString * string1 = [[NSAttributedString alloc] initWithString:@"Now is the time..." attributes:attrs1];
        NSSize size = [string1 size];
        [string1 drawAtPoint:NSMakePoint((bounds.size.width - size.width) / 2, ((bounds.size.height - size.height) / 2) + (size.height / 15))];
        [string1 release];

        NSDictionary *attrs2 = [NSDictionary dictionaryWithObjectsAndKeys:
            [NSFont fontWithName:@"Lucida Grande" size:72.0],    NSFontAttributeName,
            [NSColor whiteColor],                                NSForegroundColorAttributeName,
            nil];
        NSAttributedString * string2 = [[NSAttributedString alloc] initWithString:@"Now is the time..." attributes:attrs2];
        size = [string2 size];
        [string2 drawAtPoint:NSMakePoint(((bounds.size.width - size.width) / 2) + 1, ((bounds.size.height - size.height) / 2) + (size.height / 15))];
        [string2 release];





        [lock unlock];
}



Is it an ortho problem maybe?

- Chase





On June 4, 2007, Paul Bruneau wrote:

> On Jun 4, 2007, at 4:08 PM, Douglas Davidson wrote:
>
> > On Jun 4, 2007, at 12:45 PM, Chase wrote:
> >
> >> I'm trying to draw text with outline of a user-specified thickness
> >> (in pixels).  I had to do something similar in a REALbasic app
> >> once, and the effect was achieved by drawing once with a stroke
> >> thickness twice that of the user-specified "text outline
> >> thickness" and then drawing the original text again, directly over
> >> the top (with no outline this time).
> >
> > It's not clear to me exactly what kind of effect you want, but with
> > simple attributes you can specify independent stroke and fill
> > colors as well as the stroke width.  Use
> > NSForegroundColorAttributeName, NSStrokeColorAttributeName, and
> > NSStrokeWidthAttributeName.  The stroke width is not in pixels, but
> > is relative to the font size, so you would need to set it in your
> > text on a per-font-size basis.  See the comments in AppKit/
> > NSAttributedString.h for the exact interpretation of the values.
>
> I think what he means is that stroke width alone will not cut it. If
> you don't want the stroke to encroach on the interior of the letter
> forms, you have to sort of mask the stroke from the inside of the
> letter form, and let it only "grow outward" from the center of the
> stroke.
>
> In Illustrator, you would do just as he says, you would have one copy
> of the text with the stroke on it, then a second copy opaque over the
> top with no stroke, which would then hide the "interior" part of the
> stroke.
>
> Otherwise once your stroke gets larger, it will make the letters
> unreadable or at least ugly.
>
> Here is an example of what I think he means:
>
> http://ethicalpaul.com/share/outline example.png
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: [CoreData] Background Insertion
  • Next by Date: Re: [CoreData] Background Insertion
  • Previous by thread: Re: text to bezier path
  • Next by thread: Re: text to bezier path
  • Index(es):
    • Date
    • Thread