Skip to content
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

How can I determine the line-height of a font? #134

Closed
NathanWailes opened this issue Jul 31, 2019 · 1 comment
Closed

How can I determine the line-height of a font? #134

NathanWailes opened this issue Jul 31, 2019 · 1 comment

Comments

@NathanWailes
Copy link

NathanWailes commented Jul 31, 2019

Hi,

I'm trying to use cairocffi to render text to PNGs which I then stitch into a lyrics video that highlights the currently-performed syllable, kind of like karoake. You can see an example of the goal here (this example uses PIL instead of cairocffi): https://www.youtube.com/watch?v=9u9ylseLAfU

The problem with PIL is that if I separately-render two parts of a word so that I can have the parts colored differently, the kerning between the letters is lost.

You can see the previous issues I've created here:

Anyway, I'm now trying to use cairocffi, but now I'm running into issues because I don't seem to have access to information that PIL provides. For example, I don't see how I can get the height of the text that is (or will be) rendered to the screen, so that I can use that to properly vertically-position the text or limit the height of the image so that I can overlay it on top of the background image I create with PIL.

Any idea how I could get that information?

@liZe
Copy link
Member

liZe commented Aug 12, 2019

Any idea how I could get that information?

Yes!

Cairo provides text extents with width, height, and other information. You'll find other useful functions on the same page, and on the text module page.

If you have more specific questions, you should ask Cairo devs using their mailing-list or IRC, they'll probably have more useful answers! CairoCFFI is just a wrapper around Cairo.

@liZe liZe closed this as completed Aug 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants