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 Android font support #1005

Merged
merged 5 commits into from
Jul 31, 2020
Merged

Conversation

paulproteus
Copy link
Contributor

Add Android font support for text widgets (Label, NumberInput, TextInput) including bold & italic & font size.

This does not add fantasy or cursive support. Those are a smidge more complicated, and I'd prefer to add those in a separate pull request.

Screenshot of TravelTips now:

image

Feedback welcome.

Implementation choices

Sometimes, calls to Android measure() will throw NullPointerException. For some widgets, they need LayoutParams (which are only added in Toga when a widget gets added to a container) before measure() can be called. This does an explicit check for None in those cases, which does the job fine, so I propose we roll with it.

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

@paulproteus
Copy link
Contributor Author

Cursive and Fantasy fonts aren't enabled here. They're not part of the Android Typeface class, although it looks possible to add support with decent reliability. I'm not 100% sure. If that's important, I'm happy to see an issue assigned to me.

If you have cosmetic/smallish changes to make, then feel very free to make them.

If there are larger or otherwise issues you think I should address, then I'm happy to.

Cheers!

@paulproteus
Copy link
Contributor Author

I've added support for cursive!

You can see it working in this screenshot.

image

(I've modified the app to use cursive for one of the tip fields -- look for a lot of 6s, and one of those two fields is cursive.)

Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

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

Mostly looks good. I've made some small tweaks around the original font definition and the way font binding is handled; plus I've added font usage to multiline text.

@freakboy3742 freakboy3742 merged commit 2f97b59 into beeware:master Jul 31, 2020
@paulproteus paulproteus deleted the add-android-fonts branch July 31, 2020 10:32
@paulproteus paulproteus mentioned this pull request Aug 7, 2020
4 tasks
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