Menu

#1618 Add support for dark mode

All
closed
nobody
None
5
2021-12-23
2021-09-17
No

Add dark mode support. When dark mode is enabled, colors in the PDF should appear as if the System Preference's "Invert Display Color" mode is turned on. That is, the background of a typical text PDF would appear black and the text would appear white (instead of black text on a white background).

Discussion

1 2 > >> (Page 1 of 2)
  • Lane Schwartz

    Lane Schwartz - 2021-09-17

    This documentation might be useful.

     

    Last edit: Lane Schwartz 2021-09-17
  • Lane Schwartz

    Lane Schwartz - 2021-09-17
     

    Last edit: Lane Schwartz 2021-09-17
  • Christiaan Hofman

    • status: open --> closed
     
  • Christiaan Hofman

    PDF is content. That should not be inverted. Dark mode is about UI, not content. And co,lor inversion has nothing to do with dark mode support.

     
    • Lane Schwartz

      Lane Schwartz - 2021-09-17

      Christiaan, take a look at how Mail handles Dark Mode. The entire UI background color is black, and the foreground color is white. Is it possible for an email to actively specify its foreground and background colors? Yes. But most emails don't. And those emails that don't appear with white text on black background when Dark Mode is enabled for Mail.

      The same could apply to PDFs. I proposed inverting colors because that seems to be a straightforward mechanism to achieve white text on black background.

      I read through some of the other closed tickets that were asking for white text on black background. The second two links seem like they might be what you need to get PDFKit to give you that result.

      Another option could be adding a preference (or a hidden preference) for to enable Invert Colors. Would you be willing to consider that?

       
      • Christiaan Hofman

        You cannot compare UI. Mail displays text. For text there are dark mode properties defined, and only for specific colors, where the background and foreground have specific dark mode sensitive values. Not PDF content, which defines its own content as it should be displayed. It does not use dynamic colors.And again, color inversion has nothing to do with dark mode.

        If you want to define dark mode sensitive PDFs, you should ask Adobe to define =a notion of dark mode sensitive content, and ask Apple to support it. Otherwise, there is nothing to do.

         
        • Lane Schwartz

          Lane Schwartz - 2021-09-17

          Christiaan,

          First of all, thank you for your excellent work on Skim. I really appreciate it.

          Secondly, my understanding is that PDFs can specify a background color and can specify a color for text, but most don't. Is that your understanding, too?

          Thanks,
          Lane

           
          • Christiaan Hofman

            Yes, they can specify background and text colors, and they usually don't provide background colors (in the sense of page background colors). My understanding is that they do provide the text color (usually black). As for the default page background color, that is determined by Apple's PDFView, and cannot be modified. (there was hidden a possibility a long time ago, but Apple disabled that).

             
            • Lane Schwartz

              Lane Schwartz - 2021-09-17

              Christiaan, thanks. That's helpful.

              So in terms of supporting white text on black background, the issue is that PDFKit doesn't allow this. Is that correct?

               
              • Christiaan Hofman

                Yes, that is correct.

                 
                • Lane Schwartz

                  Lane Schwartz - 2021-09-17

                  OK. That's unfortunate.

                  If there were a way of setting white text on black background (at least for simple text-heavy PDFs) using PDFKit, is that something that you would be willing to implement (again, assuming it could be done within PDFKit)?

                   
                  • Christiaan Hofman

                    No, as it would not work universally, and we could not know when it would not work (as that is content dependent, not user dependent). Apart from that, it is irrelevant, because there is no way. (I have tried every private pageBackground property in PDFKit, and they do exactly nothing, and there are not even any private text color properties; and then we're talking private, which means unreliable, and prohibited by Apple).

                     
                    • Lane Schwartz

                      Lane Schwartz - 2021-09-17

                      What about modifying the strokeColor and fillColor of the CGContextRef before calling drawPage: toContext?

                      Edit: updated links to strokeColor and fillColor

                       

                      Last edit: Lane Schwartz 2021-09-17
  • Christiaan Hofman

    Apart from this, what you seem to be referring to is support in UIKit. I see nothing of the kind in AppKit. This is not iOS.

     
    • Lane Schwartz

      Lane Schwartz - 2021-09-17

      I think the links I sent are for SwiftUI, which can be used for both macOS and iOS. I'm not familiar, though, with the interface between SwiftUI and AppKit.

       
      • Christiaan Hofman

        Skim is not programmed in Swift, and I don't see anything in Objective-C. BTW, m ost of your links are invalid.

         
        • Christiaan Hofman

          Moreover, even as far as it would be possible to bring SwiftUI into an objective-c program, it would never be compatible with older OS versions. And Skim supports up to 10.10. So this is simply impossible.

           
        • Lane Schwartz

          Lane Schwartz - 2021-09-17

          Right. I'll let you know if I find anything about interfacing the SwiftUI APIs from Objective-C. That might or might not be possible.

          Sorry about the broken links. I have now fixed them.

           

          Last edit: Lane Schwartz 2021-09-17
          • Christiaan Hofman

            The only thing I see is including some custom SwiftUI views in an ObjC project. But we are talking about an existing view class. Apple simply does not provide the support.

            And that is apart from not wanting it.

             
  • Christiaan Hofman

    • status: closed --> open
     
  • Christiaan Hofman

    I found a way to invert the colors in the pdf view. It will be available only through a hidden preference though, because of the reasons detailed above.

     
    • Roi Holtzman

      Roi Holtzman - 2021-10-02

      How did you invert the colors?

       
      • Christiaan Hofman

        Setting content filters on the displaying views.

         
        • Roi Holtzman

          Roi Holtzman - 2021-10-02

          I am sorry, but I could not find any content filters. can you please point me to where it is?

           
1 2 > >> (Page 1 of 2)

Log in to post a comment.