Open mazzegi opened 3 years ago
Same here just changing color bunch of times. Anybody has an idea on how to solve this ?
Here is an illustration of the problem.
I iterate over each char of the word Geisha and change the color of one given char. I do that 6 times. The later I change the color, wider is the space 🤷
After debug, the problem seems to be here: https://github.com/signintech/gopdf/blob/master/list_cache_content.go#L53
When adding char, it creates one "boxes" of chars per font configuration. When the font config is different (bold vs normal, new color, etc.), it creates a new "box". The coordinate x,y of the next "box" is calculated on the line above.
If I understand correctly the code, it adds the width of the "box" to x to float the box to the left. But in our case, the next box should be just behind the previous box and not x+previous_box_width if that make sense.
I fixed it https://github.com/signintech/gopdf/pull/232
@oneplus1000 can you close this issue if it has been resolved?
Given the following code
... produces that strange result:![image](https://user-images.githubusercontent.com/15996236/94299495-08f24c00-ff68-11ea-9766-8870dbbc499f.png)
It seems, that with every single call to
pdf.Text()
the spacing before the final boldamet
get's bigger.You may ask, why not combining several calls of
pdf.Text()
into one, but in reality this happens in a kind of automatism, where it's hard to avoid.Any clues? Thanks