-
Notifications
You must be signed in to change notification settings - Fork 27
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
Parley rendering beyond measured bounds #165
Comments
Seems like it may be a matter of adding functions to measure real layout overflow, rather than the ‘layout size’ (total inline advance of the longest line by total of line heights). There might also be use for a layout mode that limits the real overflow bounds, because there is not a simple or efficient way to implement this on top of the current functionality. And of course, this calls for better documentation, and possibly more descriptive naming, on the existing functions. |
Parley probably doesn’t want to be in the business of loading/scaling outlines so computing the full ink rectangle is likely out of scope. I can be convinced otherwise but my current thinking is that the information for doing this is likely already available in the application’s glyph cache and we don’t want to do redundant work. The overflow of the last line is more concerning because we’re apparently not even including the baseline in the computed height. That said, the roughly 8 pixel overflow is very close to the applied padding of 10px so I wonder if something funky is going on there. |
Thanks for the responses. @dfrg That makes sense that it is out of scope. Based on that I've implemented my own code which measures the full pixel width and height, and also the pixel offset, and this now renders nicely in the box: Interestingly the width constraint seems to have been hit exactly when I measure it manually:
Regarding the overflow of the last line using the built in However, as I am now using my own measuring this isn't a blocker for me. Feel free to close this issue if you think it makes sense. |
I think this bug ought to be left open. I believe we ought to be able to compute reasonable bounds just using the font metrics, and the fact we are not is simply a bug, quite possibly introduced in #84 which switched us from using font metrics to using I'm glad you have found a workaround for the time being. |
Agreed with keeping this open. We don’t guarantee ink bounds but we should provide bounds that fully enclose the text based on metrics. |
Ink bounds can be important for when you want to put some text in a clipped box or a texture, but the most common use case for this is single-line text in a field, where Parley consumers can generally figure that out (since they are dealing with positioning and horizontal scrolling themselves). After looking at it, yeah it looks like it would be very invasive to do real ink-bounded layouts in Parley, even as a feature. |
I'm using Parley with Taffy to render text within flexbox layouts. However Parley is rendering it's text beyond the bounds given by its computed layout.
This seems like it might be slightly related to issue 119, although I'm already using a larger line height of 1.3 as suggested.
I've cobbled together a simple project that shows the issue by adapting various examples from Parley and Taffy (here, here and here):
The project is here:
https://github.com/jamesthurley/parley-test
First run
download_fonts.sh
which will fetch the OpenSans font from google's github repo, to ensure we're all looking at exactly the same output, and then you can docargo run
and it will create a file calledoutput.png
.Or, if you just want to use system fonts you can comment out lines
66-71
and line233
.The example uses Taffy to create a layout with two vertically oriented boxes. The top box will take as much space as required by the text within (using Parley to compute the required size, and to render the text), the second box takes up the remaining space. There is a 10 pixel border to make things clearer.
This is the output image I get:
Looking more closely, there seems to be perhaps three visible issues.
First, the text is offset vertically downwards by about 4 pixels (overlapping the red line is fine, going beyond it isn't):
Second, the measured pixel height returned by Parley is too short. You see here the rendered text extends down 8 pixels beyond the red box:
Third, also visible in the above image, the
j
extends one pixel too far to the left.I am certain I have rendered the red box with the correct position and height, as shown by the console output:
It's very possible I've made a mistake with how I'm using Parley. Any pointers would be appreciated.
The text was updated successfully, but these errors were encountered: