-
Notifications
You must be signed in to change notification settings - Fork 16
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
Text envelope generation is fontsize ignorant #68
Comments
Yeah, there's definitely some very strange stuff going on at the Pango interface. (When I added text annotations to dynamic-plot, I never really understood how the boxes work out, but with some trial&error I was able to get the results I wanted. Hardly satisfying...) I think it would be good to make some test code that allows directly comparing the results of SVGFonts text for reference with those generated by diagrams-cairo / Pango. That will hopefully point us to where the problem lies. |
Thanks for reporting this. Sorry the As you have noticed, Pango needs to know the final rendering size of the Diagram in order to layout / measure text. I think the I believe it is correct for the origin to be at the baseline. I'm surprised that Pango reports a logical extent that doesn't include the baseline, and doesn't include leading above either. These dimensions are part of the font. What font is this? It's possible that I misunderstand what Pango means by "logical extents", or maybe I just swapped
I think you're right. Can you send a PR to correct this? |
Agreed. Makes sense.
Yes. I think you swapped them. Funnily, I only realised that when looking at the pango docs, thinking the haddocks be wrong as they mention the result in the order "logical and ink". Only just realised that the haddocks also include an annotation to the result. Guess I'm not used to reading those.
I'll certainly give it a go. That change on its own is certainly easy enough. However, it's not all that satisfying on its own as the origin and envelope are still a bit messed up. Would you mind if I introduced a |
Those both sound like good ideas. Thank you! |
It seems that
results in the envelope of
t
being computed at size 12 (px/pt/?), as witnessed by the discrepancy between the size of the text and its envelope by renderingversus
Sifting through the documentation of
diagrams-core
reveals thatFontSize
is a measured attribute, which cannot simply be extracted viagetAttr
, resulting intextLineBoundedIO
gettingNothing
, and surely ,fmap getFontSize (getAttr (mempty # fontSizeL 12)) == Nothing
. I'm not sure what would be a good fix to this, as we cannot reasonably know what to pass to pango at this point, as the proper font size to select depends on the size the text eventually ends up at when rendered. Or if it is safe as long as the font size measure is Local?Additionally, the
fontSize
attribute in the style argument totextLineBoundedIO
is simply thrown away by the current implementation. I would expect it to be retained in the resulting Diagram.The text was updated successfully, but these errors were encountered: