// https://www.shadertoy.com/view/MtVXRd
#pragma iChannel0 font1.png

//--------------------------------------------------------
// FontTextureInfo.glsl   
//
//   v1.0  2017-01-27  1st release
//   v1.1  2017-01-31  mouse.x improvement
//   v1.2  2018-11-30  simplified
//
// original questions asked:
// - Is there somewhere out a description about
//   what red, green, blue and alpha values
//   of the font texture are used for?
// - How can the font texture be drawn with its
//   original size (1024*1024)?
//
// Font Texture channels: (thank you IQ for this info)
//       Red: Antialiased font value
//     Green: x gradient of distance field
//      Blue: y gradient of distance field
//     Alpha: distance field
//
// More info: https://www.shadertoy.com/view/llcXRl
//  scroller: https://www.shadertoy.com/view/MtySzd
//--------------------------------------------------------
#define res iChannelResolution[0].xy

void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
  // draw font texture with it's original size
  vec2 uv = fragCoord / res;
  uv -= 0.5 * (iResolution.xy - res) / res;   // center image

  if (uv.x <= 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0)
  {
      fragColor = vec4(0,0,0,1);  // black background
      return;
  }

  vec4 color = texture(iChannel0, uv);
  if (iMouse.z > 0.0)    // mousePressed ?
  {
    int fkt = int(iMouse.x / iResolution.x * 7.0);
    if      (fkt == 0) fragColor = color.xxxx;  // aa font
    else if (fkt == 1) fragColor = color.wwwx;  // draw distance field
    else if (fkt == 2) fragColor = color.xxwx;  // aa font & distance field
    else if (fkt == 3) fragColor = color.yyyx;  // x gradient
    else if (fkt == 4) fragColor = color.zzzx;  // y gradient
    else if (fkt == 5) fragColor = color.yzzx;  // x&y gradient
    else if (fkt == 6) fragColor = color.yzwx;  // x&y & distance field
  }
  else fragColor = color;  
}