[justify] Fix shrink/expand conditions
This commit is contained in:
parent
039ea9adda
commit
ab249fd24b
|
@ -168,9 +168,10 @@ class Line:
|
||||||
def justify(self):
|
def justify(self):
|
||||||
buf, text = makebuffer(str(self))
|
buf, text = makebuffer(str(self))
|
||||||
|
|
||||||
|
wiggle = 5
|
||||||
advance = self.advance
|
advance = self.advance
|
||||||
shrink = self._target_advance > advance
|
shrink = self._target_advance - wiggle < advance
|
||||||
expand = not shrink
|
expand = self._target_advance + wiggle > advance
|
||||||
|
|
||||||
ret, advance, tag, value = hb.shape_justify(
|
ret, advance, tag, value = hb.shape_justify(
|
||||||
self._font,
|
self._font,
|
||||||
|
@ -184,15 +185,17 @@ class Line:
|
||||||
|
|
||||||
if not ret:
|
if not ret:
|
||||||
return False
|
return False
|
||||||
if shrink and advance > self._target_advance:
|
|
||||||
return False
|
|
||||||
if expand and advance < self._target_advance:
|
|
||||||
return False
|
|
||||||
|
|
||||||
self._variation = hb.variation_t()
|
self._variation = hb.variation_t()
|
||||||
self._variation.tag = tag
|
self._variation.tag = tag
|
||||||
self._variation.value = value
|
self._variation.value = value
|
||||||
self._words = makewords(buf, self._font, text)
|
self._words = makewords(buf, self._font, text)
|
||||||
|
|
||||||
|
if shrink and advance > self._target_advance + wiggle:
|
||||||
|
return False
|
||||||
|
if expand and advance < self._target_advance - wiggle:
|
||||||
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
|
|
Loading…
Reference in New Issue