modesty / modesty/pdf2json

how to add a new font or style?

Open
#211 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
2.2k
Forks
394
Avg merge
3d 5h
Merged PRs (30d)
7

Description

I'm having problems with fonts in the pdffont.js file.
The font I need to add is times new roman. I couldn't add it and in the main sources I didn't find any serif
`
let _stdFonts = ["arial", "helvetica", "sans-serif ", "courier ", "monospace ", "ocr "];

let _kFontFaces = [
    "quicktype,arial,helvetica,sans-serif",							// 00 - QuickType - sans-serif variable font
    "quicktype condensed,arial narrow,arial,helvetica,sans-serif",	// 01 - QuickType Condensed - thin sans-serif variable font
    "quicktypepi,quicktypeiipi",										// 02 - QuickType Pi
    "quicktype mono,courier new,courier,monospace",					// 03 - QuickType Mono - san-serif fixed font
    "ocr-a,courier new,courier,monospace",							// 04 - OCR-A - OCR readable san-serif fixed font
    "ocr b mt,courier new,courier,monospace"							// 05 - OCR-B MT - OCR readable san-serif fixed font
];

let _kFontStyles = [
    // Face		Size	Bold	Italic		StyleID(Comment)
    // -----	----	----	-----		-----------------
    [0, 6, 0, 0],			//00
    [0, 8, 0, 0],			//01
    [0, 10, 0, 0],			//02
    [0, 12, 0, 0],			//03
    [0, 14, 0, 0],			//04
    [0, 18, 0, 0],			//05
    [0, 6, 1, 0],			//06
    [0, 8, 1, 0],			//07
    [0, 10, 1, 0],			//08
    [0, 12, 1, 0],			//09
    [0, 14, 1, 0],			//10
    [0, 18, 1, 0],			//11
    [0, 6, 0, 1],			//12
    [0, 8, 0, 1],			//13
    [0, 10, 0, 1],			//14
    [0, 12, 0, 1],			//15
    [0, 14, 0, 1],			//16
    [0, 18, 0, 1],			//17
    [0, 6, 1, 1],			//18
    [0, 8, 1, 1],			//19
    [0, 10, 1, 1],			//20
    [0, 12, 1, 1],			//21
    [0, 14, 1, 1],			//22
    [0, 18, 1, 1],			//23
    [1, 6, 0, 0],			//24
    [1, 8, 0, 0],			//25
    [1, 10, 0, 0],			//26
    [1, 12, 0, 0],			//27
    [1, 14, 0, 0],			//28
    [1, 18, 0, 0],			//29
    [1, 6, 1, 0],			//30
    [1, 8, 1, 0],			//31
    [1, 10, 1, 0],			//32
    [1, 12, 1, 0],			//33
    [1, 14, 1, 0],			//34
    [1, 18, 1, 0],			//35
    [1, 6, 0, 1],			//36
    [1, 8, 0, 1],			//37
    [1, 10, 0, 1],			//38
    [1, 12, 0, 1],			//39
    [1, 14, 0, 1],			//40
    [1, 18, 0, 1],			//41
    [2, 8, 0, 0],			//42
    [2, 10, 0, 0],			//43
    [2, 12, 0, 0],			//44
    [2, 14, 0, 0],			//45
    [2, 18, 0, 0],			//46
    [3, 8, 0, 0],			//47
    [3, 10, 0, 0],			//48
    [3, 12, 0, 0],			//49
    [4, 12, 0, 0],			//50
    [0, 9, 0, 0],			//51
    [0, 9, 1, 0],			//52
    [0, 9, 0, 1],			//53
    [0, 9, 1, 1],			//54
    [1, 9, 0, 0],			//55
    [1, 9, 1, 0],			//56
    [1, 9, 1, 1],			//57
    [4, 10, 0, 0],			//58
    [5, 10, 0, 0],			//59
    [5, 12, 0, 0]			//60
];

`Is this where I add? Like?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading pdffont.js around _stdFonts, _kFontFaces, and _kFontStyles to understand how the existing font faces and styles are represented. The issue names no tests, entry point beyond these arrays, or acceptance condition, so confirm the supported approach and expected result with maintainers before making a change.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.