private Font getFontForCharacter(char c) { for(Font font: fontPriority) { if(font.canDisplay(c)) { return font; } } //No available font here, what to do...? return fontPriority.get(0); }
for (int i = 0; i < fonts.length; i++) { Font font = fonts[i]; if (font.canDisplay(curr)) { foundFont = true; result.add(new FontRange(text, base, start, fonts[0]));
private static int nextPart(Font fontMapped, String runText, int beginPart, int endPart, boolean isDisplayed) { int rIdx = beginPart; while (rIdx < endPart) { int codepoint = runText.codePointAt(rIdx); if (fontMapped.canDisplay(codepoint) != isDisplayed) { break; } rIdx += Character.charCount(codepoint); } return rIdx; }
/** * @noinspection ALL */ private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { if (currentFont == null) return null; String resultName; if (fontName == null) { resultName = currentFont.getName(); } else { Font testFont = new Font(fontName, Font.PLAIN, 10); if (testFont.canDisplay('a') && testFont.canDisplay('1')) { resultName = fontName; } else { resultName = currentFont.getName(); } } return new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); }
@Signature public boolean canDisplay(char ch) { return getFont().canDisplay(ch); }
isMissing = !unicodeFont.getFont().canDisplay((char)codePoint);
isMissing = !unicodeFont.getFont().canDisplay((char)codePoint);
if (font.canDisplay(i)) System.out.println(((int) i) + ": " + Long.toHexString(i)); GlyphVector textGlyphVector = font.createGlyphVector(FONT_RENDER_CONTEXT, new char[] {,}); Shape shape = textGlyphVector.getOutline();
private Shape getShape(String fontFamilyName, char character) { Font font = FontCache.getDefaultInstance().getFont(fontFamilyName); if (font == null) { throw new IllegalArgumentException("Unknown font " + fontFamilyName); } // handle charmap code reporting issues if (!font.canDisplay(character)) { char alternative = (char) (0xF000 | character); if (font.canDisplay(alternative)) { character = alternative; } } // build the shape out of the font GlyphVector textGlyphVector = font.createGlyphVector(FONT_RENDER_CONTEXT, new char[] {(char) character}); Shape s = textGlyphVector.getOutline(); // have the shape be centered in the origin, and sitting in a square of side 1 Rectangle2D bounds = s.getBounds2D(); AffineTransform tx = new AffineTransform(); double max = Math.max(bounds.getWidth(), bounds.getHeight()); // all shapes are defined looking "upwards" (see ShapeMarkFactory or WellKnownMarkFactory) // but the fonts ones are flipped to compensate for the fact the y coords grow from top // to bottom on the screen. We have to flip the symbol so that it conforms to the // other marks convention tx.scale(1 / max, -1 / max); tx.translate(-bounds.getCenterX(), -bounds.getCenterY()); ExplicitBoundsShape shape = new ExplicitBoundsShape(tx.createTransformedShape(s)); shape.setBounds(new Rectangle2D.Double(-0.5, 0.5, 1.0, 1.0)); return shape; }
@Override public int canDisplayUpTo(char[] str, int start, int limit) { for (int i = start; i < limit; i++) { if (!this.baseFont.canDisplay(str[i])) return i; } return -1; }
/** * Checks if this font can display the specified character. * * @param c The character to check. * @return Whether or not the character can be displayed. */ public boolean canDisplay(char c) { return awtFont.canDisplay(c); }
final Font f = new Font(...); for (char c = 0x0000; c <= 0xFFFF; c++) { if (f.canDisplay(c)) { // draw it ... } }
private Font getFontForCharacter(char c) { for(Font font: fontPriority) { if(font.canDisplay(c)) { return font; } } //No available font here, what to do...? return fontPriority.get(0); }
@Override public int canDisplayUpTo(String str) { for (int i = 0; i < str.length(); i++) { if (!this.baseFont.canDisplay(str.charAt(i))) return i; } return -1; }
/** {@inheritDoc} */ @Override public boolean canDisplay(char c) { return super.canDisplay(c) || backingFont.canDisplay(c); }
/** {@inheritDoc} */ @Override public boolean canDisplay(int codePoint) { return super.canDisplay(codePoint) || backingFont.canDisplay(codePoint); }
Font font = Font.createFont(int fontFormat, File fontFile) /(int fontFormat, InputStream fontStream) GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); ge.registerFont(font); if (font.canDisplay()/canDisplayUpTo()){ //your code with font..... }
@NotNull protected static String spaceAndThinSpace() { String thinSpace = UIUtil.getLabelFont().canDisplay('\u2009') ? String.valueOf('\u2009') : " "; return " " + thinSpace; }
/** * Indicates whether the font contains a particular character/glyph. * @param family font family (jave name) to use * @param style font style (jave def.) to use * @param size font size * @param c the glyph to check * @return true if the character is supported */ public boolean hasChar(String family, int style, int size, char c) { setFont(family, style, size); return f1.canDisplay(c); }
private double getSmallThrehold(Font font){ if(font.canDisplay('A')){ return font.getLineMetrics("A",context).getAscent()/3; } return 0; } private boolean isSmall(int c,Font font,double threhold){