当前位置: 首页>>代码示例>>Java>>正文


Java PFont.Glyph方法代码示例

本文整理汇总了Java中processing.core.PFont.Glyph方法的典型用法代码示例。如果您正苦于以下问题:Java PFont.Glyph方法的具体用法?Java PFont.Glyph怎么用?Java PFont.Glyph使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在processing.core.PFont的用法示例。


在下文中一共展示了PFont.Glyph方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initTexture

import processing.core.PFont; //导入方法依赖的package包/类
protected void initTexture(PGraphicsOpenGL pg, PFont font) {
  currentTex = -1;
  lastTex = -1;

  int spow = PGL.nextPowerOfTwo(font.getSize());
  minSize = PApplet.min(PGraphicsOpenGL.maxTextureSize,
                        PApplet.max(PGL.MIN_FONT_TEX_SIZE, spow));
  maxSize = PApplet.min(PGraphicsOpenGL.maxTextureSize,
                        PApplet.max(PGL.MAX_FONT_TEX_SIZE, 2 * spow));

  if (maxSize < spow) {
    PGraphics.showWarning("The font size is too large to be properly " +
                          "displayed with OpenGL");
  }

  addTexture(pg);

  offsetX = 0;
  offsetY = 0;
  lineHeight = 0;

  texinfoMap = new HashMap<PFont.Glyph, TextureInfo>();
  glyphTexinfos = new TextureInfo[font.getGlyphCount()];
  addAllGlyphsToTexture(pg, font);
}
 
开发者ID:d2fn,项目名称:passage,代码行数:26,代码来源:FontTexture.java

示例2: addToTexture

import processing.core.PFont; //导入方法依赖的package包/类
public TextureInfo addToTexture(PGraphicsOpenGL pg, PFont.Glyph glyph) {
  int n = glyphTexinfos.length;
  if (n == 0) {
    glyphTexinfos = new TextureInfo[1];
  }
  addToTexture(pg, n, glyph);
  return glyphTexinfos[n];
}
 
开发者ID:d2fn,项目名称:passage,代码行数:9,代码来源:FontTexture.java

示例3: BitFont

import processing.core.PFont; //导入方法依赖的package包/类
public BitFont(byte[] theBytes) {

		super();

		texture = decodeBitFont(theBytes);

		make();

		size = lineHeight;
		glyphs = new Glyph[256];
		ascii = new int[128];
		Arrays.fill(ascii, -1);
		lazy = false;
		ascent = 4;
		descent = 4;
		glyphCount = 128;
		for (int i = 0; i < 128; i++) {

			// unfortunately the PFont.Glyph constructor in the android source code is for whatever
			// reason protected and not public like in the java application source, therefore the
			// bitfont will only be used in the java application mode until changes to the
			// processing core code have been made. see issue
			// http://code.google.com/p/processing/issues/detail?id=1293

			try {
				Constructor<PFont.Glyph>[] constructors = (Constructor<PFont.Glyph>[]) PFont.Glyph.class.getDeclaredConstructors();
				Constructor<PFont.Glyph> constructor = (Constructor<PFont.Glyph>) PFont.Glyph.class.getDeclaredConstructors()[0];
				constructor.setAccessible(true);
				for (Constructor<PFont.Glyph> c : constructors) {
					c.setAccessible(true);
					if (c.getParameterTypes().length == 1) {
						glyphs[i] = c.newInstance(this);
						break;
					}
				}
			} catch (Exception e) {
				System.out.println(e);
			}

			// as soon as the constructor is public, the line below will replace the hack above
			// glyphs[i] = new Glyph();

			glyphs[i].value = i;

			if (glyphs[i].value < 128) {
				ascii[glyphs[i].value] = i;
			}

			glyphs[i].index = i;
			int id = i - 32;
			if (id >= 0) {
				glyphs[i].image = new PImage(charWidth[id], 9, ALPHA);
				for (int n = 0; n < chars[id].length; n++) {
					glyphs[i].image.pixels[n] = (chars[id][n] == 1) ? 0xffffffff : 0x00000000;
				}
				glyphs[i].height = 9;
				glyphs[i].width = charWidth[id];
				glyphs[i].index = i;
				glyphs[i].value = i;
				glyphs[i].setWidth = charWidth[id];
				glyphs[i].topExtent = 4;
				glyphs[i].leftExtent = 0;
			} else {
				glyphs[i].image = new PImage(1, 1);
			}
		}
	}
 
开发者ID:d2fn,项目名称:passage,代码行数:68,代码来源:BitFont.java

示例4: getTexInfo

import processing.core.PFont; //导入方法依赖的package包/类
public TextureInfo getTexInfo(PFont.Glyph glyph) {
  TextureInfo info = texinfoMap.get(glyph);
  return info;
}
 
开发者ID:d2fn,项目名称:passage,代码行数:5,代码来源:FontTexture.java

示例5: BitFont

import processing.core.PFont; //导入方法依赖的package包/类
public BitFont( byte[] theBytes ) {
	super( );

	texture = decodeBitFont( theBytes );
	make( );

	size = lineHeight;
	glyphs = new Glyph[ 256 ];
	ascii = new int[ 128 ];
	Arrays.fill( ascii , -1 );
	lazy = false;
	ascent = 4;
	descent = 4;
	glyphCount = 128;
	for ( int i = 0 ; i < 128 ; i++ ) {

		// unfortunately the PFont.Glyph constructor in
		// the android source code is for whatever
		// reason protected and not public like in the
		// java application source, therefore the
		// bitfont will only be used in the java
		// application mode until changes to the
		// processing core code have been made. see
		// issue
		// http://code.google.com/p/processing/issues/detail?id=1293

		try {
			Constructor< PFont.Glyph >[] constructors = ( Constructor< PFont.Glyph >[] ) PFont.Glyph.class.getDeclaredConstructors( );
			Constructor< PFont.Glyph > constructor = ( Constructor< PFont.Glyph > ) PFont.Glyph.class.getDeclaredConstructors( )[ 0 ];
			constructor.setAccessible( true );
			for ( Constructor< PFont.Glyph > c : constructors ) {
				c.setAccessible( true );
				if ( c.getParameterTypes( ).length == 1 ) {
					glyphs[ i ] = c.newInstance( this );
					break;
				}
			}
		} catch ( Exception e ) {
			System.out.println( e );
		}

		// as soon as the constructor is public, the
		// line below will replace the hack above
		// glyphs[i] = new Glyph();

		glyphs[ i ].value = i;

		if ( glyphs[ i ].value < 128 ) {
			ascii[ glyphs[ i ].value ] = i;
		}

		glyphs[ i ].index = i;
		int id = i - 32;
		if ( id >= 0 ) {
			glyphs[ i ].image = new PImage( charWidth[ id ] , 9 , ALPHA );
			for ( int n = 0 ; n < chars[ id ].length ; n++ ) {
				glyphs[ i ].image.pixels[ n ] = ( chars[ id ][ n ] == 1 ) ? 0xffffffff : 0x00000000;
			}
			glyphs[ i ].height = 9;
			glyphs[ i ].width = charWidth[ id ];
			glyphs[ i ].index = i;
			glyphs[ i ].value = i;
			glyphs[ i ].setWidth = charWidth[ id ];
			glyphs[ i ].topExtent = 4;
			glyphs[ i ].leftExtent = 0;
		} else {
			glyphs[ i ].image = new PImage( 1 , 1 );
		}
	}
}
 
开发者ID:sojamo,项目名称:controlp5,代码行数:71,代码来源:BitFont.java


注:本文中的processing.core.PFont.Glyph方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。