All Projects → MarcinOrlowski → Fonty

MarcinOrlowski / Fonty

Licence: apache-2.0
Android library allowing you to easily change the typeface of your UI elements.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Fonty

Open Huninn Font
「jf open 粉圓」是基於 Kosugi Maru 改作, 由 justfont 設計師針對台灣日常應用加以優化的開源字型。 歡迎大家自由應用、自由優化、自由改做!
Stars: ✭ 665 (+1650%)
Mutual labels:  fonts, typeface
Awesome Typography
✏︎ Curated list about digital typography 🔥
Stars: ✭ 947 (+2392.11%)
Mutual labels:  fonts, typeface
Urbanist
Urbanist is a low-contrast, geometric sans-serif inspired by Modernist design and typography.
Stars: ✭ 374 (+884.21%)
Mutual labels:  fonts, typeface
Open Sauce Fonts
Open Sauce Fonts is a font super family that I developed for Creative Sauce's internal type system. It is a compact typeface that is optimised for better viewing small text on screen and print. Open Sauce fonts (Sans, One and Two) are under the SIL Open Font License and is going to be actively developed, improved and tested.
Stars: ✭ 189 (+397.37%)
Mutual labels:  fonts, typeface
icursive-nerd-font
Nerd Fonts with Cursive Italic Styles
Stars: ✭ 172 (+352.63%)
Mutual labels:  fonts, typeface
Sprat-type
Display typeface
Stars: ✭ 58 (+52.63%)
Mutual labels:  fonts, typeface
MultiFontViewKotlin-Android
MultiFontViewKotlin library can be used to select custom fonts for the view dynamically in your XML
Stars: ✭ 13 (-65.79%)
Mutual labels:  fonts, typeface
Iosevka-Mayukai
Font based on Iosevka Custom Build, with combination from Iosevka SS04 Menlo, SS07 Monaco, SS09 Source Code Pro, SS12 Ubuntu Mono, SS14 Jetbrains Mono, Hack Style, and some Nerd Font Patching.
Stars: ✭ 149 (+292.11%)
Mutual labels:  fonts, typeface
Slice
An open-source, cross-platform GUI app to generate custom font design spaces from variable fonts
Stars: ✭ 62 (+63.16%)
Mutual labels:  fonts, typeface
Mohave-Typefaces
Mohave is a titling display typeface, built in mind with modulated form.
Stars: ✭ 48 (+26.32%)
Mutual labels:  fonts, typeface
San Francisco Family
All the fonts in San Francisco family font, developed by Apple. Including new SF Camera font from iOS 13!
Stars: ✭ 141 (+271.05%)
Mutual labels:  fonts, typeface
Inriafonts
Fonts and UFO Masters of Inria Serif and Inria Sans Typeface
Stars: ✭ 292 (+668.42%)
Mutual labels:  fonts, typeface
Work Sans
A grotesque sans.
Stars: ✭ 1,319 (+3371.05%)
Mutual labels:  fonts, typeface
ark-pixel-font
Open source Pan-CJK pixel font / 开源的泛中日韩像素字体
Stars: ✭ 1,767 (+4550%)
Mutual labels:  fonts, typeface
Fonts
A curation of fonts from all over the world.
Stars: ✭ 144 (+278.95%)
Mutual labels:  fonts, typeface
font-wonder-unit
Free and open source sans-serif font, brought to you by Wonder Unit.
Stars: ✭ 57 (+50%)
Mutual labels:  fonts, typeface
Codeface
Typefaces for source code beautification
Stars: ✭ 5,612 (+14668.42%)
Mutual labels:  fonts, typeface
Firasystemfontreplacement
Modified version of the Fira Sans fonts to replace the default system font on macOS
Stars: ✭ 730 (+1821.05%)
Mutual labels:  fonts
React Native Deploy Checklist
Compilado de problemas do React Native em relação ao deploy e suas soluções
Stars: ✭ 26 (-31.58%)
Mutual labels:  fonts
Sarasa Gothic
Sarasa Gothic / 更纱黑体 / 更紗黑體 / 更紗ゴシック / 사라사 고딕
Stars: ✭ 6,771 (+17718.42%)
Mutual labels:  typeface

Fonty

Repository License

Curent Release jitpack Downloads Android Arsenal

Fonty is simple Android library allowing you to easily change the typeface of your UI elements. Contrary to other libraries of that type, Fonty is designed with the assumption that if you want to change the font for your app, then you change it globally per whole application, to achieve consistency across your Fragments or Activities. If you want different fonts per each widget, then Fonty is most likely not what you need.

Using Fonty requires no change to your layout files and all you need to do is to initialize the library and specify what typeface you want to be used as normal, italic or boldfaced ones.

Screenshot

Download demo application APK from releases section. Source code in project's app/ module.

Features

  • Does not require any changes to your layout XML files,
  • Fast and lightweight,
  • No extra dependencies,
  • Simple API,
  • Supports the following UI elements and all their subclasses:
    • TextInputLayout (see notes below!),
    • Navigation Drawer (including drawer's header view),
    • Toolbar
    • TextView (incl. Checkbox, EditText, CheckedTextView, Chronometer, DigitalClock, TextClock, ...),
    • Button (incl. Switch, RadioButton, CompoundButton, ...),
  • Can be used in libraries.

Installation

Edit your master gradle.build file and add maven { url 'https://jitpack.io' } to your current repositories block content (if you use other jitpack hosted libraries, then this step can be skipped):

allprojects {
  repositories {
    maven { url 'https://jitpack.io' }
    }
}

Next, edit your module's build.gradle and the following dependency:

implements 'com.github.MarcinOrlowski:fonty:<VERSION>'

For right value of <VERSION> consult release section or see jitpack page.

Configuration

Put your TrueType (*.ttf) font files into module's assets/fonts folder (<MODULE>/src/main/assets/fonts folder, where <MODULE> usually equals to app).

Then add the following lines to your custom Application's class' onCreate() method (if you do not use own Application subclass, see demo app for how to make one and how it should be referenced form your AndroidManifest.xml file):

Fonty
    .context(this)
    .normalTypeface("Xenotron.ttf")
    .italicTypeface("Carramba.ttf")
    .boldTypeface("XPED.ttf")
    .build();

The above sets up Xenotron.ttf to be used whenever NORMAL font should be rendered and XPED.ttf to be used if your UI elements sets android:textStyle="bold" attribute and Carramba.ttf for android:textStyle="italic".

If you prefer to have font files stored elsewhere than in assets' fonts/ subfolder use fontDir() in your builder chain:

Fonty
    .context(this)
    .fontDir("my-fonts")
    .normalTypeface("Xenotron.ttf")
    .italicTypeface("Carramba.ttf")
    .boldTypeface("XPED.ttf")
    .build();

and put your font files into <MODULE>/src/main/assets/my-fonts folder.

Font substitution

This sets up font substitution but we yet need to apply fonts to widgets.

For Activity add this as last entry in your onCreate():

Fonty.setFonts(this);

Same for Fragments, add the following to your onCreateView():

 Fonty.setfonts(view);

where view is the View is what you just inflated.

Using it with RecyclerView is also pretty simple. Edit your onCreateViewHolder() and add:

 Fonty.setFonts(view);

where view stands for first argument passed to your onCreateViewHolder() method.

If you are using Android Data Binding library, then you just need to call:

 Fonty.setFonts((ViewGroup)binding.getRoot());

Layout files

Once Fonty is properly initialized and applied, all supported widgets will automatically be convinced to use fonts of your choice. Font specified with setRegularFont() is used as default, if widget sets android:textStyle="bold" then font set with boldTypeface() is applied and if android:textStyle="italic" is used then italicTypeface() applies.

    <TextView
        android:text="This will use normal typeface"
        ... />

    <EditText
        android:text="This will use boldfaced typeface"
        android:textStyle="bold"
        ... />

Toolbars

Unfortunately changing Toolbar/ActionBar title and subtitle fonts cannot be handled automatically by Fonty in some cases. This is due to Toolbar's internals as it simply have not instance of TextView created unless title or subtitle is set (even to empty string), so there's nothing Fonty can manipulate in advance.

The simples solution is to set toolbar title (and/or subtitle) in onCreate() causing EditText creation prior calling Fonty.setFonts():

 @Override
 protected void onCreate(Bundle state) {
     super.onCreate(bundle);
     setContentView(...);
     
     Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
     toolbar.setTitle(...);
     toolbar.setSubtitle(...);
     
     setSupportActionBar(toolbar);
     
     ...
     
     Fonty.setFonts(this);
 }

Alternatively, you can edit/create base activity class for your app with the following code:

 private Toolbar mActivityActionBarToolbar;

 @Override
 public void setSupportActionBar(@Nullable Toolbar toolbar) {
    super.setSupportActionBar(toolbar);
    mActivityActionBarToolbar = toolbar;
 }

 @Override
 public void setTitle(CharSequence title) {
    ActionBar ab = getSupportActionBar();
    if (ab != null) {
       ab.setTitle(title);
       Fonty.setFonts(mActivityActionBarToolbar);
    }
 }

 public void setSubtitle(CharSequence subtitle) {
    ActionBar ab = getSupportActionBar();
    if (ab != null) {
       ab.setSubtitle(subtitle);
       Fonty.setFonts(mActivityActionBarToolbar);
    }
}

TextInputLayout

If you use TextInputLayout and its error message feature (text shown below the EditText widget), and you want error text typeface to be changed by Fonty as well, then you must either set app:errorEnabled="true" in the XML layout or call setErrorEnabled(true) on the object prior calling Fonty.setFonts(). This is because of how TextInputLayout works internally.

NOTE: Typeface used for hints and error messages will be derrived from one set for EditText.

Limitations

Due to limitations of the Android API, once fonts are replaced by Fonty, former style information (like bold, normal) is lost, so all calls to i.e. isBold() or isItalic() will always return false. However because this information is gone, and Fonty relies on it, calling Fonty.setFonts() twice on the same layout elements will end up with wrong results (mostly all widgets will be using normal typeface). At the moment there's no workaround for this except for not calling setFonts() more than once. Hopefuly IRL scenarios this should not affect many.

Contributing

Please report any issue spotted using GitHub's project tracker.

If you'd like to contribute to the this project, please open new ticket before doing any work. This will help us save your time in case I'd not be able to accept such changes. But if all is good and clear then follow common routine:

  • fork the project
  • create new branch
  • do your changes
  • send pull request

License

  • Written and copyrighted ©2013-2020 by Marcin Orlowski <mail (#) marcinorlowski (.) com>
  • Fonty is open-sourced library licensed under the Apache 2.0 license
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].