Java Code Examples for java.awt.font.GlyphVector#getGlyphCode()
The following examples show how to use
java.awt.font.GlyphVector#getGlyphCode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GlyphVectorSerializationWrapper.java From pumpernickel with MIT License | 6 votes |
public GlyphElement(GlyphVector gv, int index) { glyphCode = gv.getGlyphCode(index); transform = gv.getGlyphTransform(index); outline = new ShapeSerializationWrapper(gv.getGlyphOutline(index)); position = new Point2DSerializationWrapper( gv.getGlyphPosition(index)); logicalBounds = new ShapeSerializationWrapper( gv.getGlyphLogicalBounds(index)); GlyphJustificationInfo gji = gv.getGlyphJustificationInfo(index); justificationInfo = gji == null ? null : new GlyphJustificationInfoSerializationWrapper(gji); glyphMetrics = new GlyphMetricsSerializationWrapper( gv.getGlyphMetrics(index)); visualBounds = new ShapeSerializationWrapper( gv.getGlyphVisualBounds(index)); }
Example 2
Source File: FontDetails.java From itext2 with GNU Lesser General Public License v3.0 | 5 votes |
byte[] convertToBytes(GlyphVector glyphVector) { if (fontType != BaseFont.FONT_TYPE_TTUNI || symbolic) { throw new UnsupportedOperationException("Only supported for True Type Unicode fonts"); } char[] glyphs = new char[glyphVector.getNumGlyphs()]; int glyphCount = 0; for (int i = 0; i < glyphs.length; i++) { int code = glyphVector.getGlyphCode(i); if (code == 0xFFFE || code == 0xFFFF) {// considered non-glyphs by // AWT continue; } glyphs[glyphCount++] = (char) code;// FIXME supplementary plane? Integer codeKey = Integer.valueOf(code); if (!longTag.containsKey(codeKey)) { int glyphWidth = ttu.getGlyphWidth(code); Integer charCode = ttu.getCharacterCode(code); int[] metrics = charCode != null ? new int[] { code, glyphWidth, charCode.intValue() } : new int[] { code, glyphWidth }; longTag.put(codeKey, metrics); } } String s = new String(glyphs, 0, glyphCount); try { byte[] b = s.getBytes(CJKFont.CJK_ENCODING); return b; } catch (UnsupportedEncodingException e) { throw new ExceptionConverter(e); } }
Example 3
Source File: FontKerningFuncTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testKerning () throws IOException { if (EOperatingSystem.getCurrentOS ().isWindowsBased ()) { // required to get graphics up and running... GraphicsEnvironment.getLocalGraphicsEnvironment (); final int nFontSize = 25; final ICommonsMap <TextAttribute, Object> aTextAttributes = new CommonsHashMap <> (); aTextAttributes.put (TextAttribute.FAMILY, "Arial"); aTextAttributes.put (TextAttribute.SIZE, Float.valueOf (nFontSize)); final Font aFont = Font.getFont (aTextAttributes); final char [] aChars = "T,".toCharArray (); final GlyphVector aGlyphVector = aFont.layoutGlyphVector (new FontRenderContext (new AffineTransform (), false, true), aChars, 0, aChars.length, Font.LAYOUT_LEFT_TO_RIGHT); final int tCode = aGlyphVector.getGlyphCode (0); final int commaCode = aGlyphVector.getGlyphCode (1); final Kerning aKerning = new Kerning (new FileInputStream (System.getenv ("windir") + "/fonts/ARIAL.TTF")); LOGGER.info (Float.toString (aKerning.getValue (tCode, commaCode, nFontSize))); } else LOGGER.warn ("Works only on Windows!"); }
Example 4
Source File: BMFontUtil.java From gdx-skineditor with Apache License 2.0 | 4 votes |
private int getGlyphCode (Font font, int codePoint) { char[] chars = Character.toChars(codePoint); GlyphVector vector = font.layoutGlyphVector(GlyphPage.renderContext, chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT); return vector.getGlyphCode(0); }
Example 5
Source File: BMFontUtil.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 4 votes |
private int getGlyphCode (Font font, int codePoint) { char[] chars = Character.toChars(codePoint); GlyphVector vector = font.layoutGlyphVector(GlyphPage.renderContext, chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT); return vector.getGlyphCode(0); }