# Question about Italic angle x positions

I’m trying to write a script that will shift a glyph so that the _anchor will be at x=0 (in an italic font), I thought it was as simple as the following but I realise I don’t understand how the bounding box is shifting in an italic font.

What I have so far is https://pastebin.com/ugxCFLaW but it is always a bit off… any help is appreciated.

I think I found it:

``````def italicSkew( x, y, angle=10.0 ):
"""Skews x/y along the x axis and returns skewed x value."""
new_angle = ( angle / 180.0 ) * math.pi
return x + y * math.tan( new_angle )
``````

`italicCorrection = italicSkew( 0.0, selectedXheight/2.0, italicAngle )`

try the `italic` snippet from my repository:

``````import math
def italicize( thisPoint, italicAngle=0.0, pivotalY=0.0 ):
"""
Returns the italicized position of an NSPoint 'thisPoint'
for a given angle 'italicAngle' and the pivotal height 'pivotalY',
around which the italic slanting is executed, usually half x-height.
Usage: myPoint = italicize(myPoint,10,xHeight*0.5)
"""
x = thisPoint.x
yOffset = thisPoint.y - pivotalY # calculate vertical offset
italicAngle = math.radians( italicAngle ) # convert to radians
tangens = math.tan( italicAngle ) # math.tan needs radians
horizontalDeviance = tangens * yOffset # vertical distance from pivotal point
x += horizontalDeviance # x of point that is yOffset from pivotal point
return NSPoint( x, thisPoint.y )
``````