Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: labeleR
Title: Automate the Production of Custom Labels, Badges, Certificates, and Other Documents
Version: 0.4.0
Version: 0.4.1
Authors@R:
c(
person("Ignacio", "Ramos-Gutierrez",, "ig.ramosgutierrez@gmail.com", role = c("aut", "cre", "cph"),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# labeleR 0.4.1

* New argument `font` allows users to change the document font

# labeleR 0.4.0

* New function to create book of abstracts
Expand Down
19 changes: 17 additions & 2 deletions R/abstractbook.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@
#' in the output folder? Default is FALSE.
#' @param template Character (optional) RMarkdown template to use. If not provided,
#' using the default template included in `labeleR`.
#' @inheritParams create_badge
#'
#' @return A PDF file named after `filename` is saved on disk, in the folder defined
#' by `path`. If `keep.files = TRUE`, an RMarkdown will also
#' appear in the same folder.
#'
#' @details You can copy and modify at your convenience \href{https://docs.google.com/forms/d/1u4SFWDobQrD8AEvKpvPCdwAZiVGd55B2dAtPmPEfU6E/copy}{this Google form template}
#' @note
#' You can copy and modify at your convenience \href{https://docs.google.com/forms/d/1u4SFWDobQrD8AEvKpvPCdwAZiVGd55B2dAtPmPEfU6E/copy}{this Google form template}
#' to retrieve abstract information which will match labeleR's requirements for a straightforward use.
#'
#' @inherit create_badge details
#'
#' @export
#'
Expand All @@ -50,6 +53,7 @@
#' title.cex = 20,
#' authors.cex = 15,
#' affiliations.cex = 14,
#' font = "libertinus",
#' text.cex = 12,
#' frontpage = "Congress_frontpage.pdf"
#')
Expand All @@ -68,6 +72,7 @@ create_abstractbook <- function(data = NULL,
authors.cex = 16,
affiliations.cex = 14,
text.cex = 14,
font = NULL,
keep.files = FALSE,
template = NULL) {

Expand All @@ -92,6 +97,15 @@ create_abstractbook <- function(data = NULL,
filename <- "AbstractBook"
}

if(is.null(font)){
font <- ""
}else{
font <- as.character(font)
if(length(font)!= 1){
stop("Font length should be 1")
}
}

# if (is.null(event)) {
# message("No event provided")
# event <- ""
Expand Down Expand Up @@ -239,7 +253,8 @@ create_abstractbook <- function(data = NULL,
title.cex = as.character(rep(title.cex , times = nrow(data))) ,
authors.cex = as.character(rep(authors.cex , times = nrow(data))) ,
affiliations.cex = as.character(rep(affiliations.cex , times = nrow(data))) ,
text.cex = as.character(rep(text.cex , times = nrow(data)))
text.cex = as.character(rep(text.cex , times = nrow(data))),
font = font

)
)
Expand Down
42 changes: 41 additions & 1 deletion R/badge.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#' storing participants' affiliation.
#' @param lpic Character (optional) Path to a PNG image to be located in the badge top-left.
#' @param rpic Character (optional) Path to a PNG image to be located in the badge top-right.
#' @param font Character. Font face to use. Default is Latin Modern. NOTE: not all fonts are supported, so unexpected results may occur. A list of fonts is available at \url{https://tug.org/FontCatalogue/opentypefonts.html}. See Details for more information.
#' @param keep.files Logical. Keep the RMarkdown template and associated files
#' in the output folder? Default is FALSE.
#' @param template Character (optional) RMarkdown template to use. If not provided,
Expand All @@ -20,6 +21,33 @@
#' by `path`. If `keep.files = TRUE`, an RMarkdown and PNG lpic and rpic files will also
#' appear in the same folder.
#'
#' @details
#'
#' **font**
#' Not all fonts can be used. Consider only those which are stated to be 'Part of TeX Live',
#' and have OTF and TT available. Additionally, fonts whose 'Usage' differs from
#' `\normalfont`, `\itshape` and `\bfseries` usually fail during installation and/or rendering.
#'
#' Several fonts tried that seem to work are:
#' - libertinus
#' - accanthis
#' - Alegreya
#' - algolrevived
#' - almendra
#' - antpolt
#' - Archivo
#' - Baskervaldx
#' - bitter
#' - tgbonum
#' - caladea
#' - librecaslon
#' - tgchorus
#' - cyklop
#' - forum
#' - imfellEnglish
#' - LobsterTwo
#' - quattrocento
#'
#' @export
#'
#' @author Ignacio Ramos-Gutierrez, Julia G. de Aledo, Francisco Rodriguez-Sanchez
Expand All @@ -32,6 +60,7 @@
#' event = "INTERNATIONAL CONFERENCE OF MUGGLEOLOGY",
#' name.column = "List",
#' affiliation.column = "Affiliation",
#' font = "libertinus",
#' lpic = NULL,
#' rpic = NULL)

Expand All @@ -43,6 +72,7 @@ create_badge <- function(data = NULL,
affiliation.column = NULL,
lpic = NULL,
rpic = NULL,
font = NULL,
keep.files = FALSE,
template = NULL) {

Expand Down Expand Up @@ -72,6 +102,15 @@ create_badge <- function(data = NULL,
event <- ""
}

if(is.null(font)){
font <- ""
}else{
font <- as.character(font)
if(length(font)!= 1){
stop("Font length should be 1")
}
}

check_column_in_df(data, name.column)
data[,name.column] <- check_latex(data, name.column)

Expand Down Expand Up @@ -126,7 +165,8 @@ create_badge <- function(data = NULL,
params = list(
event = event,
names = data[, name.column],
affiliations = if (affiliation.column == "") {"~"} else {data[, affiliation.column]}
affiliations = if (affiliation.column == "") {"~"} else {data[, affiliation.column]},
font = font
)
)

Expand Down
17 changes: 16 additions & 1 deletion R/certificate_attendance.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@
#' in the output folder? Default is FALSE.
#' @param template Character (optional) RMarkdown template to use. If not provided,
#' using the default template included in `labeleR`.
#' @inheritParams create_badge
#'
#' @return PDF certificates are saved on disk, in the folder defined
#' by `path`. If `keep.files = TRUE`, the RMarkdown template and PNG logo files
#' will also appear in the same folder.
#'
#' @inherit create_badge details
#'
#' @export
#'
#' @author Ignacio Ramos-Gutierrez, Julia G. de Aledo, Francisco Rodriguez-Sanchez
Expand All @@ -52,6 +55,7 @@
#' lpic = NULL,
#' rpic = NULL,
#' signature.pic = NULL,
#' font = "libertinus"
#' )


Expand All @@ -73,6 +77,7 @@ create_attendance_certificate <- function(
signature.pic = NULL,
lpic = NULL,
rpic = NULL,
font = NULL,
keep.files = FALSE,
template = NULL) {

Expand Down Expand Up @@ -101,6 +106,15 @@ create_attendance_certificate <- function(
if (language == "Spanish") {filename <- "Asistencia"}
}

if(is.null(font)){
font <- ""
}else{
font <- as.character(font)
if(length(font)!= 1){
stop("Font length should be 1")
}
}


sendmail <- sendmail_setup(email.column, email.info)

Expand Down Expand Up @@ -203,7 +217,8 @@ create_attendance_certificate <- function(
date = if (date == "") {bl.char} else {date},
hours = if (hours == "") {bl.char} else {hours},
signer = if (signer == "") {bl.char} else {signer},
signer.role = if (signer.role == "") {bl.char} else {signer.role}
signer.role = if (signer.role == "") {bl.char} else {signer.role},
font = font
)
)

Expand Down
18 changes: 16 additions & 2 deletions R/certificate_participation.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
#' in the output folder? Default is FALSE.
#' @param template Character (optional) RMarkdown template to use. If not provided,
#' using the default template included in `labeleR`.
#' @inheritParams create_badge
#'
#' @inherit create_badge details
#'
#' @return PDF certificates are saved on disk, in the folder defined
#' by `path`. If `keep.files = TRUE`, the RMarkdown template and PNG logo files
Expand Down Expand Up @@ -60,7 +63,8 @@
#' signer.role = "School Headmaster",
#' lpic = NULL,
#' rpic = NULL,
#' signature.pic = NULL
#' signature.pic = NULL,
#' font = "libertinus"
#' )

create_participation_certificate <- function(
Expand All @@ -84,6 +88,7 @@ create_participation_certificate <- function(
signature.pic = NULL,
lpic = NULL,
rpic = NULL,
font = NULL,
keep.files = FALSE,
template = NULL
){
Expand Down Expand Up @@ -112,6 +117,14 @@ create_participation_certificate <- function(
if (language == "Spanish") {filename <- "Participacion"}
}

if(is.null(font)){
font <- ""
}else{
font <- as.character(font)
if(length(font)!= 1){
stop("Font length should be 1")
}
}

sendmail <- sendmail_setup(email.column, email.info)

Expand Down Expand Up @@ -238,7 +251,8 @@ create_participation_certificate <- function(
date.i = if (date.column == "") {bl.char} else {data[i, date.column]},
freetext.i = if (freetext == "") {bl.char} else {freetext},
signer.i = if (signer == "") {bl.char} else {signer},
signer.role.i = if (signer.role == "") {bl.char} else {signer.role}
signer.role.i = if (signer.role == "") {bl.char} else {signer.role},
font = font
)
)

Expand Down
18 changes: 16 additions & 2 deletions R/collection_label.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#' by `path`. If `keep.files = TRUE`, an RMarkdown and PNG logo files will also
#' appear in the same folder.
#'
#' @inherit create_badge details
#'
#' @export
#'
#' @author Ignacio Ramos-Gutierrez, Julia G. de Aledo, Francisco Rodriguez-Sanchez
Expand Down Expand Up @@ -56,6 +58,7 @@ create_collection_label <- function(data = NULL,
logo = NULL,
bgcolor = "D0ECC1",
textcolor = "1E3F20",
font = NULL,
keep.files = FALSE,
template = NULL) {

Expand All @@ -81,6 +84,15 @@ create_collection_label <- function(data = NULL,
filename <- "Collection_label"
}

if(is.null(font)){
font <- ""
}else{
font <- as.character(font)
if(length(font)!= 1){
stop("Font length should be 1")
}
}



## QR code
Expand Down Expand Up @@ -163,8 +175,10 @@ create_collection_label <- function(data = NULL,
field4.i = if (field4.column == "") {bl.char} else {data[,field4.column]},
field5.i = if (field5.column == "") {bl.char} else {data[,field5.column]},
bgcolor = bgcolor,
textcolor = textcolor
textcolor = textcolor,
font = font
)
)

}

}
18 changes: 16 additions & 2 deletions R/herbarium.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
#' was collected.
#' @inheritParams create_badge
#'
#' @inherit create_badge details
#'
#' @return A pdf file with four herbarium labels per page within an 'output' folder.
#'
#' @export
Expand Down Expand Up @@ -69,7 +71,8 @@
#' collector.column = "Collector",
#' collection.column = "Collection_number",
#' assistants.column = "Assistants",
#' date.column = "Date"
#' date.column = "Date",
#' font = "libertinus"
#' )

create_herbarium_label <- function(data = data,
Expand All @@ -95,6 +98,7 @@ create_herbarium_label <- function(data = data,
collection.column = NULL,
assistants.column = NULL,
date.column = NULL,
font = NULL,
keep.files = FALSE,
template = NULL
){
Expand All @@ -119,6 +123,15 @@ create_herbarium_label <- function(data = data,
filename <- "Herbarium"
}

if(is.null(font)){
font <- ""
}else{
font <- as.character(font)
if(length(font)!= 1){
stop("Font length should be 1")
}
}


if (any(apply(data, 1, nchar) > 150)) {
message("Too long texts may give undesired results. Please consider shortening long fields.")
Expand Down Expand Up @@ -274,7 +287,8 @@ create_herbarium_label <- function(data = data,
collector.i = if (collector.column == "") {bl.char} else {data[,collector.column]},
collection.i = if (collection.column == "") {bl.char} else {data[,collection.column]},
assistants.i = if (assistants.column == "") {bl.char} else {data[,assistants.column]},
date.i = if (date.column == "") {bl.char} else {data[,date.column]}
date.i = if (date.column == "") {bl.char} else {data[,date.column]},
font = font
)
)

Expand Down
Loading
Loading