Trying to make a plugin, why is the text all wonky?
Why my text wonky?
Context
I'm trying to develop a plugin so that I can open groff_ms
documents directly in zathura without having to compile them first
The plugin
The plugin runs groff_ms -Z -Tpdf
, then it interprets the troff intermediate language and draws each page. The documentation for this intermediate format can be found here but all you need to know is that assuming that
- the page is A4 size
- the page has a DPI of 72
- The page uses the Times font family
the language describes various drawing and movement commands for how and where to draw text to the screen. Here is a commented example (The page that zathura is configured with has a width of 595.275624 and a height of 841.889736, so all the commands with integer parameters are converted to floating point and divided by 1000.0)
x T zathura // Groff is configured to use zathura
x res 72000 1 1 // The resolution of the page is 72 DPI
x init // Init command
p1 // Begin page 1
x font 5 TR // Associate the number 5 with Times Roman
f5 // Switch to font 5 (Times Roman)
s10000 // set the font size to pt. 10
V12000 // Move to the vertical position 12 on the page
H72000 // Move to the horizontal position 72 on the page
md // Set the font color to black
DFd // Set the fill color for shapes and such to black
tLik // At the current cursor position write "Lik"
H85790 // Move to the horizontal position 85.79 on the page
te // At the current cursor position write "e"
wh2500 // Move the curosr to the right 2.5 units and indicate that this movement represents a whitespace
tW // At the current cursor position write "e"
H101370 // Move to the horizontal position 101.37 on the page
tater // At the current cursor position write "ater"
wh2500 // Move the curosr to the right 2.5 units and indicate that this movement represents a whitespace
tfor // At the current cursor position write "for"
wh2500 // Move the curosr to the right 2.5 units and indicate that this movement represents a whitespace
tChocolate // At the current cursor position write "Chocolate"
This results in the top of the page looking like this
So what's the problem?
When I interpret documents using my plugin, depending on the zoom of the document, it interferes with my draw commands and it renders text either too close together or too far apart
Is their a way I can adjust my plugin to account for this? I've tried everything I can think of but the problem persists.