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

Apply styles to a subset of the text being added? #865

Closed
xZwei opened this issue Apr 21, 2021 · 3 comments
Closed

Apply styles to a subset of the text being added? #865

xZwei opened this issue Apr 21, 2021 · 3 comments

Comments

@xZwei
Copy link

xZwei commented Apr 21, 2021

when calling .drawText("some text to draw", { ...options }), is there a way to have text styles apply to only a subset of the text being added? Say, I want to change the font color of "some text" but leave "to draw" as is. Or just a way to add styles to text separately from the .drawText() call?

@MonteePoke
Copy link

I doubt you can draw text with different styles with single drawText call, at least i didn't find a way to do it.
Instead I made a parser which splits text into array of strings. If string starts with and ends with i swap current font to bold and drawText.
I also used code for line wrapping made by raphaelvazuso in this issue

@Hopding
Copy link
Owner

Hopding commented Sep 23, 2021

@MonteePoke is spot on!

@vedantrajc
Copy link

I doubt you can draw text with different styles with single drawText call, at least i didn't find a way to do it. Instead I made a parser which splits text into array of strings. If string starts with and ends with i swap current font to bold and drawText. I also used code for line wrapping made by raphaelvazuso in this issue

Can anyone explain in more detail, as to how this can be done?

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

4 participants