Skip to content

Custom TypeFace (FontFamily)

Harsh Bhakta edited this page Nov 13, 2017 · 2 revisions

Use custom typeFace

FontFamily or TypeFace of CCP view and dialog can be changed in order to match rest of the view of your screen.

  • Font can be set only programmatically.

    • Step 1: create a folder named 'assets' under 'app/src/main/' folder. If you already have 'app/src/main/assets' then jump to next step.
    • Step 2: put your font's .ttf file in assets folder. For example if file name is 'myfonts.ttf', it should be 'app/src/main/assets/myfonts.ttf'. Make sure that the extension '.ttf' have contain small letters only. '.TTF' might not work.
    • Step 3: Prepare typeFace using Typeface typeFace=Typeface.createFromAsset(getContext().getAssets(),"myfonts.ttf");
    • Step 4: finally apply the type face on ccp ccp.setTypeFace(typeFace); OR ccp.setTypeFace(typeFace,customStyle); Following above steps with apply "myfonts" to CCP view's text and dialog as well.

Want to use different typefaces for CCP view and Dialog?

For flexibility, CCP maintains two typefaces. One for CCP view and one for dialog. For ease, it updates both when ccp.setTypeFace(); is called.

  • If you want to use typeface only for dialog's text, use ccp.setDialogTypeFace().
  • If want to use typeface for CCP view but want to keep dialog's typeface as default. SO should call ccp.setTypeFace(typeFace,customStyle); and then ccp.setDialogTypeFace(null);
Clone this wiki locally