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


Java TrueTypeFont类代码示例

本文整理汇总了Java中org.newdawn.slick.TrueTypeFont的典型用法代码示例。如果您正苦于以下问题:Java TrueTypeFont类的具体用法?Java TrueTypeFont怎么用?Java TrueTypeFont使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: init

import org.newdawn.slick.TrueTypeFont; //导入依赖的package包/类
/**
 * @see org.newdawn.slick.Game#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
	awtFont = new java.awt.Font("Verdana", Font.PLAIN, 16);
	font = new TrueTypeFont(awtFont, false);

	for (int j = 0; j < 2; j++) {
		int lineLen = 90;
		for (int i = 0; i < text.length(); i += lineLen) {
			if (i + lineLen > text.length()) {
				lineLen = text.length() - i;
			}

			lines.add(text.substring(i, i + lineLen));
		}
		lines.add("");
	}
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:20,代码来源:TrueTypeFontPerformanceTest.java

示例2: init

import org.newdawn.slick.TrueTypeFont; //导入依赖的package包/类
public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
    sb = sbg;
    InputProvider provider = new InputProvider(gc.getInput());
    provider.addListener(this);

    fps = new TrueTypeFont(Fonts.fpsCounter.getFont(), true);
    active = new TrueTypeFont(Fonts.active.getFont(), true);
    inactive = new TrueTypeFont(Fonts.inactive.getFont(), true);

    provider.bindCommand(new KeyControl(Input.KEY_UP), up);
    provider.bindCommand(new KeyControl(Input.KEY_DOWN), down);
    provider.bindCommand(new KeyControl(Input.KEY_LEFT), left);
    provider.bindCommand(new KeyControl(Input.KEY_RIGHT), right);
    provider.bindCommand(new KeyControl(Input.KEY_ENTER), enter);

    for (int i = 0; i < rect.length; i++) {
        rect[i] = new Rectangle(20, 20 + (70 * i), statValues[i] * 40, Play.width/30);
    }
}
 
开发者ID:nitrodragon,项目名称:ThunderingSky,代码行数:20,代码来源:Menu.java

示例3: Fonts

import org.newdawn.slick.TrueTypeFont; //导入依赖的package包/类
public Fonts() {
    char tabc[] = {'ą', 'ę', 'ó', 'ć', 'ż', 'ł', 'ś', 'ź', 'ń', 'Ł', 'Ó','Ś','Ę',};
    try {
        //Utworzenie czcionki
        font = Font.createFont(Font.TRUETYPE_FONT, new File("res/fonts/TrajanPro-Regular.otf"));
        //font = font.deriveFont(Font.BOLD, 48f);
    } catch (FontFormatException fe) {
        System.out.println("FONT - FontFormatException");
    } catch (IOException ioe) {
        System.out.println("FILE - IOException");
    }
    
    //stworzenie zmiennej printLabel i printHead, ustalenie parametrów czcionki
    printLabel = new TrueTypeFont(font.deriveFont(Font.BOLD, 18f), true, tabc);
    printHead = new TrueTypeFont(font.deriveFont(Font.BOLD, 28f), true, tabc);
    printBig = new TrueTypeFont(font.deriveFont(Font.BOLD, 25f), true, tabc);
    printMediumLogo = new TrueTypeFont(font.deriveFont(Font.BOLD, 46f), true, tabc);
    printBigLogo = new TrueTypeFont(font.deriveFont(Font.BOLD, 78f), true, tabc);
}
 
开发者ID:Kalwador,项目名称:Java-2D-Game,代码行数:20,代码来源:Fonts.java

示例4: init

import org.newdawn.slick.TrueTypeFont; //导入依赖的package包/类
public void init(GameContainer container) throws SlickException //fait par VS, JD et FS
{
	
	//Initialisation of animation when BOOOOM !
	explosionAnimation  = new Animation();
	explosionImage1 = new Image ("boom1.png");
	explosionImage2 = new Image ("boom2.png");
	explosionImage3 = new Image ("boom3.png");
	explosionImage4 = new Image ("boom4.png");
	explosionAnimation.addFrame(explosionImage1, 25);
	explosionAnimation.addFrame(explosionImage2, 35);
	explosionAnimation.addFrame(explosionImage3, 35);
	explosionAnimation.addFrame(explosionImage4, 150);
	explosionAnimation.setLooping(false);
	
	//Graphic aspect
	ttf = new TrueTypeFont(font, true);
	container.getGraphics().setBackground(new Color(193, 184, 176)); 
	
	//Input management on TextArea
	pseudoEntry = new TextArea(20,20,150,20);
	container.getInput().addKeyListener(pseudoEntry);
	container.getInput().addMouseListener(pseudoEntry);
	pseudoEntry.setPosition(grid.getRightPosition(), getNextCommandPosition(0));
}
 
开发者ID:UTBroM,项目名称:2COA,代码行数:26,代码来源:WindowGame.java

示例5: Score

import org.newdawn.slick.TrueTypeFont; //导入依赖的package包/类
/**
 * Initialise resources
 */
public Score() {
	readHighScore();
	//load a default java font
    Font awtFont = new Font("Times New Roman", Font.BOLD, 24);
    font = new TrueTypeFont(awtFont, antiAlias);
     
    // load font from file
    try {
        InputStream inputStream = ResourceLoader.getResourceAsStream("res/fonts/brick.ttf");
         
        Font awtFont2 = Font.createFont(Font.TRUETYPE_FONT, inputStream);
        awtFont2 = awtFont2.deriveFont(50f); // set font size
        font2 = new TrueTypeFont(awtFont2, antiAlias);
         
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:harryi3t,项目名称:Save-The-Ball,代码行数:22,代码来源:Score.java

示例6: init

import org.newdawn.slick.TrueTypeFont; //导入依赖的package包/类
public void init(GameContainer container, StateBasedGame game)
        throws SlickException {
    ConfigsManager.getInstance().applicateConfigs();
	LoadingList.setDeferredLoading(true);
    
    DatasManager.getInstance().addFile("LivingEntity.name", new TrueTypeFont(new Font("Verdana", Font.BOLD, 12), true));
    DatasManager.getInstance().addFile("TextEffect.damages", new TrueTypeFont(new Font("Verdana", Font.BOLD, 12), true));
    DatasManager.getInstance().addFile("TextEffect.status", new TrueTypeFont(new Font("Verdana", Font.BOLD, 14), true));
    
    DatasManager.getInstance().addFile("MouseCursor.default", new Image("res/images/cursors/default.png"));
    
    DatasManager.getInstance().addMap("test.tmx");
    try {
        ResourcesManager.getInstance().loadResources();
    } catch (Exception e) {
        throw new SlickException(e.getMessage());
    }
    super.init(container, game);
}
 
开发者ID:AlexMog,项目名称:MMO-Rulemasters-World,代码行数:20,代码来源:LoadingState.java

示例7: GUI

import org.newdawn.slick.TrueTypeFont; //导入依赖的package包/类
public GUI(GameContainer container, int x, int y) {
super(container);

setLocation(x, y);
Font buttonFont = new TrueTypeFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 14), true);
//North and south
speedUp = new TextButton(container, "Speed Up", getCompX(0), getCompY(0), buttonFont);
speedDown = new TextButton(container, "Speed Down", getCompX(speedUp.getWidth() + 30), getCompY(0), buttonFont);

pause = new TextButton(container, "Pause", getCompX(0), speedUp.getY() + speedUp.getHeight() + 10, buttonFont);
restart = new TextButton(container, "Restart", speedDown.getX(), speedUp.getY() + speedUp.getHeight() + 10, buttonFont);

euler = new TextButton(container, "Angle set: " + getAngleSet(), getCompX(0), pause.getY() + pause.getHeight() + 10, buttonFont);

hemisphere = new TextButton(container, getHemisphereText(), getCompX(0), euler.getY() + euler.getHeight() + 10, buttonFont);

close = new TextButton(container, "X", speedDown.getX() + speedDown.getWidth() + 50, getCompY(0), buttonFont);

contents = new Rectangle(x - 5, y - 5, width, height);
sf = new GradientFill(0, 0, new Color(10, 10, 10, 200), width, 0, new Color(60, 60, 60, 200));
   }
 
开发者ID:langurmonkey,项目名称:celestial-pole-motion,代码行数:22,代码来源:GUI.java

示例8: GuiBar

import org.newdawn.slick.TrueTypeFont; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public GuiBar(Sprite sprite, float x, float y) {
	super(sprite, x, y);
	awtFont = new Font(fontName, Font.PLAIN, 34);
	font = new TrueTypeFont(awtFont, antiAlias);

	// Kod för att ladda in custom fonts
	// try {
	// //InputStream inputStream =
	// ResourceLoader.getResourceAsStream("ZOMBIE.TTF");
	// InputStream inputStream =
	// ResourceLoader.getResourceAsStream("impact.ttf");
	//
	// awtFont2 = Font.createFont(Font.TRUETYPE_FONT, inputStream);
	// awtFont2 = awtFont2.deriveFont(24f); // set font size
	// font2 = new TrueTypeFont(awtFont2, antiAlias);
	//
	// } catch (Exception e) {
	// e.printStackTrace();
	// }
}
 
开发者ID:MiFF-Stockholm,项目名称:szo,代码行数:22,代码来源:GuiBar.java

示例9: init

import org.newdawn.slick.TrueTypeFont; //导入依赖的package包/类
/**
 * Initialise resources
 */
public void init() {
	// load a default java font
	Font awtFont = new Font("Consolas", Font.BOLD, 24);
	font = new TrueTypeFont(awtFont, antiAlias);
	
	// load font from file
	try {
		InputStream inputStream	= ResourceLoader.getResourceAsStream("myfont.ttf");
		
		Font awtFont2 = Font.createFont(Font.TRUETYPE_FONT, inputStream);
		awtFont2 = awtFont2.deriveFont(24f); // set font size
		font2 = new TrueTypeFont(awtFont2, antiAlias);
		
	} catch (Exception e) {
		e.printStackTrace();
                       font2 = font;
	}
}
 
开发者ID:akarnokd,项目名称:akarnokd-opengl-experiment,代码行数:22,代码来源:FontExample.java

示例10: TooltipText

import org.newdawn.slick.TrueTypeFont; //导入依赖的package包/类
public TooltipText(TrueTypeFont ttf_, String text_, String tooltip_, Color color_, Pair<Float> pos_) {
	this.ttf = ttf_;
	this.text = text_;
	this.tooltip = tooltip_;
	this.color = color_;
	this.pos = pos_;
}
 
开发者ID:packetpirate,项目名称:Generic-Zombie-Shooter-Redux,代码行数:8,代码来源:TooltipText.java

示例11: Inventory

import org.newdawn.slick.TrueTypeFont; //导入依赖的package包/类
public Inventory(float x, float y, int width, int height)
{
	this.x = x;
	this.y = y;
	
	this.width = width;
	this.height = height;
	
	slots = new SlotItem[width * height];
	
	int widthIndex = 0;
	int heightIndex = 0;
	
	for(int i = 0; i < width * height; i++)
	{
		slots[i] = new SlotItem(i, widthIndex * 22F, heightIndex * 22F);
		
 	widthIndex++;
 	
 	if(widthIndex == width)
 	{	
 		heightIndex++;

 		widthIndex = 0;
 	}
	}
	
	ttf = new TrueTypeFont(new Font("Arial", Font.PLAIN, 14), false);
}
 
开发者ID:ItzDennisz,项目名称:Hellbound-Rewrite,代码行数:30,代码来源:Inventory.java

示例12: TextBox

import org.newdawn.slick.TrueTypeFont; //导入依赖的package包/类
public TextBox(String font) {
	try {
		InputStream inputStream = ResourceLoader.getResourceAsStream(font);
		Font awtFont = Font.createFont(Font.TRUETYPE_FONT, inputStream);
		awtFont = awtFont.deriveFont(32f); //font size
		this.font = new TrueTypeFont(awtFont, false);
	}
	catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:massm039,项目名称:SRPG,代码行数:12,代码来源:TextBox.java

示例13: changeFont

import org.newdawn.slick.TrueTypeFont; //导入依赖的package包/类
public void changeFont(String font) {
	try {
		InputStream inputStream = ResourceLoader.getResourceAsStream(font);
		Font awtFont = Font.createFont(Font.TRUETYPE_FONT, inputStream);
		awtFont = awtFont.deriveFont(32f); //font size
		this.font = new TrueTypeFont(awtFont, false);
	}
	catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:massm039,项目名称:SRPG,代码行数:12,代码来源:TextBox.java

示例14: loadFonts

import org.newdawn.slick.TrueTypeFont; //导入依赖的package包/类
/**
 * Loads the fonts to be used for drawing text. Default fonts are Helvetica, 
 * KGBlankSpaceSolid and size 12, 18, 30, and 44 feel free to come in here and 
 * change to any font supported by java.awt.Font, or add a font to the font res 
 * folder and modify the loadfonts code or just ask me (adam) to do for you :)
 * 
 * Takes a few seconds to load font so account for this when you call this
 * method. Should only be called once while initializing for the first time.
 */
public static void loadFonts()
{
  // small test fonts
  Font awtFontSmall = new Font("Helvetica", Font.TRUETYPE_FONT, 12);
  fontSmall = new TrueTypeFont(awtFontSmall, true);
  Font awtFontNormal = new Font("Helvetica", Font.TRUETYPE_FONT, 18);
  fontNormal = new TrueTypeFont(awtFontNormal, true);
  
  try
  {
    // main game fonts
    InputStream inputStream = ResourceLoader.getResourceAsStream("res/fonts/KGBlankSpaceSolid.ttf");
    InputStream inputStream2 = ResourceLoader.getResourceAsStream("res/fonts/KGBlankSpaceSolid.ttf");

    Font awtFontBigger = Font.createFont(Font.TRUETYPE_FONT, inputStream2);
    awtFontBigger = awtFontBigger.deriveFont(30f);
    fontBig = new TrueTypeFont(awtFontBigger, true);
    
    //Color.white.bind();
    Font awtExtraLargeFont = Font.createFont(Font.TRUETYPE_FONT, inputStream);
    awtExtraLargeFont = awtExtraLargeFont.deriveFont(44f);
    fontBigger = new TrueTypeFont(awtExtraLargeFont, true);
    Color.white.bind();
  }
  catch (Exception e)
  {
    e.printStackTrace();
  }
}
 
开发者ID:l50,项目名称:redrun,代码行数:39,代码来源:FontTools.java

示例15: TextObject

import org.newdawn.slick.TrueTypeFont; //导入依赖的package包/类
/**
 * A constructor for the text object
 * @param str the string of text
 * @param pos the position of the text
 * @param color the color of the text
 * @param size the size of the text
 */
public TextObject(String str, Vector2f pos, Color color, float size) {
	super(0, 0, 0, pos);
	super.setType(GameObjectType.TEXT);
	try {
		this.str = str;
		this.color = color;
		this.size = size;
		this.font = new TrueTypeFont(Font.createFont(Font.TRUETYPE_FONT, ResourceLoader.getResourceAsStream(Game.getFontPath())).deriveFont(size), true);
	} catch (FontFormatException | IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:LucioFranco,项目名称:RobustEngine,代码行数:20,代码来源:TextObject.java


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