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

Correct documentation of line dictionary #2958

Merged
merged 1 commit into from
Jan 8, 2024
Merged

Conversation

JorjMcKie
Copy link
Collaborator

The explanation of the text writing direction vector was incomplete / incorrect. The sign of trigonometric sine value appears reversed because of MuPDF's coordinate system.

@JorjMcKie JorjMcKie requested a review from jamie-lemon January 2, 2024 09:50
@JorjMcKie JorjMcKie force-pushed the clarify-line-dictionary branch from 12847c8 to 03a6595 Compare January 4, 2024 12:26
Copy link
Collaborator

@jamie-lemon jamie-lemon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few small things.

docs/shape.rst Outdated
:arg int expandtabs: controls handling of tab characters *\t* using the *string.expandtabs()* method **per each line**.
:arg float lineheight: a factor to override the line height calculated from font properties. If not `None`, a line height of `fontsize * lineheight` will be used.

:arg int expandtabs: controls handling of tab characters `\t` using the `string.expandtabs()` method **per each line**.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The backslash t here will need two backticks on either side (not one) to faithfully display.

docs/shape.rst Outdated

:arg float stroke_opacity: *(new in v1.18.1)* set transparency for stroke colors. Negative values and values > 1 will be ignored. Default is 1 (intransparent).
:arg float fill_opacity: *(new in v1.18.1)* set transparency for fill colors. Default is 1 (intransparent). Use this value to control transparency of the text color. Stroke opacity **only** affects the border line of characters.

:arg int rotate: requests text to be rotated in the rectangle. This value must be a multiple of 90 degrees. Default is 0 (no rotation). Effectively, four different values are processed: 0, 90, 180 and 270 (= -90), each causing the text to start in a different rectangle corner. Bottom-left is 90, bottom-right is 180, and -90 / 270 is top-right. See the example how text is filled in a rectangle. This argument takes precedence over morphing. See the second example, which shows text first rotated left by 90 degrees and then the whole rectangle rotated clockwise around is lower left corner.
:arg int rotate: requests text to be rotated in the rectangle. This value must be a multiple of 90 degrees. Default is 0 (no rotation). Effectively, four the values 0, 90, 180 and 270 (= -90) are processed, each causing the text to start in a different rectangle corner. Bottom-left is 90, bottom-right is 180, and -90 / 270 is top-right. See the example how text is filled in a rectangle. This argument takes precedence over morphing. See the second example, which shows text first rotated left by 90 degrees and then the whole rectangle rotated clockwise around is lower left corner.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"four the values" -> "four of the values" or just "four values". Also we could back tick all the numbers as it might look nicer?

.. [#f1] Image specifications for a PDF page are done in a page's (sub-) :data:`dictionary`, called *"/Resources"*. Resource dictionaries can be **inherited** from the page's parent object (usually the :data:`catalog`). The PDF creator may e.g. define one */Resources* on file level, naming all images and all fonts ever used by any page. In these cases, :meth:`Page.get_images` and :meth:`Page.get_fonts` will return the same lists for all pages.
.. [#f1] Image specifications for a PDF page are done in a page's (sub-) :data:`dictionary`, called `/Resources`. Resource dictionaries can be **inherited** from any of the page's parent objects (usually the :data:`catalog` -- the top-level parent). The PDF creator may e.g. define one `/Resources` on file level, naming all images and / or all fonts ever used by any page. In these cases, :meth:`Page.get_images` and :meth:`Page.get_fonts` will consequently return the same lists for all pages. If desired, this situation can be reverted using :meth:`Page.clean_contents`. After execution, the page's object definition will show fonts and images that are actually used.

.. [#f2] The coordinate systems of MuPDF and PDF are different in that MuPDF uses the page's top-left point as (0,0). In PDF, this is the bottom-left point. Therefore, the positive direction for MuPDF's y-axis is **from top to bottom**. This causes the sign change for the sine value here: a **negative** value indicates anti-clockwise rotation of the text.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

backtick (0,0) , just to look nicer?

Correct and clarify line dict and others

Document "lineheight" parameter in "insert_textbox()".

Correct documentation of line dictionary

The explanation of the text writing direction vector was incomplete / incorrect.
The sign of trigonometric sine value appears reversed because of MuPDF's coordinate system.
@JorjMcKie JorjMcKie force-pushed the clarify-line-dictionary branch from 03a6595 to ad58d09 Compare January 8, 2024 16:38
@JorjMcKie JorjMcKie requested a review from jamie-lemon January 8, 2024 16:58
Copy link
Collaborator

@jamie-lemon jamie-lemon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jamie-lemon jamie-lemon merged commit bd045e5 into main Jan 8, 2024
2 checks passed
@jamie-lemon jamie-lemon deleted the clarify-line-dictionary branch January 8, 2024 17:27
@github-actions github-actions bot locked and limited conversation to collaborators Jan 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants