Documentation
How to use the web fonts, Python converter, and LaTeX package in your projects.
Web Fonts
Install the web fonts package and import the CSS for the families you need.
Install
npm install @nepalibhasha/fonts
Import CSS
/* Import one or more font families */
@import '@nepalibhasha/fonts/css/noto-sans-devanagari.css';
@import '@nepalibhasha/fonts/css/mukta.css';
@import '@nepalibhasha/fonts/css/hind.css';
@import '@nepalibhasha/fonts/css/noto-serif-devanagari.css';
Use in CSS
body {
font-family: 'Noto Sans Devanagari', sans-serif;
}
.serif-text {
font-family: 'Noto Serif Devanagari', serif;
}
Nepali-only subsets
For smaller file sizes, use the -nepali variant CSS files which only include Devanagari + Basic Latin glyphs:
@import '@nepalibhasha/fonts/css/noto-sans-devanagari-nepali.css';
@import '@nepalibhasha/fonts/css/mukta-nepali.css';
Python Converter
Convert legacy Nepali font text (Preeti, Kantipur, Sagarmatha, Himalb) to Unicode.
Install
pip install nepali-converter
Python API
from nepali_converter import convert, detect_font
# Auto-detect and convert
font = detect_font("g]kfn") # returns "preeti"
text = convert("g]kfn", "preeti") # returns "नेपाल"
# Convert with known font
text = convert("g]kfn", "preeti")
CLI
# Convert a file
nepali-convert --font preeti input.txt -o output.txt
# Auto-detect font
nepali-convert --font auto input.txt
# Convert from stdin
echo "g]kfn" | nepali-convert --font preeti
JavaScript Converter
Use the converter in Node.js or browser applications.
Install
npm install @nepalibhasha/converter
Usage (ESM)
import { convert, detectFont } from '@nepalibhasha/converter';
const font = detectFont("g]kfn"); // "preeti"
const text = convert("g]kfn", "preeti"); // "नेपाल"
Browser (script tag)
<script src="path/to/converter.js"></script>
<script>
const text = NepaliConverter.convert("g]kfn", "preeti");
const font = NepaliConverter.detectFont("g]kfn");
</script>
LaTeX Package
Typeset Nepali text with XeLaTeX using the included font families.
Usage
\documentclass{article}
\usepackage{nepali}
\begin{document}
\begin{nepali}
नमस्ते संसार
\end{nepali}
\end{document}
Compile
xelatex document.tex
Font selection
The package auto-detects Noto Sans/Serif Devanagari by default. To override, use \setnepalifont:
% Override the default font
\setnepalifont[Script=Devanagari, Language=Nepali]{Mukta}
% Compile with xelatex or lualatex (pdflatex is not supported)