GithubHelp home page GithubHelp logo

Comments (15)

gonzobrains avatar gonzobrains commented on July 29, 2024 1

I added this in MainApplication:OnCreate():

CalligraphyConfig.Builder builder = new CalligraphyConfig.Builder();
CalligraphyConfig config = builder.SetDefaultFontPath("/fonts/Ubuntu-Regular.ttf").Build();
CalligraphyConfig.InitDefault(config);

I didn't have anything here before. My TextViews all have something like this:

fontPath="fonts/Ubuntu-Medium.ttf"

My BaseActivity.cs looks like this:

protected override void AttachBaseContext(Context newBase)
{
base.AttachBaseContext(CalligraphyContextWrapper.Wrap(newBase));
}

My fonts are in this folder:

image

from calligraphy.xamarin.

gonzobrains avatar gonzobrains commented on July 29, 2024 1

The mikescandy one:

https://github.com/mikescandy/Calligraphy-xamarin

I uninstalled it, installed yours, and made some tweaks.

from calligraphy.xamarin.

nwestfall avatar nwestfall commented on July 29, 2024

Can you provide a sample snippet of the code?

What were you using previously?

from calligraphy.xamarin.

gonzobrains avatar gonzobrains commented on July 29, 2024

Just as I suspected, Android can't find my fonts. How do I update the path to work with your library?

image

from calligraphy.xamarin.

gonzobrains avatar gonzobrains commented on July 29, 2024

I just read your TypeFace load() code. I may have to remove the leading "/"

from calligraphy.xamarin.

gonzobrains avatar gonzobrains commented on July 29, 2024

Hi, again. It looks like I resolved the error, but the fonts are still not being used. What else should I try?

from calligraphy.xamarin.

nwestfall avatar nwestfall commented on July 29, 2024

Are you compiling the fonts correct as assets?

from calligraphy.xamarin.

gonzobrains avatar gonzobrains commented on July 29, 2024

Hi. Thanks for the quick response. I did not originally write the code so I am not familiar with the original usage of the old Calligraphy 2 library.

Is this what you mean by compiling them correctly (ie., setting the Build Action to AndroidAsset)?

image

I've literally left everything in place as it was with the old library (fonts, font paths, layout XML files, etc). The only change I made was to the Application class as I wrote above. Do I need to add an interceptor or something? I didn't see that in your instructions but I see some dialog about it in the underlying native project's github.

Thanks again!

from calligraphy.xamarin.

nwestfall avatar nwestfall commented on July 29, 2024

What are you referring to with the "Old Calligraphy 2" Library? you mean the original java one?

from calligraphy.xamarin.

nwestfall avatar nwestfall commented on July 29, 2024

If you can do a quick test, Android compilers someones don't like having a - in the filename. I know this is mostly for resources, but maybe you can test the fonts as well? Either remove the - or change to a _

from calligraphy.xamarin.

gonzobrains avatar gonzobrains commented on July 29, 2024

from calligraphy.xamarin.

gonzobrains avatar gonzobrains commented on July 29, 2024

If you can do a quick test, Android compilers someones don't like having a - in the filename. I know this is mostly for resources, but maybe you can test the fonts as well? Either remove the - or change to a _

I tried this. It didn't help.

from calligraphy.xamarin.

gonzobrains avatar gonzobrains commented on July 29, 2024

Can you explain how to do this (from your documentation)? Perhaps I am missing something:

"Define your default font using CalligraphyConfig, in your Application class in the #onCreate() method and pass it to the CalligraphyInterceptor that you add to your ViewPump builder."

from calligraphy.xamarin.

bencat86 avatar bencat86 commented on July 29, 2024

I have a similar issue with fonts not loading. I made the same switch from https://github.com/mikescandy/Calligraphy-xamarin as part of an upgrade to API30.

I've found that the default font using SetDefaultFontPath("...") is applied correctly.
I'm also using the fontPath property in xml to apply FontAwesome to some controls as needed, but these don't get applied at all. It seems that fontPath is ignored in favour of the default font above.

from calligraphy.xamarin.

bencat86 avatar bencat86 commented on July 29, 2024

I cloned the source to see what was going on, and I think I've found the issue (at least in my case).

In CalligraphyFactory.OnViewCreatedInternal the font path is correctly resolved from the xml property.
The next part then sets the textViewFont variable to null (in my case it's the else branch that gets called):

// Try theme attributes
if(!string.IsNullOrEmpty(textViewFont))
{
	int[] styleForTextView = GetStyleForTextView(textView);
	if (styleForTextView[1] != -1)
		textViewFont = CalligraphyUtils.PullFontPathFromTheme(context, styleForTextView[0], styleForTextView[1], attributeId);
	else
		textViewFont = CalligraphyUtils.PullFontPathFromTheme(context, styleForTextView[0], attributeId);
}

Commenting out the above section loads the font as expected.

Digging deeper, CalligraphyUtils.cs line 238 seems to be setting the null from the typedArray.GetString(0) call.

from calligraphy.xamarin.

Related Issues (9)

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.