If the dash_pos variable is relative to pen width, we need to fix the other references to it. It doesn't make sense to compare it directly with segment_length and segment_pos.
Or we could scale the whole dash_pattern array by pen width at the start.