A lightweight Android library for use iconic fonts.

Overview

Print

Android Arsenal

A lightweight Android library for use iconic fonts.

image

Get it on Google Play

Download

Gradle:

compile 'com.github.johnkil.print:print:1.3.1'

Maven:

<dependency>
    <groupId>com.github.johnkil.print</groupId>
    <artifactId>print</artifactId>
    <version>1.3.1</version>
    <type>aar</type>
</dependency>

Getting started

Add fonts

Add your custom iconic fonts to assets/.

Setup default font

Define your default iconic font using PrintConfig in Application.onCreate() method. This font will be used in cases when the value of a font is not specified.

public class MyApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();                
        PrintConfig.initDefault(getAssets(), "fonts/iconic-font.ttf");
    }

}

Note: The definition of the default font is not necessary, in this case, you must specify the value of the font all the time.

Usage

PrintDrawable

If you need an icon in ImageView or in ActionBar, then you should use PrintDrawable. To create the drawable using PrintDrawable.Builder.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    // Set an icon in the ActionBar
    menu.findItem(R.id.action_info).setIcon(
            new PrintDrawable.Builder(context)
                    .iconTextRes(R.string.ic_info)
                    .iconColorRes(R.color.ab_icon_color)
                    .iconSizeRes(R.dimen.ab_icon_size)
                    .build()
    );
    return true;
}

Custom views

Use PrintView as single icon in your layout.

<com.github.johnkil.print.PrintView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:print_iconText="@string/ic_android"
        app:print_iconColor="@color/icon_color"
        app:print_iconSize="@dimen/icon_size"/>

Or use PrintButton to create a button with an icon. Using a view similar to PrintView.

<com.github.johnkil.print.PrintButton
        ... />

XML Attributes

Attribute Name Related Method
print_iconText setIconTextRes(int resId)
setIconText(CharSequence text)
print_iconCode setIconCodeRes(int resId)
setIconCode(int code)
print_iconColor setIconColorRes(int resId)
setIconColor(int color)
setIconColor(ColorStateList colors)
print_iconSize setIconSizeRes(int resId)
setIconSizeDp(float size)
setIconSize(int unit, float size)
print_iconFont setIconFont(String path)
setIconFont(Typeface font)

Links

License

Copyright 2014 Evgeny Shishkin

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Comments
  • UTF-16 Issue

    UTF-16 Issue

    I get "input is not valid Modified UTF-8: illegal start byte 0xf0" exception when i'm trying to use icon like 📞 I found similar problems it seems like parser issue. I have the solution for this can I make a pull request with changes?

    bug 
    opened by bmelnychuk 5
  • RuntimeException: Font asset not found fonts/iconic-font.ttf

    RuntimeException: Font asset not found fonts/iconic-font.ttf

    I'm the developer of this project: https://github.com/BenoitDuffez/AndroidCupsPrint

    I received a crash report from your code:

    Fatal Exception: java.lang.RuntimeException: Unable to create application com.android.tools.fd.runtime.BootstrapApplication: java.lang.RuntimeException: Font asset not found fonts/iconic-font.ttf
           at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4710)
           at android.app.ActivityThread.-wrap1(ActivityThread.java)
           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
           at android.os.Handler.dispatchMessage(Handler.java:102)
           at android.os.Looper.loop(Looper.java:148)
           at android.app.ActivityThread.main(ActivityThread.java:5417)
           at java.lang.reflect.Method.invoke(Method.java)
           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
    Caused by java.lang.RuntimeException: Font asset not found fonts/iconic-font.ttf
           at android.graphics.Typeface.createFromAsset(Typeface.java:190)
           at com.github.johnkil.print.TypefaceManager.load(TypefaceManager.java:48)
           at com.github.johnkil.print.PrintConfig.initDefault(PrintConfig.java:35)
           at io.github.benoitduffez.cupsprint.CupsPrintApp.onCreate(CupsPrintApp.java:45)
           at com.android.tools.fd.runtime.BootstrapApplication.onCreate(BootstrapApplication.java:370)
           at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013)
           at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4707)
           at android.app.ActivityThread.-wrap1(ActivityThread.java)
           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
           at android.os.Handler.dispatchMessage(Handler.java:102)
           at android.os.Looper.loop(Looper.java:148)
           at android.app.ActivityThread.main(ActivityThread.java:5417)
           at java.lang.reflect.Method.invoke(Method.java)
           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
    

    I thought you might be interested in knowing that.

    opened by BenoitDuffez 4
  • how dynamic string can be use to generate image drawable.

    how dynamic string can be use to generate image drawable.

    CharSequence charseq = ""; holder.image.setImageDrawable(new PrintDrawable.Builder(mActivity.getApplicationContext()) .iconText(charseq) .iconColorRes(R.color.bl_accent) .iconSizeRes(R.dimen.big_margin) .build());

    in above code, if i am trying to set char sequence dynamically in icontext, it does not generating icon but only text, only work if i define icon in string xml as resource. how can put icon code like this to work. please help. thanks.

    opened by satishkadyan 4
  • Issue with font icon alignment in action bar

    Issue with font icon alignment in action bar

    Hi johnkil, Thank you very much for such a amazing library. I used your library to make font icons in action bar and i ended up like this (Used font awesome ttf)

    action_bar

    I need my icons to be aligned in parallel with the setting icon which is on the right corner like an usual action bar.

    Please help me in achieving this.

    bug 
    opened by SanthoshDhandapani 4
  • OutOfMemoryError during build

    OutOfMemoryError during build

    Just by adding the dependency to build.gradle, I'm getting this during :app:dexDebug:

    [...]
    :app:packageAllDebugClassesForMultiDex
    :app:shrinkDebugMultiDexComponents
    :app:createDebugMainDexClassList
    :app:dexDebug
    AGPBI: {"kind":"SIMPLE","text":"UNEXPECTED TOP-LEVEL ERROR:","position":{},"original":"UNEXPECTED TOP-LEVEL ERROR:"}
    AGPBI: {"kind":"SIMPLE","text":"java.lang.OutOfMemoryError: Java heap space","position":{},"original":"java.lang.OutOfMemoryError: Java heap space"}
    AGPBI: {"kind":"SIMPLE","text":"\tat java.util.BitSet.initWords(BitSet.java:164)","position":{},"original":"\tat java.util.BitSet.initWords(BitSet.java:164)"}
    AGPBI: {"kind":"SIMPLE","text":"\tat java.util.BitSet.\u003cinit\u003e(BitSet.java:159)","position":{},"original":"\tat java.util.BitSet.\u003cinit\u003e(BitSet.java:159)"}
    AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.ssa.SsaMethod.bitSetFromLabelList(SsaMethod.java:137)","position":{},"original":"\tat com.android.dx.ssa.SsaMethod.bitSetFromLabelList(SsaMethod.java:137)"}
    AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.ssa.SsaBasicBlock.newFromRop(SsaBasicBlock.java:161)","position":{},"original":"\tat com.android.dx.ssa.SsaBasicBlock.newFromRop(SsaBasicBlock.java:161)"}
    AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.ssa.SsaMethod.convertRopToSsaBlocks(SsaMethod.java:173)","position":{},"original":"\tat com.android.dx.ssa.SsaMethod.convertRopToSsaBlocks(SsaMethod.java:173)"}
    AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.ssa.SsaMethod.newFromRopMethod(SsaMethod.java:103)","position":{},"original":"\tat com.android.dx.ssa.SsaMethod.newFromRopMethod(SsaMethod.java:103)"}
    AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.ssa.SsaConverter.convertToSsaMethod(SsaConverter.java:44)","position":{},"original":"\tat com.android.dx.ssa.SsaConverter.convertToSsaMethod(SsaConverter.java:44)"}
    AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.ssa.Optimizer.optimize(Optimizer.java:98)","position":{},"original":"\tat com.android.dx.ssa.Optimizer.optimize(Optimizer.java:98)"}
    AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.ssa.Optimizer.optimize(Optimizer.java:72)","position":{},"original":"\tat com.android.dx.ssa.Optimizer.optimize(Optimizer.java:72)"}
    AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:297)","position":{},"original":"\tat com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:297)"}
    AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:137)","position":{},"original":"\tat com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:137)"}
    AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:93)","position":{},"original":"\tat com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:93)"}
    AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.processClass(Main.java:729)","position":{},"original":"\tat com.android.dx.command.dexer.Main.processClass(Main.java:729)"}
    AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)","position":{},"original":"\tat com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)"}
    AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.access$300(Main.java:83)","position":{},"original":"\tat com.android.dx.command.dexer.Main.access$300(Main.java:83)"}
    AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)","position":{},"original":"\tat com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)"}
    AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)","position":{},"original":"\tat com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)"}
    AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)","position":{},"original":"\tat com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)"}
    AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)","position":{},"original":"\tat com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)"}
    AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.processOne(Main.java:632)","position":{},"original":"\tat com.android.dx.command.dexer.Main.processOne(Main.java:632)"}
    AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.processAllFiles(Main.java:505)","position":{},"original":"\tat com.android.dx.command.dexer.Main.processAllFiles(Main.java:505)"}
    AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.runMultiDex(Main.java:334)","position":{},"original":"\tat com.android.dx.command.dexer.Main.runMultiDex(Main.java:334)"}
    AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.run(Main.java:244)","position":{},"original":"\tat com.android.dx.command.dexer.Main.run(Main.java:244)"}
    AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.main(Main.java:215)","position":{},"original":"\tat com.android.dx.command.dexer.Main.main(Main.java:215)"}
    AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.Main.main(Main.java:106)","position":{},"original":"\tat com.android.dx.command.Main.main(Main.java:106)"}
    
    
     FAILED
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':app:dexDebug'.
    > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_25\bin\java.exe'' finished with non-zero exit value 3
    

    Rings a bell?

    opened by freezy 2
  • create PrintView in code

    create PrintView in code

    I have next code:

            PrintView statusView = new PrintView(context);
    

    and get this stack trace

        java.lang.NullPointerException
                at com.github.johnkil.print.PrintDrawable.updateIconColors(PrintDrawable.java:241)
                at com.github.johnkil.print.PrintDrawable.<init>(PrintDrawable.java:148)
                at com.github.johnkil.print.PrintDrawable.<init>(PrintDrawable.java:41)
                at com.github.johnkil.print.PrintDrawable$Builder.build(PrintDrawable.java:117)
                at com.github.johnkil.print.PrintViewUtils.initIcon(PrintViewUtils.java:63)
                at com.github.johnkil.print.PrintView.init(PrintView.java:56)
                at com.github.johnkil.print.PrintView.<init>(PrintView.java:36)
                at su.keysoft.inventory.rfid_inventory.extendedrow.InventoryRow.<init>(InventoryRow.java:37)
    

    in class PrintViewUtils method initIcon i have AttributeSet attrs is null. And PrintDrawable have mIconColor is null.

    Can you help me with this error? What i doing wrong.

    opened by skew 1
  • Fix for Issue #11.

    Fix for Issue #11.

    The idea is to use integer values instead of strings, which I think is a good idea as all the symbols are represent by numeric value. Additional font added and demo updated to show icons that previously could not be shown

    opened by bmelnychuk 1
  • Confusing text in README

    Confusing text in README

    First, you need to initialize the default iconic font in Application.onCreate() method. If the font is not specified, then the font is used by default.

    I'm not sure what this means. Does this mean that if a font is not specified in the layout xml then this is the font that will be used?

    Can the custom view be used without specifying the default font by always specifying it in the layout xml?

    opened by intrications 1
  • Issue in showing layout preview of layout editor while using iconSize attribute

    Issue in showing layout preview of layout editor while using iconSize attribute

    Hi johnkil, Your library works so amazing. The only thing which bothers me is whenever i use it in layout editor it spoils my graphics preview in layout editor because of the iconSize attribute. selection_004 Other than this i just love your work. Please fix this asap.

    bug 
    opened by SanthoshDhandapani 1
  • Added multiple fonts support

    Added multiple fonts support

    Now you can initialize multiple fonts. Font name can be specified as fontName attribute in XML layout. If not fontName specified, the first font to be initialized will be used (i.e. the default font). Font names can be extracted automatically from font file name, or set explicitly when initializing.

    The code is backward-compatible, so implementations using older lib versions will not be affected.

    I added another font for the sake of demonstration.

    opened by majedev 1
  • Error:(2) Attribute

    Error:(2) Attribute "iconSize" has already been defined

    I have tried to user this library but when I sync it with project I get the following error:

    Error:(2) Attribute "iconSize" has already been defined

    Values.xml of library com.baoyz.pullrefreshlayout:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <!-- From: file:/Users/baoyz/Developer/GitHub/Widget/android-      PullRefreshLayout/library/src/main/res/values/strings.xml -->
        <eat-comment/>
        <integer-array name="google_colors">
            <item>@color/red</item>
            <item>@color/blue</item>
            <item>@color/yellow</item>
            <item>@color/green</item>
        </integer-array>
        <!-- From: file:/Users/baoyz/Developer/GitHub/Widget/android-PullRefreshLayout/library/src/main/res/values/colors.xml -->
        <eat-comment/>
         <color name="blue">#FF375BF1</color>
        <color name="green">#FF34A350</color>
        <color name="red">#FFC93437</color>
         <color name="yellow">#FFF7D23E</color>
        <declare-styleable name="PullRefreshLayout"><attr format="enum" name="type"><enum name="material" value="0"/><enum name="circles" value="1"/><enum name="water_drop" value="2"/><enum name="ring" value="3"/></attr><attr format="reference" name="colors"/></declare-styleable>
     </resources>
    

    Is there a way how can I fix this ?

    Edit1: Can you please rename the attribute and update the project ? This may fix the project.

    https://github.com/johnkil/Print/blob/master/print/src/main/res/values/attrs.xml

    opened by marianpavel 0
  • Moved PrintButton to PrintImageButton.

    Moved PrintButton to PrintImageButton.

    • Moved PrintButton to PrintImageButton.
    • Created PrintButton extended from Button.
    • It will lead to incompatibility due PrintButton was something else before these changes.
    opened by orlleite 0
Releases(1.3.1)
Owner
Evgeny Shishkin
Senior Android Developer
Evgeny Shishkin
Material and Holo iconic fonts.

Android Icon Fonts Material and Holo iconic fonts. Source Material Extracted 433 Material Design icons from Google's Project Polymer website by Shreya

Evgeny Shishkin 223 Dec 27, 2022
Android Library to use custom fonts with ease.

FontometricsLibrary A Simple Android Library to use Custom Fonts with Ease. Use Customs Fonts in your Android project without adding any .ttf/.otf in

Ishmeet Singh 188 Nov 15, 2022
Custom fonts in Android the easy way...

This version of Calligraphy has reached its end-of-life and is no longer maintained. Please migrate to Calligraphy 3! Calligraphy Custom fonts in Andr

Christopher Jenkins 8.6k Jan 3, 2023
A full example of custom fonts in XML using data binding and including font caching.

[Deprecated] Fonts in XML are now supported by the Android support library as of 26.0, including in styles and themes. I recommend using the support l

Lisa Wray 776 Sep 24, 2022
Custom font library for android | Library to change/add font of Entire Android Application at once without wasting your time - TextViews, EditText, Buttons, Views etc.,

AppFontChanger In a Single shot change font of Entire Android Application - TextViews, EditText, Buttons, Views etc., Kindly use the following links t

Prabhakar Thota 48 Aug 10, 2022
An android library to display FontAwesome Icons in any View or a MenuItem

DroidAwesome A library to display FontAwesome Icons in any View or a MenuItem Views Supported: TextView AutoComplete TextView EditText Switch CheckBox

Livin 38 Aug 25, 2022
Fontize is an Android library that enables multi-font selection functionality to diversify your app.

Fontize Android Library Built with ❤︎ by Gourav Khunger Fontize is an Android library, written in kotlin, that enables your android app have multiple

Gourav Khunger 8 Nov 28, 2022
A library that gives full control over text related technologies such as bidirectional algorithm, open type shaping, text typesetting and text rendering

Tehreer-Android Tehreer is a library which gives full control over following text related technologies. Bidirectional Algorithm OpenType Shaping Engin

Tehreer 61 Dec 15, 2022
Typeface helper for Android

Android Typeface Helper Android lacks proper support for custom typefaces. Most obvious method of defining typeface for UI elements via XML attributes

Norbsoft Sp. z o.o. 756 Aug 8, 2022
Helper object for injecting typeface into various text views of android.

TypefaceHelper Helper object for injecting typeface into various text views of android. Overview We can use various custom typefaces asset for any tex

Drivemode, Inc. 105 Nov 25, 2022
A lightweight Android library for use iconic fonts.

Print A lightweight Android library for use iconic fonts. Download Gradle: compile 'com.github.johnkil.print:print:1.3.1' Maven: <dependency> <gro

Evgeny Shishkin 202 Dec 27, 2022
IconicDroid is a custom Android Drawable which allows to draw icons from several iconic fonts.

IconicDroid IconicDroid is a custom Android Drawable which allows to draw icons from several iconic fonts. Try out the sample application on the Googl

Artur Termenji 387 Nov 20, 2022
Material and Holo iconic fonts.

Android Icon Fonts Material and Holo iconic fonts. Source Material Extracted 433 Material Design icons from Google's Project Polymer website by Shreya

Evgeny Shishkin 223 Dec 27, 2022
****. Use the native and support library variants instead - https://developer.android.com/guide/topics/ui/look-and-feel/fonts-in-xml.html. An android library that makes it easy to add custom fonts to edittexts and textviews

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

Workarounds 43 Nov 6, 2021
Implementation of a TextView and all its direct/indirect subclasses with native support for the Roboto fonts, includes the brand new Roboto Slab fonts.

Android-RobotoTextView Implementation of a TextView and all its direct/indirect subclasses with native support for the Roboto fonts, includes the bran

Evgeny Shishkin 782 Nov 12, 2022
📲💬 react-native-fontext is a lightweight library to integrate fonts in your React Native application that works seamlessly in android and iOS devices.

React Native Fontext react-native-fontext is a lightweight library to integrate fonts in your React Native application that works seamlessly in androi

mroads 9 Dec 3, 2021
Useful library to use custom fonts in your android app

EasyFonts A simple and useful android library to use custom fonts in android apps without adding fonts into asset/resource folder.Also by using this l

Vijay Vankhede 419 Sep 9, 2022
Android Library to use custom fonts with ease.

FontometricsLibrary A Simple Android Library to use Custom Fonts with Ease. Use Customs Fonts in your Android project without adding any .ttf/.otf in

Ishmeet Singh 188 Nov 15, 2022
Material Design implementation for Android 4.0+. Shadows, ripples, vectors, fonts, animations, widgets, rounded corners and more.

Carbon Material Design implementation for Android 4.0 and newer. This is not the exact copy of the Lollipop's API and features. It's a custom implemen

null 3k Dec 30, 2022
Custom fonts in Android the easy way...

This version of Calligraphy has reached its end-of-life and is no longer maintained. Please migrate to Calligraphy 3! Calligraphy Custom fonts in Andr

Christopher Jenkins 8.6k Jan 3, 2023