Computer Graphics Asked on December 23, 2021
One of my friend got a pretty pretty Chinese hand-writing font. However, the font has no bold version, since it is handwritten. And I would like to help generate a bold one automatically by code.
I searched the Internet but didn’t find any materials about it. My friend told me that his Kindle could “bold” that font automatically by setting “contrast”. So I tried to firstly convert the outline font to bitmap, then change the contrast of the glyphs one by one, and finally output a bitmap “bolded” font. Everything went well except the processed font is aliased, i.e. looks blocky, since that the bitmaps is binary images, i.e. there are no gray pixels. But I can’t find a popular font type that supports bitmap plus gray pixels.
So, is there an algorithm to bold an outline font? What is it?
The best way to do proper outlines, is unfortunately, also the hardest. It involves calculating an offset curve, usually from the medial axis or straight skeletons, which are non-trivial to calculate. Once you have those, you can calculate the distance of any point from the input object and decide whether to draw the outline or bolding, or not.
A simpler way to do it, which doesn't look quite as nice, is to use a MinMax filter. This is a sliding 2D box filter that calculates either the minimum or maximum value within the box at each input pixel. If you have black text on a white background, you can use the min filter to generate an outline. Use the max if it's white text on a black background. Other shapes, such as a circular area will produce different results that may be better for some fonts. In most cases, you'll end up either rounding off or squaring off corners as the size of the filter increases.
Answered by user1118321 on December 23, 2021
I think dilation would be close enough to what you want.
It is likely that font processing software would have more advanced algorithms to avoid rounding all the corners, among other things. Fonts are a whole separate world with a lot of rules about how things should be done to look right. No simple image processing algorithm will respect all those rules.
Answered by Olivier on December 23, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP