Comments (15)
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:
from calligraphy.xamarin.
The mikescandy one:
https://github.com/mikescandy/Calligraphy-xamarin
I uninstalled it, installed yours, and made some tweaks.
from calligraphy.xamarin.
Can you provide a sample snippet of the code?
What were you using previously?
from calligraphy.xamarin.
Just as I suspected, Android can't find my fonts. How do I update the path to work with your library?
from calligraphy.xamarin.
I just read your TypeFace load() code. I may have to remove the leading "/"
from calligraphy.xamarin.
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.
Are you compiling the fonts correct as assets
?
from calligraphy.xamarin.
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)?
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.
What are you referring to with the "Old Calligraphy 2" Library? you mean the original java one?
from calligraphy.xamarin.
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.
from calligraphy.xamarin.
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.
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.
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.
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)
- CalligraphyFactory.OnViewCreatedInternal throws an InvalidCastException on Android 10 HOT 18
- Problem with many devices HOT 3
- Check over changes now that Calligraphy is changing owners and moving to v3
- Doesn't clone CalligraphyLayoutInflated properly
- Works in test app, but not in another app with custom styles HOT 1
- Add logging
- After upgrade of Visual Studio Community to 16.6.0 HOT 3
- Please update the code to support Android 10 HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from calligraphy.xamarin.