\usemodule[simplefonts]
\setmainfont[Arabic Typesetting][features=arabic]

\setuplayout[grid=force]
\showgrid

\starttext

\startluacode
  local otfdata  = fonts.ids[font.current()].shared.otfdata
  local ascent   = otfdata.metadata.ascent
  local descent  = otfdata.metadata.descent

  local tascent  = (otfdata.pfminfo.os2_typoascent  + ascent ) / 1000
  local tdescent =-(otfdata.pfminfo.os2_typodescent - descent) / 1000
  local linegap  = (otfdata.pfminfo.linegap)                   / 1000

  tex.sprint(
    string.format(
      "\\setupinterlinespace[height=\%sem, depth=\%sem, distance=\%sem]",
      tascent, -tdescent, linegap
    )
  )
\stopluacode

\pardir TRT \textdir TRT
\input ibn_hisham.txt

\stoptext
