Search
 
SCRIPT & CODE EXAMPLE
 

DART

Flutter default device font PlatformChannel

private String getDefaultFont() {
        File configFilename = new File("/system/etc/system_fonts.xml");
        // sans-serif is the default font family name in Android SDK, check out the code in Typeface.java
        String defaultFontName = "sans-serif";

        try {
            FileInputStream fontsIn = new FileInputStream(configFilename);
            XmlPullParser parser = Xml.newPullParser();
            parser.setInput(fontsIn, null);
            boolean done = false;
            boolean getTheText = false;
            int eventType;
            while (!done) {
                eventType = parser.next();
                if (eventType == parser.START_TAG && parser.getName().equalsIgnoreCase("name")) {
                    getTheText = true;
                }
                if (eventType == parser.TEXT && getTheText) {
                    // first name
                    defaultFontName = parser.getText();
                    done = true;
                }
                if (eventType == parser.END_DOCUMENT) {
                    done = true;
                }
            }
        } catch (RuntimeException e) {
            System.err.println("Didn't create default family (most likely, non-Minikin build)");
        } catch (FileNotFoundException e) {
            System.err.println("GetDefaultFont: config file Not found");
        } catch (IOException e) {
            System.err.println("GetDefaultFont: IO exception: " + e.getMessage());
        } catch (XmlPullParserException e) {
            System.err.println("getDefaultFont: XML parse exception " + e.getMessage());
        }
        return defaultFontName;
    }
Comment

PREVIOUS NEXT
Code Example
Dart :: glowing buttons in flutter 
Dart :: flutter center title ignore button 
Dart :: string to int in flutter 
Dart :: flutter firebase_messaging 9 ios 
Dart :: convert to string flutter 
Dart :: customscrollview add container widget 
Swift :: string to capital letter dart 
Swift :: swiftui width screen 
Swift :: save date to userdefaults swift 
Swift :: show alert with textfield swift 
Swift :: swift set view z order front 
Swift :: access dictionary with index swift 
Swift :: remove back button from navigation bar swift 
Swift :: xcode label rotate text 
Swift :: swift uibutton programmatically set ontap function 
Swift :: swiftui button style 
Swift :: swift constraint center vertically 
Swift :: hide bottom tab bar swift 
Swift :: power number in swift13 
Swift :: how to insert element at start of the array ios swift 
Swift :: swiftui background color 
Swift :: swift hex color 
Swift :: check if string in array of string swift 
Swift :: set white place holder color in swift 
Swift :: rounded ios button 
Swift :: add callbacks to view swiftui 
Swift :: swift extension Array of element 
Swift :: while loop in swift 
Swift :: Swift Named Tuples 
Swift :: Type Constraints Swift 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =