As of API level 26, it has been possible to include fonts in a project as XML resources in the res directory. This feature has simplified the task of using nondefault fonts in an application as well as bringing the process into line with other resource management.
Adding XML fonts is remarkably simple, as the following exercise demonstrates:
- Right-click on the res directory and select New | Android resource directory.
- Select font from the Resource type drop-down and click on OK.
- Right-click on the newly created font folder and select Show in Explorer.
- Rename your font files so that they only contain permissible characters. For example, times_new_roman.ttf not TimesNewRoman.ttf.
- Place your selected fonts in the font directory.