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

Add boldListItemNumber theme property #316

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bastienleonard
Copy link

It controls whether we show the number part of ordered lists in bold.

It controls whether we show the number part of ordered lists in bold.
@noties
Copy link
Owner

noties commented Dec 3, 2020

Hello @bastienleonard ,

thank you for your submission. Unfortunately achieving bold ordering numbers would require a bit more complex approach. Mainly due to the code:

paint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));

which would create a default bold typeface. There are numerous ways to set a typeface on a TextView and implicitly applying a default typeface might result in an unexpected visual style. As the absolute minimum TextView's typeface must be used in order to create a bold variant of it. You can obtain it by inspecting TextPaint that we receive in a span. And then creating a bold variant based on that. A good example is system's StyleSpan.

And then there is another problem - order number margin. Ordering numbers are drawn on canvas, and not present in actual text. So, we need to know ordering number width before-hand (before rendering) so span can correctly report margin taken and position number on canvas accordingly. Markwon measures ordering number before rendering using typeface of a TextView. Without inspecting MarkwonTheme. So, in case of a bold typeface, measuring would be off. (number can go out of original TextView bounds, aka clipped). I see no easy way out of this. Except maybe changing how ordering lists are marked. Most likely, using ordering numbers as text (and not drawing them on canvas).

If you wish, please continue with this pull request, but be aware that maybe ordered lists are going to be changed

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

Successfully merging this pull request may close these issues.

2 participants