java font2d,Java Font2DHandle类代码示例

import sun.font.Font2DHandle; //导入依赖的package包/类

/**

* Returns a new Font using the specified font type

* and the specified font file. The new Font is

* created with a point size of 1 and style {@link #PLAIN PLAIN}.

* This base font can then be used with the deriveFont

* methods in this class to derive new Font objects with

* varying sizes, styles, transforms and font features.

* @param fontFormat the type of the Font, which is

* {@link #TRUETYPE_FONT TRUETYPE_FONT} if a TrueType resource is

* specified or {@link #TYPE1_FONT TYPE1_FONT} if a Type 1 resource is

* specified.

* So long as the returned font, or its derived fonts are referenced

* the implementation may continue to access fontFile

* to retrieve font data. Thus the results are undefined if the file

* is changed, or becomes inaccessible.

*

* To make the Font available to Font constructors the

* returned Font must be registered in the

* GraphicsEnviroment by calling

* {@link GraphicsEnvironment#registerFont(Font) registerFont(Font)}.

* @param fontFile a File object representing the

* input data for the font.

* @return a new Font created with the specified font type.

* @throws IllegalArgumentException if fontFormat is not

* TRUETYPE_FONTorTYPE1_FONT.

* @throws NullPointerException if fontFile is null.

* @throws IOException if the fontFile cannot be read.

* @throws FontFormatException if fontFile does

* not contain the required font tables for the specified format.

* @throws SecurityException if the executing code does not have

* permission to read from the file.

* @see GraphicsEnvironment#registerFont(Font)

* @since 1.5

*/

public static Font createFont(int fontFormat, File fontFile)

throws java.awt.FontFormatException, java.io.IOException {

fontFile = new File(fontFile.getPath());

if (fontFormat != Font.TRUETYPE_FONT &&

fontFormat != Font.TYPE1_FONT) {

throw new IllegalArgumentException ("font format not recognized");

}

SecurityManager sm = System.getSecurityManager();

if (sm != null) {

FilePermission filePermission =

new FilePermission(fontFile.getPath(), "read");

sm.checkPermission(filePermission);

}

if (!fontFile.canRead()) {

throw new IOException("Can't read " + fontFile);

}

// create a private Font Collection and add the font data

PrivateFontCollection pfc = new PrivateFontCollection();

try {

String fileName = fontFile.getPath();

pfc.AddFontFile( fileName );

RemoveFontResourceEx( fileName );// hack for bug http://stackoverflow.com/questions/26671026/how-to-delete-the-file-of-a-privatefontcollection-addfontfile

if (false) throw new cli.System.IO.FileNotFoundException();

} catch( cli.System.IO.FileNotFoundException fnfe ) {

FileNotFoundException ex = new FileNotFoundException(fnfe.getMessage());

ex.initCause( fnfe );

throw ex;

}

// create the font object

Font2D font2D = SunFontManager.createFont2D( pfc.get_Families()[0], 0 );

Font2DHandle font2DHandle = font2D.handle;

Font font = new Font( font2D.getFontName( Locale.getDefault() ), PLAIN, 1, true, font2DHandle );

return font;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
解释一下 GLES20.glClearColor(0.0f, 0.0f, 0.0f, Vuforia.requiresAlpha() ? 0.0f : 1.0f); for (Texture t : mTextures) { GLES20.glGenTextures(1, t.mTextureID, 0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, t.mTextureID[0]); GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, t.mWidth, t.mHeight, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, t.mData); } shaderProgramID = SampleUtils.createProgramFromShaderSrc( CubeShaders.CUBE_MESH_VERTEX_SHADER, CubeShaders.CUBE_MESH_FRAGMENT_SHADER); vertexHandle = GLES20.glGetAttribLocation(shaderProgramID, "vertexPosition"); // textureCoordHandle = GLES20.glGetAttribLocation(shaderProgramID, // "vertexTexCoord"); mVColorCenterHandler = GLES20.glGetUniformLocation(shaderProgramID, "vColorCenter"); mvpMatrixHandle = GLES20.glGetUniformLocation(shaderProgramID, "modelViewProjectionMatrix"); texSampler2DHandle = GLES20.glGetUniformLocation(shaderProgramID, "texSampler2D"); if(!mModelIsLoaded) { mTeapot = new Teapot(); mxyz1 = new xyz1(); try { mBuildingsModel = new SampleApplication3DModel(); mBuildingsModel.loadModel(mActivityRef.get().getResources().getAssets(), "ImageTargets/Buildings.txt"); mModelIsLoaded = true; } catch (IOException e) { Log.e(LOGTAG, "Unable to load buildings"); } // Hide the Loading Dialog mActivityRef.get().loadingDialogHandler .sendEmptyMessage(LoadingDialogHandler.HIDE_LOADING_DIALOG); } }
最新发布
06-03
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值