package ru.dbotthepony.kstarbound.client.freetype.struct;

import com.sun.jna.Pointer;
import com.sun.jna.Structure;

@Structure.FieldOrder({
	"n_contours",
	"n_points",
	"points",
	"tags",
	"contours",
	"flags",
})
public class FT_Outline extends Structure {
	public short       n_contours;      /* number of contours in glyph        */
	public short       n_points;        /* number of points in the glyph      */

	/**
	 * FT_Vector*
	 */
	public FT_Vector.Ref  points;       /* the outline's points               */

	/**
	 * char*
	 */
	public Pointer tags;            /* the points flags                   */

	/**
	 * short*
	 */
	public Pointer contours;        /* the contour end points             */

	public int flags;           /* outline masks                      */

	public FT_Vector[] readPoints() {
		//if (points == null)
		//	return new FT_Vector[0];

		return (FT_Vector[]) points.toArray(n_points);
	}

	public short[] readContours() {
		//if (contours == null)
		//	return new short[0];

		short[] read = new short[n_contours];
		contours.read(0L, read, 0, n_contours);
		return read;
	}
}
