Fields Summary |
---|
public static final int | FONT_WEIGHT_ALLValues when all the font weights are used |
public static final int | FONT_STYLE_ALLValue whena all the font styles are used |
public static final float | UNITS_PER_EM_DEFAULTDefault value for units per em |
public static final float[] | FONT_SIZE_ALLValue when all the font sizes match |
protected String[] | fontFamiliesList of font families that constitute a match |
protected int | fontStylesDescribes the styles that constitute a match for this
font. This can be a combination (or'd) of the various
FONT_STYLE_XXX values. |
protected int | fontWeightsDescribes the weights that constitute a match for this
font. This can be a combination (or'd) of the various
FONT_WEIGHT_XXX values.
The values FONT_WEIGHT_BOLDER and FONT_WEIGHT_LIGHTER
are not allowed. |
protected float[] | fontSizesFont sizes that constitute a match for this font during
font selection. A null value means that all font-sizes
can be matched by this font |
protected float | unitsPerEmNumber of coordinate units on the em square.
Defaults to 1000. |
protected Font | fontParent Font |
protected float | emSquareScaleThe main scale factor needed to convert from the em square
grid to the text's current position coordinate system.
The transform built from the returned value is:
scale 0 0
0 -scale 0
0 0 1
|
Methods Summary |
---|
Glyph | canDisplay(char[] s, int index)
return font.canDisplay(s, index);
|
protected void | computeEmSquareScale()Computes the scale that should be applied to glyphs to
transform glyph coordinates into the text coordiate system.
// The number of units per em defines the number of
// units in 1x1 em square grid. Hence, the 1/unitsPerEm
// scale factor.
// The Y axis points up for the em square grid, which
// is why the Y axis scale is negative.
emSquareScale = 1f / unitsPerEm;
|
public int | fontWeightDistance(int refFontWeight)The distance between the input refFontWeight and this
FontFace's fontWeights
// This FontFace matches all, this is a zero distance
if (fontWeights == FONT_WEIGHT_ALL) {
return 0;
}
// This FontFace matches the requested fontWeight,
// this is a zero distance.
if ((fontWeights & refFontWeight) != 0) {
return 0;
}
// The requested fontWeight is not part of the ones
// matching exactly this FontFace. Compute how far is
// the closes match.
int dA = fontWeights;
int i = 0;
while ((dA & 0x01) == 0) {
dA >>= 1;
i++;
}
dA = i;
i = 0;
int curD = 100; // Infinity in this algorithm
int d = 100;
for (i = 0; i < 9; i++) {
if (((refFontWeight >> i) & 0x01) != 0) {
d = (dA - i) * (dA - i);
if (d < curD) {
curD = d;
}
}
}
return curD;
|
public float | getEmSquareScale()
return emSquareScale;
|
public java.lang.String[] | getFontFamilies()
return fontFamilies;
|
public float[] | getFontSizes()
return fontSizes;
|
public int | getFontStyles()
return fontStyles;
|
public int | getFontWeights()
return fontWeights;
|
public java.lang.String | getLocalName()
return SVGConstants.SVG_FONT_FACE_TAG;
|
Glyph | getMissingGlyph()
return font.getMissingGlyph();
|
public java.lang.String | getTraitImpl(java.lang.String name)FontFace handles the font-family, font-style, font-weight, font-size,
and unitsPerEm attributes.
Other traits are handled by the super class.
if (SVGConstants.SVG_FONT_FAMILY_ATTRIBUTE == name) {
return toStringTraitQuote(getFontFamilies());
} else if (SVGConstants.SVG_FONT_STYLE_ATTRIBUTE == name) {
return fontStylesToStringTrait(getFontStyles());
} else if (SVGConstants.SVG_FONT_WEIGHT_ATTRIBUTE == name) {
return fontWeightsToStringTrait(getFontWeights());
} else if (SVGConstants.SVG_FONT_SIZE_ATTRIBUTE == name) {
if (getFontSizes() == FONT_SIZE_ALL) {
return SVGConstants.CSS_ALL_VALUE;
}
return toStringTrait(getFontSizes());
} else if (SVGConstants.SVG_UNITS_PER_EM_ATTRIBUTE == name) {
return Float.toString(getUnitsPerEm());
} else {
return super.getTraitImpl(name);
}
|
public float | getUnitsPerEm()
return unitsPerEm;
|
public ElementNode | newInstance(DocumentNode doc)Used by DocumentNode to create a new instance from
a prototype FontFace .
return new FontFace(doc);
|
public void | setFontFamilies(java.lang.String[] newFontFamilies)
if (equal(fontFamilies, newFontFamilies)) {
return;
}
modifyingNode();
this.fontFamilies = newFontFamilies;
modifiedNode();
|
public void | setFontSizes(float[] newFontSizes)
if (equal(newFontSizes, fontSizes)) {
return;
}
modifyingNode();
this.fontSizes = newFontSizes;
modifiedNode();
|
public void | setFontStyles(int newFontStyles)
if (newFontStyles == fontStyles) {
return;
}
modifyingNode();
this.fontStyles = newFontStyles;
modifiedNode();
|
public void | setFontWeights(int newFontWeights)
if (newFontWeights == fontWeights) {
return;
}
modifyingNode();
this.fontWeights = newFontWeights;
modifiedNode();
|
public void | setParent(ModelNode parent)If the parent is a Font object, keep track of it in the
font member.
super.setParent(parent);
if (parent instanceof Font) {
this.font = (Font) parent;
} else {
this.font = null;
}
|
public void | setTraitImpl(java.lang.String name, java.lang.String value)FontFace handles the font-family, font-style, font-weight, font-size,
and unitsPerEm attributes.
Other traits are handled by the super class.
if (SVGConstants.SVG_FONT_FAMILY_ATTRIBUTE == name) {
checkWriteLoading(name);
setFontFamilies(parseFontFamilyTrait(name, value));
} else if (SVGConstants.SVG_FONT_STYLE_ATTRIBUTE == name) {
checkWriteLoading(name);
setFontStyles(parseFontStylesTrait(name, value));
} else if (SVGConstants.SVG_FONT_WEIGHT_ATTRIBUTE == name) {
checkWriteLoading(name);
setFontWeights(parseFontWeightsTrait(name, value));
} else if (SVGConstants.SVG_FONT_SIZE_ATTRIBUTE == name) {
checkWriteLoading(name);
if (SVGConstants.CSS_ALL_VALUE.equals(value)) {
setFontSizes(FONT_SIZE_ALL);
} else {
setFontSizes(parseFloatArrayTrait(name, value));
}
} else if (SVGConstants.SVG_UNITS_PER_EM_ATTRIBUTE == name) {
checkWriteLoading(name);
setUnitsPerEm(parseFloatTrait(name, value));
} else {
super.setTraitImpl(name, value);
}
|
public void | setUnitsPerEm(float newUnitsPerEm)
if (newUnitsPerEm == unitsPerEm) {
return;
}
modifyingNode();
this.unitsPerEm = newUnitsPerEm;
computeEmSquareScale();
modifiedNode();
|
boolean | supportsTrait(java.lang.String traitName)FontFace handles the font-family, font-style, font-weight, font-size,
and unitsPerEm attributes.
if (SVGConstants.SVG_FONT_FAMILY_ATTRIBUTE == traitName
||
SVGConstants.SVG_FONT_STYLE_ATTRIBUTE == traitName
||
SVGConstants.SVG_FONT_WEIGHT_ATTRIBUTE == traitName
||
SVGConstants.SVG_FONT_SIZE_ATTRIBUTE == traitName
||
SVGConstants.SVG_UNITS_PER_EM_ATTRIBUTE == traitName) {
return true;
}
return super.supportsTrait(traitName);
|