All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.mathiewz.slick.Font Maven / Gradle / Ivy

Go to download

The main purpose of this libraryis to modernize and maintain the slick2D library.

The newest version!
package com.github.mathiewz.slick;

/**
 * The proprites of any font implementation
 *
 * @author Kevin Glass
 */
public interface Font {
    /**
     * Get the width of the given string
     *
     * @param str
     *            The string to obtain the rendered with of
     * @return The width of the given string
     */
    public abstract int getWidth(String str);

    /**
     *
     * Get the logical width of the given string, meaning the space the string should occupy
     * if written on a line with strings around it.
     * This differs from the {@link #getWidth(String)} getWidth} which gets the visual width.
     * Logical width is very useful for placing text in relation to other pieces of text.
     *
     * @param str
     *            the string to obtain the logical width of
     * @return the width the given string will occupy
     */
    public abstract int getLogicalWidth(String str);

    /**
     * Get the height of the given string
     *
     * @param str
     *            The string to obtain the rendered with of
     * @return The width of the given string
     */
    public abstract int getHeight(String str);

    /**
     * Get the maximum height of any line drawn by this font
     *
     * @return The maxium height of any line drawn by this font
     */
    public int getLineHeight();

    /**
     * Draw a string to the screen
     *
     * @param x
     *            The x location at which to draw the string
     * @param y
     *            The y location at which to draw the string
     * @param text
     *            The text to be displayed
     */
    public abstract void drawString(float x, float y, String text);

    /**
     * Draw a string to the screen
     *
     * @param x
     *            The x location at which to draw the string
     * @param y
     *            The y location at which to draw the string
     * @param text
     *            The text to be displayed
     * @param col
     *            The colour to draw with
     */
    public abstract void drawString(float x, float y, String text, Color col);

    /**
     * Draw part of a string to the screen. Note that this will
     * still position the text as though it's part of the bigger string.
     *
     * @param x
     *            The x location at which to draw the string
     * @param y
     *            The y location at which to draw the string
     * @param text
     *            The text to be displayed
     * @param col
     *            The colour to draw with
     * @param startIndex
     *            The index of the first character to draw
     * @param endIndex
     *            The index of the last character from the string to draw
     */
    public abstract void drawString(float x, float y, String text, Color col, int startIndex, int endIndex);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy