Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returning the color on PDF::Inspector::Text#font_settings #33

Open
juan-ki opened this issue Oct 30, 2024 · 2 comments
Open

Returning the color on PDF::Inspector::Text#font_settings #33

juan-ki opened this issue Oct 30, 2024 · 2 comments

Comments

@juan-ki
Copy link

juan-ki commented Oct 30, 2024

When calling PDF::Inspector::Text#font_settings, it returns an array of objects with font name and size. I’d like to add the color of the text as well. From looking at the code, it seems these attributes are set here:

      def set_text_font_and_size(*params)
        @state.set_text_font_and_size(*params)
        @font_settings << { name: @fonts[params[0]], size: params[1] }
      end

If you agree that this would be a good addition, could you please advise on where to start in order to add this parameter?, I’d be happy to collaborate on a PR for this feature.

@pointlessone
Copy link
Member

I'm not against it in principle.

IIRC, set_text_font_and_size is a callback for PDF graphic stream command. There should be corresponding callbacks for commands for setting fill color (what is usually used for text color). You'd need to keep track of the current fill color to assign it to the text. You probably would also need to keep track of the drawing mode (e.g. fill only, outline only, etc.) because you probably can have fill color set but not actually used.

Study material:

  • PDF Reference
    • Either PDF Reference 1.7 (or ISO 32000-1:2008)
      • 4.4.2 Path-Painting Operators
      • 5: Text, and specifically:
        • 5.1.2 Achieving Special Graphical Effects
        • 5.2.5 Text Rendering Mode
    • Or PDF 2.0 (ISO 32000-2:2020)
      • 8.5.3: Path-painting operators
      • 9: Text, and specifically:
        • 9.2.3 Achieving special graphical effects
        • 9.3.6: Text Rendering Mode
  • PDF::Reader codebase

@juan-ki
Copy link
Author

juan-ki commented Nov 4, 2024

I'll take a look, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants