{"id":15529105,"url":"https://github.com/marcinorlowski/fonty","last_synced_at":"2025-04-23T12:35:31.178Z","repository":{"id":101431490,"uuid":"84652339","full_name":"MarcinOrlowski/Fonty","owner":"MarcinOrlowski","description":"Android library allowing you to easily change the typeface   of your UI elements.","archived":false,"fork":false,"pushed_at":"2022-11-20T19:45:08.000Z","size":862,"stargazers_count":43,"open_issues_count":0,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-29T23:41:18.188Z","etag":null,"topics":["android","androidx","fonts","typeface"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MarcinOrlowski.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-03-11T13:36:06.000Z","updated_at":"2024-05-17T12:34:16.000Z","dependencies_parsed_at":"2023-07-01T11:31:01.807Z","dependency_job_id":null,"html_url":"https://github.com/MarcinOrlowski/Fonty","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcinOrlowski%2FFonty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcinOrlowski%2FFonty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcinOrlowski%2FFonty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcinOrlowski%2FFonty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MarcinOrlowski","download_url":"https://codeload.github.com/MarcinOrlowski/Fonty/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250435972,"owners_count":21430381,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","androidx","fonts","typeface"],"created_at":"2024-10-02T11:16:21.815Z","updated_at":"2025-04-23T12:35:31.156Z","avatar_url":"https://github.com/MarcinOrlowski.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"Fonty\n=====\n\n [![Repository](https://img.shields.io/badge/repo-GitHub-blue.svg)](https://github.com/MarcinOrlowski/fonty)\n ![License](https://img.shields.io/github/license/MarcinOrlowski/fonty.svg)\n\n [![Curent Release](https://jitpack.io/v/MarcinOrlowski/fonty.svg)](https://jitpack.io/#MarcinOrlowski/fonty)\n ![jitpack Downloads](https://jitpack.io/v/MarcinOrlowski/Fonty/month.svg)\n [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Fonty-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/5489)\n\n\n `Fonty` is simple Android library allowing you to easily change the typeface of your UI elements.\n Contrary to other libraries of that type, `Fonty` is designed with the assumption that if you want\n to change the font for your app, then you change it **globally** per whole application, to achieve\n consistency across your Fragments or Activities. If you want different fonts per each widget, then\n `Fonty` is most likely not what you need.\n\n Using `Fonty` requires **no change** to your layout files and all you need to do is to initialize\n the library and specify what typeface you want to be used as normal, italic or boldfaced ones.\n\n ![Screenshot](img/shot.png)\n\n Download demo application APK from [releases section](https://github.com/MarcinOrlowski/fonty/releases).\n Source code in project's [app/](https://github.com/MarcinOrlowski/fonty/tree/master/app/src/main) module.\n\nFeatures\n========\n\n - Does not require any changes to your layout XML files,\n - Fast and lightweight,\n - No extra dependencies,\n - Simple API,\n - Supports the following UI elements and all their subclasses:\n   * `TextInputLayout` (see [notes](#textinputlayout) below!),\n   * `Navigation Drawer` (including drawer's header view),\n   * `Toolbar`\n   * `TextView` (incl. `Checkbox`, `EditText`, `CheckedTextView`, `Chronometer`, `DigitalClock`, `TextClock`, ...),\n   * `Button` (incl. `Switch`, `RadioButton`, `CompoundButton`, ...),\n - Can be used in libraries.\n\nInstallation\n============\n\n Edit your master `gradle.build` file and **add** `maven { url 'https://jitpack.io' }` to your current\n `repositories` block content (if you use other jitpack hosted libraries, then this step can be skipped):\n\n    allprojects {\n      repositories {\n        maven { url 'https://jitpack.io' }\n        }\n    }\n\n Next, edit your **module**'s `build.gradle` and the following dependency:\n\n    implements 'com.github.MarcinOrlowski:fonty:\u003cVERSION\u003e'\n\n For right value of `\u003cVERSION\u003e` consult [release section](https://github.com/MarcinOrlowski/fonty/releases)\n or see [jitpack page](https://jitpack.io/#MarcinOrlowski/fonty).\n\nConfiguration\n=============\n\n Put your [TrueType](https://en.wikipedia.org/wiki/TrueType) (`*.ttf`) font files into module's\n `assets/fonts` folder (`\u003cMODULE\u003e/src/main/assets/fonts` folder, where `\u003cMODULE\u003e` usually equals\n to `app`).\n\n Then add the following lines to your custom Application's class' `onCreate()`\n method (if you do not use own `Application` subclass, see demo app for how\n to make one and how it should be referenced form your `AndroidManifest.xml` file):\n\n    Fonty\n        .context(this)\n        .normalTypeface(\"Xenotron.ttf\")\n        .italicTypeface(\"Carramba.ttf\")\n        .boldTypeface(\"XPED.ttf\")\n        .build();\n\n The above sets up `Xenotron.ttf` to be used whenever NORMAL font should be rendered\n and `XPED.ttf` to be used if your UI elements sets `android:textStyle=\"bold\"` attribute and\n `Carramba.ttf` for `android:textStyle=\"italic\"`.\n\n If you prefer to have font files stored elsewhere than in assets' `fonts/` subfolder use `fontDir()`\n in your builder chain:\n\n    Fonty\n        .context(this)\n        .fontDir(\"my-fonts\")\n        .normalTypeface(\"Xenotron.ttf\")\n        .italicTypeface(\"Carramba.ttf\")\n        .boldTypeface(\"XPED.ttf\")\n        .build();\n\n and put your font files into `\u003cMODULE\u003e/src/main/assets/my-fonts` folder.\n\nFont substitution\n=================\n\n This sets up font substitution but we yet need to apply fonts to widgets.\n\n For `Activity` add this as last entry in your `onCreate()`:\n\n    Fonty.setFonts(this);\n\n Same for `Fragments`, add the following to your `onCreateView()`:\n\n     Fonty.setfonts(view);\n\n where `view` is the `View` is what you just inflated.\n\n Using it with `RecyclerView` is also pretty simple. Edit your `onCreateViewHolder()` and\n add:\n\n     Fonty.setFonts(view);\n\n where `view` stands for first argument passed to your `onCreateViewHolder()` method.\n\n If you are using [Android Data Binding library](https://developer.android.com/topic/libraries/data-binding/index.html),\n then you just need to call:\n\n     Fonty.setFonts((ViewGroup)binding.getRoot());\n\n\nLayout files\n============\n\n Once `Fonty` is properly initialized and applied, all supported widgets will automatically\n be convinced to use fonts of your choice. Font specified with `setRegularFont()` is used\n as default, if widget sets `android:textStyle=\"bold\"` then font set with `boldTypeface()`\n is applied and if `android:textStyle=\"italic\"` is used then `italicTypeface()` applies.\n\n\n        \u003cTextView\n            android:text=\"This will use normal typeface\"\n            ... /\u003e\n\n        \u003cEditText\n            android:text=\"This will use boldfaced typeface\"\n            android:textStyle=\"bold\"\n            ... /\u003e\n\n\nToolbars\n========\n\n Unfortunately changing `Toolbar`/`ActionBar` title and subtitle fonts cannot be handled automatically\n by `Fonty` in some cases. This is due to `Toolbar`'s internals as it simply have not instance of `TextView`\n created unless title or subtitle is set (even to empty string), so there's nothing `Fonty` can manipulate\n in advance.\n\n The simplest solution is to set toolbar title (and/or subtitle) in `onCreate()` causing `EditText`\n creation prior calling `Fonty.setFonts()`:\n\n     @Override\n     protected void onCreate(Bundle state) {\n         super.onCreate(bundle);\n         setContentView(...);\n\n         Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);\n         toolbar.setTitle(...);\n         toolbar.setSubtitle(...);\n\n         setSupportActionBar(toolbar);\n\n         ...\n\n         Fonty.setFonts(this);\n     }\n\n Alternatively, you can edit/create base activity class for your app with the following code:\n\n     private Toolbar mActivityActionBarToolbar;\n\n     @Override\n     public void setSupportActionBar(@Nullable Toolbar toolbar) {\n        super.setSupportActionBar(toolbar);\n        mActivityActionBarToolbar = toolbar;\n     }\n\n     @Override\n     public void setTitle(CharSequence title) {\n        final var ab = getSupportActionBar();\n        if (ab != null) {\n           ab.setTitle(title);\n           Fonty.setFonts(mActivityActionBarToolbar);\n        }\n     }\n\n     public void setSubtitle(CharSequence subtitle) {\n        final var ab = getSupportActionBar();\n        if (ab != null) {\n           ab.setSubtitle(subtitle);\n           Fonty.setFonts(mActivityActionBarToolbar);\n        }\n    }\n\n\nTextInputLayout\n===============\n\n If you use `TextInputLayout` and its error message feature (text shown below the `EditText` widget),\n and you want error text typeface to be changed by `Fonty` as well, then you must either set\n `app:errorEnabled=\"true\"` in the XML layout or call `setErrorEnabled(true)` on the object\n **prior** calling `Fonty.setFonts()`. This is because of how `TextInputLayout` works internally.\n\n **NOTE:** Typeface used for hints and error messages will be derrived from one set for `EditText`.\n\n\nLimitations\n===========\n\n Due to limitations of the Android API, once fonts are replaced by `Fonty`, former style information\n (like `bold`, `normal`) is lost, so all calls to i.e. `isBold()` or `isItalic()` will always\n return `false`. However because this information is gone, and `Fonty` relies on it, calling\n `Fonty.setFonts()` twice on the same layout elements will end up with wrong results (mostly\n all widgets will be using normal typeface). At the moment there's no workaround for this except\n for not calling `setFonts()` more than once. Hopefully IRL scenarios this should not affect many.\n\n\nContributing\n============\n\n Please report any issue spotted using [GitHub's project tracker](https://github.com/MarcinOrlowski/fonty/issues).\n\n If you'd like to contribute to the this project, please [open new ticket](https://github.com/MarcinOrlowski/fonty/issues)\n **before doing any work**. This will help us save your time in case I'd not be able to accept such\n changes. But if all is good and clear then follow common routine:\n\n  * fork the project\n  * create new branch\n  * do your changes\n  * send pull request\n\nLicense\n=======\n\n  * Written and copyrighted \u0026copy;2013-2022 by [Marcin Orlowski](https://marcinOrlowski.com/)\n  * `Fonty` is open-sourced library licensed under the Apache 2.0 license\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcinorlowski%2Ffonty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcinorlowski%2Ffonty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcinorlowski%2Ffonty/lists"}