for (Expression family : curr.getFamily()) { String requestedFont = evalToString(family, feature, null); java.awt.Font javaFont = FontCache.getDefaultInstance().getFont(requestedFont);
for (Expression family : selectedFont.getFamily()) { String familyName = ((Literal) family).getValue().toString(); for (int index = 0; index < families.length; index++) {
/** Null safe copy of a single font */ protected Font copy(Font font) { if (font == null) return font; List<Expression> fontFamily = copyExpressions(font.getFamily()); Expression fontStyle = copy(font.getStyle()); Expression fontWeight = copy(font.getWeight()); Expression fontSize = copy(font.getSize()); Font copy = sf.font(fontFamily, fontStyle, fontWeight, fontSize); return copy; }
/** * Checks if font name set. * * @return true, if is font name set */ public boolean isFontNameSet() { return ((font != null) && !font.getFamily().isEmpty()); }
/** * Checks if is font name updated. * * @return the fontNameUpdated */ public boolean isFontNameUpdated() { return ((font != null) && !(originalFontName.equals(font.getFamily()))); }
/** * Gets the font name. * * @return the fontName */ public String getFontName() { if (isFontNameSet()) { return this.font.getFamily().get(0).toString(); } return NOT_SET_STRING; }
@SuppressWarnings("deprecation") @Test public void font() throws Exception { List<Expression> family = new ArrayList<Expression>(); family.add(ff.literal("ariel")); family.add(ff.literal("Helvetica")); family.add(ff.literal("sanserif")); Expression style = ff.literal("noraml"); Expression weight = ff.literal("normal"); Expression size = ff.literal(12); Font font = sf.font(family, style, weight, size); assertEquals(family, font.getFamily()); assertEquals(style, font.getStyle()); // oblique or italic assertEquals(weight, font.getWeight()); // bold or normal assertEquals(size, font.getSize()); assertSame(font.getFontStyle(), font.getStyle()); assertSame(font.getFontFamily(), family.get(0)); assertSame(font.getFontWeight(), font.getWeight()); assertSame(font.getFontSize(), font.getSize()); FontImpl cast = FontImpl.cast(font); assertSame(cast, font); }
/** * Sets the font. * * @param newFont the new font */ public void setFont(Font newFont) { if (newFont != null) { this.font = styleFactory.getDefaultFont(); font.getFamily().clear(); font.getFamily().addAll(newFont.getFamily()); font.setStyle(newFont.getStyle()); font.setWeight(newFont.getWeight()); font.setSize(newFont.getSize()); setOriginalData(newFont); } }
/** * Sets the original data. * * @param newFont the new original data */ private void setOriginalData(Font newFont) { this.originalFontName = newFont.getFamily(); this.originalFontStyle = newFont.getStyle(); this.originalFontWeight = newFont.getWeight(); this.originalFontSize = newFont.getSize(); }
/** * Gets the font. * * @return the font */ public Font getFont() { List<Expression> family = new ArrayList<>(); Expression style = null; Expression weight = null; Expression size = null; if (firstEntry != null) { family = (familyMultipleValue ? firstEntry.getFamily() : family); style = (styleMultipleValue ? firstEntry.getStyle() : null); weight = (weightMultipleValue ? firstEntry.getWeight() : null); size = (sizeMultipleValue ? firstEntry.getSize() : null); } return styleFactory.font(family, style, weight, size); } }
assertEquals("Arial", Filters.asString(font.getFamily().get(0))); assertEquals(12, Filters.asInt(font.getSize())); assertEquals("bold", Filters.asString(font.getWeight()));
assertEquals("Arial", Filters.asString(font.getFamily().get(0))); assertEquals(12, Filters.asInt(font.getSize())); assertEquals("bold", Filters.asString(font.getWeight()));