PDF:如何知道字符的总宽度,包括提前宽度

时间:2015-12-29 18:18:54

标签: c pdf width measurement em

当打印为XML时显示MuPDF:

<char bbox="144.1 547.9049 152.682 564.2018" x="144.1" y="560.9" c="T"/>
<char bbox="152.682 547.9049 161.488 564.2018" x="152.682" y="560.9" c="h"/>
<char bbox="161.488 547.9049 165.38002 564.2018" x="161.488" y="560.9" c="i"/>
<char bbox="165.38002 547.9049 175.36201 564.2018" x="165.38002" y="560.9" c="s"/>
<char bbox="175.36201 547.9049 182.44601 564.2018" x="175.36201" y="560.9" c=" "/>
<char bbox="182.44601 547.9049 191.02802 564.2018" x="182.44601" y="560.9" c="a"/>

根据PDF宽度的字体字典如下:

Width[000]=0600 Width[001]=0770 Width[002]=0277 Width[003]=0817 Width[004]=0612
Width[005]=0633 Width[006]=0317 Width[007]=0634 Width[008]=0634 Width[009]=0633 
Width[010]=0317 Width[011]=0684 Width[012]=0634 Width[013]=0615 Width[014]=0277
Width[015]=0392 Width[016]=0684 Width[017]=0411 Width[018]=0520 Width[019]=0633
Width[020]=0557 Width[021]=0352 Width[022]=0294 Width[023]=0549 Width[024]=0698
Width[025]=0611 Width[026]=0634 Width[027]=1000 Width[028]=0694 Width[029]=0610
Width[030]=0277 Width[031]=0974 Width[032]=0636 Width[033]=0636 Width[034]=0636

我还解析了显示hmtx的{​​{1}}字体文件表,如下所示:

advance widths

0. advanceWidth= 1229; lsb=102 1. advanceWidth= 1577; lsb=201 2. advanceWidth= 569; lsb=193 3. advanceWidth= 1675; lsb= 86 4. advanceWidth= 1255; lsb=123 5. advanceWidth= 1298; lsb=186 6. advanceWidth= 651; lsb= 0 7. advanceWidth= 1300; lsb=135 8. advanceWidth= 1300; lsb=113 9. advanceWidth= 1298; lsb=186 10. advanceWidth= 651; lsb=219 11. advanceWidth= 1401; lsb= 16 12. advanceWidth= 1300; lsb=186 13. advanceWidth= 1260; lsb=113 14. advanceWidth= 569; lsb=193 15. advanceWidth= 803; lsb= 55 16. advanceWidth= 1401; lsb= 16 17. advanceWidth= 842; lsb=186 18. advanceWidth= 1067; lsb=111 19. advanceWidth= 1298; lsb=174 20. advanceWidth= 1141; lsb=201 21. advanceWidth= 721; lsb= 47 22. advanceWidth= 604; lsb=201 23. advanceWidth= 1126; lsb=113 24. advanceWidth= 1430; lsb=115 25. advanceWidth= 1253; lsb=113 26. advanceWidth= 1300; lsb=113 27. advanceWidth= 2048; lsb=236 28. advanceWidth= 1423; lsb=201 29. advanceWidth= 1251; lsb= -6 表:

head

flags=31; unitsPerEm=2048; xMin=-106; yMin=-426; xMax=1958; yMax=1556; macStyle=0; lowestRecPPEM=8;

HHEA

Ascender=1901; Descender=-483;

MaxP

当我使用Font Dictionary Widths时,值为:

 maxPoints=48; maxZones=2; maxTwilightPoints=16; maxStorage=153; 
 maxFunctionDefs=8; maxInstructionDefs=0; maxStackElements=1045;
 maxSizeOfInstructions=534; maxComponentElements=8; maxComponentDepth=4;

font size = 14

029|T|084 X Start =>144.100006; X End => 152.640006; Y => 231.100006 009|h|104 X Start =>152.639999; X End => 161.502000; Y => 231.100006 002|i|105 X Start =>161.501999; X End => 165.379999; Y => 231.100006 018|s|115 X Start =>165.380005; X End => 172.660005; Y => 231.100006 006| |032 X Start =>172.660004; X End => 177.098004; Y => 231.100006 004|a|097 X Start =>177.098007; X End => 185.666007; Y => 231.100006 表中提供的值为htmxem的值如何更改为em

1 个答案:

答案 0 :(得分:2)

em是&#34;字体大小&#34;点,所以如果字体大小是14,则em是14分。请注意,htmx表中的单位实际上是1/2048的em,由头表中的unitsPerEm=2048条目指定。

对持怀疑态度的下击者的参考: