WP7 - Not picking up embedded fonts - windows-phone-7

I have been trying to use some custom fonts within my WP7 app.
I followed the example as per http://www.jeffblankenburg.com/2010/10/24/31-days-of-windows-phone-day-24-embedding-fonts/ but in my project it simply will not pick up the custom font.
I have downloaded the sample project in this example and this one does work okay.
So, I have now used the same font used in there, and included in my project. I have ensured that the properties on the file are identical (Build Action = 'Content' and Copy To Output Directory = "Always")
I have used in my XAML in exactly the same way i.e.
FontFamily="Fonts/DigitalDream.ttf#Digital Dream" FontSize="24"
But to no avail. The custom font is just ignored. Is there something that I am missing, or a setting .. anything that would allow this to work in one project, but not another?
I have discovered that it will work if my XAML page is defined at the root level, i.e. immediately under the project, but in my case I have it in a 'Views' folder.
My understanding was that
FontFamily="/Fonts/DigitalDream.ttf#Digital Dream" FontSize="24"
should start at the root folder of the project?
thanks

Custom fonts can be a little tricky. I spent several hours once trying to embed an .otf font only to find that it just didn't seem to be doable.
You're on the right track, though. A .ttf font should be embedable. It's hard to get the right combination of paths and filenames to make the font work, though.
The easiest way I've found to handle some of these more difficult "magic string" type of situations in XAML is to let Expression Blend do the heavy lifting.
Here's a blog post about using Blend to embed fonts. The nice thing about using Blend is that it gives you some visual indications that things are set up correctly--i.e. you can see the font you want in the font selection menu. This is what finally clued me in on the .otf issue. I couldn't see the font in Blend.
And here's an example of a custom font that I've used in one of my apps:
<TextBlock Name="MyTextblock"
FontFamily="/MyAppName;component/fonts/Fonts.zip#Segoe UI Mono">
That's FontFamily URI is a pain to get right. I'm pretty sure that's your problem.

I was actually having the same problem. I followed everything to the dot and still I wasn't able to embed one particular font. So I created a new project and tried embedding the font there. Still no luck. I then tried embedding some other font. And lo and behold, as soon as I typed the FontFamily attribute, I could see that it had embedded. This was particularly odd since I didn't have to change any properties of the font.
I opened the project in Blend and clicked on the font property box to the right. It took a few seconds and then it embedded the font I was having problems with in the first place.

Related

How to display Bootstrap icons in Xamarin?

I'm new to Xamarin development, but try to be exact.
Using Visual Studio 2022, with Xamarin version 17.0.0.182 (as displayed in VS About).
Found this great article on how to use Bootstrap icons, but it seems to be out of date. When I followed the steps and provided hex codes for the characters, I didn't get the expected glyiphs.
I found that
new Xamarin needs new methods,
new Bootstrap fonts need new ways.
Here they are.
1.) Get the font from the Bootstrap github repo at https://github.com/twbs/icons
Go to releases (https://github.com/twbs/icons/releases), choose latest, scroll down to Assets, download the bootstrap-icons-x.x.x.xip file.
Unzip it, and find fonts/bootstrap-icons.woff.
Not something you can use in Xamarin right away :-(
2.) Convert the woff file to ttf
I googled for a converter and used https://cloudconvert.com/woff-to-ttf
Now you have the ttf you need :-)
3.) Now follow the current Xamarin method of adding a font to your app.
The process is described here: https://devblogs.microsoft.com/xamarin/embedded-fonts-xamarin-forms/
In short:
add the ttf file to the shared Xamarin project, Embedded Resources / Fonts
change file properties / Build Action to "Embedded resource"
register the font by adding a line to the end of Assemblyinfo.cs:
[assembly: ExportFont("bootstrap-icons.ttf", Alias = "Bootstrap")]
4.) Use it in xaml like
<Label FontFamily="Bootstrap" Text=""/>
to display a magnifying glass.
You may also define a Label style, but I'll skip that for now.
4/b.) To use it in xaml via binding
Oh, if things were easy...
When using a binding to display a glyph, there's one more hoop to jump, thanks to these guys for the solution: Using data binding, how do I bind text which contains emojis to a label and have it display correctly?
So, in xaml:
<!-- set BindingContext to MyViewModel -->
<Label FontFamily="Bootstrap" Text="{Binding StateIconName}" />
in your MyViewModel:
public string StateIconName
{
get => WebUtility.HtmlDecode("");
}
5.) To browse available glyphs (icons)
Open the overview page: https://icons.getbootstrap.com/
6.) To find the unicode character code, also referred to as "Unicode HTML Entity"
Check the name of the icon above in step 5.
Open the Bootstrap-icons.css file from Github: https://github.com/twbs/icons/blob/main/font/bootstrap-icons.css
Search for the name of the glyph to find the character code, something like:
.bi-zoom-in::before { content: "\f62c"; }
Use this code in xaml like

ToolbarItem icon set after the loss

my English level is limited, it may be difficult to read, please understand.
I use the NSSidebarTemplate icon in the ToolbarItem control of the project. But every time you open the Xcode, will be lost, there is no way to use NSSidebarTemplate. The missing results are shown in the picture. Open the project will have a pop-up box prompts, probably meaning
The document "Main.storyboard" had an internal inconsistency that was
found and repaired.
I have no way to use this NSSidebarTemplate, but most of the other icons do not have such a problem, such as NSActionTemplate is normal
It comes from a template project from Apple. The image name is NSSidebarTemplate. You can see it by digging into the storyboard or xib xml:
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="NSSidebarTemplate" imagePosition="overlaps" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="zzz-zzz-zzz">
There might have been a change in Xcode that made the image name displayed as 'Unknown' at some point, though internally it's still there.
This is also discussed here: The Sidebar Icon image name in OSX

Use ApplicationBar Icons from other assemblies?

I have a Page in a Windows Phone class library. This page has an appbar. I would prefer everything this page needs to be included within the class library so the setup list for consumers of this page / assembly is minimal.
However, When I set ApplicationBar icons, they get added to the class library project under the folder 'icons' just like normal, they show up fine in Blend, but at runtime they are no where to be found!
When I put the icons in the Windows Phone Application project all is well. However this is not my desired scenario as it is additional configuration / setup by the application author to use my pages.
I tried using the resource pathing using /{AssemblyName};component/icons/{IconName} but of course the AppBar needs them to be of type "Content" not "Resource". So I am thinking this is impossible but I wanted to know if anybody out there figured out how to do this.
Sorry guys. I just figured it out. I changed the newly added icons from "Resource" to "Content" but I forgot to set "Copy if newer" so they weren't getting outputted to the Bin\Debug\icons folder of the windows Phone Application. something to keep an eye on I guess.

Monodroid Custom UI controls

I want to know where I can get access to the NinePatch images specifically for Monodroid. I want to change the default coloring from blue to orange (if I was doing this in Java it would already be orange).
All I need is to change an edittext so that it's default colors are different. I have seen
http://www.androidworks.com/changing-the-android-edittext-ui-widget
which is really helpful but only as far as vanilla Android is concerned. I tried following the instructions, but I found the standard orange java images, not the Mono ones, which are blue.
Minimum framework is 2.2. I know that I am getting the java images because when I go to C:\Android\android-sdk\platforms there is no android-2.2 folder.
I'm not really sure what you are referring to. Mono for Android does not ship any NinePatch images. Mono for Android simply provides a thin binding over the Java API, it does not do anything custom.
Maybe it is triggered by changing your Android target framework?
I found my answer - and thank goodnesss it did not involve changing the 9Patches!
You can make an xml in the drawable folder which describes your button, textbox, etc. and make a selector with a solid tag, pressed event, etc. (http://developer.android.com/guide/topics/resources/drawable-resource.html)
Then you can set up the colors as a constant set in the Values folder and boom! Solution!

Why is my text messed up in Firefox 3.5 in Windows 7? (see pic) How can I fix this?

It only happens on some web pages, and only for some text items. On splurb.com, it is happening all over:
http://scottelkin.com/images/splurb.jpg
Going to splurb.com it looks like the font used is in the family of Helvetica,Arial,sans-serif(lifted from the css). Those fonts should be included into windows. Perhaps they have been removed. Make sure those fonts are installed.

Resources