great-tables icon indicating copy to clipboard operation
great-tables copied to clipboard

Add the `opt_table_font()` method

Open rich-iannone opened this issue 1 year ago • 1 comments

This adds the opt_table_font() method, which can be used for the easy addition of fonts (or a font stack) to the table. Here's an example where a font stack was used:

from great_tables import GT, exibble

gt_ex = (
    GT(exibble.head(5), rowname_col="row", groupname_col="group")
    .tab_header("THE HEADING", "(a subtitle)")
    .tab_stubhead("THE STUBHEAD")
    .tab_source_note("THE SOURCE NOTE")
    .opt_table_font(stack="industrial")
)

gt_ex
opt_table_font_font_stack

Here's another example where a single font name is prepended to the list of default fonts:

from great_tables import GT, exibble

gt_ex = (
    GT(exibble.head(5), rowname_col="row", groupname_col="group")
    .tab_header("THE HEADING", "(a subtitle)")
    .tab_stubhead("THE STUBHEAD")
    .tab_source_note("THE SOURCE NOTE")
    .opt_table_font(font="Comic Sans MS")
)

gt_ex
opt_table_font_prepend_font

Fixes: https://github.com/posit-dev/great-tables/issues/175

rich-iannone avatar Apr 10 '24 16:04 rich-iannone

Sounds good. PR #260 is ready for a re-review.

rich-iannone avatar Apr 10 '24 17:04 rich-iannone

Codecov Report

Attention: Patch coverage is 85.71429% with 5 lines in your changes missing coverage. Please review.

Project coverage is 86.45%. Comparing base (4f1af8d) to head (41b2a0f).

:exclamation: Current head 41b2a0f differs from pull request most recent head 11ddbb6

Please upload reports for the commit 11ddbb6 to get more accurate results.

Files Patch % Lines
great_tables/_options.py 85.29% 5 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #272      +/-   ##
==========================================
+ Coverage   86.44%   86.45%   +0.01%     
==========================================
  Files          42       42              
  Lines        4654     4689      +35     
==========================================
+ Hits         4023     4054      +31     
- Misses        631      635       +4     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jun 04 '24 14:06 codecov[bot]

I've incorporated your suggestions in two commits. If CI passes I'll merge this PR. Thanks!

rich-iannone avatar Jun 28 '24 17:06 rich-iannone