mirror of
				https://github.com/ImranR98/Obtainium.git
				synced 2025-10-22 18:33:45 +02:00 
			
		
		
		
	Don't load font if loaded
This commit is contained in:
		| @@ -37,7 +37,7 @@ List<MapEntry<Locale, String>> supportedLocales = const [ | ||||
|   MapEntry(Locale('fr'), 'Français'), | ||||
|   MapEntry(Locale('es'), 'Español'), | ||||
|   MapEntry(Locale('pl'), 'Polski'), | ||||
|   MapEntry(Locale('ru'), 'Русский язык'), | ||||
|   MapEntry(Locale('ru'), 'Русский'), | ||||
|   MapEntry(Locale('bs'), 'Bosanski'), | ||||
|   MapEntry(Locale('pt'), 'Brasileiro'), | ||||
|   MapEntry(Locale('cs'), 'Česky'), | ||||
|   | ||||
| @@ -5,6 +5,7 @@ import 'package:flutter/services.dart'; | ||||
| class NativeFeatures { | ||||
|   static const MethodChannel _channel = MethodChannel('native'); | ||||
|   static bool _callbacksApplied = false; | ||||
|   static bool _systemFontLoaded = false; | ||||
|   static int _resPermShizuku = -2;  // not set | ||||
|  | ||||
|   static Future<ByteData> _readFileBytes(String path) async { | ||||
| @@ -34,11 +35,13 @@ class NativeFeatures { | ||||
|   } | ||||
|  | ||||
|   static Future<bool> tryLoadSystemFont() async { | ||||
|     if (_systemFontLoaded) { return true; } | ||||
|     var font = await _channel.invokeMethod('getSystemFont'); | ||||
|     if (font == null) { return false; } | ||||
|     var fontLoader = FontLoader('SystemFont'); | ||||
|     fontLoader.addFont(_readFileBytes(font)); | ||||
|     await fontLoader.load(); | ||||
|     _systemFontLoaded = true; | ||||
|     return true; | ||||
|   } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user