Coder Social home page Coder Social logo

Comments (10)

carmelc avatar carmelc commented on May 29, 2024 1

I guess that it is simply because they define font without the option to define a font-stretch,
See https://www.w3schools.com/cssref/pr_font_font.asp, w3schools defines the structure as:

The font property is a shorthand property for:

  • font-style
  • font-variant
  • font-weight
  • font-size/line-height
  • font-family

I am usually considering MDN as a more reliable source, either case, the logic in question should be removed.
Let me know if you are OK with that and I will remove the check, the props are already defaulted to 'normal'.

from parse-css-font.

jednano avatar jednano commented on May 29, 2024
  1. This appears to be a bug.
  2. I agree that I should keep track of which tokens are already set and filter them out.
  3. The logic around this check is the following formal syntax: [ <'font-style'> || <font-variant-css21> || <'font-weight'> || <'font-stretch'> ]?. The || operator combined with ? instead of * threw me off, misleading me into thinking that only one could be supplied, without repetition.

I'm still quite confused, in fact, because the following CSS doesn't validate:

p {
  font: italic small-caps bold expanded 18px/1.4em "open sans", sans-serif;
}

It seems to have a problem with the font-stretch: expanded part.

Do you have a more human way to interpret how this portion of the formal syntax should operate?

from parse-css-font.

carmelc avatar carmelc commented on May 29, 2024

What do you mean by a problem with expanded? this is a valid font,
The part which is confusing in MDN is that each part is optional, but the order is important.
I am thinking that maybe you can remove this part altogether and just default these attributes to "normal",
WDYT?

from parse-css-font.

jednano avatar jednano commented on May 29, 2024

expanded is a valid font-stretch, but it doesn't validate via The W3C CSS Validation Service.

I don't want to guess anything here, so I'm afraid I'm still not 100% comfortable with a solution.

Anyone out there know more about how this works or why my example above is failing CSS validation?

from parse-css-font.

jednano avatar jednano commented on May 29, 2024

from parse-css-font.

carmelc avatar carmelc commented on May 29, 2024

I think that it is the other way around, that MDN is correct.
I tested in a browser and font-stretch is supported, so it seems that W3schools are missing this props and the error is on their side.

from parse-css-font.

jednano avatar jednano commented on May 29, 2024

Not just W3schools but the W3C validation service is missing it as well. That's what's so disconcerting!

from parse-css-font.

jednano avatar jednano commented on May 29, 2024

https://codepen.io/jedmao/pen/omxqbv

  • Chrome and Firefox both parse the shorthand and convert the font-stretch into 125%.
  • Microsoft Edge does not parse the font shorthand and doesn't even set the font size or anything else as a result of the "error" unless I remove expanded.

I think it's safe to say that this package should support the font-stretch.

from parse-css-font.

carmelc avatar carmelc commented on May 29, 2024

According to https://drafts.csswg.org/css-fonts-3/#propdef-font there is a forth property font-strech,
according to https://www.w3.org/TR/CSS2/fonts.html#font-shorthand there isn't, but there is a disclaimer at the bottom that this is not the most up to date, and "Cascading Style Sheets (CSS) — The Official Definition" should be used, So I am guessing that the package should support it.
So do we agree that the logic mentioned at the begining of the thread should be removed?

from parse-css-font.

jednano avatar jednano commented on May 29, 2024

I'm not sure if removed is the right solution. I think it needs to be changed. First step is to submit a PR with breaking tests.

from parse-css-font.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.