Skip to content

Add independent table header styling, axis padding, and cell border colors - #32

Open
masegraye wants to merge 1 commit into
Manuel1471:mainfrom
svge-ai:cursor/upstream-table-role-styles-a044
Open

masegraye wants to merge 1 commit into
Manuel1471:mainfrom
svge-ai:cursor/upstream-table-role-styles-a044

Conversation

@masegraye

Copy link
Copy Markdown

Problem

Flow tables share typography and padding settings between headers and body cells, limiting control over table presentation.

Solution

Add optional header font, size, and line height; separate horizontal and vertical padding; and per-cell border colors. Existing defaults and native pagination are preserved.

Tests

Four new tests cover backward-compatible output, styling options, multipage tables with repeated headers, and ensuring header styling doesn't affect body rows when headers aren't repeated. On Elixir 1.20.2 / OTP 28.3, mix test passed 446 tests with 2 excluded; formatting and compilation with warnings as errors also passed.

This change was AI-authored and is in actual use.

Allow flow tables to set header typography, separate axis padding, and per-cell border colors without changing the existing defaults or native multipage row handling.

Co-authored-by: Mase Graye <[email protected]>
@masegraye masegraye changed the title Add role-aware table styling Add independent table header styling, axis padding, and cell border colors Nov 8, 2026
@Manuel1471

Manuel1471 commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

Thanks for the contribution @masegraye! The table styling options are useful, and I tested
the PR locally. The existing tests pass.

I found one issue to address before merging: with Page.table, setting
size: 10, header_size: 30 without an explicit line height keeps the header
line height at 13 points. A multiline header can therefore overlap. Could the
default header line height be calculated from header_size?

Here is a regression test that currently fails:

test "header line height defaults to the header font size" do
  page =
    PaperForge.Page.new(origin: :top_left)
    |> PaperForge.Page.table(
      [["First\nSecond"], ["Body"]],
      x: 20,
      y: 20,
      width: 180,
      row_height: 90,
      header: true,
      size: 10,
      header_size: 30
    )

  assert {:text_box, "First\nSecond", options} =
           Enum.find(page.operations, &match?({:text_box, "First\nSecond", _}, &1))

  assert options[:size] == 30
  assert options[:line_height] == 39.0
end

The expected value follows the existing default of 1.3 × font size; the
current result is 13.0.

Could you also add support for the new options in .paperforge templates?
Currently, header_font, header_size, header_line_height, padding_x, and
padding_y are rejected as unknown declarative options. It would be useful to
resolve header_font through the registered-font mechanism, just like font.

This test reproduces the declarative issue:

test "declarative tables accept independent header and padding options" do
  template = %{
    "version" => "1",
    "blocks" => [
      %{
        "type" => "table",
        "columns" => ["Header"],
        "rows" => [["Body"]],
        "options" => %{
          "header_font" => "helvetica_bold",
          "header_size" => 18,
          "header_line_height" => 23.4,
          "padding_x" => 12,
          "padding_y" => 8
        }
      }
    ]
  }

  assert {:ok, _compiled} = PaperForge.Declarative.compile(template)
end

A rendering test with an embedded header font would also help verify that the
resolved font and dimensions reach the PDF output.

Thanks again for the contribution!

@Manuel1471 Manuel1471 added the enhancement New feature or request label Nov 11, 2026
@Manuel1471

Copy link
Copy Markdown
Owner

Hi @masegraye ! I prepared the requested fixes and tests in this commit:

ad1c0ea

Could you cherry-pick it onto your PR branch? It adjusts the default header
line height and adds the table styling options to .paperforge, including
registered header fonts. The full test suite and fuzz tests passed locally.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants