Rounding a diagonal line to the grid in TrueType
Options
pthomas505
Posts: 54
Is there a method in TrueType hinting to round a point to the grid along one axis, and then shift another point by the same amount, but along a different axis?
I am attempting to shift a diagonal line such that it remains at a 45 degree angle, but has both its endpoints rounded to the nearest intersections of the raster grid lines. I have managed to get the top point in the attached picture rounded to the grid in the vertical direction, and the bottom left point shifted in the vertical direction to match, and to get the bottom left point rounded to the grid in the horizontal direction, and the top point shifted in the horizontal direction to match, using this xgridfit code:
<withroundstate round="togrid">
<withvectors axis="x">
<move>
<point num="1"/>
<shift><point num="2"/></shift>
</move>
</withvectors>
<withvectors axis="y">
<move>
<point num="2"/>
<shift><point num="1"/></shift>
</move>
</withvectors>
</withroundstate>
Point 1 is the point in the bottom left of the picture. Point 2 is the point at the top of the picture. The line connecting them is the one I am trying to keep at 45 degrees.
The next step is to round the top point in the horizontal direction, and
move the bottom point in the vertical direction the same amount to
compensate and keep the angle of the line at 45 degrees.
Thank you for your time,
Patrick
Tagged:
0
Comments

The larger encompassing question that I should probably have asked is how to hint these four points such that the diagonal stem width matches the horizontal and vertical stem widths as closely as mathematically possible at every point size.
0 
0 
This is an attempt to describe what I mean by "as closely as mathematically possible".
I note that the width of a diagonal line at 45 degrees can be any half integer multiple of sqrt(2) that is greater than or equal to sqrt(2). For example, the line on the left in the attached picture has a width of sqrt(2) and the line on the right in the attached picture has a width of 1.5 * sqrt(2).Therefore, if the width of the horizontal and vertical stems is n pixels across, then the width of the diagonal stem should be the half integer multiple of sqrt(2) that is as close to n as possible.
1 
Is it possible in the TrueType hinting instructions to say something like "If the current ppem is x then render the font by turning on the same pixels that would be if the ppem was y.", where y is the nearest integer multiple of 16 to x?
0 
At two different ppems, there is no possibility of “the same pixels” as such.
And other than dropout control being on/off, there is no notion of pixels being on: all you do is control distances between specified points (typically oncurve points, but they can be offcurve). You can move specified points either before or after you interpolate untouched points (IUP) for all other points. For most big effects and regularization, you are doing “before” hints. For fine tuning of a curve or diagonal, it might be after.
0 
I guess I mean, I can achieve what I am after to a degree in the TrueType instructions by scaling all of the point coordinates in proportion to the current ppem, but I'm wondering if there is a less complicated and more exact way.
0 
You can get the difference between the original position of a point and its current position and shift a point by that amount on the current axis (I am using the compact syntax of xgridfit3, and do note that I haven't testedbut post here or message me if this doesn't work):<setvs axis="x"/><mv p="1"><sh p="2"/></mv><setvs axis="y"/><! There is no compact version of shiftabsolute ><shiftabsolute pixeldistance="xcoord(2)  initialxcoord(2)"><pt n="2"/></shiftabsolute>0

Thank you.
0 
This is confusing me. The hinted distance projected onto the x axis from point 14 to point 15 (bottom left line of bottom right contour) should be equal to the CVT value of 5: 32 (0.50), that is 0.50 pixels. Looking at the images it jumped from about 0.50 pixels at 35 ppem (correct) to about 1.5 pixels at 36 ppem (incorrect), but the CVT value is 0.50 pixels at both ppems. It makes odd jumps like this at other ppems too.0

I think I found the issue. I think it was being caused by the controlvaluecutin. Setting the controlvaluecutin to 2.0 seemed to make the problem go away.Is there a way to ensure that the control values are always used rather than just increasing this value to one that should be big enough?0

Perhaps delete the cvt cut in code : )0

Do you mean this line: <setcontrolvaluecutin value="2.0" /> ? I had to add that entire line for the fix. Without it it defaults to something smaller than 2.0.0

ahh ok, I didnt know it defaults to that smaller number0

Xgridfit leaves the cutin at the TrueType default of 17/16 pixels unless you change it.
0
Categories
 All Categories
 40 Introductions
 3.6K Typeface Design
 778 Font Technology
 1K Technique and Theory
 598 Type Business
 437 Type Design Critiques
 529 Type Design Software
 30 Punchcutting
 135 Lettering and Calligraphy
 82 Technique and Theory
 53 Lettering Critiques
 467 Typography
 292 History of Typography
 112 Education
 63 Resources
 484 Announcements
 76 Events
 105 Job Postings
 147 Type Releases
 155 Miscellaneous News
 264 About TypeDrawers
 53 TypeDrawers Announcements
 112 Suggestions and Bug Reports