-
Notifications
You must be signed in to change notification settings - Fork 81
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
Conversation
There was a problem hiding this 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()) { |
There was a problem hiding this comment.
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 '/'.
There was a problem hiding this comment.
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);
}
Squashed and merged in #25, thanks! |
We are using exclusive device.
This device has fonts already installed in
/system/fonts
directory.I improved to load fonts with absolute path.