asciidoctor / asciidoctor-pdf

:page_with_curl: Asciidoctor PDF: A native PDF converter for AsciiDoc based on Asciidoctor and Prawn, written entirely in Ruby.
https://docs.asciidoctor.org/pdf-converter/latest/
MIT License
1.15k stars 499 forks source link

table font_size is not applied for `a|` cells #926

Closed habamax closed 4 years ago

habamax commented 6 years ago

Theme file snippet:

base:
  font_size: 12

table:
  border_color: a0a0a0
  border_width: $base_border_width
  font_size: 8.5

Asciidoctor snippet:

...
| `ORIGIN`
| `VARCHAR(100)`
| Source system code. `ice#dp_contact_official#denied_entity`

| `SOURCE_ID`
| `VARCHAR(200)`
| Identifier of the denied entity in the list of given type.

| `TYPE`
| `INT`
a|
Type of the entity:

- `1` -- Individual Person
- `2` -- Legal entity
- `3` -- Other
...

How it looks like:

image

I believe that font size specified for table should be applied to all cells.

mojavelinux commented 6 years ago

You're correct that the table / table cell settings don't inherit into an AsciiDoc table cell. That's because an AsciiDoc table cell is effectively a separate / sub document. It would be extremely difficult to have it inherit the settings because it would require the converter for every other block to check if it is inside of a table and change the behavior accordingly. I'm happy to be proven wrong.

habamax commented 6 years ago

Got it. Let us hope we will resolve it sometime in the future.

7SW commented 6 years ago

@mojavelinux: just replied to your remark in #852: making this a scale (%) in the yaml (for both adoc and non-adoc table content) would be great.

antfred commented 5 years ago

Hi, I'm affected by the problem as well and would be very happy to see a fix.

The solution based on a scaling factor would already be very useful. Alternatively I could imagine that being able to apply a custom style (as discussed in #483 ) would also work and allow for more flexibility

DaneWeber commented 5 years ago

It took me a bit to figure out that this was the cause of my inability to format a table cells.

Is there a workaround? I'm trying to figure out if there's a way to add some specificity to the cells so that I can apply a small font_size to the a cells.

DaneWeber commented 5 years ago

@mojavelinux Can you point me to the relevant code where the sub-document rendering is triggered? I'd like to try my hand at adding this feature.

Update: It looks like the below link points to where the a cell rendering is triggered. Let me know if I'm on the wrong path. https://github.com/asciidoctor/asciidoctor-pdf/blob/master/lib/asciidoctor-pdf/converter.rb#L1683-L1686

7SW commented 5 years ago

Hi @DaneWeber,

Did you have the opportunity to look at this yet? Maybe we can come up with a 'simple solution' (affecting only text-size...). Would be wonderful. Not Ruby-savvy here, but if I can help, I'd love to.

logicsalad commented 4 years ago

Are there any news or solutions for this issue?

I understand the difficulties that could arise when using sections, etc. inside the cell so maybe inheriting the font size could be optional via a separate setting in the theme. This would make it work at least when just simple formatting like lists or images are used. Also the proposed scale factor would be fine.

It somehow works when using the docbook/FOP toolchain but I don't know to which extend.

mojavelinux commented 4 years ago

If we ignore the style overrides from elements in the cell, this is rather easy to implement. I have submitted a proposal that merely inherits the font properties from the table (like other cells). See https://github.com/asciidoctor/asciidoctor-pdf/pull/1678

It somehow works when using the docbook/FOP toolchain but I don't know to which extend.

This is not a helpful statement since that's a completely different technology. You're comparing apples to oranges.

habamax commented 4 years ago

Thx, will test it as soon as it lands into master.

mojavelinux commented 4 years ago

I think I can implement a very crude font scaling for elements that define their own font size. They would be scaled by the ratio of the table font size to the base font size. It may miss some cases, but we can deal with those.

Since this change is rather significant, I think we may need to consider a global setting to disable this behavior.

habamax commented 4 years ago

They would be scaled by the ratio of the table font size to the base font size. It may miss some cases, but we can deal with those.

Sounds good!

logicsalad commented 4 years ago

I think I can implement a very crude font scaling for elements that define their own font size. They would be scaled by the ratio of the table font size to the base font size. It may miss some cases, but we can deal with those.

This sounds good, thank you!

It somehow works when using the docbook/FOP toolchain but I don't know to which extend.

This is not a helpful statement since that's a completely different technology. You're comparing apples to oranges.

Yes, but maybe they should produce a rather similar output when using similar style/template settings and using the same asciidoc source. There are other features which work well with Asciidoctor-PDF but do not seem to work with docbook/FOP (e.g. column headers).

mojavelinux commented 4 years ago

I'm glad you like the idea.

maybe they should produce a rather similar output when using similar style/template settings and using the same asciidoc source.

Aside from the AsciiDoc source, there's nothing similar about these technologies. They have completely different ways of working and of styling. You could say that you're able to do something with FOP and you'd like to be able to do it with Asciidoctor PDF. And that's useful. But just because it works in FOP doesn't mean it does or can work here in this converter.

mojavelinux commented 4 years ago

Let's say that by default the font properties inherit from table (which also means the font of nested blocks will be scaled). To disable this behavior, you can set table_asciidoc_cell_style: initial in the theme. In this case, initial means to reset the styling back to what it would be initially, ignoring the table cell styles. In other words, initial means "don't inherit".

mojavelinux commented 4 years ago

I think this PR is ready to go.

habamax commented 4 years ago

Thx, looks good for me

The only "issue" is that literal cells are not affected:

image

habamax commented 4 years ago

I will just stop using literal cells and for me issue is closed, thank you again!

mojavelinux commented 4 years ago

You're right that literal cells are something entirely different. They take on the size of the code block, not the table cell (though it might be reasonable to consider scaling that font size too).

habamax commented 4 years ago

Thank you!

mojavelinux commented 4 years ago

You're welcome!

If you'd like to file that follow-up issue for literal table cells, go ahead.