renderCharacterTextQuad ::
     TextRenderer -> Character -> Int -> Int -> Font -> IO (Int, Int)
renderCharacterTextQuad renderer (Character c width height adv xBearing yBearing text) x y font =
  let baseline = fromIntegral (y - fontAscender font)
      gX1 = fromIntegral (x + xBearing)
      gX2 = gX1 + fromIntegral width
      gY1 = baseline + fromIntegral yBearing
      gY2 = gY1 - fromIntegral height
      charVerts =
        [ gX1
        , gY1
        , 0.0
        , 0.0 -- coord 1
        , gX1
        , gY2
        , 0.0
        , 1.0 -- coord 2
        , gX2
        , gY1
        , 1.0
        , 0.0 -- coord 3
        , gX1
        , gY2
        , 0.0
        , 1.0 -- coord 4
        , gX2
        , gY2
        , 1.0
        , 1.0 -- coord 5
        , gX2
        , gY1
        , 1.0
        , 0.0 -- coord 6
        ] :: [GLfloat]
      charDrawFunc = do
        GL.activeTexture $= TextureUnit 0
        GL.textureBinding Texture2D $= Just text
        textColourU <-
          GL.get $ GL.uniformLocation (textprogram renderer) "textColor"
        GL.uniform textColourU $= colToGLCol (textColour renderer)
        textBGColourU <-
          GL.get $ GL.uniformLocation (textprogram renderer) "textBGColor"
        GL.uniform textBGColourU $= colToGLCol (textBGColour renderer)
   in do renderCharacterQuad
           (textprogram renderer)
           (pMatrix renderer)
           (characterQuad renderer)
           charDrawFunc
           charVerts
         return (x + adv, y)
renderCharacterTextQuad ::
     TextRenderer -> Character -> Int -> Int -> Font -> IO (Int, Int)
renderCharacterTextQuad renderer (Character c width height adv xBearing yBearing text) x y font =
  let baseline = fromIntegral (y - fontAscender font)
      gX1 = fromIntegral (x + xBearing)
      gX2 = gX1 + fromIntegral width
      gY1 = baseline + fromIntegral yBearing
      gY2 = gY1 - fromIntegral height
      charVerts =
        [ gX1
        , gY1
        , 0.0
        , 0.0 -- coord 1
        , gX1
        , gY2
        , 0.0
        , 1.0 -- coord 2
        , gX2
        , gY1
        , 1.0
        , 0.0 -- coord 3
        , gX1
        , gY2
        , 0.0
        , 1.0 -- coord 4
        , gX2
        , gY2
        , 1.0
        , 1.0 -- coord 5
        , gX2
        , gY1
        , 1.0
        , 0.0 -- coord 6
        ] :: [GLfloat]
      charDrawFunc = do
        GL.activeTexture $= TextureUnit 0
        GL.textureBinding Texture2D $= Just text
        textColourU <-
          GL.get $ GL.uniformLocation (textprogram renderer) "textColor"
        GL.uniform textColourU $= colToGLCol (textColour renderer)
        textBGColourU <-
          GL.get $ GL.uniformLocation (textprogram renderer) "textBGColor"
        GL.uniform textBGColourU $= colToGLCol (textBGColour renderer)
   in do renderCharacterQuad
           (textprogram renderer)
           (pMatrix renderer)
           (characterQuad renderer)
           charDrawFunc
           charVerts
         return (x + adv, y)
renderCharacterTextQuad renderer (Character c width height adv xBearing yBearing text) x y font =
  let baseline = fromIntegral (y - fontAscender font)
      gX1 = fromIntegral (x + xBearing)
      gX2 = gX1 + fromIntegral width
      gY1 = baseline + fromIntegral yBearing
      gY2 = gY1 - fromIntegral height
      charVerts =
        [ gX1
        , gY1
        , 0.0
        , 0.0 -- coord 1
        , gX1
        , gY2
        , 0.0
        , 1.0 -- coord 2
        , gX2
        , gY1
        , 1.0
        , 0.0 -- coord 3
        , gX1
        , gY2
        , 0.0
        , 1.0 -- coord 4
        , gX2
        , gY2
        , 1.0
        , 1.0 -- coord 5
        , gX2
        , gY1
        , 1.0
        , 0.0 -- coord 6
        ] :: [GLfloat]
      charDrawFunc = do
        GL.activeTexture $= TextureUnit 0
        GL.textureBinding Texture2D $= Just text
        textColourU <-
          GL.get $ GL.uniformLocation (textprogram renderer) "textColor"
        GL.uniform textColourU $= colToGLCol (textColour renderer)
        textBGColourU <-
          GL.get $ GL.uniformLocation (textprogram renderer) "textBGColor"
        GL.uniform textBGColourU $= colToGLCol (textBGColour renderer)
   in do renderCharacterQuad
           (textprogram renderer)
           (pMatrix renderer)
           (characterQuad renderer)
           charDrawFunc
           charVerts
         return (x + adv, y)