@Dal_1 = [@aDal.fina @aDal.fina_BaaDal @aDal.fina_KafDal @aDal.fina_LamDal
          @aDal.isol];
@1st_2 = [@RaaWaw @AlefHamzaBelow];
@1st_4 = [@aHeh.isol @aHeh.fina @aHeh.fina_KafHeh @aHeh.fina_LamHeh];

// final alef with no hamza above
@Alf_1 = [uni0627.fina_LamAlfFina uni0625.fina_LamAlfFina];
@Alf_2 = [@aAlf.fina @aAlf.fina_KafAlf @aAlf.fina_KafMemAlf
          @aAlf.fina_LamAlfFina @aAlf.fina_LamAlfIsol @aAlf.fina_MemAlfFina];

@Kaf_1 = [@aKaf.init_KafHeh
          @aKaf.init_KafMemIsol];
@Kaf_2 = [@aKaf.init_KafBaaInit @aKaf.init_KafMemAlf];
@Kaf_3 = [@aKaf.init @aKaf.init_KafLam @aGaf.isol];
@Kaf_4 = [@aKaf.init_KafYaaIsol];
@Kaf_5 = [@aKaf.init_KafMemInit @aKaf.init_KafRaaIsol];
@Raa_1 = [@RaaWaw @aDal.fina @aDal.isol @aDal.fina_BaaDal @aDal.fina_KafDal
          @aDal.fina_LamDal];
@Raa_2 = [@aRaa.fina_MemRaaIsol];
@2nd_3 = [@aSen.init_SenHaaInit @aSad.init_SadHaaInit @aLam.init_LamHaaHaaInit];
@2nd_4 = [@aSad.init_AboveHaa @aSen.init_AboveHaa @aHeh.init_AboveHaa
          @aHaa.init_AboveHaa @aMem.init_AboveHaa @aKaf.init_AboveHaa
          @aAyn.init_AboveHaa];
@Teh_m = [uni0629.fina_LamHeh uni0629.fina_KafHeh // teh marbuta
          uni06C3.fina_LamHeh uni06C3.fina_KafHeh];

feature kern {
  // we don't want to kern those if there is tashkil as it touches the kaf
  pos @RaaWaw' <-600 0 -600 0>  @Kaf_1;
  pos @RaaWaw' <-300 0 -300 0>  @Kaf_4;
  pos @Dal_1'  <-600 0 -600 0>  @Kaf_1;
  pos @Dal_1'  <-400 0 -400 0>  @Kaf_4;
} kern;

lookup YaaBari3Kern {
  pos @aAyn.init <0 0 440 0>;
  pos @aFaa.init <0 0 710 0>;
  pos @aHeh.init <0 0 400 0>;
  pos @aLam.init <0 0 955 0>;
  pos @aMem.init <0 0 520 0>;
  pos @aSen.init <0 0 150 0>;
  pos @aTaa.init <0 0 150 0>;
  pos uni06BE.init <0 0 400 0>;
} YaaBari3Kern;

feature kern {
  lookupflag IgnoreMarks;
  pos @RaaWaw' <-600 0 -600 0>  @Kaf_5;
  pos @RaaWaw' <-300 0 -300 0> [@Kaf_2 @Kaf_3];

  pos @RaaWaw' <-100 0 -100 0> @2nd_3;

  pos @Dal_1'  <-600 0 -600 0>  @Kaf_5;
  pos @Dal_1'  <-400 0 -400 0> [@Kaf_2 @Kaf_3];

  pos @Raa_2' <-400 0 -400 0> [@Kaf_2 @Kaf_3 @Kaf_4];
  pos @Raa_2' <-800 0 -800 0> [@Kaf_1 @Kaf_5];
  pos @Raa_2' <-200 0 -200 0> @2nd_3;
  pos @Raa_2' <-400 0 -400 0> @2nd_4;

  // the dots of teh marbuta are very close to exclamation mark
  pos @Teh_m' < 150 0  150 0> exclam;

  // +ve kern so that the tail of raa/waw does not touch the dot of baa
  pos @1st_2' < 170 0  170 0> @aBaaDotBelow;

  // increase advance width for first glyph in 3-letter Baree Yaa ligatures
  pos [@aAyn.init @aFaa.init @aHeh.init @aLam.init
       @aMem.init @aSen.init @aTaa.init uni06BE.init]' lookup YaaBari3Kern
       @aBaa.medi_YaaBari;
} kern;

// we don't want to ignore marks here
feature kern {
  pos @Alf_1' <-500 0 -500 0> [@Kaf_1 @Kaf_5];
  pos @Alf_1' <-200 0 -200 0> @Kaf_2;
  pos @Alf_1' <-250 0 -250 0> @Kaf_3;
  pos @Alf_1' <-300 0 -300 0> @Kaf_4;

  // raa/waw/dal followed by isolated dagger alef followed by madda needs some
  // space to avoid fatha/madda clash
  pos @Raa_1' < 200 0  200 0> uni064E uni0670.isol [uni0653 uni06E4];

  pos [uni0621]' < 200 0  200 0> uni064E uni0670.isol;
} kern;

feature kern {
  lookupflag IgnoreMarks;
  pos @RaaWaw' <80 0 80 0> @aYaa.init;
} kern;

feature kern {
  lookupflag IgnoreMarks;
  // kern heh isol/final followed by kaf, does not happen in Arabic but can be
  // seen in Kurdish or Persian using ZWNJ between them.
  pos @1st_4 uni200C [@Kaf_1 @Kaf_2 @Kaf_3 @Kaf_4 @Kaf_5]' -500;
  // Uniscribe replace ZWNJ with space
  pos @1st_4 space   [@Kaf_1 @Kaf_2 @Kaf_3 @Kaf_4 @Kaf_5]' -500;
  // some applications might just remove it
  pos @1st_4         [@Kaf_1 @Kaf_2 @Kaf_3 @Kaf_4 @Kaf_5]' -500;
} kern;

// were are only interested in subset of already defined classes; the ones with
// wide dots below.
@aYaa_1 = [uni0680.init uni0776.init uni0750.init uni06CE.init uni0775.init uni06BD.init
           uni064A.init uni0755.init uni067E.init uni067B.init uni0753.init uni0752.init
           uni063D.init uni0754.init uni06D1.init uni06D0.init uni06CC.init uni0767.init
           uni0680.init_BaaRaaIsol uni0776.init_BaaRaaIsol uni0750.init_BaaRaaIsol
           uni06CE.init_BaaRaaIsol uni0775.init_BaaRaaIsol uni06BD.init_BaaRaaIsol
           uni064A.init_BaaRaaIsol uni0755.init_BaaRaaIsol uni067E.init_BaaRaaIsol
           uni067B.init_BaaRaaIsol uni0753.init_BaaRaaIsol uni0752.init_BaaRaaIsol
           uni063D.init_BaaRaaIsol uni0754.init_BaaRaaIsol uni06D1.init_BaaRaaIsol
           uni06D0.init_BaaRaaIsol uni06CC.init_BaaRaaIsol uni0767.init_BaaRaaIsol
           uni0680.init_BaaNonIsol uni0776.init_BaaNonIsol uni0750.init_BaaNonIsol
           uni06CE.init_BaaNonIsol uni0775.init_BaaNonIsol uni06BD.init_BaaNonIsol
           uni064A.init_BaaNonIsol uni0755.init_BaaNonIsol uni067E.init_BaaNonIsol
           uni067B.init_BaaNonIsol uni0753.init_BaaNonIsol uni0752.init_BaaNonIsol
           uni063D.init_BaaNonIsol uni0754.init_BaaNonIsol uni06D1.init_BaaNonIsol
           uni06D0.init_BaaNonIsol uni06CC.init_BaaNonIsol uni0767.init_BaaNonIsol
           uni0680.init_BaaYaaIsol uni0776.init_BaaYaaIsol uni0750.init_BaaYaaIsol
           uni06CE.init_BaaYaaIsol uni0775.init_BaaYaaIsol uni06BD.init_BaaYaaIsol
           uni064A.init_BaaYaaIsol uni0755.init_BaaYaaIsol uni067E.init_BaaYaaIsol
           uni067B.init_BaaYaaIsol uni0753.init_BaaYaaIsol uni0752.init_BaaYaaIsol
           uni063D.init_BaaYaaIsol uni0754.init_BaaYaaIsol uni06D1.init_BaaYaaIsol
           uni06D0.init_BaaYaaIsol uni06CC.init_BaaYaaIsol uni0767.init_BaaYaaIsol
           uni0680.init_BaaMemIsol uni0776.init_BaaMemIsol uni0750.init_BaaMemIsol
           uni06CE.init_BaaMemIsol uni0775.init_BaaMemIsol uni06BD.init_BaaMemIsol
           uni064A.init_BaaMemIsol uni0755.init_BaaMemIsol uni067E.init_BaaMemIsol
           uni067B.init_BaaMemIsol uni0753.init_BaaMemIsol uni0752.init_BaaMemIsol
           uni063D.init_BaaMemIsol uni0754.init_BaaMemIsol uni06D1.init_BaaMemIsol
           uni06D0.init_BaaMemIsol uni06CC.init_BaaMemIsol uni0767.init_BaaMemIsol
           uni0680.init_BaaSenAltInit uni0776.init_BaaSenAltInit uni0750.init_BaaSenAltInit
           uni06CE.init_BaaSenAltInit uni0775.init_BaaSenAltInit uni06BD.init_BaaSenAltInit
           uni064A.init_BaaSenAltInit uni0755.init_BaaSenAltInit uni067E.init_BaaSenAltInit
           uni067B.init_BaaSenAltInit uni0753.init_BaaSenAltInit uni0752.init_BaaSenAltInit
           uni063D.init_BaaSenAltInit uni0754.init_BaaSenAltInit uni06D1.init_BaaSenAltInit
           uni06D0.init_BaaSenAltInit uni06CC.init_BaaSenAltInit uni0767.init_BaaSenAltInit];

feature kern {
  lookupflag IgnoreMarks;
    pos @Raa_2' <180 0 180 0> @aYaa_1;
} kern;

feature kern {
  lookupflag IgnoreMarks;
#ifndef QURAN
    pos period.ara' <-300 0 -300 0> [quotedblleft quoteleft];
    pos period' -150 [quotedblright quoteright];
#else
    pos period'     <-300 0 -300 0> [quotedblleft quoteleft];
#endif
} kern;

#ifdef ITALIC
feature kern {
  lookupflag IgnoreMarks;
  pos @Alf_2 <300 0 300 0> [parenleft bracketleft braceleft];

  pos [parenright bracketright braceright] <-100 0 -100 0> [@Kaf_1 @Kaf_2 @Kaf_4 @Kaf_5];
  pos [parenright bracketright braceright] <-200 0 -200 0> [@Kaf_3];

  pos [braceright] <-200 0 -200 0> [@Kaf_1 @Kaf_2 @Kaf_4 @Kaf_5];
  pos [braceright] <-300 0 -300 0> [@Kaf_3];
} kern;
#endif

// proportional digits
feature kern {
  pos uni0661.prop uni0662.prop -100;
  pos uni0661.prop uni0663.prop -100;
  pos uni0661.prop uni0666.prop -200;
  pos uni0661.prop uni0669.prop -100;

  pos uni0662.prop uni0667.prop  100;
  pos uni0662.prop uni0668.prop  -50;

  pos uni0663.prop uni0667.prop  100;

  pos uni0664.prop uni0661.prop  -50;
  pos uni0664.prop uni0668.prop   50;

  pos uni0666.prop uni0661.prop  -50;

  pos uni0667.prop uni0661.prop  -50;
  pos uni0667.prop uni0668.prop  -50;

  pos uni0668.prop uni0661.prop -100;
  pos uni0668.prop uni0662.prop -100;
  pos uni0668.prop uni0663.prop -100;
  pos uni0668.prop uni0666.prop -100;
  pos uni0668.prop uni0667.prop -100;

  pos uni0669.prop uni0668.prop   50;
  pos uni0669.prop uni0660.prop   50;

  pos uni0660.prop uni0667.prop   50;
  pos uni0660.prop uni0668.prop   50;
} kern;

// generated features for anchor points will be inserted here by build script
{%anchors%}

// With ss05 on, kasra is below shadda, so move the shadda up a bit to
// compensate for the kasra.
feature ss05 {
  pos uni0651' <0 210 0 0> [uni0650.small];
  pos uni0651' <0 350 0 0> [uni064D.small];
} ss05;
