gdx-studio

#libgdx#java#desktop

git clone https://git.pyrossh.dev/gdx-studio

An IDE for creating Games using libgdx and Java supported on all platforms Android, iOS, Desktop


src_libs/com/badlogic/gdx/tools/hiero/unicodefont/UnicodeFontTest.java
a62d533 1
/*******************************************************************************
a62d533 2
 * Copyright 2011 See AUTHORS file.
a62d533 3
 * 
a62d533 4
 * Licensed under the Apache License, Version 2.0 (the "License");
a62d533 5
 * you may not use this file except in compliance with the License.
a62d533 6
 * You may obtain a copy of the License at
a62d533 7
 * 
a62d533 8
 *   http://www.apache.org/licenses/LICENSE-2.0
a62d533 9
 * 
a62d533 10
 * Unless required by applicable law or agreed to in writing, software
a62d533 11
 * distributed under the License is distributed on an "AS IS" BASIS,
a62d533 12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
a62d533 13
 * See the License for the specific language governing permissions and
a62d533 14
 * limitations under the License.
a62d533 15
 ******************************************************************************/
a62d533 16
a62d533 17
package com.badlogic.gdx.tools.hiero.unicodefont;
a62d533 18
a62d533 19
import org.lwjgl.opengl.GL11;
a62d533 20
a62d533 21
import com.badlogic.gdx.ApplicationListener;
a62d533 22
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
a62d533 23
import com.badlogic.gdx.tools.hiero.unicodefont.effects.ColorEffect;
a62d533 24
a62d533 25
import static org.lwjgl.opengl.GL11.*;
a62d533 26
a62d533 27
public class UnicodeFontTest implements ApplicationListener {
a62d533 28
	private UnicodeFont unicodeFont;
a62d533 29
a62d533 30
	@Override
a62d533 31
	public void create () {
a62d533 32
		unicodeFont = new UnicodeFont("c:/windows/fonts/arial.ttf", 48, false, false);
a62d533 33
		unicodeFont.getEffects().add(new ColorEffect(java.awt.Color.white));
a62d533 34
	}
a62d533 35
a62d533 36
	@Override
a62d533 37
	public void resize (int width, int height) {
a62d533 38
		glViewport(0, 0, width, height);
a62d533 39
		glScissor(0, 0, width, height);
a62d533 40
		glEnable(GL_SCISSOR_TEST);
a62d533 41
a62d533 42
		glMatrixMode(GL_PROJECTION);
a62d533 43
		glLoadIdentity();
a62d533 44
		glOrtho(0, width, height, 0, 1, -1);
a62d533 45
		glMatrixMode(GL_MODELVIEW);
a62d533 46
		glLoadIdentity();
a62d533 47
a62d533 48
		glEnable(GL_TEXTURE_2D);
a62d533 49
		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
a62d533 50
		glEnableClientState(GL_VERTEX_ARRAY);
a62d533 51
a62d533 52
		glClearColor(0, 0, 0, 0);
a62d533 53
		glClearDepth(1);
a62d533 54
a62d533 55
		glDisable(GL_LIGHTING);
a62d533 56
a62d533 57
		glEnable(GL_BLEND);
a62d533 58
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
a62d533 59
	}
a62d533 60
a62d533 61
	@Override
a62d533 62
	public void render () {
a62d533 63
		GL11.glClear(GL_COLOR_BUFFER_BIT);
a62d533 64
a62d533 65
		unicodeFont.loadGlyphs(1);
a62d533 66
a62d533 67
		String text = "This is UnicodeFont!\nIt rockz. Kerning: T,";
a62d533 68
		unicodeFont.drawString(10, 33, text);
a62d533 69
		unicodeFont.drawString(10, 330, text);
a62d533 70
a62d533 71
		unicodeFont.addGlyphs("~!@!#!#$%___--");
a62d533 72
		// Cypriot Syllabary glyphs (Everson Mono font):
a62d533 73
		// \uD802\uDC02\uD802\uDC03\uD802\uDC12 == 0x10802, 0x10803, s0x10812
a62d533 74
	}
a62d533 75
a62d533 76
	public static void main (String[] args) {
a62d533 77
		new LwjglApplication(new UnicodeFontTest(), "UnicodeFont Test", 800, 600, false);
a62d533 78
	}
a62d533 79
a62d533 80
	@Override
a62d533 81
	public void dispose () {
a62d533 82
	}
a62d533 83
a62d533 84
	@Override
a62d533 85
	public void pause () {
a62d533 86
	}
a62d533 87
a62d533 88
	@Override
a62d533 89
	public void resume () {
a62d533 90
	}
a62d533 91
}