maroto icon indicating copy to clipboard operation
maroto copied to clipboard

Cell background color is superimposed on text

Open lordofscripts opened this issue 1 year ago • 0 comments

Describe the bug

The text color (black) appears erased almost in their entirety by the grey/light blue stripes of the background color of each row. Furthermore, I would expect that a font size 12 would fit perfectly into a row height of 4 but it seems disproportionate.

To Reproduce

Steps to reproduce the behavior:

  1. Instantiated instance of Maroto
  2. Default font is Arial Regular 12
  3. With a loop, fill a whole document page with rows of alternating colors with a text on it
  4. See error

Related code:

func main()  {
      const ROW_HEIGHT float64 = 4
      dm := GetPoroto() // code seen in previous bug report, nothing extraordinary

      // an attempt to identify the relation between row height, font height & page height
      for i := range numberOfRows {
		dm.OneRow(strconv.Itoa(i), ROW_HEIGHT, i % 2 != 0)
      }
}

func (p *Poroto) OneRow(txt string, height float64, alt bool) {
        // to print rows in alternate colors so I can identify their height spans
	var bgCol props.Color = ColorLightSkyBlue
	if alt {
		bgCol = ColorGray
	}

        // cell property to set the background color
	var cps props.Cell = props.Cell{
		BackgroundColor: &bgCol,
	}

	var tps *props.Text = p.styler.getTextPropertiesFor(StyDefault) // source in previous bug report...
	var col core.Col = text.NewCol(12, txt, *tps)
	var row core.Row = row.New(height).WithStyle(&cps).Add(col)

	p.maroto.AddRows(row)
}

Expected behavior

The background color of the row (either gray or light blue) should stay in the background, and the black text should be visible on top of the row/column/cell background color. The background colors and the foreground colors are dissimilar, so that the text should be completely visible.

Stacktrace n.a.

Additional details (please complete the following information):

  • OS: Linux/Debian
  • GO Version 1.22
  • Maroto: v2.0.7

Additional context

As you see I have to spend considerable time trying to figure out (or rather guessing out) the relation between row height, page height and font size...

lordofscripts avatar Jun 14 '24 18:06 lordofscripts