You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This might be related to my other issue posted about certain Styles not having an effect. Using the UIExplorerApp example app again to keep things consistent. I've added attempted to the font - Open Sans Condensed Light (OpenSans-CondLight.ttf) to the project in a number of different places:
windows/UIExplorerApp/Assets/ and then included it in the project in VS (build action: content, copy to output: do not copy)
UIExplorer/fonts right alongside the js folder similar to the way I used an images folder in my app
windows/UIExplorer/Assets/fonts
As for usage in the app, I modified the TextExample.windows.js file referencing the font in a bunch of ways. A few examples below.
<Text style={{fontFamily: 'Open Sans Condensed Light'}}>
Open Sans Condensed Light
</Text>
<Text style={{fontFamily: '../../../Open-Sans-CondLight.ttf'}}>
Open Sans Condensed Light
</Text>
<Text style={{fontFamily: 'Open-Sans-CondLight.ttf'}}>
Open Sans Condensed Light
</Text>
<Text style={{fontFamily: 'Assets/OpenSans-CondLight.ttf'}}>
Open Sans Condensed Light
</Text>
I must be missing another step in the setup to ensure the font is included in the project and available to the js. The /fonts folder was present when I initially ran react-native windows, in case that matters.
Per Eric Rozell (@rozele) in the discord chat, custom fonts should work, but don't have great support. they should be similar to how image URIs resolve. So I'll try that. And if it works, will post the result here in case others run across similar question.
Eric Rozell (@rozele) Yeah I tried that. I also tried Copy always, just in case. Neither one pulled in the font. I'll try doing this inside the example app app, too. Maybe I'm missing a setting in my app.
Eric Rozell (@rozele) I was not able to get it to work in the Movies app either. Dropped the font in Assets, set it to Copy if newer. But it did not have any effect.
I don't believe there are any custom settings in the Playground project to allow this. It could also be a problem with the font in general. You could try to create a blank UWP app in Visual Studio and create a simple XAML page with a custom font. I did the same to figure out how the feature works, here's my MainPage.xaml:
<Pagex:Class="App1.MainPage"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:local="using:App1"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"mc:Ignorable="d">
<GridBackground="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<TextBlockName="Foo"FontFamily="Assets/coneria.ttf#Coneria Script Demo"TextWrapping="Wrap">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc finibus volutpat ligula nec euismod. Aliquam erat volutpat.
Vestibulum sagittis sollicitudin mi ut semper. Nunc tempus non nulla eget vulputate. Quisque pulvinar diam risus, semper
blandit metus euismod quis. Cras eleifend ultricies mauris, sed rhoncus nisl malesuada a. Integer interdum dignissim
suscipit. Integer a lorem at nibh placerat pellentesque. Aenean id lectus tristique, porttitor quam mattis, maximus dolor.
Nulla odio orci, tristique condimentum urna nec, ultricies vestibulum nibh. Nulla rutrum iaculis tellus at efficitur.
Morbi neque dui, fermentum in dapibus vel, tempus ac ligula. Aliquam dignissim, leo at varius blandit, neque.
</TextBlock>
</Grid>
</Page>
Thanks for the detail, Eric Rozell (@rozele)! It could very well be the font. I'll try another one first. Then I'll try your other suggestions and see what happens. Thanks again.
It was the font. I used the same font you did and it worked both in my app and a fresh UWP app.
After closer inspection, Open Sans Cond Light is an OpenType font not a TrueType font. I imagine if I dig into the UWP details, TTF is support and OT is not.
Thanks for digging into this one, massively helpful. Looks like I'll be sticking with Segoe!
To give an update since I was stuck here as well: it seems that OpenType fonts are (now) supported. I used Source Sans Pro and it worked fine with a few twists. I followed the instructions from this thread:
put the font files into the windows/%yourprojectname%/Assets folder
in the Solutions Explorer go to your project, then Assets and make sure the files are there (drag & drop if they are not)
select all files, right click and click Properties. For Copy to Output Directory select copy if newer
now you can use them in JS by adding fontFamily: 'Assets/FontFamily-Type.ttf#FontFamily'
Make sure the file name and the font names are correct. For me, the problem was that even though the bold version was called Source Sans Pro Bold, I had to use Source Sans Pro (without Bold) after the #. So the resulting font declaration in JS looks like this:
const sourceSansPro = {
light: 'Assets/SourceSansPro-Light.ttf#Source Sans Pro',
regular: 'Assets/SourceSansPro-Regular.ttf#Source Sans Pro',
semibold: 'Assets/SourceSansPro-SemiBold.ttf#Source Sans Pro',
bold: 'Assets/SourceSansPro-Bold.ttf#Source Sans Pro',
}
Wasili Adamow (@gtRfnkN) thank you for the above details.
just wondering if the above code is something you loading the fonts at startup of the project? Or is it has to be used in every style property ?
An example implementation would be helpful.
ghost added
Needs: Attention 👋An issue that had been tagged "Needs: Author Feedback" has received activity (label applied by bot)
Activity
kcfgl commentedon Aug 29, 2016
Per Eric Rozell (@rozele) in the discord chat, custom fonts should work, but don't have great support. they should be similar to how image URIs resolve. So I'll try that. And if it works, will post the result here in case others run across similar question.
rozele commentedon Aug 29, 2016
Kane Cochran (@kcfgl) You'll also need to add a #Font Name, so something like:
kcfgl commentedon Aug 29, 2016
Eric Rozell (@rozele) OK. I updated just my JS to:
style={{fontFamily: 'Assets/OpenSans-CondLight.ttf#Open Sans Condensed Light'}}I do have that font in my Assets folder. So that path would be windows/project-name/Assets/OpenSans-CondLight.ttf
I went ahead and rebuilt as well. But sadly, this didn't work.
rozele commentedon Aug 29, 2016
Kane Cochran (@kcfgl) Did you set the behavior of the file in the Assets folder to "Copy If Newer"? I.e.,

kcfgl commentedon Aug 29, 2016
Eric Rozell (@rozele) Yeah I tried that. I also tried Copy always, just in case. Neither one pulled in the font. I'll try doing this inside the example app app, too. Maybe I'm missing a setting in my app.
kcfgl commentedon Aug 29, 2016
Eric Rozell (@rozele) I was not able to get it to work in the Movies app either. Dropped the font in Assets, set it to Copy if newer. But it did not have any effect.
rozele commentedon Aug 29, 2016
Kane Cochran (@kcfgl) I was just able to use a custom font pretty easily in the ReactWindows Playground project.
fontFamilystyle prop toAssets/font.ttf#Font Name.Can you open up the .ttf file and ensure you have the correct name for the font after #?
rozele commentedon Aug 29, 2016
I don't believe there are any custom settings in the Playground project to allow this. It could also be a problem with the font in general. You could try to create a blank UWP app in Visual Studio and create a simple XAML page with a custom font. I did the same to figure out how the feature works, here's my MainPage.xaml:
rozele commentedon Aug 29, 2016
obviously just replace the FontFamily there with your font family.
kcfgl commentedon Aug 29, 2016
Thanks for the detail, Eric Rozell (@rozele)! It could very well be the font. I'll try another one first. Then I'll try your other suggestions and see what happens. Thanks again.
kcfgl commentedon Aug 29, 2016
It was the font. I used the same font you did and it worked both in my app and a fresh UWP app.
After closer inspection, Open Sans Cond Light is an OpenType font not a TrueType font. I imagine if I dig into the UWP details, TTF is support and OT is not.
Thanks for digging into this one, massively helpful. Looks like I'll be sticking with Segoe!
gtRfnkN commentedon Jul 23, 2018
To give an update since I was stuck here as well: it seems that OpenType fonts are (now) supported. I used Source Sans Pro and it worked fine with a few twists. I followed the instructions from this thread:
windows/%yourprojectname%/AssetsfolderSolutions Explorergo to your project, thenAssetsand make sure the files are there (drag & drop if they are not)Properties. ForCopy to Output Directoryselectcopy if newerfontFamily: 'Assets/FontFamily-Type.ttf#FontFamily'Make sure the file name and the font names are correct. For me, the problem was that even though the bold version was called
Source Sans Pro Bold, I had to useSource Sans Pro(withoutBold) after the#. So the resulting font declaration in JS looks like this:khanzzirfan commentedon Sep 27, 2020
Wasili Adamow (@gtRfnkN) thank you for the above details.
just wondering if the above code is something you loading the fonts at startup of the project? Or is it has to be used in every style property ?
An example implementation would be helpful.