Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font fix for WPF #944

Merged
merged 4 commits into from Jan 12, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 17 additions & 2 deletions ReactWindows/ReactNative.Net46/Views/Text/ReactTextShadowNode.cs
Expand Up @@ -3,6 +3,7 @@
using ReactNative.Reflection;
using ReactNative.UIManager;
using ReactNative.UIManager.Annotations;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
Expand Down Expand Up @@ -146,7 +147,7 @@ public virtual void SetNumberOfLines(int numberOfLines)
[ReactProp(ViewProps.TextAlign)]
public void SetTextAlign(string textAlign)
{
var textAlignment = textAlign == "auto" || textAlign == null ?
var textAlignment = textAlign == "auto" || textAlign == null ?
TextAlignment.Left :
EnumHelpers.Parse<TextAlignment>(textAlign);

Expand Down Expand Up @@ -232,11 +233,25 @@ private void UpdateTextBlockCore(TextBlock textBlock, bool measureOnly)
//textBlock.MaxLines = _numberOfLines;
textBlock.LineHeight = _lineHeight != 0 ? _lineHeight : double.NaN;
textBlock.TextAlignment = _textAlignment;
textBlock.FontFamily = _fontFamily != null ? new FontFamily(_fontFamily) : new FontFamily();
textBlock.FontSize = _fontSize ?? 15;
textBlock.FontStyle = _fontStyle ?? new FontStyle();
textBlock.FontWeight = _fontWeight ?? FontWeights.Normal;

if (_fontFamily != null)
{
// convert font string into something WPF can use
// e.g. FontFamily(new System.Uri("pack://application:,,,/"), "./Assets/#fontname")
string[] path = _fontFamily.Split('/');
path = path.Take(path.Count() - 1).ToArray();
string cleanPath = "./" + string.Join("/", path) + "/";
string[] fontParts = _fontFamily.Split('#');
textBlock.FontFamily = new FontFamily(new System.Uri("pack://application:,,,/"), cleanPath + "#" + fontParts.Last());
Copy link
Collaborator

@rozele rozele Jan 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

application [](start = 77, length = 11)

Do you have a pointer to some documentation on this URI? #Closed

}
else
{
textBlock.FontFamily = new FontFamily();
}

if (!measureOnly)
{
textBlock.Padding = new Thickness(
Expand Down