-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
Rotation and draw-text. #38
Comments
FWIW, I thought the answer to the dancing text was going to be creating a font with |
An obversation - made after I wrote the guess below: The rotate? flag in The loop in https://github.com/racket/draw/blob/master/draw-lib/racket/draw/private/dc.rkt#L1709 My intution - but I am far from sure - is that the alignments of each individual character Let's say we want to draw the text hello. The bounding box is a rectangle ABCD with the line AB If A is aligned to A1 and we set B1 to B+(A1-A), then the upper left corners of each I haven't grooked the Pango part of the draw-text code, but this aligns each individual character: |
You can avoid the character-by-character loop by providing Yes, as I remember/understand the code, the normal code path is meant to be taken when rotation is in the transformation. |
You are right, using |
You have looked at fonts and text rendering recently. Have you spotted something that explains the behaviour in the video? /Jens Axel |
Hi, @soegaard—I just took a look at this. After some investigation, I suspect that Unfortunately, when I actually experimented with disabling rounding, I found that it didn’t seem to affect the rendering at all on my machine. While I’m not sure why that would be the case, after some further reading, I get the sense this may be because the version of Cairo I have on my machine (which is running Ubuntu 20.04) doesn’t support subpixel positioning (which is distinct from what’s normally called “subpixel rendering”!) for the necessary font backend. If you’re on macOS, you might want to give it a try yourself (and disable hinting) and see if that changes anything. Having said all of this, I think you probably don’t want to be using Instead, I think what you almost certainly want to do is convert the text to an outline first using the There are two major downsides to rendering text this way:
tl;dr: I’m not exactly sure what the problem is, but there are probably too many moving parts to make animated text look good in a backend-agnostic way without just drawing the glyphs yourself. Try that, instead. |
Hi @lexi-lambda Thanks for the very thorough answer. I am currently using Since it is part of Sketching, I don't know whether the text will be used I'll make an experiment with I was hoping there were some low-level Cairo routines I could have used. |
This example shows a rotating text.
Zooming in on the text (on macOS use ctrl and swipe up with two fingers to zoom in)
shows that the letters are "dancing". It looks as if each letter is rotated individually
instead of the text being drawn as a whole.
The expected result can be seen here (using p5.js):
https://processing.org/examples/textrotation.html
The example also shows that the thickness of the line varies.
Zoom in on the line and it becomes apparent that the line at some angles shrink in width.
In an animation this looks odd.
Turning on smoothing fixes the line thickness problem - but the reason for turning
it off was for speed.
Screen recording:
Screen.Recording.2021-07-01.at.14.22.31.mov
The text was updated successfully, but these errors were encountered: