package com.danitheskunk.skunkworks.gfx.font;

import com.danitheskunk.skunkworks.Vec2i;
import com.danitheskunk.skunkworks.gfx.ITexture;

import java.util.List;

public class FontTileset implements IFont {
	private final Vec2i charSize;
	private final List<ITexture> textures;

	public FontTileset(List<ITexture> textures) {
		this.textures = textures;
		charSize = textures.get(0).getSize();
	}

	@Override
	public int getLineHeight(int ch) {
		return charSize.getY();
	}

	@Override
	public Vec2i getMonospaceSize() {
		return charSize;
	}

	@Override
	public Vec2i getOffset(int ch) {
		return Vec2i.ZERO;
	}

	@Override
	public ITexture getTexture(int ch) {
		if(ch >= 256 || ch < 0) {
			ch = 0;
		}
		return textures.get(ch);
	}

	@Override
	public int getXAdvance(int ch) {
		return charSize.getX();
	}

	@Override
	public boolean isCP437() {
		return true;
	}

	@Override
	public boolean isMonospace() {
		return true;
	}
}
