Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inserted row breaks appear as Times New Roman 12-pt #14

Closed
Robert-Krajcik opened this issue Mar 19, 2021 · 8 comments
Closed

Inserted row breaks appear as Times New Roman 12-pt #14

Robert-Krajcik opened this issue Mar 19, 2021 · 8 comments

Comments

@Robert-Krajcik
Copy link

After inserting row breaks between groups,
I noticed that the row breaks themselves are using the RTF default of Times New Roman 12-pt.
image

Reprex provided below.

I did find a workaround, using this code to reset the default font size from 12 to whatever was used in the rtf_body:

xyz_encode <- iris_rtf %>% 
  rtf_encode()

# set default font size for Times New Roman
fs <- format(2*attr(iris_rtf, "text_font_size")[1])
xyz_encode$start <- paste0(xyz_encode$start, "\\f0\\fs",fs)

xyz_encode %>% 
  write_rtf("output/l-iris.rtf")

I was wondering if you might entertain the idea of adding an option to set the default font size in r2rtf?
Thanks for reading this.
Robert

library(dplyr)
library(tibble)
library(r2rtf)

data("iris")

set.seed(34567)
sample_iris <- iris %>% 
  group_by(Species) %>% 
  slice_sample(n = 5) %>%          # take 5 rows of each Species
  do(add_row(., .before = 1)) %>%  # add a blank row before each group
  ungroup()

iris_rtf <- sample_iris %>% 
  select(Species, everything()) %>% 
  rtf_page(orientation = "landscape", 
           border_first = "single", border_last = "single",
           margin = c(1.0, 1.0, 1.0, 1.0, 0.5, 0.5) ) %>% 
  
  rtf_title( title=paste("\\b\\fs24","Iris data by Species","\\b0"), 
             subtitle = paste("\\fs20","Page \\pagenumber of \\totalpage"),
             text_justification = "l",
             text_convert = TRUE  ) %>%
  
  rtf_colheader(colheader = c(" Species | Sepal.Length | Sepal.Width | Petal.Length | Petal.Width "), 
                text_format = "b", 
                col_rel_width = c(rep(2,5)),
                cell_justification = "l",
                text_justification = c("l",rep("d",4)),
                border_left = "", border_right = ""  ) %>%
  
  rtf_body(col_rel_width = c(rep(2,5)),
           cell_justification = "l",
           text_justification = c("l",rep("d",4)),
           text_font = 9,  # Courier New
           border_left = "", border_right = "") 

iris_rtf %>% 
  rtf_encode() %>% 
  write_rtf("output/l-iris.rtf") 
@elong0527
Copy link
Collaborator

Excellent idea! I will add default settings for font styles in rtf_page.

We have a target to release next version in Q2. May I invite you to review the work before releasing to CRAN?

The focus is to enhance the documentations and fulfills feature requests like this.

@Robert-Krajcik
Copy link
Author

Yes of course, Yilong. I'd be glad review/test anything on this package.

@elong0527
Copy link
Collaborator

Thanks for the help. Please rerun the code based on v0.2.0.9000 branch. I think the issue has been addressed.

@Robert-Krajcik
Copy link
Author

Hi @elong0527
How do I install a local copy of this dev branch? I see the PR, but nothing for me to copy
#15

@elong0527
Copy link
Collaborator

You can use git with RStudio to access the source code

https://r-pkgs.org/git.html or watch https://rstudio.com/resources/webinars/managing-part-2-github-and-rstudio/

To install from dev version in specific branch, you can do the following in RStudio.

clone -> change branch -> run devtools::install()

An overview can be found in https://r-pkgs.org/whole-game.html

@Robert-Krajcik
Copy link
Author

Got it, Thanks @elong0527

@Robert-Krajcik
Copy link
Author

devtools::install_github("https://github.com/Merck/r2rtf/pull/15.git") worked

@Robert-Krajcik
Copy link
Author

I reran my test report based on v0.2.0.9000 branch, and the issue is gone.
The blank rows are using the font size specified in rtf_body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants