Giter VIP home page Giter VIP logo

typefacecustomtype's Introduction

CustomType

CustomType allows you to easily use different typfaces in your app. It was created to initially work with the Roboto family of fonts, but has since been adapted to allow you to use any typeface that you would like.

CustomType maintains static Typeface objects to avoid potential memory leaks that can occur. Hence, it is the ideal manner of using any custom typeface in your app, regardless of whether or not it belongs to the Roboto family.

CustomType can be used in two ways:

  1. Via XML: =============== If you would like to mention your Typeface in the XML file itself, you would need to use the in.raveesh.customtype.TextView object in your XML files in place of android.widget.TextView. After that, using a custom typeface in a TextView is as simple as follows (note the custom implementation of a TextView)

    <in.raveesh.customtype.TextView android:text="@string/lorem_ipsum_short" android:layout_width="wrap_content" android:layout_height="wrap_content" app:typeface="fonts/RobotoCondensed/Light.ttf" android:textSize="@dimen/typesize_headline" android:textColor="@color/text_primary_light" android:layout_marginBottom="@dimen/activity_vertical_margin"/>

What you're looking to do is set app:typeface to the path to the typeface file inside the assets folder.

  1. Via JAVA: ============== The FontManager.getTypeface() method returns a typeface object that you can apply to any view that supports the setTypeface() method. You do not need to use the bundled custom TextView or EditText for this. Example code

    tv.setTypeface(CustomType.getTypeface(this,"folder/typeface.ttf"));

Do note: the font file must be present within your projects assets folder.

Additional Resources

The library comes with additional resources, including the text sizes in line with the Material Design spec and the default text colors for the light and dark themes.

How to use the library

Add the following line to your build.gradle dependencies

compile 'in.raveesh:customtype:1.0.0'

Apps Using Customtype

Is your app using Customtype? Submit a pull request to list it here, or tweet out to me at @raveeshbhalla

typefacecustomtype's People

Contributors

raveeshbhalla avatar sagar-viradiya avatar

Watchers

James Cloos avatar Ranjan Kumar Singh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.