• 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: NSLayoutManager's setDefaultAttachmentScaling: not working in custom PDF NSContexts.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSLayoutManager's setDefaultAttachmentScaling: not working in custom PDF NSContexts.


  • Subject: Re: NSLayoutManager's setDefaultAttachmentScaling: not working in custom PDF NSContexts.
  • From: Aki Inoue <email@hidden>
  • Date: Mon, 30 Jan 2012 14:49:41 -0800

Sounds like a bug.

File a bug report.

Thanks,

Aki

On Jan 29, 2012, at 10:03 AM, Gus Mueller <email@hidden> wrote:

> I have an issue where using NSLayoutManager's setDefaultAttachmentScaling:NSImageScaleProportionallyDown doesn't seem to work if I setup my own NSGraphicsContext + CGPDFContext.
>
> The problem is that large inline images are not scaled down when drawn like they would be in an NSTextView.  Text after the image is positioned as if it was scaled though, so I end up with text that is drawn over an image.
>
> Here's the abbreviated code for what I'm doing:
>
> .. make a CGPDFContext "ctx", wrap it up in a flipped NSGraphicsContext
> .. load an NSTextStorage "contents" up with my RTFD file
>
> NSLayoutManager *layoutManager = [[[NSLayoutManager alloc] init] autorelease];
> [contents addLayoutManager:layoutManager];
>
> [layoutManager setDefaultAttachmentScaling:NSImageScaleProportionallyDown];
>
> BOOL clipped = NO;
> do {
>    CGContextBeginPage(ctx, &box);
>    CGContextTranslateCTM( ctx, 0, box.size.height);
>    CGContextScaleCTM(ctx, 1.0, -1.0 );
>
>    NSTextContainer *textContainer = [[[NSTextContainer alloc] initWithContainerSize:box.size] autorelease];
>    [layoutManager addTextContainer:textContainer];
>    [layoutManager ensureLayoutForTextContainer:textContainer];
>
>    NSRange glyphRange = [layoutManager glyphRangeForTextContainer:textContainer];
>    NSRange charRange  = [layoutManager characterRangeForGlyphRange:glyphRange actualGlyphRange:nil];
>
>    [layoutManager drawGlyphsForGlyphRange:glyphRange atPoint:NSZeroPoint];
>
>    clipped = (NSMaxRange(charRange) < [contents length]);
>
>    CGContextEndPage(ctx);
> }
> while (clipped);
>
> .. cleanup
>
> I've got some very simple sample code which reproduces the behavior here:
> http://gusmueller.com/stuff/NSLayoutImageScalingPDFProblem.zip
>
> Can anyone shed some light on what I'm doing wrong?
> This is on 10.7.2 btw.
>
> thanks,
>
> -gus
>
> --
>
> August 'Gus' Mueller
> Flying Meat Inc.
> http://flyingmeat.com/
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please 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)

Please 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


References: 
 >NSLayoutManager's setDefaultAttachmentScaling: not working in custom PDF NSContexts. (From: Gus Mueller <email@hidden>)

  • Prev by Date: Re: NSLayoutManager's setDefaultAttachmentScaling: not working in custom PDF NSContexts.
  • Next by Date: Re: How do you run an app on the device with Instruments?
  • Previous by thread: Re: NSLayoutManager's setDefaultAttachmentScaling: not working in custom PDF NSContexts.
  • Next by thread: Sensitivity of swipe gesture
  • Index(es):
    • Date
    • Thread