.NET Maui font problems
Hi,
I am building an app in .Net Maui. I use custom fonts. They worked very well and suddenly, the program started to crash, saying the fonts uri was not correct. I haven't moved anything. I opened a similar project and it worked well, same configuration. I simply do lot get it.
71 Replies
$details
When you ask a question, make sure you include as much detail as possible. Such as code, the issue you are facing, and what you expect the result to be. Upload code here https://paste.mod.gg/ (see $code for more information on how to paste your code)
And the error:
FontFamily="FUTURA BOOK FONT"
u named it FuturaBookItalic when u add it
so you should call FontFamily="FuturaBookItalic"
if you still have issues I would try to rename the otf file to lower case and remove the space to see if it finds it first
I use FUTURA BOOK. I tried renaming too. Matched perfectly, without success, with or without spaces.
and have u tried to name the otf file all lower case with no space?
in your solution explorer
I've seen Maui having issue with files with name spaces and upper case letter some times
u can also open the otf/ttf file and use the name inside
because it can sometimes contain multiple types
so here I can use
FontFamily="Eina03-Bold"
Pretty sure I did, will try again and get back to you! Thanks!
csproj
Somehow it gets stuck on this capital letter thing
Even though it's nowhere
u have to remove the other 2 with space on the name
from here I mean, otherwise it will still try to load the wrong named fonts and fail
wait why they marked as none remove
ah no that's right mine is the same thou it should be something else
Yeah, they are genuinely nowhere and not referenced either
in the properties its marked as MauiFont right?
yep
I mean in here you still have the 2 entries of the files with space on the name
u need to remove those
My problem was fixed, but it crashes anyway
I do not get the error caused by the fonts though
try to clean the solution
then rebuild
The rebuild succeeded but it crashes when i Debug
in xaml how are u calling the font inthe fontfamily
as I should
as far as i know
and does it work if u remove it?
nope
and if u comment the 2 entries loading the fonts in the maui cs file
does it work?
fonts.AddFont("bloomings.otf", "bloomings");
fonts.AddFont("futurabook.ttf", "futurabook");
fonts.AddFont("futurabookitalic.ttf", "futurabookitalic"); These?
crashes too
This is insane
It worked all afternoon
then your problem now is else where I guess
do u have a github of this project?
GitHub
GitHub - dotnetemmanuel/ChlorophyGUITests
Contribute to dotnetemmanuel/ChlorophyGUITests development by creating an account on GitHub.
is it up to date with the issue ur having?
yeah
I just pushed it
ok give me 15 minutes and I will take a look
Awesome! Thanks!
you're building it for windows?
right now yeah
it's a university project
ok found it
Seriously?
that was causing it to crash
Why?
the negative 230 is probably causing some issue
I dont know what the image is or what u want to do with it so hard to tell
Haha, i just want to offset it
It should fill the whole border, bit I want to offset it
To the left
I have also removed one of the fonts
they were both the same file wise apparently
Which one?
futura
I left this one fonts.AddFont("futurabook.ttf", "futurabook");
Haha yeah that image shouldnt look that way
Will try tomorrow
Thanks so much!
Will get back to you. Whats your timezone?
im not sure I understood
that tip of something at the bottom in the middle?
Yeah, you should see a whole fucking loads of succulents
Will keep trying tomorrow
ok but you want to fill it inside not on the border?
-3
you should probably add a grid to your border
and work from there u will get a much easier result
then negativating margins
True
Thanks for the advice
Started with maui yesterday so it's still a bit fresh
its ok 😉 althou I would suggest you either use WPF or UWP if your target is only windows
due to the proportion of that image u will have a hard time filling it the way u want
I see what is going on its rescaling it making it grow under
Yeah, our teacher chose Maui, this app will be for android and windows. Thats why
fair, at least you're learning xaml and not winforms 🙂
Maui is quite buggy
But i like it somehow
well youre dealing with edge technology so yeah
there will be things that wont be as simple as u think they will 🙂
and u might need to do hacks to get around some
It's not as counterintuitive as i thought
but MAUI is getting a lot of love so who knows in a few more years
its just sad it gets no linux support which would probably make it a lot more popular
People are too dismissive too fast imo
I wouldn't say dismissive its just that they need to consider for example
say u need a crossplatform app that also works on linux
MAUI does all the 4 other platform u need
so now u need to create a MAUI app and then another app with another tech to cover for linux
so you have to maintain 2 separated code bases
as oppose to choose a tech that covers all of it
so people just go for the latter
either it being electron, tauri, avalonia or w/e
Also as far as I remember, last I checked MAUI was still not production ready even thou it does work quite well to some extent
Yeah, i meant people in general, complaining about Maui not woeking properly. It's still quite impressive
yeah, I mean that will always exist specially when its something free and some parts get more attention than others.
Thanks again for your help! I got it to work in no time! Really appreciate