@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); }
@Override protected void encode(Font font) { putName("font-family", font.getFontFamily()); put("font-size", font.getSize()); putName("font-style", font.getStyle()); putName("font-weight", font.getWeight()); } }
/** * 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); } }
public void setEdited(Font font){ this.font = font; if(font != null){ guiFamily.setExpression(font.getFontFamily()); guiSize.setExpression(font.getFontSize()); guiStyle.setExpression(font.getFontStyle()); guiWeight.setExpression(font.getFontWeight()); } }
/** * Utility method to capture the default font in one place. * * @return */ static Font createDefault(FilterFactory filterFactory) { Font font = new FontImpl(); try { font.setSize(filterFactory.literal(Integer.valueOf(10))); font.setStyle(filterFactory.literal("normal")); font.setWeight(filterFactory.literal("normal")); font.setFontFamily(filterFactory.literal("Serif")); } catch (org.geotools.filter.IllegalFilterException ife) { throw new RuntimeException("Error creating default", ife); } return font; }
private java.awt.Font styleFont( Object feature, Font curr, java.awt.Font javaFont, TextSymbolizer symbolizer) { String reqStyle = evalToString(curr.getFontStyle(), feature, null); String reqWeight = evalToString(curr.getFontWeight(), feature, null); float size = evalToFloat(curr.getSize(), feature, 10);
if (firstFontFamily) { font.getFamily().clear(); firstFontFamily = false; font.getFamily().add(parseCssParameter(child)); } else if (res.equalsIgnoreCase("font-style")) { font.setFontStyle(parseCssParameter(child)); } else if (res.equalsIgnoreCase("font-size")) { font.setFontSize(parseCssParameter(child)); } else if (res.equalsIgnoreCase("font-weight")) { font.setFontWeight(parseCssParameter(child));
int textSize = getPositiveValue(font.getSize()); int delta = -1; if (text.getLabelPlacement() instanceof PointPlacement) {
for (Expression family : curr.getFamily()) { String requestedFont = evalToString(family, feature, null); java.awt.Font javaFont = FontCache.getDefaultInstance().getFont(requestedFont);
/** * Checks if font weight set. * * @return true, if is font name set */ public boolean isFontWeightSet() { return ((font != null) && (font.getWeight() != null)); }
/** * Checks if font style set. * * @return true, if is font name set */ public boolean isFontStyleSet() { return ((font != null) && (font.getStyle() != null)); }
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel lbl = (JLabel) super.getTableCellRendererComponent(table, text, isSelected, hasFocus, row, column); Font f = (Font) value; java.awt.Font font = new java.awt.Font(f.getFontFamily().toString(), java.awt.Font.PLAIN, 12); lbl.setFont(font); return lbl; } }
public class HeaderAndFooter extends PdfPageEventHelper { private Font footerFont; public HeaderAndFooter() { super(); footerFont = getFontObj(BaseColor.LIGHT_GRAY, 15); footerFont.setStyle(Font.ITALIC); } @Override public void onEndPage(PdfWriter writer, Document document) { PdfContentByte cb = writer.getDirectContent(); ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, new Phrase(String.format("Page %d", writer.getPageNumber()),footerFont), (document.left() + document.right())/2 , document.bottom()-20, 0); } }
f1.setSize(16);
/** * Update font. * * @param fontData the font data */ public void updateFont(Font fontData) { if ((fontData != null) && (font != null)) { if (!fontData.getFamily().isEmpty() && (!(fontData.getFamily().equals(font.getFamily())))) { font.getFamily().clear(); font.getFamily().addAll(fontData.getFamily()); } if ((fontData.getWeight() != null) && (!(fontData.getWeight().equals(font.getWeight())))) { font.setWeight(fontData.getWeight()); } if ((fontData.getStyle() != null) && (!(fontData.getStyle().equals(font.getStyle())))) { font.setStyle(fontData.getStyle()); } if ((fontData.getSize() != null) && (!(fontData.getSize().equals(font.getSize())))) { font.setSize(fontData.getSize()); } } }
/** Null safe copy of a single font */ protected Font copy(Font font) { if( font == null) return font; Expression fontFamily = copy( font.getFontFamily() ); Expression fontStyle = copy( font.getFontStyle() ); Expression fontWeight = copy( font.getFontWeight() ); Expression fontSize = copy( font.getFontSize() ); Font copy = sf.createFont(fontFamily, fontStyle, fontWeight, fontSize); return copy; }