Re: FW: Text rendering issues with gm convert and unifont

Bob Friesenhahn <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.help
Message-ID <[email protected]>
On Sat, 21 May 2016, Neil Youngman wrote:

> I am trying to render plain text to fax and I need to support as wide a
> range of characters as possible, ideally the whole Unicode BMP.
>
> Combining gm convert with unifont might meet this requirement, as long
> as I can get it to render cleanly.
>
> The simplest approach is:
>
> gm convert -font /usr/share/fonts/truetype/unifont/unifont.ttf
> -pointsize 12 -density 204x196 -units PixelsPerInch -geometry
> 1728x2292\! -depth 1 -monochrome -compress fax /tmp/4778.txt /tmp/test.tif

Try something like

~~~~~~~~~~~~~~~~~~~~~
gm convert -font /usr/share/fonts/truetype/unifont/unifont.ttf 
-pointsize 12 -density 178x180 -page Letter txt:/tmp/4778.txt 
-background white -extent 1728x2292-100-200 +dither -type bilevel 
-compress fax -density 204x196 /tmp/test.tif
~~~~~~~~~~~~~~~~~~~~~

Use -page to specify the target page size for rendering the text 
(-page can also accept a numeric type geometry).  I reduced the 
resolution so that the rendered text is small enough to add a border. 
The result is placed on a 1728x2292 white image using -extent (with 
offset) and then -density is re-specified to satisfy FAX.

This also seems to work to add a top and left margin as part of the 
-page specification when the text is originally rendered, rather than 
via -extent:

~~~~~~~~~~~~~~~~~~~~~
gm convert -font /usr/share/fonts/truetype/unifont/unifont.ttf
-pointsize 12 -density 178x180 -page Letter+100+200 txt:/tmp/4778.txt
-background white -extent 1728x2292 +dither -type bilevel
-compress fax -density 204x196 /tmp/test.tif
~~~~~~~~~~~~~~~~~~~~~

Given that the output is bilevel, it is best to do as little 
processing (e.g. resize) on the image as possible.

Bob
-- 
Bob Friesenhahn
[email protected], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/

------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.