Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4f6f6aa
@ font-face font-weight descriptor per https://www.w3.org/TR/2021/WD-…
ylafon Sep 13, 2021
b5cb6e5
fix the 'auto' single value case
ylafon Sep 13, 2021
dd5021b
@​font-face font-stretch descriptor per https://www.w3.org/TR/2021/WD…
ylafon Sep 13, 2021
cddac56
forgot number check...
ylafon Sep 13, 2021
2937875
@​font-face font-style descriptor per https://www.w3.org/TR/2021/WD-c…
ylafon Sep 13, 2021
9a7a5f6
@ font-face font-weight descriptor per https://www.w3.org/TR/2021/WD-…
ylafon Sep 13, 2021
dc1f3f5
fix the 'auto' single value case
ylafon Sep 13, 2021
614ae37
@​font-face font-stretch descriptor per https://www.w3.org/TR/2021/WD…
ylafon Sep 13, 2021
a333b54
forgot number check...
ylafon Sep 13, 2021
e00ae04
@​font-face font-style descriptor per https://www.w3.org/TR/2021/WD-c…
ylafon Sep 13, 2021
0371dc7
Merge branch 'font-face-4' of github.com:w3c/css-validator into font-…
ylafon Sep 20, 2021
4d03595
@ font-face font-weight descriptor per https://www.w3.org/TR/2021/WD-…
ylafon Sep 13, 2021
7c94d60
fix the 'auto' single value case
ylafon Sep 13, 2021
5534c15
@​font-face font-stretch descriptor per https://www.w3.org/TR/2021/WD…
ylafon Sep 13, 2021
98a78be
forgot number check...
ylafon Sep 13, 2021
4a0040c
@​font-face font-style descriptor per https://www.w3.org/TR/2021/WD-c…
ylafon Sep 13, 2021
4055d67
Merge branch 'font-face-4' of github.com:w3c/css-validator into font-…
ylafon Sep 24, 2021
122e3d5
@​font-face font-named-instance per https://www.w3.org/TR/2021/WD-css…
ylafon Sep 24, 2021
f1b1587
@​font-face ascent-override per https://www.w3.org/TR/2021/WD-css-fon…
ylafon Sep 25, 2021
00e961d
@​font-face descent-override per https://www.w3.org/TR/2021/WD-css-fo…
ylafon Sep 25, 2021
1608148
@​font-face line-gap-override per https://www.w3.org/TR/2021/WD-css-f…
ylafon Sep 25, 2021
3615cac
@​font-face unicode-range per https://www.w3.org/TR/2021/WD-css-fonts…
ylafon Sep 25, 2021
b11e994
@​font-face font-language-override per https://www.w3.org/TR/2021/WD-…
ylafon Sep 25, 2021
ba50fee
@​font-face font-family per https://www.w3.org/TR/2021/WD-css-fonts-4…
ylafon Sep 25, 2021
aecdbb0
@​font-face font-feature-settings per https://www.w3.org/TR/2021/WD-c…
ylafon Sep 25, 2021
f54ccbe
set ident check to public to be reused in fontface
ylafon Sep 25, 2021
cb6c2a8
@​font-face font-variation-settings per https://www.w3.org/TR/2021/WD…
ylafon Sep 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
@​font-face font-style descriptor per https://www.w3.org/TR/2021/WD-c…
  • Loading branch information
ylafon committed Sep 24, 2021
commit 4a0040cf1409306c3eae20b97044edc0e8936848
4 changes: 2 additions & 2 deletions org/w3c/css/properties/CSS3Properties.properties
Original file line number Diff line number Diff line change
Expand Up @@ -516,12 +516,12 @@ lighting-color: org.w3c.css.properties.css3.CssLightingC
@font-face.definition-src: org.w3c.css.properties.css2.font.DefinitionSrc
@font-face.mathline: org.w3c.css.properties.css2.font.Mathline
@font-face.topline: org.w3c.css.properties.css2.font.Topline
@font-face.font-style: org.w3c.css.properties.css2.font.FontStyle
@font-face.font-style: org.w3c.css.properties.css3.fontface.CssFontStyle
@font-face.font-variant: org.w3c.css.properties.css2.font.FontVariant
@font-face.font-weight: org.w3c.css.properties.css3.fontface.CssFontWeight
@font-face.font-size: org.w3c.css.properties.css2.font.FontSize
@font-face.font-family: org.w3c.css.properties.css2.font.FontFamily
@font-face.font-stretch: org.w3c.css.properties.css3.fontface.CssFontStretch\
@font-face.font-stretch: org.w3c.css.properties.css3.fontface.CssFontStretch
@font-face.font-display: org.w3c.css.properties.css3.fontface.CssFontDisplay

// mediafeatures
Expand Down
113 changes: 113 additions & 0 deletions org/w3c/css/properties/css/fontface/CssFontStyle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
//
// Author: Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2021.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css.fontface;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css.CssProperty;
import org.w3c.css.properties.css3.Css3Style;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;

/**
* @since CSS3
*/
public class CssFontStyle extends CssProperty {

/**
* Create a new CssFontStyle
*/
public CssFontStyle() {
}

/**
* Creates a new CssFontStyle
*
* @param expression The expression for this property
* @throws InvalidParamException Expressions are incorrect
*/
public CssFontStyle(ApplContext ac, CssExpression expression, boolean check)
throws InvalidParamException {
throw new InvalidParamException("value",
expression.getValue().toString(),
getPropertyName(), ac);
}

public CssFontStyle(ApplContext ac, CssExpression expression)
throws InvalidParamException {
this(ac, expression, false);
}

/**
* Returns the value of this property
*/
public Object get() {
return value;
}


/**
* Returns the name of this property
*/
public final String getPropertyName() {
return "font-style";
}

/**
* Returns true if this property is "softly" inherited
* e.g. his value is equals to inherit
*/
public boolean isSoftlyInherited() {
return value.equals(inherit);
}

/**
* Returns a string representation of the object.
*/
public String toString() {
return value.toString();
}

/**
* Add this property to the CssStyle.
*
* @param style The CssStyle
*/
public void addToStyle(ApplContext ac, CssStyle style) {
Css3Style s = (Css3Style) style;
if (s.fontFaceCssFontStyle != null) {
style.addRedefinitionWarning(ac, this);
}
s.fontFaceCssFontStyle = this;
}


/**
* Compares two properties for equality.
*
* @param property The other property.
*/
public boolean equals(CssProperty property) {
return (property instanceof CssFontStyle &&
value.equals(property.value));
}


/**
* Get this property in the style.
*
* @param style The style where the property is
* @param resolve if true, resolve the style to find this property
*/
public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
if (resolve) {
return ((Css3Style) style).getFontFaceCssFontStyle();
} else {
return ((Css3Style) style).fontFaceCssFontStyle;
}
}
}

11 changes: 11 additions & 0 deletions org/w3c/css/properties/css3/Css3Style.java
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@
import org.w3c.css.properties.css.counterstyle.CssSystem;
import org.w3c.css.properties.css.fontface.CssFontDisplay;
import org.w3c.css.properties.css.fontface.CssFontStretch;
import org.w3c.css.properties.css.fontface.CssFontStyle;
import org.w3c.css.properties.css.fontface.CssFontWeight;
import org.w3c.css.properties.css.viewport.CssMaxZoom;
import org.w3c.css.properties.css.viewport.CssMinZoom;
Expand Down Expand Up @@ -582,6 +583,7 @@ public class Css3Style extends ATSCStyle {
public CssFontDisplay fontFaceCssFontDisplay;
public CssFontWeight fontFaceCssFontWeight;
public CssFontStretch fontFaceCssFontStretch;
public CssFontStyle fontFaceCssFontStyle;

public CssColorAdjust cssColorAdjust;
public CssForcedColorAdjust cssForcedColorAdjust;
Expand Down Expand Up @@ -1301,6 +1303,15 @@ public CssFontStretch getFontFaceCssFontStretch() {
}
return fontFaceCssFontStretch;
}

public CssFontStyle getFontFaceCssFontStyle() {
if (fontFaceCssFontStyle == null) {
fontFaceCssFontStyle =
(CssFontStyle) style.CascadingOrder(new CssFontStyle(),
style, selector);
}
return fontFaceCssFontStyle;
}

public CssFontWeight getFontFaceCssFontWeight() {
if (fontFaceCssFontWeight == null) {
Expand Down
2 changes: 1 addition & 1 deletion org/w3c/css/properties/css3/CssFontStyle.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class CssFontStyle extends org.w3c.css.properties.css.CssFontStyle {

static final String[] _allowed_values = {"italic", "normal", "oblique"};
static final ArrayList<CssIdent> allowed_values;
static final CssIdent oblique = CssIdent.getIdent("oblique");
static public final CssIdent oblique = CssIdent.getIdent("oblique");

static {
allowed_values = new ArrayList<CssIdent>(_allowed_values.length);
Expand Down
121 changes: 121 additions & 0 deletions org/w3c/css/properties/css3/fontface/CssFontStyle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
//
// Author: Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2018.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css3.fontface;

import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssIdent;
import org.w3c.css.values.CssTypes;
import org.w3c.css.values.CssValue;
import org.w3c.css.values.CssValueList;

import java.util.ArrayList;

import static org.w3c.css.properties.css3.CssFontStyle.getMatchingIdent;
import static org.w3c.css.properties.css3.CssFontStyle.oblique;
import static org.w3c.css.values.CssOperator.SPACE;

/**
* @spec https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/#descdef-font-face-font-style
* @see org.w3c.css.properties.css3.CssFontStyle
*/
public class CssFontStyle extends org.w3c.css.properties.css.fontface.CssFontStyle {

public static final CssIdent auto = CssIdent.getIdent("auto");

/**
* Create a new CssFontStyle
*/
public CssFontStyle() {
value = initial;
}

/**
* Creates a new CssFontStyle
*
* @param expression The expression for this property
* @throws InvalidParamException Expressions are incorrect
*/
public CssFontStyle(ApplContext ac, CssExpression expression, boolean check)
throws InvalidParamException {
if (check && expression.getCount() > 3) {
throw new InvalidParamException("unrecognize", ac);
}

setByUser();

char op;
CssValue val;
ArrayList<CssValue> values = new ArrayList<>();

val = expression.getValue();
op = expression.getOperator();

switch (val.getType()) {
case CssTypes.CSS_IDENT:
CssIdent id = val.getIdent();
if (auto.equals(id)) {
if (expression.getCount() > 1) {
throw new InvalidParamException("unrecognize", ac);
}
value = val;
expression.next();
break;
}
if (getMatchingIdent(id) != null) {
if (oblique.equals(id)) {
values.add(val);
// check for extra angle values
expression.next();
while (!expression.end()) {
if (op != SPACE) {
throw new InvalidParamException("operator",
Character.toString(op), ac);
}
val = expression.getValue();
op = expression.getOperator();
if (val.getType() != CssTypes.CSS_ANGLE) {
throw new InvalidParamException("value",
val.toString(),
getPropertyName(), ac);
}
values.add(val);
expression.next();
}
if (values.size() > 3) {
throw new InvalidParamException("value",
values.get(values.size() - 1).toString(),
getPropertyName(), ac);
}
value = new CssValueList(values);
} else {
// single value
if (expression.getCount() > 1) {
throw new InvalidParamException("value",
val.toString(),
getPropertyName(), ac);
}
value = val;
expression.next();
}
break;
}
default:
throw new InvalidParamException("value",
val.toString(),
getPropertyName(), ac);
}

}

public CssFontStyle(ApplContext ac, CssExpression expression)
throws InvalidParamException {
this(ac, expression, false);
}

}