<p>I think <a href="https://en.wikipedia.org/wiki/Dilation_(morphology)" rel="noreferrer">dilation</a> would be close enough to what you want.</p>

<p>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.</p>

CC BY-SA 3.0
2018-03-23T15:46:21.137Z
2018-03-23T15:46:21.137Z
Olivier
<p>The best way to do proper outlines, is unfortunately, also the hardest. It involves calculating an offset curve, usually from the <a href="https://en.wikipedia.org/wiki/Medial_axis" rel="noreferrer">medial axis</a> or <a href="https://en.wikipedia.org/wiki/Straight_skeleton" rel="noreferrer">straight skeletons</a>, 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.</p>

<p>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.</p>

CC BY-SA 3.0
2018-03-24T03:55:32.083Z
2018-03-24T03:55:32.083Z
user1118321
<p>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.</p>

<p>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.</p>

<p>So, is there an algorithm to bold an outline font? What is it?</p>

<font-rendering>
Is there an algorithm to bold an outline font?
Limina102
# Is there an algorithm to bold an outline font?

(Asked by: username_0 on 2018-03-23)

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?

**Tags:** font-rendering


---

## 2 answers

### Answer by username_1 on 2018-03-23. Score: 6 | Accepted answer

I think [dilation](https://en.wikipedia.org/wiki/Dilation_(morphology)) 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.


---

### Answer by username_2 on 2018-03-24. Score: 7

The best way to do proper outlines, is unfortunately, also the hardest. It involves calculating an offset curve, usually from the [medial axis](https://en.wikipedia.org/wiki/Medial_axis) or [straight skeletons](https://en.wikipedia.org/wiki/Straight_skeleton), 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.


---

