#font #cff #nipdf #part #pdf-file #convert #image

nipdf-cff-parser

A library that parses CFF files, part of nipdf library

2 releases

0.1.1 Feb 20, 2025
0.1.0 Feb 17, 2025

#835 in Algorithms

Download history 244/week @ 2025-02-16 22/week @ 2025-02-23 8/week @ 2025-03-02

274 downloads per month
Used in 3 crates (via nipdf)

MIT license

6MB
8K SLoC

NiPdf

Nipdf is a PDF file reader and tools written in Rust. It is still in development, lack some features, but it can view most PDF files without problem.

Workspace structure

  • nipdf: The core library.
  • nipdf-macro: The macro library for nipdf library.
  • nipdf-render: Render library using tiny-skia library.
  • nipdf-dump: The command line interface tool to extract, dump and convert PDF file to png image.
  • nipdf-reader: The GUI viewer using iced gui library.
  • nipdf-viewer: The GUI viewer using gtk gui library.
  • prescript: Postscript virtual machine, to handle postscript function, type1 font, cmap, etc.
  • cff-parser: CFF font parser.

Start

Run cargo run -p nipdf-reader -- path-of-pdf-file

Screenshot

screenshot

TODO

  • PDF 2.0 support
  • Annotation render
  • Interactive Form
  • Wasm
  • Pure Rust
  • Shadings
    • Radius shading with two circles
    • Free-form Gouraud-shaded triangle meshes (Type 4)
    • Lattice-form Gouraud-shaded triangle meshes (Type 5)
    • Coons patch meshes (Type 6)
    • Tensor-product patch meshes (Type 7)
  • Stable core API

Pure Rust

Fowling C/C++ lib used because of no equivalent rust crates or has missing some feature or bug.

  1. zlib, rust version failed handle some deflate cases
  2. freetype, ttf-parser can not render type1 font, and failed render some cjk glyphs

lib.rs:

Decode Adobe CFF font files.

The entry type is File, use File::open() method to parses a CFF file and returns File

File is a struct that contains all the data in a CFF file. derived types borrows data hold by File.

File::fonts() returns a iterator of Font which is a struct that provides info for that font, such as encoding, charset, etc.

Dependencies