#include <stdint.h>

#include "math/float_types.hpp"

#include "holly/ta_parameter.hpp"

namespace font {

  struct face {
    uint32_t texture_size;
    uint32_t texture_offset;
    int16_t texture_width;
    int16_t texture_height;
    int8_t hori_advance;
    int8_t width;
    int8_t height;
    int8_t row_stride;

    void global(ta_parameter_writer& writer) const;

    void draw_glyph(ta_parameter_writer& writer,
                    const vec3& p,
                    int c,
                    uint32_t base_color) const;

    inline void draw_string(ta_parameter_writer& writer,
                            const vec3& p,
                            const char * s,
                            uint32_t base_color) const
    {
      const uint8_t * u8 = (const uint8_t *)s;
      float x = p.x;
      while (*u8) {
        int c = *u8++;
        draw_glyph(writer, {x, p.y, p.z}, c, base_color);
        x += hori_advance;
      }
    }

    int draw_int(ta_parameter_writer& writer,
                 const vec3& p,
                 int num,
                 uint32_t base_color,
                 int length) const;

    int draw_float(ta_parameter_writer& writer,
                   const vec3& p,
                   float num,
                   uint32_t base_color,
                   int length = 0) const;

    void draw_mat4(ta_parameter_writer& writer,
                   const vec3& p,
                   const mat4x4& mat,
                   uint32_t base_color,
                   int value_length) const;
  };

  extern const face ter_u12n;
  extern const face ter_u32n;
}
