Typography

Additional

Language
Java
Version
N/A
Created
Aug 23, 2015
Updated
Feb 26, 2016
Owner
Workarounds (workarounds)
Contributors
madki
manidesto
2
Activity
Badge
Generate
Download
ZIP

Advertising

Build Status

Add to your project

Add this line to your dependencies in build.gradle

compile 'in.workarounds.typography:typography:0.0.8'

Using the views

There are two important attributes that define a font

  • font_name Ex: 'Roboto', 'Helvetica'
  • font_variant Ex: 'Bold', 'Condensed'

So if you want to add a TextView with the font 'Roboto-Condensed', you add the following to your layout file

<in.workarounds.typography.TextView
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:font_name="Roboto"
    app:font_variant="Condensed"
    android:textSize="16sp"
/>

You can utilize the following views to improve the typography in your app: in.workarounds.typography.

  • TextView
  • EditText
  • AutoCompleteTextView
  • Button
  • Checkbox
  • RadioButton
  • ToggleButton

Font Files

Place your fonts in assets/fonts/ folder and use the following naming convention

`<font_name>-<font_variant>.<ext>`

<ext> can be ttf or otf. Both font_name and font_variant attribute are case insensitive.

Note: If you want to use Roboto.ttf, do not use the font_variant attribute.

FontLoader

FontLoader is the class responsible for caching the Typefaces and setting the fonts to the Views.

Set the default font name and font variant in your Application class

FontLoader.setDefaultFont(fontName, fontVariant)

Enable detailed logs(errors are always logged)

FontLoader.setLoggingEnabled(true)

To get this project into your build

Information:
  • It may be not the official build, but possibility to simplify access to some artifacts.
  • The project may be also unavailable on JitPack.io. If it is the case, you can open a corresponding issue in the project to resolve this problem.

Step 1. Select your build system:

Step 2. Add the specific repository to your build file:


Step 3. Add the dependency in your build file (do not forget to specify the correct qualifier, usually 'aar'):


That's it!

Information:
  • StackOverflow service is used to find questions and answers.
  • Results are close to the actual, but not completely accurate or exact. It depends on the uniqueness of the project name.
  • You can also ask a question, but remember how to do it correctly.

Loading...

Wait a little bit, it could take some time.