Repository navigation
Draw a plain borderless free text box as PDF.js does - #118
Open
KleiKodesh wants to merge 1 commit into
Open
KleiKodesh wants to merge 1 commit into
KleiKodesh wants to merge 1 commit into
Conversation
A free text box without /BS took the default 1 pt border even when its /Border array says 0, so a box PDF.js wrote (/Border [0 0 0], no /AP, no /RC) got a frame and a text plate inset by 2 pt on every side. Its rect fits the text as PDF.js measured it, so the text then wrapped and the second line was clipped away. - Without /BS, the box's border width is the /Border array's, as the callout already reads it. - A plain box (no /RC) whose border is 0 lays out as PDF.js draws it: lines break only at line breaks, text too wide or too tall for the box is drawn smaller to fit (CPDF_RichTextLayout::Options:: shrink_to_fit), and each paragraph reads in its text's direction.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A free text annotation without
/BSalways got the default 1 pt border, even when its/Borderarray says 0. PDF.js writes exactly that kind of box:/Border [0 0 0],/Contents,/DA, no/RC, and for non-Latin text no/APat all. Generating its appearance then:Changes:
/BS, a free text box's border width comes from/Border(ISO 32000-1 12.5.2), as the callout path already reads it./RC) with no border lays out as PDF.js draws it (FreeTextAnnotation/FakeUnicodeFont.createAppearance): lines break only at line breaks, and text wider or taller than the box is drawn smaller, by the smaller of the two ratios. Each paragraph reads in its text's direction, so right-to-left text lines up from the right edge when/Qasks for it.CPDF_RichTextLayout::Options::shrink_to_fitcarries the new layout mode; auto size (/DAsize 0) keeps its ladder.Boxes with a border, with
/RC, or written by Acrobat lay out as before.Tests
CPDFGenerateAPTest.FreeTextWithoutBorderShrinksToFit: a 40 pt wide box with/Border [0 0 0]and "hello world" at 12 pt draws no border stroke and a font size below 12.