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

feat: letter spacing #128

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

Conversation

GWAnthonyAdams
Copy link

Add letterSpacing support for styles.

If scaled pixels value is provided, convert the value to em so we can better use the setLetterSpacing function. (Wouldn't it have been nice if it supported it out of the box!)

fun TextView.applyLetterSpacing(letterSpacing: TextUnit) {
if (letterSpacing != TextUnit.Unspecified) {
if (letterSpacing.isSp) {
setLetterSpacing((letterSpacing.value * 0.0624).toFloat())
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what 0.0624 means? where is it coming from?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, I was using a value used by others here https://chrisdavies.github.io/sp-to-em/ which seemed to be fairly consistent across screen sizes.

I've ended up using another custom solution over this project as a result of letter spacing not being consistent with existing behaviour (as a result of letter spacing only supporting EM for AndroidViews out of the box)

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