Is there an algorithm to bold an outline font?

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?

2 Answers

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

Add your own answers!

Related Questions

Why does opengl use 4d matrices for everything?

3  Asked on August 27, 2021 by yoris


Defining “inside” and “outside” of a 3D space

2  Asked on August 27, 2021 by avatrin


Which perspective projection matrix to use

1  Asked on August 27, 2021 by nixcc


How do you apply a normal map to a 3d mesh?

1  Asked on August 27, 2021 by calvin-godfrey


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir