mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-30 11:37:45 +00:00
Merge pull request #4924 from keymanapp/cherrypick/android/4905-dont-load-woff-on-n
fix(android/engine): Don't load woff fonts on Android N 🍒
This commit is contained in:
commit
8f54b0c856
1 changed files with 12 additions and 5 deletions
|
|
@ -1008,22 +1008,29 @@ public final class KMManager {
|
|||
* Get the font typeface from a fully pathed font name
|
||||
* @param context
|
||||
* @param fontFilename String - full path to the font file
|
||||
* @return Typeface
|
||||
* @return Typeface - null if font file doesn't exist or is Woff on Android 7.0 / 7.1
|
||||
*/
|
||||
public static Typeface getFontTypeface(Context context, String fontFilename) {
|
||||
Typeface font = null;
|
||||
|
||||
try {
|
||||
if ((fontFilename != null) && FileUtils.hasFontExtension(fontFilename)) {
|
||||
// Ignore .woff files if Android 7.0 / 7.1 (Issue #4896)
|
||||
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) &&
|
||||
(Build.VERSION.SDK_INT <= Build.VERSION_CODES.N_MR1) &&
|
||||
fontFilename.toLowerCase().endsWith(FileUtils.WOFFFONT)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
File file = new File(fontFilename);
|
||||
if (file.exists()) {
|
||||
font = Typeface.createFromFile(file);
|
||||
return Typeface.createFromFile(file);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
KMLog.LogException(TAG, "Failed to create Typeface: " + fontFilename, e);
|
||||
}
|
||||
return font;
|
||||
|
||||
// No valid font to load
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<Keyboard> getKeyboardsList(Context context) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue