Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HELP] Custom Font Support #71

Open
ShubhKotnala opened this issue Oct 25, 2019 · 1 comment
Open

[HELP] Custom Font Support #71

ShubhKotnala opened this issue Oct 25, 2019 · 1 comment

Comments

@ShubhKotnala
Copy link

ShubhKotnala commented Oct 25, 2019

Hi,
I am using Calligraphy for custom font support of user choice. But after coming to Cyanea, the fonts are not applied to the application.

I read about the FontDecorator but is it only to be used in XML (Also I'm not getting the kotlin part, I'm still using Java). I want to use custom fonts of user choice from a list of given fonts stored in assets. How am I supposed to use them?

@DatL4g
Copy link

DatL4g commented Jun 3, 2020

@jaredrummler Any news about that?

Calligraphy3 and ViewPump basically set a standard font in all views, including dialogs, snack bars, etc.
And you can set a different font in xml views if you want a text in bold type, for example

Maybe it would be better if you remove the font option and create an extra module for that?!

I got it partly working:

abstract class AdvancedActivity : AppCompatActivity(), BaseCyaneaActivity {

    companion object {
        init {
            AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
        }
    }

    private val delegate: CyaneaDelegate by lazy {
        CyaneaDelegate.create(this, cyanea, getThemeResId())
    }

    private val resources: CyaneaResources by lazy {
        CyaneaResources(super.getResources(), cyanea)
    }

    override fun attachBaseContext(newBase: Context) {
        super.attachBaseContext(ViewPumpContextWrapper.wrap(delegate.wrap(newBase)))
    }

    override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) {
        delegate.onCreate(savedInstanceState)
        super.onCreate(savedInstanceState, persistentState)
    }

    override fun onPostCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) {
        super.onPostCreate(savedInstanceState, persistentState)
        delegate.onPostCreate(savedInstanceState)
    }

    override fun onStart() {
        super.onStart()
        delegate.onStart()
    }

    override fun onResume() {
        super.onResume()
        delegate.onResume()
    }

    override fun onCreateOptionsMenu(menu: Menu): Boolean {
        delegate.onCreateOptionsMenu(menu)
        return super.onCreateOptionsMenu(menu)
    }

    override fun getResources(): Resources = resources

}

And MainActivity extending AdvancedActivity:

class MainActivity : AdvancedActivity() {
...
}

However my custom toolbars e.g. does not apply changed colors (works like a charm when using without calligraphy and viewpump)
Having default red Toolbar and changing to blue but the toolbar is still red for example (all other parts are changed as intended)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants