[HarfBuzz] hb-view

Adam Twardoch (List) list.adam at twardoch.com
Thu Apr 21 14:21:31 PDT 2011


So far so good!

Two suggestions, which would make my, and some other people's, life
wonderful:

1. Please add a --text-width option that would be mutually exclusive to
the --font-size option (i.e. it would override it). If used, hb-view
should render the text to a given width, i.e. calculate the appropriate
font-size itself. It's quite trivial to make, of course, especially with
your method of drawing the text twice. That would be tremendously
useful. (So if I specify --text-width=480 and --margin=10, the result
will always be 500 pixels/points wide).

2. Please add a --format option, which should take the values "png",
"pdf", "svg" and "txt". This is very simple to do (using
cairo_show_glyphs), but I'm sure you know that. 

In fact, I made a copy of hb-view, called it hb-pdf, and improvised to
patch it in order to turn your PNG context drawing functions into some
that draw onto SVG or PDF. I got it working, and it works well. So it's
very simple to do, but I am too stupid to add the option switching to
hb-view and put it all into one code myself, and especially deal with
the background/foreground setting in SVG/PDF (it seems that the
cairo_pattern_reference functions don't work for me for the background,
or I just don't know how to do it). So for now, my own little hb-pdf
only can do black text on white background, but it has to be some
trivial problem.

Please bear in mind that it's the first time in my life that I touched
some C or C++ code EVER. But your code was clear enough for me to figure
out how to do it (especially when I realized that you get the size of
the canvas by calling draw() twice).

Actually, this really is wonderful -- since this is based on Cairo, I
get very clean SVG and PDF output as well, so it would be greatly useful
if you added this to hb-view.

The "txt" format (which could be named differently, and could also be
Json, or XML, I don't care), should output:
* The actual font size used (useful with --text-width)
* The dimensions of the text (width and height)
* Tuples of (glyph IDs, x-pos, y-pos) used for rendering

I think it should be no more than 1-2 hours, and you'd make me really
happy. Plus, that would allow me to run REALLY extensive tests on LOTS
of fonts -- which might help me find some potential bugs or problems.

Many thanks,
Adam




More information about the HarfBuzz mailing list