TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Devnagari ASCII Art Generator, How to Make?

1 pointsby shivajikobardanalmost 2 years ago
This is an example of Nepali sentence. Nepali is based on Devanagari Script.<p>यो फोरम मलाई एकदम मन पर्छ|<p>https:&#x2F;&#x2F;nepalilanguage.org&#x2F;alphabet&#x2F;#:~:text=Each%20of%20the%20following%2033,%2F%2C%20%E0%A4%AB%20%2Fp%CA%B0a%2F%2C These are the vowels and consonants in Nepali.<p>A Nepali consonant can take these many forms. &quot;Ka&quot; is first letter of Nepali consonant.<p>Expected Input<p>यो फोरम मलाई एकदम मन पर्छ|<p>And any character like a,b,c,.,&#x2F;,<i>,+,- based on which the ASCII art will be generated.<p>Expected Output<p>Every letter should be scaled and drawn with the given character, say for example &quot;</i>&quot;. Like below.<p>Plan 1:<p>1) Accept Nepali characters as input. And parse each character.<p>example यो फोरम मलाई एकदम मन पर्छ|<p>2) Get the shape of each character.<p>3) Scale the shape.<p>4) Redraw the shape using &quot;*&quot; or anything given by user as input.<p>Plan 2:<p>1) Take Nepali character as input<p>2) Convert to Unicode.<p>3) Process the Unicode.<p>4) Display Nepali as output.<p>I&#x27;m wondering how could I do this? Language doesn&#x27;t matter but I&#x27;d prefer, C, C++ or Javascript.<p>Here are the images used in the post.<p>https:&#x2F;&#x2F;imgur.com&#x2F;a&#x2F;GIUljrK

2 comments

Someonealmost 2 years ago
1) render string at large font size to monochrome bitmap<p>2) loop over all pixels in the bitmap, writing spaces or asterisks depending on bit value<p>You can also render anti-aliased to grayscale and use blacker&#x2F;whiter ASCII characters.<p>Many languages have libraries&#x2F;support for #1, and for accessing individual pixels in a bitmap. If you have that, #2 is trivial.<p>The most difficult part may be to make sure to pick a font that allows you to do whatever you want to do with the ASCII art.
yawpitchalmost 2 years ago
Never tried anything like this, but I’d assume you’d probably use Freetype to render an existing Devanagari font to a matrix, then map each pixel position and brightness to a corresponding ASCII character… effectively your result is just a larger image that uses very large, letter-snapped “pixels” to represent shades of grey.<p>One possible (and randomly found) starting off point, in Go: <a href="https:&#x2F;&#x2F;fiwippi.net&#x2F;blog&#x2F;post&#x2F;rendering_images_with_ascii_characters_in_go" rel="nofollow noreferrer">https:&#x2F;&#x2F;fiwippi.net&#x2F;blog&#x2F;post&#x2F;rendering_images_with_ascii_ch...</a>