[Leopard] bug in [NSGraphicsContext attributes]

  • Hi!

    When creating an NSGraphicsContext using -graphicsContextWithGraphicsPort:flipped:
    with a CGPDFContext as graphics port, the dictionary returned by -attributes
    of the created NSGraphicsContext no longer contains the documented key-value pairs.

    In Tiger the attribute dict contains keys like
    NSGraphicsContextRepresentationFormatAttributeName and
    NSGraphicsContextDestinationAttributeName.
    In Leopard no more.

    If you rely on these keys and values, I'd suggest to check your apps.

    As this bug also affects possible analysis while printing:
    Any ideas how to find out if current context's graphics port
    (e.g. while printing a PDF via NSPrintPanel) is a PDF context or not?

    Michael

    P.S.: Yes, I will file a bug report for sure :-)

    ---
    Michael Monscheuer
    www.icalamus.net
  • Hi Michael,

    Yes, please file a bug if something changed here.

    Would -[NSGraphicsContext isDrawingToScreen] work for you?  It really
    has more to do with whether the destination context is pixel-based
    than with whether it's the screen.

    "A return value of NO may mean that the drawing destination is a
    printer, but the destination may also be a PDF or EPS file."

    This will not help if your goal is to distinguish between printing to
    a printer and printing to a PDF.

    -Ken
    Cocoa Frameworks

    On Nov 6, 2007 5:02 AM, Michael Monscheuer <michi...> wrote:
    > Hi!
    >
    > When creating an NSGraphicsContext using -graphicsContextWithGraphicsPort:flipped:
    > with a CGPDFContext as graphics port, the dictionary returned by -attributes
    > of the created NSGraphicsContext no longer contains the documented key-value pairs.
    >
    > In Tiger the attribute dict contains keys like
    > NSGraphicsContextRepresentationFormatAttributeName and
    > NSGraphicsContextDestinationAttributeName.
    > In Leopard no more.
    >
    > If you rely on these keys and values, I'd suggest to check your apps.
    >
    > As this bug also affects possible analysis while printing:
    > Any ideas how to find out if current context's graphics port
    > (e.g. while printing a PDF via NSPrintPanel) is a PDF context or not?
    >
    > Michael
    >
    > P.S.: Yes, I will file a bug report for sure :-)
    >
    > ---
    > Michael Monscheuer
    > www.icalamus.net
    >
  • Hi!

    > This will not help if your goal is to distinguish between printing to
    > a printer and printing to a PDF.

    Right. We use -[NSGraphicsContext attributes] *and* -[NSGraphicsContext isDrawingToScreen]
    on the current graphics context in -[NSView drawRect:] methods to distinguish between
    screen, PDF, PS and manual bitmap contexts.

    I filed a report (Bug ID# 5584898) with a simple example app attached.

    I managed to find a workaround by (mis)using an existing hack in our app.
    But I don't like hacks. Would feel better to be able to use the official API...

    Michael

    Ken Ferry schrieb:
    > Hi Michael,
    >
    > Yes, please file a bug if something changed here.
    >
    > Would -[NSGraphicsContext isDrawingToScreen] work for you?  It really
    > has more to do with whether the destination context is pixel-based
    > than with whether it's the screen.
    >
    > "A return value of NO may mean that the drawing destination is a
    > printer, but the destination may also be a PDF or EPS file."
    >
    > This will not help if your goal is to distinguish between printing to
    > a printer and printing to a PDF.
    >
    > -Ken
    > Cocoa Frameworks
    >
    > On Nov 6, 2007 5:02 AM, Michael Monscheuer <michi...> wrote:
    >> Hi!
    >>
    >> When creating an NSGraphicsContext using -graphicsContextWithGraphicsPort:flipped:
    >> with a CGPDFContext as graphics port, the dictionary returned by -attributes
    >> of the created NSGraphicsContext no longer contains the documented key-value pairs.
    >>
    >> In Tiger the attribute dict contains keys like
    >> NSGraphicsContextRepresentationFormatAttributeName and
    >> NSGraphicsContextDestinationAttributeName.
    >> In Leopard no more.
    >>
    >> If you rely on these keys and values, I'd suggest to check your apps.
    >>
    >> As this bug also affects possible analysis while printing:
    >> Any ideas how to find out if current context's graphics port
    >> (e.g. while printing a PDF via NSPrintPanel) is a PDF context or not?
    >>
    >> Michael
    >>
    >> P.S.: Yes, I will file a bug report for sure :-)
    >>
    >> ---
    >> Michael Monscheuer
    >> www.icalamus.net
    >>
    >

    --
    =======================================================
    And refashioning the fashioned
    lest it stiffen into iron
    is work of endless vital activity.
    [Goethe]

    Michael Monscheuer
    Askanierweg 5a
    21465 Wentorf

    Tel.:+49 40 72699442
    Fax.:+49 40 72410664

    mailto:<monscheuer...>
    mailto:<michi...>

    http://www.icalamus.net

    =======================================================
previous month november 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    
Go to today