Skip to contents

Returns the font properties PDFium exposes for obj's text: the base font name (e.g. "Helvetica-Bold"), the family name (e.g. "Helvetica"), weight (typographic weight integer, 400 = regular, 700 = bold), italic angle in degrees (negative for italic slant), whether the font is embedded in the PDF, and the PDF font-descriptor flags bitmask (see PDF spec section "Font Descriptors", Table 123).

Usage

pdf_text_font(obj)

Arguments

obj

A pdfium_obj of type "text" (from pdf_page_objects()).

Value

A named list with elements (matching the font_* columns that pdf_text_runs() returns for the same text object, so either shape can feed directly into a row of the other):

  • font_base_name - character scalar, base font name; UTF-8

  • font_family - character scalar, font family name; UTF-8

  • font_weight - integer (e.g. 400, 500, 700)

  • font_italic_angle - integer degrees; 0 for upright

  • font_is_embedded - logical

  • font_flags - integer bitmask

Details

If the text object has no font set (rare; usually only for malformed PDFs), every field is NA.

Examples

fixture <- system.file("extdata", "fixtures", "shapes.pdf",
  package = "pdfium"
)
if (nzchar(fixture)) {
  doc <- pdf_doc_open(fixture)
  p <- pdf_page_load(doc, 1)
  text_obj <- Filter(\(o) o$type == "text", pdf_page_objects(p))[[1]]
  pdf_text_font(text_obj)
  pdf_page_close(p)
  pdf_doc_close(doc)
}