Fonts in XAML

Started by jonz, January 29, 2019, 07:42:23 PM

Previous topic - Next topic

jonz

I am having trouble selecting fonts with the FontFamily tag in XAML. What fonts are available through FontFamily? I can't find a list anywhere.

Mario

As far as I know, all fonts installed in Windows. I used the name shown in the Windows fonts app and it worked great:

<TextBlock Cursor="Hand" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="32" FontFamily="Comic Sans MS">The fox jumps over the lazy sheep.</TextBlock>
<TextBlock Cursor="Hand" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="32" FontFamily="Frutiger LT 87 ExtraBlackCN">The fox jumps over the lazy sheep.</TextBlock>
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

jonz

>As far as I know, all fonts installed in Windows.

I wish I could say the same thing. The only two fonts I seem to be able to get working are Arial Narrow and Times New Roman. Could it be something about the RUN statement?

<Run FontSize='20pt' FontFamily='Arial Narrow' FontWeight='Bold' Foreground='Firebrick'>{File.MD.XMP::dc\title\Title\0}</Run>  <Run FontFamily='Arial Narrow' FontSize='20pt' Foreground='Black'>{File.MD.XMP::dc\description\Description\0}.</Run>

If I change Arial Narrow to something like Tekton Pro it breaks the output and the font seems to go to a default, which looks like Arial normal.

I've tried a lot of approaches but I can't get it to work as you describe.

Thanks!

Mario

No problems here.

I tried your font and another special font in bot a markup tester and the IMatch File Window Tip:

<Run FontSize='20pt' FontFamily='Tekton Pro' FontWeight='Bold' Foreground='Firebrick'>{File.MD.XMP::dc\title\Title\0}</Run>  <Run FontFamily='Calligraphic' FontSize='20pt' Foreground='White'>{File.MD.XMP::dc\description\Description\0}.</Run>

produces:



Upper image: File Window tip. The lower text is from a markup test. I used the same XAML but replaced the variables with normal text.
Windows 10. 64-bit. IMatch 2019.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

jonz

#4
I'm getting things working too, after I took out the bold attribute. I do think it's important to point out that it appears to me that the FontWeight attribute and the <Bold> and <Italic> etc appear to call the appropriate font file of the specified font, which makes it a little confusing. So for instance, Arial Bold is called through FontFamily='Arial' FontWeight='Bold' and not FontFamily='Arial Bold'. That makes sense, really, and is correct, but it's not as simple as stripping in the font name as it appears in the file explorer

It's wonderful to have this underlying formatting language, very useful. Thanks for the help, Mario, and I hope you have a good new year.

sinus

Agree, cool stuff.

Here something else (from the help, parts)

<TextBlock TextWrapping="Wrap" FontFamily="Comic Sans MS" FontSize="14pt">
<Bold>This text is bold.</Bold> Now follows normal text that should wrap into a second line.
We can also use a LineBreak<LineBreak/>to start a <Bold> new line</Bold>.<LineBreak/><LineBreak/>
With <Run Foreground="#ff0000" FontFamily="Harrington" FontSize="36pt">a Run we can</Run> change color and font font <Run FontSize="48">whenever</Run> we want.
<Run Background="#fcc0ff">Even the background color.</Run>.
</TextBlock>

<TextBlock TextWrapping="Wrap" FontFamily="Showcard Gothic" FontSize="14pt">
<Bold>This text is bold.</Bold> Now follows normal text that should wrap into a second line.
We can also use a LineBreak<LineBreak/>to start a <Bold> new line</Bold>.<LineBreak/><LineBreak/>
With <Run Foreground="#ff0000" FontFamily="Times New Roman" FontSize="36pt">a Run we can</Run> change color and font font <Run FontSize="48">whenever</Run> we want.
<Run Background="#fcc0ff">Even the background color.</Run>.
</TextBlock>
Best wishes from Switzerland! :-)
Markus

jonz

Thanks to all. Being able to do these things is very useful.