DEV Community

Cover image for How I Built a Free Arabic Calligraphy Generator with HTML, CSS & JavaScript
keke lele
keke lele

Posted on

How I Built a Free Arabic Calligraphy Generator with HTML, CSS & JavaScript

Introduction

Arabic calligraphy is one of the most beautiful art forms in the world. I wanted to create a simple web tool that lets anyone generate Arabic calligraphy from English text — no design skills needed.

In this post, I'll share how I built Arabic Calligraphy Generator using just HTML, CSS, and vanilla JavaScript.

The Challenge

Building this tool came with some interesting challenges:

  1. Right-to-Left (RTL) text rendering — Arabic reads from right to left
  2. Font loading — Arabic calligraphy fonts are large files
  3. Translation — Converting English input to Arabic script
  4. Export options — Users need to download their creations

Tech Stack

I kept it simple:

  • HTML5 Canvas for rendering
  • Vanilla JavaScript (no frameworks)
  • Google Fonts for Arabic typefaces
  • Canvas API for PNG/JPG export

Key Implementation

1. Handling RTL Text

The most important CSS rule for Arabic text:

.arabic-text {
  direction: rtl;
  text-align: right;
  font-family: 'Noto Naskh Arabic', serif;
}
Enter fullscreen mode Exit fullscreen mode

2. Loading Arabic Fonts

I used multiple calligraphy styles. Here's how to preload them:



Enter fullscreen mode Exit fullscreen mode

3. Canvas Export Function

function exportAsImage(format) {
  const canvas = document.getElementById('calligraphy-canvas');
  const link = document.createElement('a');
  link.download = `calligraphy.${format}`;
  link.href = canvas.toDataURL(`image/${format}`);
  link.click();
}
Enter fullscreen mode Exit fullscreen mode

Lessons Learned

  • Start simple — I launched with 3 fonts, now it has 11
  • Performance matters — Arabic fonts are heavy, lazy loading helps
  • User feedback is gold — Real users found bugs I never imagined

Try It Out

You can check out the live tool here: Arabic Calligraphy Generator

It's completely free — no signup required. Just type your text, choose a style, and download.

What's Next?

I'm planning to add:

  • More calligraphy styles (Diwani, Maghrebi)
  • Custom color options
  • Social sharing features

Thanks for reading! If you have questions about building multilingual web tools, drop a comment below. 👇

Top comments (0)