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-family per https://www.w3.org/TR/2021/WD-css-fonts-4…
  • Loading branch information
ylafon committed Sep 25, 2021
commit ba50fee68494c620ccd7fc497a413b7793ab4582
118 changes: 118 additions & 0 deletions org/w3c/css/properties/css/fontface/CssFontFamily.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
//
// 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;
import org.w3c.css.values.CssValue;

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

public CssValue value;

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

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

public CssFontFamily(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-family";
}

/**
* 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.fontFaceCssFontFamily != null) {
style.addRedefinitionWarning(ac, this);
}
s.fontFaceCssFontFamily = this;
}


/**
* Compares two properties for equality.
*
* @param property The other property.
*/
public boolean equals(CssProperty property) {
return (property instanceof CssFontFamily &&
value.equals(((CssFontFamily) 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).getFontFaceCssFontFamily();
} else {
return ((Css3Style) style).fontFaceCssFontFamily;
}
}
}

10 changes: 10 additions & 0 deletions org/w3c/css/properties/css3/Css3Style.java
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ public class Css3Style extends ATSCStyle {
public CssDescentOverride fontFaceCssDescentOverride;
public CssLineGapOverride fontFaceCssLineGapOverride;
public CssUnicodeRange fontFaceCssUnicodeRange;
public org.w3c.css.properties.css.fontface.CssFontFamily fontFaceCssFontFamily;

public CssColorAdjust cssColorAdjust;
public CssForcedColorAdjust cssForcedColorAdjust;
Expand Down Expand Up @@ -1297,6 +1298,15 @@ public org.w3c.css.properties.css.page.CssMarks getPageCssMarks() {
return pageCssMarks;
}

public org.w3c.css.properties.css.fontface.CssFontFamily getFontFaceCssFontFamily() {
if (fontFaceCssFontFamily == null) {
fontFaceCssFontFamily =
(org.w3c.css.properties.css.fontface.CssFontFamily) style.CascadingOrder(new org.w3c.css.properties.css.fontface.CssFontFamily(),
style, selector);
}
return fontFaceCssFontFamily;
}

public CssUnicodeRange getFontFaceCssUnicodeRange() {
if (fontFaceCssUnicodeRange == null) {
fontFaceCssUnicodeRange =
Expand Down
123 changes: 123 additions & 0 deletions org/w3c/css/properties/css3/fontface/CssFontFamily.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
//
// 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.CssString;
import org.w3c.css.values.CssTypes;
import org.w3c.css.values.CssValue;

import java.util.ArrayList;

import static org.w3c.css.values.CssOperator.SPACE;

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


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

/**
* Creates a new CssFontFamily
*
* @param expression The expression for this property
* @throws InvalidParamException Expressions are incorrect
*/
public CssFontFamily(ApplContext ac, CssExpression expression, boolean check)
throws InvalidParamException {
setByUser();

char op;
CssValue val;

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

switch (val.getType()) {
case CssTypes.CSS_STRING:
value = val;
if (check && expression.getCount() > 1) {
throw new InvalidParamException("unrecognize", ac);
}
break;
case CssTypes.CSS_IDENT:
// we can have multiple values here
ArrayList<CssIdent> idval = new ArrayList<CssIdent>();
idval.add(val.getIdent());
// we add idents if separated by spaces...
while (op == SPACE && expression.getRemainingCount() > 1) {
expression.next();
op = expression.getOperator();
val = expression.getValue();
if (val.getType() == CssTypes.CSS_IDENT) {
idval.add(val.getIdent());
} else {
throw new InvalidParamException("value", val,
getPropertyName(), ac);
}
}
if (op != SPACE) {
throw new InvalidParamException("operator",
Character.toString(op), ac);
}
value = checkExpression(ac, idval);
break;
default:
throw new InvalidParamException("value",
val.toString(),
getPropertyName(), ac);
}
expression.next();
}

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

private CssValue checkExpression(ApplContext ac, ArrayList<CssIdent> values)
throws InvalidParamException {
CssIdent val;
if (values.size() > 1) {
// create a value out of that. We could even create
// a CssString for the output (TODO ?)
StringBuilder sb = new StringBuilder("\"");
boolean addSpace = false;
for (CssIdent id : values) {
if (addSpace) {
sb.append(' ');
} else {
addSpace = true;
}
sb.append(id);
}
sb.append('"');
ac.getFrame().addWarning("with-space", 1);
return new CssString(sb.toString());
} else {
val = values.get(0);
// could be done in the consistency check, but...
if (null != org.w3c.css.properties.css3.CssFontFamily.getGenericFontName(val)) {
throw new InvalidParamException("value", val,
getPropertyName(), ac);
}
return val;
}
}

}