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

Font fix for WPF #944

merged 4 commits into from Jan 12, 2017

Conversation

GantMan
Copy link
Contributor

@GantMan GantMan commented Dec 28, 2016

custom fontFamily props were not working in WPF because assets are accessed differently in WPF. This PR re-arranges the string to be consumed by a URI that can properly access and set the fontFamily for text.

image

@matthargett
Copy link
Contributor

Can this be made more congruent (and/or maybe shared) with the loading of embedded resources in InitialtizeAsync() here: https://github.com/ReactWindows/react-native-windows/blob/fb60d23ea1d6434e2e394ddbd33816f65ca9b33e/ReactWindows/ReactNative.Shared/Bridge/JavaScriptBundleLoader.cs#L98
?

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

@GantMan
Copy link
Contributor Author

GantMan commented Jan 3, 2017

Scroll to "Referencing Font Resource Items from Code"
https://msdn.microsoft.com/en-us/library/ms753303(v=vs.110).aspx

There's also a corresponding stack overflow answer from similar questions.

100% transparency, I have no clue what secret knock this URI is doing. It's pretty crazy with the "tres comas" - and additional pomp. But it works.

My goal was to take any UWP friendly code and make it work for WPF

@GantMan
Copy link
Contributor Author

GantMan commented Jan 3, 2017

In addition - Leon will be using this to scan for any other asset related issues. Once we have a large list of asset problems, a more centralized solution might reveal itself.

Regardless, the fontFamily string needs to parsed differently for WPF.

@rozele
Copy link
Collaborator

rozele commented Jan 3, 2017

Could we put the MSDN reference in a comment in the code?


In reply to: 270129550 [](ancestors = 270129550)

@GantMan
Copy link
Contributor Author

GantMan commented Jan 5, 2017

@rozele - comment added.

Copy link
Contributor

@matthargett matthargett left a comment

Choose a reason for hiding this comment

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

No further review comments, and all feedback implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants