Using downloadable fonts in Sketchware

This post demonstrates how to use the Downloadable Fonts feature introduced in Android O in Sketchware. Downloadable Fonts is a feature that allows apps to request a certain font from a provider instead of bundling it or downloading it themselves. This means, there is no need to bundle the font as an asset.

1. Create a new project in Sketchware.

2. Switch on AppCompat and design.

3. In main.xml add a spinner spinner1, and three TextViews textview1, textview2 and textview3.

4. Add a Shared preferences component spref:spref.

5. Add a String list font_list, and three String variables query, cert_string1, cert_string2.

6. In onCreate,

a. Add items to font_list using following code:
Copy code
font_list.addAll(
Arrays.asList(new String[]{
"ABeeZee",
"Abel",
"Abhaya Libre",
"Abril Fatface",
"Aclonica",
"Acme",
"Actor",
"Adamina",
"Advent Pro",
"Aguafina Script",
"Akronim",
"Aladin",
"Aldrich",
"Alef",
"Alegreya",
"Alegreya SC",
"Alegreya Sans",
"Alegreya Sans SC",
"Alex Brush",
"Alfa Slab One",
"Alice",
"Alike",
"Alike Angular",
"Allan",
"Allerta",
"Allerta Stencil",
"Allura",
"Almendra",
"Almendra Display",
"Almendra SC",
"Amarante",
"Amaranth",
"Amatic SC",
"Amatica SC",
"Amethysta",
"Amiko",
"Amiri",
"Amita",
"Anaheim",
"Andada",
"Andika",
"Angkor",
"Annie Use Your Telescope",
"Anonymous Pro",
"Antic",
"Antic Didone",
"Antic Slab",
"Anton",
"Arapey",
"Arbutus",
"Arbutus Slab",
"Architects Daughter",
"Archivo Black",
"Archivo Narrow",
"Aref Ruqaa",
"Arima Madurai",
"Arimo",
"Arizonia",
"Armata",
"Arsenal",
"Artifika",
"Arvo",
"Arya",
"Asap",
"Asar",
"Asset",
"Assistant",
"Astloch",
"Asul",
"Athiti",
"Atma",
"Atomic Age",
"Aubrey",
"Audiowide",
"Autour One",
"Average",
"Average Sans",
"Averia Gruesa Libre",
"Averia Libre",
"Averia Sans Libre",
"Averia Serif Libre",
"Bad Script",
"Bahiana",
"Baloo",
"Baloo Bhai",
"Baloo Bhaina",
"Baloo Chettan",
"Baloo Da",
"Baloo Paaji",
"Baloo Tamma",
"Baloo Thambi",
"Balthazar",
"Bangers",
"Barrio",
"Basic",
"Battambang",
"Baumans",
"Bayon",
"Belgrano",
"Belleza",
"BenchNine",
"Bentham",
"Berkshire Swash",
"Bevan",
"Bigelow Rules",
"Bigshot One",
"Bilbo",
"Bilbo Swash Caps",
"BioRhyme",
"BioRhyme Expanded",
"Biryani",
"Bitter",
"Black Ops One",
"Bokor",
"Bonbon",
"Boogaloo",
"Bowlby One",
"Bowlby One SC",
"Brawler",
"Bree Serif",
"Bubblegum Sans",
"Bubbler One",
"Buda",
"Buenard",
"Bungee",
"Bungee Hairline",
"Bungee Inline",
"Bungee Outline",
"Bungee Shade",
"Butcherman",
"Butterfly Kids",
"Cabin",
"Cabin Condensed",
"Cabin Sketch",
"Caesar Dressing",
"Cagliostro",
"Cairo",
"Calligraffitti",
"Cambay",
"Cambo",
"Candal",
"Cantarell",
"Cantata One",
"Cantora One",
"Capriola",
"Cardo",
"Carme",
"Carrois Gothic",
"Carrois Gothic SC",
"Carter One",
"Catamaran",
"Caudex",
"Caveat",
"Caveat Brush",
"Cedarville Cursive",
"Ceviche One",
"Changa",
"Changa One",
"Chango",
"Chathura",
"Chau Philomene One",
"Chela One",
"Chelsea Market",
"Chenla",
"Cherry Cream Soda",
"Cherry Swash",
"Chewy",
"Chicle",
"Chivo",
"Chonburi",
"Cinzel",
"Cinzel Decorative",
"Clicker Script",
"Coda",
"Coda Caption",
"Codystar",
"Coiny",
"Combo",
"Comfortaa",
"Coming Soon",
"Concert One",
"Condiment",
"Content",
"Contrail One",
"Convergence",
"Cookie",
"Copse",
"Corben",
"Cormorant",
"Cormorant Garamond",
"Cormorant Infant",
"Cormorant SC",
"Cormorant Unicase",
"Cormorant Upright",
"Courgette",
"Cousine",
"Coustard",
"Covered By Your Grace",
"Crafty Girls",
"Creepster",
"Crete Round",
"Crimson Text",
"Croissant One",
"Crushed",
"Cuprum",
"Cutive",
"Cutive Mono",
"Damion",
"Dancing Script",
"Dangrek",
"David Libre",
"Dawning of a New Day",
"Days One",
"Dekko",
"Delius",
"Delius Swash Caps",
"Delius Unicase",
"Della Respira",
"Denk One",
"Devonshire",
"Dhurjati",
"Didact Gothic",
"Diplomata",
"Diplomata SC",
"Domine",
"Donegal One",
"Doppio One",
"Dorsa",
"Dosis",
"Dr Sugiyama",
"Droid Sans",
"Droid Sans Mono",
"Droid Serif",
"Duru Sans",
"Dynalight",
"EB Garamond",
"Eagle Lake",
"Eater",
"Economica",
"Eczar",
"Ek Mukta",
"El Messiri",
"Electrolize",
"Elsie",
"Elsie Swash Caps",
"Emblema One",
"Emilys Candy",
"Engagement",
"Englebert",
"Enriqueta",
"Erica One",
"Esteban",
"Euphoria Script",
"Ewert",
"Exo",
"Exo 2",
"Expletus Sans",
"Fanwood Text",
"Farsan",
"Fascinate",
"Fascinate Inline",
"Faster One",
"Fasthand",
"Fauna One",
"Federant",
"Federo",
"Felipa",
"Fenix",
"Finger Paint",
"Fira Mono",
"Fira Sans",
"Fira Sans Condensed",
"Fira Sans Extra Condensed",
"Fjalla One",
"Fjord One",
"Flamenco",
"Flavors",
"Fondamento",
"Fontdiner Swanky",
"Forum",
"Francois One",
"Frank Ruhl Libre",
"Freckle Face",
"Fredericka the Great",
"Fredoka One",
"Freehand",
"Fresca",
"Frijole",
"Fruktur",
"Fugaz One",
"GFS Didot",
"GFS Neohellenic",
"Gabriela",
"Gafata",
"Galada",
"Galdeano",
"Galindo",
"Gentium Basic",
"Gentium Book Basic",
"Geo",
"Geostar",
"Geostar Fill",
"Germania One",
"Gidugu",
"Gilda Display",
"Give You Glory",
"Glass Antiqua",
"Glegoo",
"Gloria Hallelujah",
"Goblin One",
"Gochi Hand",
"Gorditas",
"Goudy Bookletter 1911",
"Graduate",
"Grand Hotel",
"Gravitas One",
"Great Vibes",
"Griffy",
"Gruppo",
"Gudea",
"Gurajada",
"Habibi",
"Halant",
"Hammersmith One",
"Hanalei",
"Hanalei Fill",
"Handlee",
"Hanuman",
"Happy Monkey",
"Harmattan",
"Headland One",
"Heebo",
"Henny Penny",
"Herr Von Muellerhoff",
"Hind",
"Hind Guntur",
"Hind Madurai",
"Hind Siliguri",
"Hind Vadodara",
"Holtwood One SC",
"Homemade Apple",
"Homenaje",
"IM Fell DW Pica",
"IM Fell DW Pica SC",
"IM Fell Double Pica",
"IM Fell Double Pica SC",
"IM Fell English",
"IM Fell English SC",
"IM Fell French Canon",
"IM Fell French Canon SC",
"IM Fell Great Primer",
"IM Fell Great Primer SC",
"Iceberg",
"Iceland",
"Imprima",
"Inconsolata",
"Inder",
"Indie Flower",
"Inika",
"Inknut Antiqua",
"Irish Grover",
"Istok Web",
"Italiana",
"Italianno",
"Itim",
"Jacques Francois",
"Jacques Francois Shadow",
"Jaldi",
"Jim Nightshade",
"Jockey One",
"Jolly Lodger",
"Jomhuria",
"Josefin Sans",
"Josefin Slab",
"Joti One",
"Judson",
"Julee",
"Julius Sans One",
"Junge",
"Jura",
"Just Another Hand",
"Just Me Again Down Here",
"Kadwa",
"Kalam",
"Kameron",
"Kanit",
"Kantumruy",
"Karla",
"Karma",
"Katibeh",
"Kaushan Script",
"Kavivanar",
"Kavoon",
"Kdam Thmor",
"Keania One",
"Kelly Slab",
"Kenia",
"Khand",
"Khmer",
"Khula",
"Kite One",
"Knewave",
"Kotta One",
"Koulen",
"Kranky",
"Kreon",
"Kristi",
"Krona One",
"Kumar One",
"Kumar One Outline",
"Kurale",
"La Belle Aurore",
"Laila",
"Lakki Reddy",
"Lalezar",
"Lancelot",
"Lateef",
"Lato",
"League Script",
"Leckerli One",
"Ledger",
"Lekton",
"Lemon",
"Lemonada",
"Libre Baskerville",
"Libre Franklin",
"Life Savers",
"Lilita One",
"Lily Script One",
"Limelight",
"Linden Hill",
"Lobster",
"Lobster Two",
"Londrina Outline",
"Londrina Shadow",
"Londrina Sketch",
"Londrina Solid",
"Lora",
"Love Ya Like A Sister",
"Loved by the King",
"Lovers Quarrel",
"Luckiest Guy",
"Lusitana",
"Lustria",
"Macondo",
"Macondo Swash Caps",
"Mada",
"Magra",
"Maiden Orange",
"Maitree",
"Mako",
"Mallanna",
"Mandali",
"Marcellus",
"Marcellus SC",
"Marck Script",
"Margarine",
"Marko One",
"Marmelad",
"Martel",
"Martel Sans",
"Marvel",
"Mate",
"Mate SC",
"Maven Pro",
"McLaren",
"Meddon",
"MedievalSharp",
"Medula One",
"Meera Inimai",
"Megrim",
"Meie Script",
"Merienda",
"Merienda One",
"Merriweather",
"Merriweather Sans",
"Metal",
"Metal Mania",
"Metamorphous",
"Metrophobic",
"Michroma",
"Milonga",
"Miltonian",
"Miltonian Tattoo",
"Miniver",
"Miriam Libre",
"Mirza",
"Miss Fajardose",
"Mitr",
"Modak",
"Modern Antiqua",
"Mogra",
"Molengo",
"Molle",
"Monda",
"Monofett",
"Monoton",
"Monsieur La Doulaise",
"Montaga",
"Montez",
"Montserrat",
"Montserrat Alternates",
"Montserrat Subrayada",
"Moul",
"Moulpali",
"Mountains of Christmas",
"Mouse Memoirs",
"Mr Bedfort",
"Mr Dafoe",
"Mr De Haviland",
"Mrs Saint Delafield",
"Mrs Sheppards",
"Mukta Vaani",
"Muli",
"Mystery Quest",
"NTR",
"Neucha",
"Neuton",
"New Rocker",
"News Cycle",
"Niconne",
"Nixie One",
"Nobile",
"Nokora",
"Norican",
"Nosifer",
"Nothing You Could Do",
"Noticia Text",
"Noto Sans",
"Noto Serif",
"Nova Cut",
"Nova Flat",
"Nova Mono",
"Nova Oval",
"Nova Round",
"Nova Script",
"Nova Slim",
"Nova Square",
"Numans",
"Nunito",
"Nunito Sans",
"Odor Mean Chey",
"Offside",
"Old Standard TT",
"Oldenburg",
"Oleo Script",
"Oleo Script Swash Caps",
"Open Sans",
"Open Sans Condensed",
"Oranienbaum",
"Orbitron",
"Oregano",
"Orienta",
"Original Surfer",
"Oswald",
"Over the Rainbow",
"Overlock",
"Overlock SC",
"Overpass",
"Overpass Mono",
"Ovo",
"Oxygen",
"Oxygen Mono",
"PT Mono",
"PT Sans",
"PT Sans Caption",
"PT Sans Narrow",
"PT Serif",
"PT Serif Caption",
"Pacifico",
"Padauk",
"Palanquin",
"Palanquin Dark",
"Pangolin",
"Paprika",
"Parisienne",
"Passero One",
"Passion One",
"Pathway Gothic One",
"Patrick Hand",
"Patrick Hand SC",
"Pattaya",
"Patua One",
"Pavanam",
"Paytone One",
"Peddana",
"Peralta",
"Permanent Marker",
"Petit Formal Script",
"Petrona",
"Philosopher",
"Piedra",
"Pinyon Script",
"Pirata One",
"Plaster",
"Play",
"Playball",
"Playfair Display",
"Playfair Display SC",
"Podkova",
"Poiret One",
"Poller One",
"Poly",
"Pompiere",
"Pontano Sans",
"Poppins",
"Port Lligat Sans",
"Port Lligat Slab",
"Pragati Narrow",
"Prata",
"Preahvihear",
"Press Start 2P",
"Pridi",
"Princess Sofia",
"Prociono",
"Prompt",
"Prosto One",
"Proza Libre",
"Puritan",
"Purple Purse",
"Quando",
"Quantico",
"Quattrocento",
"Quattrocento Sans",
"Questrial",
"Quicksand",
"Quintessential",
"Qwigley",
"Racing Sans One",
"Radley",
"Rajdhani",
"Rakkas",
"Raleway",
"Raleway Dots",
"Ramabhadra",
"Ramaraja",
"Rambla",
"Rammetto One",
"Ranchers",
"Rancho",
"Ranga",
"Rasa",
"Rationale",
"Ravi Prakash",
"Redressed",
"Reem Kufi",
"Reenie Beanie",
"Revalia",
"Rhodium Libre",
"Ribeye",
"Ribeye Marrow",
"Righteous",
"Risque",
"Roboto",
"Roboto Condensed",
"Roboto Mono",
"Roboto Slab",
"Rochester",
"Rock Salt",
"Rokkitt",
"Romanesco",
"Ropa Sans",
"Rosario",
"Rosarivo",
"Rouge Script",
"Rozha One",
"Rubik",
"Rubik Mono One",
"Ruda",
"Rufina",
"Ruge Boogie",
"Ruluko",
"Rum Raisin",
"Ruslan Display",
"Russo One",
"Ruthie",
"Rye",
"Sacramento",
"Sahitya",
"Sail",
"Salsa",
"Sanchez",
"Sancreek",
"Sansita",
"Sarala",
"Sarina",
"Sarpanch",
"Satisfy",
"Scada",
"Scheherazade",
"Schoolbell",
"Scope One",
"Seaweed Script",
"Secular One",
"Sevillana",
"Seymour One",
"Shadows Into Light",
"Shadows Into Light Two",
"Shanti",
"Share",
"Share Tech",
"Share Tech Mono",
"Shojumaru",
"Short Stack",
"Shrikhand",
"Siemreap",
"Sigmar One",
"Signika",
"Signika Negative",
"Simonetta",
"Sintony",
"Sirin Stencil",
"Six Caps",
"Skranji",
"Slabo 13px",
"Slabo 27px",
"Slackey",
"Smokum",
"Smythe",
"Sniglet",
"Snippet",
"Snowburst One",
"Sofadi One",
"Sofia",
"Sonsie One",
"Sorts Mill Goudy",
"Source Code Pro",
"Source Sans Pro",
"Source Serif Pro",
"Space Mono",
"Special Elite",
"Spicy Rice",
"Spinnaker",
"Spirax",
"Squada One",
"Sree Krushnadevaraya",
"Sriracha",
"Stalemate",
"Stalinist One",
"Stardos Stencil",
"Stint Ultra Condensed",
"Stint Ultra Expanded",
"Stoke",
"Strait",
"Sue Ellen Francisco",
"Suez One",
"Sumana",
"Sunshiney",
"Supermercado One",
"Sura",
"Suranna",
"Suravaram",
"Suwannaphum",
"Swanky and Moo Moo",
"Syncopate",
"Tangerine",
"Taprom",
"Tauri",
"Taviraj",
"Teko",
"Telex",
"Tenali Ramakrishna",
"Tenor Sans",
"Text Me One",
"The Girl Next Door",
"Tienne",
"Tillana",
"Timmana",
"Tinos",
"Titan One",
"Titillium Web",
"Trade Winds",
"Trirong",
"Trocchi",
"Trochut",
"Trykker",
"Tulpen One",
"Ubuntu",
"Ubuntu Condensed",
"Ubuntu Mono",
"Ultra",
"Uncial Antiqua",
"Underdog",
"Unica One",
"UnifrakturCook",
"UnifrakturMaguntia",
"Unkempt",
"Unlock",
"Unna",
"VT323",
"Vampiro One",
"Varela",
"Varela Round",
"Vast Shadow",
"Vesper Libre",
"Vibur",
"Vidaloka",
"Viga",
"Voces",
"Volkhov",
"Vollkorn",
"Voltaire",
"Waiting for the Sunrise",
"Wallpoet",
"Walter Turncoat",
"Warnes",
"Wellfleet",
"Wendy One",
"Wire One",
"Work Sans",
"Yanone Kaffeesatz",
"Yantramanav",
"Yatra One",
"Yellowtail",
"Yeseva One",
"Yesteryear",
"Yrsa",
"Zeyada"}));

b. Display the font_list in spinner1.

c. If value of Shared preferences key font is not empty, get the value from Shared preferences and set it as selection of spinner1.

d. Set String query to the font selected in spinner.

7. In spinner1 onItemSelected event,

a. Set String query to the font selected in spinner.

b. Set shared preferences key font to the position selected in spinner.

c. Set String cert_string1 to following:
Copy code
MIIEqDCCA5CgAwIBAgIJANWFuGx90071MA0GCSqGSIb3DQEBBAUAMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAeFw0wODA0MTUyMzM2NTZaFw0zNTA5MDEyMzM2NTZaMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASAwDQYJKoZIhvcNAQEBBQADggENADCCAQgCggEBANbOLggKv+IxTdGNs8/TGFy0PTP6DHThvbbR24kT9ixcOd9W+EaBPWW+wPPKQmsHxajtWjmQwWfna8mZuSeJS48LIgAZlKkpFeVyxW0qMBujb8X8ETrWy550NaFtI6t9+u7hZeTfHwqNvacKhp1RbE6dBRGWynwMVX8XW8N1+UjFaq6GCJukT4qmpN2afb8sCjUigq0GuMwYXrFVee74bQgLHWGJwPmvmLHC69EH6kWr22ijx4OKXlSIx2xT1AsSHee70w5iD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2XFI1MvcyUTdZPErjQfTbQe3aDQsQcafEQPD+nqActifKZ0Np0IS9L9kR/wbNvyz6ENwPiTrjV2KRkEjH78ZMcUQXg0L3BYHJ3lc69Vs5Ddf9uUGGMYldX3WfMBEmh/9iFBDAaTCK

e. Put following codes in an add source directly block:
Copy code
byte[] byteArray1 = android.util.Base64.decode(cert_string1, android.util.Base64.DEFAULT);

byte[] byteArray2 = android.util.Base64.decode(cert_string2, android.util.Base64.DEFAULT);

List<List<byte[]>> certificates = Arrays.asList(Arrays.asList(byteArray1), Arrays.asList(byteArray2));

androidx.core.provider.FontRequest request = new androidx.core.provider.FontRequest("com.google.android.gms.fonts", "com.google.android.gms",
query,
certificates
);

androidx.core.provider.FontsContractCompat.FontRequestCallback callback = new androidx.core.provider.FontsContractCompat.FontRequestCallback() {
@Override
public void onTypefaceRetrieved(Typeface typeface) {
textview1.setTypeface(typeface);
textview2.setTypeface(typeface);
textview3.setTypeface(typeface);
}
 @Override
public void onTypefaceRequestFailed(int reason) {
showMessage("Failed to load fonts " +String.valueOf(reason));
}
};


Handler mHandler = null;
HandlerThread handlerThread = new HandlerThread("fonts"); handlerThread.start();
mHandler = new Handler(handlerThread.getLooper());


androidx.core.provider.FontsContractCompat.requestFont(MainActivity.this, request, callback, mHandler);


8. Save and run the project

Comments

  1. Kindly make a video to create permission injector for sketchware.

    ReplyDelete
  2. I have a lot of TextViews, something like 100+ views , how to set downloaded font up to all of them by one step ?

    ReplyDelete
  3. How to get users information ?

    ReplyDelete

Post a Comment

Popular posts from this blog

Create Music Player app in Sketchware

A Flash Light App in Sketchware

In Sketchware: How to create a calculator for any simple formula?

Firebase auth in Sketchware for Login Activity

Simple car racing android game in Sketchware