Khatat: A Reed Pen for the Screen

Personal project · Mac app and web app

Case Study -

Khatat with a Nastaliq practice sheet: rows of alifs, the letter be with its dot, a kashida and red nuqta, over slanted script guides, with the brush library open on the right

Open Khatat

Key Skills: Product Design • Interaction Design • Tool Design • Prototyping in Code


The Challenge: Arabic and Persian calligraphy is written with a qalam, a reed pen cut flat at an angle. Its thick and thin strokes come from that angle, and every letter is measured in the rhombic dots (nuqta) the pen makes. Digital tools don’t think this way: drawing apps offer round brushes, calligraphy apps mostly turn typed text into fonts, and Persian Nastaliq is rarely considered at all.

The Goal: A free tool that writes like a reed pen, teaches the proportions of each script, and keeps every stroke editable.


How the Brush Engine Works

Most painting apps stamp round dabs. Khatat treats the nib as a flat shape and fills the exact area it sweeps, the way a reed leaves ink. Draw on the paper below, then switch between the three stages.

Three stages of a stroke drawn by Khatat’s engine: flat nibs placed along a path, the shapes swept between them, and the filled stroke
  1. 01

    Record

    Position, pressure, tilt, rotation and time, at the pen’s full rate.

  2. 02

    Even out

    Re-spaced every 2 pt, so a mouse and a tablet draw the same line.

  3. 03

    Sweep

    Each pair of nibs joins into one shape, and overlaps never darken.

  4. 04

    Repeat

    A 64-bit seed per stroke, so it redraws identically on Mac and web.

A Nib With Weight

Weight puts the nib on a spring. It glides through a shaky hand, which suits long kashida strokes.

The same shaky stroke drawn twice: with no weight every tremor shows; with weight 0.7 the stroke is a smooth curve

Brush Settings

Grouped like a pen: the nib, how it responds, its weight, the stroke and the ink. These six shape a stroke the most.

The same stroke with the nib at 0, 45 and 90 degrees

Nib angle

The reed’s edge to the baseline: 70° for Naskh, 60° for Nastaliq. It can also follow the stroke or the pen’s rotation.

The same stroke with roundness 8, 35 and 100 percent

Roundness

The nib’s thickness. A cut reed is 6–14%; 100% is a square or round nib.

The same pressure drawn with curves 0.5, 1 and 2.2

Pressure curve

How quickly pressure becomes width. Below 1 feels soft, above 1 firm.

A stroke that speeds up in the middle, with speed thinning off, 0.45 and 0.85

Speed thinning

Fast strokes run thin, like a reed running short of ink.

A stroke with no taper, a taper out, and tapers in and out

Tapers

Narrow the start and end over a set length, easing in.

The same stroke with dry edge off, 0.4 and 0.85

Dry edge

Frays the outline like a dry or freshly cut reed.

Also in the panel: size, variation by pressure, tilt, rotation, speed or direction, opacity, smoothing, stabilizer, drag, taper tip, seven traditional inks, and your own saved brushes.

The brush settings panel: nib shape, an angle dial, and size and roundness that respond to pressure or pen rotation

Key Design Decisions

Guides Measured in Nuqta

Pick a script and the page sets the alif height in dots, the nib angle, line spacing and slant, and loads the matching brush. A faint tracing text can sit underneath as a model.

The page panel with Nastaliq guides: alif height three nuqta, slant guides at 22 degrees, and a tracing text

Strokes Stay Editable

A hand-drawn stroke opens as a few Bézier anchors, edited like Illustrator paths, and keeps the pen’s pressure.

A brush stroke shaped like the letter be, opened for editing, with Bézier anchors and handles along its path

Made for Right-to-Left Writers

Shortcuts follow the physical key, so they work with a Persian or Arabic keyboard layout. Tab hides the panels for focused writing, in light or dark mode.

Khatat in dark mode with the brush picker open next to the tool strip

One Engine, Two Platforms

A native Mac app, and the same tool in any browser, including an iPad with Apple Pencil. Files open on either and look identical.

9 Scripts

Guide presets from Naskh and Thuluth to Nastaliq and Square Kufic.

21 Brushes

Templates for each script and for expressive work.

Free

In any browser at khatat.saminazari.me, with PNG, SVG and PDF export.


Challenges & Trade-offs

The hardest problems were about trust. At first the same brush drew visibly different strokes on a mouse and a tablet, because smoothing counted pen events rather than distance. Measuring along the stroke instead raised how closely the two agree, for the least consistent brush, from 54% to 96%. Undo had a subtler bug: a weighted stroke finishes a moment after the pen lifts, and that late step merged with the next change, so one undo removed two strokes. Every change is now its own step. Both fixes follow one rule a calligrapher would recognise: the same gesture should always make the same mark, and undo should take back exactly one.