{.experimental: "codeReordering".}
{.deadCodeElim: on.}

import re
, sequtils
, strutils
, text_types
, ../vk/vkTypes


# proc aFont*(rec: var VKRec, path: string, size: int): Font = 
#  var 
#   face: FT_Face
#  #  ta = rec.aTextureAtlas(512, 512) 

#  discard FT_New_Face(rec.library, path, 0, face )
#  discard FT_Set_Pixel_Sizes(face, 0, FT_UInt size)
 
#  #result.ta = ta
#  result

# proc ftLoad =  
#  #add some check for enabling text or not instead of always inculding it?
#  discard FT_Init_FreeType rec.library

proc aPBMFont*(path: string = "/run/media/j/ZZZ/Dev/shapes/data/fonts/arialBlackStd.fnt"): PBMFont = 
 result = PBMFont()
 var isNum = re"(\-|)\d+" 

 for line in lines path:
  var nums: seq[int] = @[]
  if line[0..5] == "char i":
   # will return a @[0..9] length seq
   # id, x, y, width, height, xoffset, yoffset, xadvance, page, chnl
   # what's chnl for exactly?
   nums = line.findAll(isNum).map parseInt
   result.chars[nums[0]] = Bmchar( x: nums[1].uint32
                                 , y: nums[2].uint32
                                 , width: nums[3].uint32
                                 , height: nums[4].uint32
                                 , xoffset: nums[5].int32
                                 , yoffset: nums[6].int32
                                 , xadvance: nums[7].int32
                                 , page: nums[8].uint32
                                 )
   nums = @[]