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

In PrimitivePropertyBuilder.Src -> try to narrow down the PropertyValue list to a single value. This allow to link directly a google font css #423

Closed
wants to merge 1 commit into from

Conversation

syjer
Copy link
Contributor

@syjer syjer commented Dec 5, 2019

Hi @danfickle , looking at the issue #422 I was wondering why it skipped totally the src property in the following declaration:

@font-face {
  font-family: 'PT Sans';
  font-style: normal;
  font-weight: 400;
  src: local('PT Sans'), local('PTSans-Regular'), url(https://fonts.gstatic.com/s/ptsans/v11/jizaRExUiTo99u79D0KEwA.ttf) format('truetype');
}

It looks like GenericURIWithNone (which Src extends) accept only a list with a single element, thus ignoring the src declaration.

Adding a logic to get the first matching element which is not a unknown css type seems to be a decent heuristic.

As you can see from the test, you can now simply link a css from google fonts and it will work!

WDYT? :)

EDIT: by the way, I've noticed CSSParser & co is not fully generified (lot of raw List parameters/types), are you interested in a small cleanup of that class? I think I can provide a PR :D

…to a single value. This allow to link directly a google font css
@syjer syjer changed the title In PrimitivePropertyBuilder.Src -> try to narrow down the value listto a single value. This allow to link directly a google font css In PrimitivePropertyBuilder.Src -> try to narrow down the PropertyValue list to a single value. This allow to link directly a google font css Dec 5, 2019
danfickle added a commit that referenced this pull request Dec 9, 2019
Also, IDE fixes, such as removing unneeded casts and adding override annotation. In preparation of working on #423
danfickle added a commit that referenced this pull request Dec 9, 2019
with format tags. We select the truetype font. This allows some Google font stylesheets to be used (where a truetype font is provided), however, consider the network load issue if running a template multiple times.

With tests for:
+ Simple uri which was previously all we supported.
+ Multiple uris/local with format tags.
+ Import of google CSS font sheet (manual test to avoid network load on each test run).
@danfickle
Copy link
Owner

Hi @syjer,

Thanks for the effort on this. However, I haven't used it directly as I thought it could be made a bit more robust by checking the format tag after the uri.

Also, I'm trying to minimise network loads in the tests because my mac is getting slower and slower running them. On this note, could you please consider, when making a test using the @page size property to size the page as small as possible (to fit the test). This means less pixels to compare.

Thanks again,
Daniel.

@danfickle danfickle closed this Dec 9, 2019
@syjer
Copy link
Contributor Author

syjer commented Dec 9, 2019

@danfickle thank you for taking care of it :) I agree with your changes.

On this note, could you please consider, when making a test using the @page size property to size the page as small as possible (to fit the test). This means less pixels to compare.

Sure, I didn't know about this issue at all 👍

@syjer syjer deleted the better-google-fonts-support branch December 9, 2019 12:19
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.

2 participants