pdf-association / pdf-issues

Industry-based resolutions for issues and errata reported against any PDF-related specification
https://pdf-issues.pdfa.org/
62 stars 2 forks source link

Is "horizontal scaling" a percentage? #376

Closed seehuhn closed 3 months ago

seehuhn commented 5 months ago

Section 9.3.4 (Horizontal scaling) specifies the horizontal scaling parameter, $T_h$, to be a percentage:

Its value shall be specified as a percentage of the normal width of the glyphs, with 100 being the normal width.

This is supported by the examples of $T_h = 100$ and $T_h = 50$ in Figure 58.

In contrast, Table 103 states that the Tz operator sets $T_h$ to $\textrm{scale} ÷ 100$, giving the impression that only the argument to Tz is a percentage and that $T_h=1$ might correspond to normal width. This interpretation is supported by the text in section 9.4.4 (Text space details), where dimensions are multiplied with $T_h$ instead of $T_h/100$.

This leaves the question whether $T_h = 100$ or $T_h = 1$ corresponds to normal width.

Suggested fixes (assuming that the parameter value $T_h = 1$ corresponds to normal width, and that the argument to Tz is a percentage):

petervwyatt commented 5 months ago

Looking through the old Adobe legacy references $T_h$ has always been specified as a percentage (with 100 == normal) so I think the other formulae that are incorrect... @lrosenthol ?

lrosenthol commented 3 months ago

Agree with @petervwyatt - look like a bug crept in in that formula...

petervwyatt commented 3 months ago

The only places I can see $T_h$ used in a formula anywhere are NOTE 2 in 9.4.4 and the formula for $T_x$ just below. Both assume a normalized value of $T_h$ = 1 for 100% so Figure 58 is at fault and needs correction to show 100 Tz being $T_h$ = 1 and 50 Tz being $T_h$ = 0.5. Table 103 should also be corrected to have scale in italics as per OP's suggestion, but all other mentions of $T_h$ are in a mathematical 1.0 normalized sense, whereas Tz is the operator with the numeric percentage as an operand.

Where do we stand on zero and negative values?

lrosenthol commented 3 months ago

So well known implementation is fine with 0 (though it does special case it). And I see nothing that would prefer a negative value either - though I admit to not fully understanding what that would mean in real life

petervwyatt commented 3 months ago

PDF-Horizontal-Scaling.pdf

Simple test PDF for horizontal text that tests 100 (default), 50, 5, 0, -5, -50 and -100 values for Tz. All implementations I tested appear to support both zero and negative percentages, with zero meaning nothing shown and negative values reverse-mirroring the text. Suggest therefore that we note this informatively.

This makes sense given the formula in NOTE 2 of clause 9.4.4 (even if that is informative, rather than normative - which I think it should be given that it is the definition of how to apply various text state parameters)

petervwyatt commented 3 months ago

PDF TWG agree to make NOTE 2 normative and correct Figure 58

seehuhn commented 3 months ago

Possibly the start of section 9.3.4 should also be changed: It currently says

The horizontal scaling parameter, Th, adjusts the width of glyphs by stretching or compressing them in the horizontal direction. Its value shall be specified as a percentage of the normal width of the glyphs, with 100 being the normal width.

Should 100 be replaced with 1 here, since $T_h=1$ corresponds to normal width, and $T_h=100$ does not?

mkl-public commented 3 months ago

Then I would also change the remaining wording: "Its value shall be specified as ..." can be understood as "Its value shall be specified in the parameter of the Tz operator as ...", and in that case the 100 would be correct.

So something along the lines of "A value of 1 represents the normal width of the glyph." Probably followed by "Beware: When setting $T_h$ with the Tz operator, the value of the parameter of the operator will be divided by 100 before assignment."

petervwyatt commented 3 months ago

Yes - I will wordsmith appropriately. $T_h$ is the scaling factor used in the calculation of text matrices with 1.0 being normal, while the numeric operand to Tz is the percentage with 100 (meaning 100%) being normal.