Recalculate line width with CTM
Good day,
Context: I am rewriting content acquiring mechanism in Adobe Acrobat Core API.
I am having trouble recalculating line width with CTM. How it should be done?
In PDF Refernce:
The effect produced in device space depends on the current transformation matrix (CTM) in effect at the time the path is stroked. If the CTM specifies scaling by different factors in the horizontal and vertical dimensions, the thickness of stroked lines in device space shall vary according to their orientation.
As I understand, when I encounter w operator, I should only set operands fixed value to graphic state attribute line width and just before setting current path's graphic state (PDEElementSetGState) I should recalculate line width?
I tried this approach first:
ASFixedRect r;
r.bottom = fixedZero;
r.left = fixedZero;
r.right = graphic_state.lineWidth;
r.top = graphic_state.lineWidth;
ASFixedMatrixTransformRect(&r, &CTM, &r);
double x1 = ASFixedToFloat(r.right - r.left);
double y1 = ASFixedToFloat(r.top - r.bottom);
double width = sqrt((x1 * x1 + y1 * y1) / 2);
graphic_state.lineWidth = ASFloatToFixed(width);
However, I am not getting the correct (but pretty close) results when using this approach. Maybe anyone has any idea how can i approach this?
Thank you in advance,
Cheers
