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

Relative path support for embedded fonts #2145

Merged

Conversation

Projects
None yet
3 participants
@Gillibald
Copy link
Contributor

Gillibald commented Nov 28, 2018

  • What does the pull request do?
    FontFamily now supports relative URIs in XAML markup.
  • What is the current behavior?
    Currently, only absolute URIs are supported.
  • What is the updated/expected behavior with this PR?
    You can define FontFamily in XAML like you define any other asset.
  • How was the solution implemented (if it's not obvious)?
    FontFamilyKey now holds a BaseUri that is used to resolve a relative path.

Gillibald added some commits Nov 26, 2018

@@ -112,7 +114,13 @@ public static FontFamily Parse(string s)

case 2:
{
return new FontFamily(segments[1], new Uri(segments[0], UriKind.RelativeOrAbsolute));
var uri = segments[0].StartsWith("/")

This comment has been minimized.

Copy link
@kekekeks

kekekeks Nov 28, 2018

Member

We probably need some kind of Uri parsing helper to be used in converters since new Uri(string) misbehaves on Linux by trying to parse /some/path as a file Uri. It would be nicer to have that logic in one place.


return uri.IsAbsoluteUri
? new FontFamily(segments[1], uri)
: new FontFamily(segments[1], uri, baseUri);

This comment has been minimized.

Copy link
@kekekeks

kekekeks Nov 28, 2018

Member

It should be safe to always pass baseUri, since AssetLoader detects uri kind internally.

This comment has been minimized.

Copy link
@Gillibald

Gillibald Nov 28, 2018

Author Contributor

I am not sure if that is the case. I do not want to store the base uri when the path is absolute.

@@ -12,48 +11,26 @@ namespace Avalonia.Media.Fonts
public class FontFamilyKey

This comment has been minimized.

Copy link
@kekekeks

kekekeks Nov 28, 2018

Member

Does it have to be a class? There is a lot of boilerplate for comparison and GetHashCode. Another approach would be to use Equals.Fody

This comment has been minimized.

Copy link
@Gillibald

Gillibald Nov 28, 2018

Author Contributor

Just felt cleaner when I introduced this. I am fine with refactoring. The current solution isn't too much code I think.

Show resolved Hide resolved src/Avalonia.Visuals/Media/Fonts/FontFamilyLoader.cs Outdated

@kekekeks kekekeks merged commit 7fc8ced into AvaloniaUI:master Nov 28, 2018

@grokys grokys added this to the 0.8.0 milestone Apr 3, 2019

@Gillibald Gillibald deleted the Gillibald:feature/RelativePathEmbeddedFonts branch Apr 6, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.