You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently you need to compute the width of the lines twice in order to implement horizontal alignment of the text. Once its computed in breakTextIntoLines via look ahead adding words, then if you want to align the lines, you again need the width. You don't need to compute the width that many times here, but you still need to do it again.
The Idea:
type Line = {
text: string
width: number
}
function breakTextIntoLines(/* same api as now */): Line[]
Which is basically a simple change to the const lines structure and this few lines of code:
However, this would be a BC break on the API. Hence, not so good. I would like to ask what you think about the idea in general and would you say its worth create another util function for that case and if so, how would you name it. Or did I miss some other way around the issue of getting the measure?
Sure, I could just compute the line width again...
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Currently you need to compute the width of the lines twice in order to implement horizontal alignment of the text. Once its computed in
breakTextIntoLines
via look ahead adding words, then if you want to align the lines, you again need the width. You don't need to compute the width that many times here, but you still need to do it again.The Idea:
Which is basically a simple change to the
const lines
structure and this few lines of code:pdf-lib/src/utils/strings.ts
Lines 119 to 123 in 2047bb8
However, this would be a BC break on the API. Hence, not so good. I would like to ask what you think about the idea in general and would you say its worth create another util function for that case and if so, how would you name it. Or did I miss some other way around the issue of getting the measure?
Sure, I could just compute the line width again...
Beta Was this translation helpful? Give feedback.
All reactions