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

Opentype.js can only draw black text. #623

Open
ILOVEPIE opened this issue Oct 20, 2023 · 3 comments
Open

Opentype.js can only draw black text. #623

ILOVEPIE opened this issue Oct 20, 2023 · 3 comments

Comments

@ILOVEPIE
Copy link
Contributor

Expected Behavior

There should be a way to specify the color of the text being drawn.

Current Behavior

opentype.js is the Henry Ford of font rendering "Any [user] can have [their text] any color that [they want] so long as it is black."

Possible Solution

Allow a color to be selected in the draw call for Font and Glyph objects.

Context

My library has to manually draw the path to work around this, granted I have to do this anyways as I need to stroke the text too, but my point stands.

@axkibe
Copy link
Contributor

axkibe commented Jan 27, 2024

My take on this is, maybe opentype.js shouldn't draw at all. Why duplicate API? Have opentype.js just make the path on the canvas an the caller can fill and stroke it.

@ILOVEPIE
Copy link
Contributor Author

My take on this is, maybe opentype.js shouldn't draw at all. Why duplicate API? Have opentype.js just make the path on the canvas an the caller can fill and stroke it.

We could do it either way.

@Shmacked
Copy link

My take on this is, maybe opentype.js shouldn't draw at all. Why duplicate API? Have opentype.js just make the path on the canvas an the caller can fill and stroke it.

For me, I replaced the native text component for fabric.js with opentype.js drawing command. I had to rewrite the drawing command in order to be able to apply stroke and fill (and other effects, if I wanted) on it, since this isn't native to fabric.js, yet. I could convert them to paths, but I wanted the ability to to edit text and fonts.

My fix is not perfect, but it pretty dang close to getting accurate bounding boxes on the text with a given font.

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

3 participants