diff --git a/freetype/truetype/hint.go b/freetype/truetype/hint.go index 707f965441b50f2c209894501cbc90effb72e18f..510238c0719160af8ba8b66edfe771749bcc070e 100644 --- a/freetype/truetype/hint.go +++ b/freetype/truetype/hint.go @@ -545,7 +545,7 @@ func (h *Hinter) run(program []byte, pCurrent, pUnhinted, pInFontUnits []Point, case opSHC0, opSHC1: top-- - _, _, d, ok := h.displacement(opcode&1 == 0) + zonePointer, i, d, ok := h.displacement(opcode&1 == 0) if !ok { return errors.New("truetype: hinting: point out of range") } @@ -557,12 +557,15 @@ func (h *Hinter) run(program []byte, pCurrent, pUnhinted, pInFontUnits []Point, if contour < 0 || len(ends) <= int(contour) { return errors.New("truetype: hinting: contour out of range") } - j0, j1 := 0, h.ends[contour] + j0, j1 := int32(0), int32(h.ends[contour]) if contour > 0 { - j0 = h.ends[contour-1] + j0 = int32(h.ends[contour-1]) } + move := h.gs.zp[zonePointer] != h.gs.zp[2] for j := j0; j < j1; j++ { - h.move(h.point(2, current, int32(j)), d, false) + if move || j != i { + h.move(h.point(2, current, j), d, false) + } } case opSHZ0, opSHZ1: @@ -1149,7 +1152,9 @@ func (h *Hinter) run(program []byte, pCurrent, pUnhinted, pInFontUnits []Point, distance := cvtDist if opcode&0x04 != 0 { // The CVT value is only used if close enough to oldDist. - if (cvtDist - oldDist).abs() > h.gs.controlValueCutIn { + if (h.gs.zp[0] == h.gs.zp[1]) && + ((cvtDist - oldDist).abs() > h.gs.controlValueCutIn) { + distance = oldDist } distance = h.round(distance) diff --git a/freetype/truetype/truetype_test.go b/freetype/truetype/truetype_test.go index 03f4bb4ccb5ba333c1837024957b46a71369ae4d..cea20c178102e5b476f4edf38b3bdad80b4a1b73 100644 --- a/freetype/truetype/truetype_test.go +++ b/freetype/truetype/truetype_test.go @@ -255,7 +255,7 @@ var scalingTestCases = []struct { hintingBrokenAt int }{ {"luxisr", 12, -1}, - {"x-arial-bold", 11, 94}, + {"x-arial-bold", 11, 130}, {"x-deja-vu-sans-oblique", 17, -1}, {"x-droid-sans-japanese", 9, 0}, {"x-times-new-roman", 13, 0},