diff --git a/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp b/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp
index 0788ee1..44ce08f 100644
--- a/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp
+++ b/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp
@@ -754,15 +754,18 @@ getGlyphPositions(XeTeXLayoutEngine engine, float positions[])
 	if (engine->font->getLayoutDirVertical()) {
 		/* XXX I'm not sure about the code below, but it seems to math the
 		 * behaviour of old code */
-		x += hbPositions[0].y_offset / 64.0; /* hack to compensate offset of 1st glyph */
+		x -= hbPositions[0].y_offset / 64.0; /* hack to compensate offset of 1st glyph */
+		y -= hbPositions[0].x_offset / 64.0; /* hack to compensate offset of 1st glyph */
 		for (i = 0; i < glyphCount; i++) {
-			positions[2*i]   = -(x - (hbPositions[i].y_offset / 64.0)); /* negative is forwards */
-			positions[2*i+1] =  hbPositions[i].x_advance / 64.0;
+			positions[2*i]   = x + (hbPositions[i].y_offset / 64.0);
+			positions[2*i+1] = -(y + hbPositions[i].x_offset / 64.0); /* negative is upwards */
 			x += hbPositions[i].y_advance / 64.0;
+			y += hbPositions[i].x_advance / 64.0;
 		}
-		x -= hbPositions[glyphCount-1].y_offset / 64.0;
-		positions[2*i]   = -x;
-		positions[2*i+1] =  y;
+		x += hbPositions[glyphCount-1].y_offset / 64.0;
+		y += hbPositions[glyphCount-1].x_offset / 64.0;
+		positions[2*i]   = x;
+		positions[2*i+1] = -y;
 	} else {
 		for (i = 0; i < glyphCount; i++) {
 			positions[2*i]   =   x + hbPositions[i].x_offset / 64.0;
