A few days ago, while researching for new ciphers to add to my application, I came across Pigpen cipher. While this cipher has no actual application in the modern era as it's a monoalphabetic cipher - easily crackable with cryptanalysis, and often included in children's book as a quiz - I find this an interesting one to try and implement in Qt. Pigpen cipher works by assigning letters to symbols in a grid-like fashion (hence the name). The sender will encrypt the plaintext with a diagram similar to the following Afterward, he/she can send it to the receiver. Providing that the receiver has the same diagram, the ciphertext can be decrypted easily, revealing the original message. The problem now is to convert alphanumeric characters to those of Pigpen. At first, I brainstormed several ways
Well, after a while I decided that those ideas are just too complex to handle properly without spending a ton of effort debugging. And that's how a much simpler concept came to my mind: Downloading a font for Pigpen cipher online, then import it into Qt! A quick Google search later I settled on this site. The problem now, is that I haven't worked with QFont before, although I have imported other type of file like text files (.txt) or images (.png). Another quick search, and I ended up on this post from SO. So finally I'm ready to start. First, I created a QResourceFile (.qrc), then added a prefix After that, I added my .otf file (OpenType Font) Next, I added the magic bit of code that do the job of importing the font and creating the QFont At this point, I realized that I haven't added any extra widgets to test my new font, so I quickly whipped up a QTextEdit And add some more code to transform its font... Voilà! Mission accomplished!
Additional information : You can read more about QFontDatabase here. If you have any question regarding this post, please ask me in the comment section below. I'll happily assist you.
0 Comments
|