--- /dev/null
+fpgm
+{
+ # Move point rounding up
+ void 2 moveRoundUp pt
+ push 0b01001010 # RTG 6/8
+ SROUND
+ MDRP[pmrg]
+ RTG
+ ENDF
+
+ # Move point rounding down
+ void 3 moveRoundDown pt
+ push 0b01000110 # RTG 2/8
+ SROUND
+ MDRP[pmrg]
+ RTG
+ ENDF
+
+ # Based on FontForge FDEF 8
+ void 4 ipRound pt ptRP1 ptRP2
+ SRP2
+ SRP1
+ DUP
+ IP
+ MDAP[r]
+ ENDF
+
+ # Same as ipRound, but round up at low PPEM
+ void 5 ipMiddleBar pt ptRP1 ptRP2
+ MPPEM
+ push 10
+ LTEQ
+ IF
+ push 0b01001001 # RTG 5/8
+ SROUND
+ EIF
+ SRP2
+ SRP1
+ DUP
+ IP
+ MDAP[r]
+ RTG
+ ENDF
+
+ # Based on FontForge FDEF 6
+ FDEF 6 isGrayscale
+ push 34 1
+ GETINFO
+ LT
+ IF
+ push 0b00100000
+ GETINFO
+ NOT
+ NOT
+ ELSE
+ push 0
+ EIF
+ ENDF
+
+ # Based on FontForge FDEF 7
+ FDEF 7 isClearType
+ push 36 1
+ GETINFO
+ LT
+ IF
+ push 0b01000000
+ GETINFO
+ NOT
+ NOT
+ ELSE
+ push 0
+ EIF
+ ENDF
+
+ # Position point of diacritic relative to CVT
+ void 8 posDiac pt cvtGap cvtRef
+ push 0 # Twilight point
+ push 0 # Zone
+ SZP0
+
+ # Position twilight point
+ SWAP
+ MIAP[r]
+
+ # Move pt
+ RCVT
+ ROUND[w]
+ push 1.0 # Min
+ MAX
+ MSIRP[rp0]
+
+ push 1
+ SZP0
+ ENDF
+
+ # Shift diacritic on y axis, with minimum distance
+ void 9 yShiftDiac pt cvtGap ptRef
+ SVTCA[y]
+ SRP0
+
+ # Get distance
+ RCVT
+ ROUND[w]
+ push 1.0 # Min
+ MAX
+
+ # Move
+ MSIRP
+ ENDF
+
+ # Shift diacritic on y axis, without minimum distance, rounding down
+ void 10 yShiftStackedDiac pt cvtGap ptRef
+ SVTCA[y]
+ SRP0
+
+ # Get distance
+ RCVT
+ push 0b01000101 # RTG 1/8
+ SROUND
+ ROUND[w]
+ RTG
+
+ # Move
+ MSIRP
+ ENDF
+
+ # Horizontally center diacritic
+ void 11 xCenterDiac ptBaseLeft ptDiacLeft ptDiacRight ptBaseRight
+ push 0
+ push 12
+ CALL
+ ENDF
+
+ # Horizontally center diacritic, with EM offset
+ void 12 xCenterDiacOffset ptBaseLeft ptDiacLeft ptDiacRight ptBaseRight valOffset
+ SVTCA[x]
+
+ # Prepare offset
+ push 0 0 # TEMP cvt index
+ ROLL
+ WCVTF
+ RCVT
+
+ # Calculate shift to center
+ SWAP
+ GC[cur] # ptBaseRight
+ ROLL
+ GC[cur] # ptDiacRight
+ SUB
+ push 4
+ MINDEX
+ GC[cur] # ptBaseLeft
+ ADD
+ ROLL
+ # Set ref point
+ DUP
+ SRP0
+ DUP
+ GC[cur] # ptDiacLeft
+ ROLL
+ SWAP
+ SUB
+ push 2.0
+ DIV
+
+ # Add offset
+ ROLL
+ ADD
+ push 0b01000111 # RTG 3/8
+ SROUND
+ ROUND[g]
+ RTG
+
+ # Move
+ MSIRP
+ ENDF
+
+ # Move point by rounded cvt value,
+ # intended for composites
+ void 13 moveCvtRight ptRef cvtRight pt
+ ROLL
+ SRP0
+ SWAP
+ RCVT
+ ROUND[g]
+ MSIRP[rp0]
+ ENDF
+
+ # Move point by two rounded cvt values,
+ # intended for composites
+ void 14 moveCvtRightLeft ptRef cvtRight cvtLeft pt
+ ROLL
+ RCVT
+ ROUND[g]
+ ROLL
+ RCVT
+ ROUND[g]
+ push 1.0 # Min
+ MAX
+ ADD
+ ROLL
+ SRP0
+ MSIRP[rp0]
+ ENDF
+}