{"id":19878531,"url":"https://github.com/lisawray/fontbinding","last_synced_at":"2025-04-05T07:01:21.450Z","repository":{"id":93256867,"uuid":"44621984","full_name":"lisawray/fontbinding","owner":"lisawray","description":"A full example of custom fonts in XML using data binding and including font caching.","archived":false,"fork":false,"pushed_at":"2017-09-07T20:19:01.000Z","size":2686,"stargazers_count":770,"open_issues_count":0,"forks_count":59,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-03-29T06:01:30.979Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","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/lisawray.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"License.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-10-20T17:09:15.000Z","updated_at":"2024-07-19T02:53:10.000Z","dependencies_parsed_at":"2023-03-13T17:19:32.145Z","dependency_job_id":null,"html_url":"https://github.com/lisawray/fontbinding","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lisawray%2Ffontbinding","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lisawray%2Ffontbinding/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lisawray%2Ffontbinding/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lisawray%2Ffontbinding/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lisawray","download_url":"https://codeload.github.com/lisawray/fontbinding/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247299828,"owners_count":20916190,"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":[],"created_at":"2024-11-12T17:05:52.208Z","updated_at":"2025-04-05T07:01:21.392Z","avatar_url":"https://github.com/lisawray.png","language":"Java","funding_links":[],"categories":["Libs"],"sub_categories":["\u003cA NAME=\"Font\"\u003e\u003c/A\u003eFont"],"readme":"## [Deprecated]\nFonts in XML are now supported by the Android support library as of 26.0, including in styles and themes. I recommend using the support library and IDE integration for all your modern font needs! \nhttps://developer.android.com/guide/topics/ui/look-and-feel/fonts-in-xml.html#using-support-lib\n\n# fontbinding\nEasy custom fonts in XML using [data binding](http://developer.android.com/tools/data-binding/guide.html).\n\nNo setup required, no extra Java code, and no custom views.\n\n```xml\n\u003cTextView\n    android:layout_width=\"wrap_content\"\n    android:layout_height=\"wrap_content\"\n    app:font=\"@{`alegreya`}\"\n    /\u003e\n```\n\u003cimg src=\"https://raw.githubusercontent.com/lisawray/fontbinding/master/screenshot_land.png\" alt=\"Drawing\" height=\"400px\"/\u003e\n\n\nThis example includes a simple font cache that automatically loads names from your `assets/fonts` folder and lazy-loads typefaces.  Just drag and drop font files and use them in XML by their normal or lowercase filenames (e.g. \"Roboto-Italic\" or \"roboto-italic\" for `Roboto-Italic.otf`). That's it!\n\n\n### Data Binding\nMake sure to use the data binding framework to inflate your layout. \n```java\npublic class MainActivity extends AppCompatActivity {\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        DataBindingUtil.setContentView(this, R.layout.activity_main);\n    }\n}\n```\n\nMore about data binding: http://developer.android.com/tools/data-binding/guide.html\n\n### Custom Naming\nYou can set custom names for your fonts, but you don't have to.\n```java\nFontCache.getInstance().addFont(\"alegreya\", \"Alegreya-Regular.ttf\");\n```\n\n## Note: \nIt's not currently possible to define custom attributes in styles using data binding. If you require this, check out [Calligraphy](https://github.com/chrisjenx/Calligraphy) by Chris Jenx.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flisawray%2Ffontbinding","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flisawray%2Ffontbinding","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flisawray%2Ffontbinding/lists"}