Search in sources :

Example 6 with Text

use of com.b3dgs.lionengine.graphic.Text in project lionengine by b3dgs.

the class TextHeadlessTest method testBold.

/**
 * Test bold.
 */
@Test
void testBold() {
    final Text text = Graphics.createText(Constant.FONT_DIALOG, 12, TextStyle.BOLD);
    text.draw(g, 0, 0, VALUE);
}
Also used : Text(com.b3dgs.lionengine.graphic.Text) Test(org.junit.jupiter.api.Test)

Example 7 with Text

use of com.b3dgs.lionengine.graphic.Text in project lionengine by b3dgs.

the class TextAwtTest method testBold.

/**
 * Test bold.
 */
@Test
void testBold() {
    final Text text = Graphics.createText(Constant.FONT_DIALOG, 12, TextStyle.BOLD);
    text.draw(g, 0, 0, VALUE);
}
Also used : Text(com.b3dgs.lionengine.graphic.Text) Test(org.junit.jupiter.api.Test)

Example 8 with Text

use of com.b3dgs.lionengine.graphic.Text in project lionengine by b3dgs.

the class TextAwtTest method testNormal.

/**
 * Test normal.
 */
@Test
void testNormal() {
    final Text text = Graphics.createText(Constant.FONT_DIALOG, 12, TextStyle.NORMAL);
    text.draw(g, 0, 0, VALUE);
    text.draw(g, 0, 0, Align.CENTER, VALUE);
    text.draw(g, 0, 0, Align.LEFT, VALUE);
    text.draw(g, 0, 0, Align.RIGHT, VALUE);
    text.setAlign(Align.CENTER);
    text.setColor(ColorRgba.BLACK);
    text.setLocation(1.0, 5.0);
    text.setText(VALUE);
    assertEquals(12, text.getSize());
    assertEquals(1, text.getLocationX());
    assertEquals(5, text.getLocationY());
    assertTrue(text.getWidth() == 0);
    assertTrue(text.getHeight() == 0);
    text.render(g);
    text.render(g);
    assertTrue(text.getWidth() > 0);
    assertTrue(text.getHeight() > 0);
}
Also used : Text(com.b3dgs.lionengine.graphic.Text) Test(org.junit.jupiter.api.Test)

Example 9 with Text

use of com.b3dgs.lionengine.graphic.Text in project lionengine by b3dgs.

the class TextAwtTest method testItalic.

/**
 * Test italic.
 */
@Test
void testItalic() {
    final Text text = Graphics.createText(Constant.FONT_DIALOG, 12, TextStyle.ITALIC);
    text.draw(g, 0, 0, VALUE);
}
Also used : Text(com.b3dgs.lionengine.graphic.Text) Test(org.junit.jupiter.api.Test)

Example 10 with Text

use of com.b3dgs.lionengine.graphic.Text in project lionengine by b3dgs.

the class TextAwtTest method testAlignUnknown.

/**
 * Test align unknown.
 */
@Test
void testAlignUnknown() {
    final Text text = Graphics.createText(Constant.FONT_DIALOG, 12, TextStyle.NORMAL);
    final Graphic g = Graphics.createGraphic();
    g.setGraphic(ToolsAwt.createImage(1, 1, java.awt.Transparency.OPAQUE).createGraphics());
    assertThrows(() -> text.draw(g, 0, 0, Align.values()[3], Constant.EMPTY_STRING), "Unknown enum: FAIL");
}
Also used : Graphic(com.b3dgs.lionengine.graphic.Graphic) Text(com.b3dgs.lionengine.graphic.Text) Test(org.junit.jupiter.api.Test)

Aggregations

Text (com.b3dgs.lionengine.graphic.Text)11 Test (org.junit.jupiter.api.Test)7 Test (org.junit.Test)4 Graphic (com.b3dgs.lionengine.graphic.Graphic)2 Align (com.b3dgs.lionengine.Align)1 LionEngineException (com.b3dgs.lionengine.LionEngineException)1