PDF calculates glyph sizes

I (think) has all the meanings for Text-Rendering in PDF.

* Position (Text Matrix)
* FontDescriptor with Widths Array
* FontBBox
* StemV/StemH
* FontName
* Descent
* Ascent
* CapHeight
* XHeight
* ItalicAngle

My problem is that I do not know what to do with these values. I have looked through PDF Spec 1.7 several times and cannot find a form for calculating the actual pixel sizes of each glyph in PDF. Can you give me a hint?

Thank.

+3
source share
4 answers

What are you trying to do? PDF rendering is a lot of work, and you also need to consider leading, text, kerning, CTM and a number of other factors.

+3
source
Position:     (optional, you can avoid it)
Text Matrix:  (optional, you can avoid it) 
Widths Array: (use empty array [], PDF can read it directly from CFF (FontFile3 stream))
FontBBox:     font file->'CFF ' table->Top DICT INDEX->DICT-> 4 operands for 'FontBBox'     operator
StemV:        (optional, you can avoid it)
StemH:        (optional, you can avoid it)
FontName:     font file->'name' table->records
      or: font file->'CFF ' table->Top DICT INDEX->string by index 0 for 'fonts names' operator

Descent:      font file->'hhea' table->'Descender' parameter
Ascent:       font file->'hhea' table->'Ascender' parameter 
CapHeight:    font file->'OS/2' table->'sCapHeight' parameter
XHeight:      font file->'OS/2' table->'sxHeight' parameter
ItalicAngle:  font file->'OS/2' table->'sxHeight' parameter

In fact, you can calculate the Widths array. For each character:

Decoding array(PDF) -> Glyph name (PDF) -> Glyph index (CFF table of font file) -> table 'hmtx' -> Glyph 'hMetrics'[Glyph index] = array ('advanceWidth', 'leftSideBearing')   

I spent a WEEK to figure this out ...

+2

, , . , (, , , ) PDF. . ))

+1

, , . - .

FontBBox ( ) , . Widths , , . , .

, . FontBBox Widths Array ( ..). , , .

0

Source: https://habr.com/ru/post/1770503/


All Articles