PDF字形间距和TJ运算符 [英] PDF glyph spacing and TJ operator

查看:657
本文介绍了PDF字形间距和TJ运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是PDF的新手,我想操纵文件中字符之间的空格. 我已经阅读了PDFReference并理解了其中的一些内容. 现在,我的问题是如何计算文本渲染的空间.

I am new to PDF, and i want to manipulate the space between the characters in a file. I have read the PDFReference and understood some of it. Now, the problem I have is how to calculate the spaces for the text rendering.

例如,我有

1 0 0 1 0 188.28799438 cm
BT 
/F2 11.04 Tf
1 0 0 -1 0 9.38000011 Tm 
(Some)Tj ( )Tj 
21.24200058 0 Td 
(text)Tj ( )Tj 

我想变成这个:

1 0 0 1 0 188.28799438 cm
BT 
/F2 11.04 Tf
1 0 0 -1 0 9.38000011 Tm 
[(S)10(o)10(m)10(e)( )]TJ 
21.24200058 0 Td 
[(t)10(e)10(x)10(t)( )]TJ 

添加空格,然后可以对其进行操作.但是我想知道如何使用这些附加值来计算ctm和行矩阵.

To add the spaces and then be able to manipulate them. However I was wondering how to calculate the ctm and the line matrix with those added values.

我知道我们将cm与上一个连接起来.

I know that we concatenate cm with the previous one.

cm2 x cm1

cm2 x cm1

Tms未连接Tm2代替Tm1.

The Tms are not concatenated Tm2 replaces Tm1.

我被td运算符和我添加的新空格所困扰.有任何线索吗?

I am stuck with the td operator and the new spaces I added. Any clue?

推荐答案

正如评论中所阐明的,OP并未要求 TJ 数字对当前转换矩阵的影响文本行矩阵,但改为在文本矩阵 T m 上.

As clarified in comments, the OP is not asking for effects of the TJ numbers on the current transformation matrix or text line matrix but instead on the text matrix Tm.

在规范ISO 32000-1(等效于ISO 32000-2)的第9.4.4节"文本空间详细信息"中对此进行了说明:绘制字形后(可能后面跟一个数字) TJ 指令数组参数),文本矩阵应更新如下:

This is explained in the specification ISO 32000-1 (and equivalently in ISO 32000-2) in section 9.4.4 Text Space Details: After drawing a glyph (probably followed by a number in a TJ instruction array argument), the text matrix shall be updated as follows:

在水平模式下, t x 是位移,在垂直模式下, t y 为零> t x 为零, t y 为位移.适用值的计算方式为

In horizontal mode tx is the displacement and ty is zero, in vertical mode tx is zero and ty is the displacement. The applicable value is calculated as

即如果您在处理 TJ 指令时进行了此计算,并且当前绘制的字形的字符代码后面有一个数字,则该数字在此处被视为参数 T j .

I.e. if you do this calculation while processing a TJ instruction and there is a number following the character code for the currently drawn glyph, that number is considered here as the parameterTj.

因此,如果要确定仅由 TJ 数组参数的数字元素引起的位移,例如如果 TJ 数组参数中的 first 元素是一个数字,或者 TJ 数组参数中有多个连续的数字元素,并且您想知道每个人的效果-以上简化为

Thus, if you want to determine the displacement caused by a number element of a TJ array argument alone — e.g. if the first element in the TJ array argument is a number or if there are multiple consecutive number elements in the TJ array argument and you want to know the effect of each one — the above reduces to

t x =(-T j /1000)×T fs ×T h

tx = (−Tj / 1000) × Tfs × Th

t y =(-T j /1000)×T fs

ty = (−Tj / 1000) × Tfs

这篇关于PDF字形间距和TJ运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆