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: Implemented load from absolute path. #17

Closed
wants to merge 1 commit into from

Conversation

tetsukay
Copy link

We are using exclusive device.
This device has fonts already installed in /system/fonts directory.
I improved to load fonts with absolute path.

@jbarr21 jbarr21 requested review from chrisjenx and ZacSweers April 13, 2019 00:50
Copy link

@ZacSweers ZacSweers left a comment

Choose a reason for hiding this comment

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

Mind adding an example in the sample app since we don't have tests for this?

final Typeface typeface = Typeface.createFromAsset(assetManager, filePath);
final File file = new File(filePath);
final Typeface typeface;
if(file.isAbsolute()) {

Choose a reason for hiding this comment

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

better yet, let's just skip the File instance and check the first path char. Per the doc:

On Android, absolute paths start with the character '/'.

Copy link

@ZacSweers ZacSweers Apr 13, 2019

Choose a reason for hiding this comment

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

                    if (filePath.startsWith("/")) {
                        // Absolute path, so load from that file path
                        typeface = Typeface.createFromFile(filePath);
                    } else {
                        typeface = Typeface.createFromAsset(assetManager, filePath);
                    }

@ZacSweers ZacSweers mentioned this pull request Apr 15, 2019
@ZacSweers
Copy link

Squashed and merged in #25, thanks!

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.

3 participants