-
-
Notifications
You must be signed in to change notification settings - Fork 757
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
Expose y position in print callback #506
Comments
You could expose this the line counting functionality. IDK of any current way to get what you want. PRs are welcome! All the printing code is found in |
Exposing the function would accomplish the same thing though. Calling the measureText function twice... |
@Zyberg I dont think you'll be able to get past calling this function twice. We can't return anything other than image.print(font, 0, 0, "Some string", (err, image, yValue) => {
image.print(font, 0, yValue, "Some other string")
}) |
@hipstersmoothie this would work without calling the same function twice, so it looks like a great solution. |
Released in v0.4.0 |
I have to print 2 text blocks onto an image and the second one needs to be separated by exactly 100px after the first.
What I am doing right now is simply looping through the text and by using
measureText
function trying to find the number of lines that my text block has, then finding the max y value of each line of the text (which turns out to be 2px higher for every line thanfont.common.lineHeight
, so I suppose there's some padding or something? Is it consistent?)It's all kind of nice logically, BUT the way the text is being drawn on an image in the library itself is exactly by looping through all the text, counting the number of lines etc. So, I am doing practically same loop twice and increase the running time of my function twice :/
Is there a good way around this?
The text was updated successfully, but these errors were encountered: