fix: fixed kern increment/decrement while balancing para tail
This commit is contained in:
parent
ab552a70db
commit
48ebe71c8e
1 changed files with 42 additions and 14 deletions
|
@ -4,6 +4,9 @@
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Public Const MAX_CHAR_KERNING = 20
|
||||||
|
Public Const MIN_CHAR_KERNING = -15
|
||||||
|
|
||||||
Sub resetNotesStyle
|
Sub resetNotesStyle
|
||||||
Dim oDescriptor As Object
|
Dim oDescriptor As Object
|
||||||
Dim dispatcher As Object
|
Dim dispatcher As Object
|
||||||
|
@ -458,11 +461,10 @@ Sub adjustLastLineCurPara()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Sub adjustLastLine(anchor As Object)
|
Sub adjustLastLine(anchor As Object)
|
||||||
anchor.ParaAdjust = 2
|
anchor.ParaAdjust = 2
|
||||||
anchor.ParaLastLineAdjust = 2
|
anchor.ParaLastLineAdjust = 2
|
||||||
balancePara(anchor)
|
balanceParaTail(anchor)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub adjustFirstLine(anchor As Object)
|
Sub adjustFirstLine(anchor As Object)
|
||||||
|
@ -485,7 +487,7 @@ Function isLowerCase(character As String) As Boolean
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
|
||||||
Sub balancePara(targetPara As Object)
|
Sub balanceParaTail(targetPara As Object)
|
||||||
' Globalscope.BasicLibraries.LoadLibrary( "MRILib" )
|
' Globalscope.BasicLibraries.LoadLibrary( "MRILib" )
|
||||||
Dim oViewCursor As Object
|
Dim oViewCursor As Object
|
||||||
Dim oTextCursor As Object
|
Dim oTextCursor As Object
|
||||||
|
@ -536,7 +538,7 @@ Sub balancePara(targetPara As Object)
|
||||||
paraLines = getParaLines(oPara)
|
paraLines = getParaLines(oPara)
|
||||||
lineCount = getParaLinesCount(paraLines)
|
lineCount = getParaLinesCount(paraLines)
|
||||||
lineLen = getParaLineLength(paraLines,0)
|
lineLen = getParaLineLength(paraLines,0)
|
||||||
If (lineCount < initialLineCount ) OR (oPara.CharKerning < -15) Then
|
If (lineCount < initialLineCount ) OR (oPara.CharKerning < MIN_CHAR_KERNING) Then
|
||||||
'Tightened last line but it is still smaller than we need
|
'Tightened last line but it is still smaller than we need
|
||||||
fallBackSuccess = tryExpandPrevLines(oPara, minLastLineLength)
|
fallBackSuccess = tryExpandPrevLines(oPara, minLastLineLength)
|
||||||
If Not fallBackSuccess Then
|
If Not fallBackSuccess Then
|
||||||
|
@ -568,14 +570,14 @@ Function tryExpandPrevLines(oPara As Object, minLastLineLength As Integer) As Bo
|
||||||
paraLines = getParaLines(oPara)
|
paraLines = getParaLines(oPara)
|
||||||
lineCount = getParaLinesCount(paraLines)
|
lineCount = getParaLinesCount(paraLines)
|
||||||
lineLen = getParaLineLength(paraLines,0)
|
lineLen = getParaLineLength(paraLines,0)
|
||||||
If lineNum > 1 And (lineCount <> initialLineCount Or paraLine.CharKerning > 20) Then
|
If lineNum > 1 And (lineCount <> initialLineCount Or paraLine.CharKerning > MAX_CHAR_KERNING) Then
|
||||||
AddToArray(failedLines, lineNum)
|
AddToArray(failedLines, lineNum)
|
||||||
decreaseCharKerning(paraLine)
|
decreaseCharKerning(paraLine)
|
||||||
paraLines = getParaLines(oPara)
|
paraLines = getParaLines(oPara)
|
||||||
lineCount = getParaLinesCount(paraLines)
|
lineCount = getParaLinesCount(paraLines)
|
||||||
lineLen = getParaLineLength(paraLines,0)
|
lineLen = getParaLineLength(paraLines,0)
|
||||||
lineNum = 0
|
lineNum = 0
|
||||||
ElseIf lineNum = 1 And paraLine.CharKerning > 20 Then
|
ElseIf lineNum = 1 And paraLine.CharKerning > MAX_CHAR_KERNING Then
|
||||||
tryExpandPrevLines = false
|
tryExpandPrevLines = false
|
||||||
Exit Function
|
Exit Function
|
||||||
EndIf
|
EndIf
|
||||||
|
@ -626,19 +628,45 @@ End Function
|
||||||
|
|
||||||
|
|
||||||
Sub decreaseCharKerning(oPara As Object)
|
Sub decreaseCharKerning(oPara As Object)
|
||||||
|
Dim initialCharKerning As Integer
|
||||||
|
Dim textExcerpts As Object
|
||||||
|
Dim textExcerpt As Object
|
||||||
|
initialCharKerning = MIN_CHAR_KERNING
|
||||||
If(IsEmpty(oPara.CharKerning)) Then
|
If(IsEmpty(oPara.CharKerning)) Then
|
||||||
oPara.CharKerning = 0
|
textExcerpts = oPara.createEnumeration()
|
||||||
Else
|
While textExcerpts.hasMoreElements
|
||||||
oPara.CharKerning = oPara.CharKerning - 2
|
textExcerpt = textExcerpts.nextElement
|
||||||
|
If Not IsEmpty(textExcerpt.CharKerning) Then
|
||||||
|
If textExcerpt.CharKerning > initialCharKerning Then
|
||||||
|
initialCharKerning = textExcerpt.CharKerning
|
||||||
EndIf
|
EndIf
|
||||||
|
EndIf
|
||||||
|
Wend
|
||||||
|
Else
|
||||||
|
initialCharKerning = oPara.CharKerning
|
||||||
|
EndIf
|
||||||
|
oPara.CharKerning = initialCharKerning - 2
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub increaseCharKerning(oPara As Object)
|
Sub increaseCharKerning(oPara As Object)
|
||||||
|
Dim initialCharKerning As Integer
|
||||||
|
Dim textExcerpts As Object
|
||||||
|
Dim textExcerpt As Object
|
||||||
|
initialCharKerning = MAX_CHAR_KERNING
|
||||||
If(IsEmpty(oPara.CharKerning)) Then
|
If(IsEmpty(oPara.CharKerning)) Then
|
||||||
oPara.CharKerning = 0
|
textExcerpts = oPara.createEnumeration()
|
||||||
Else
|
While textExcerpts.hasMoreElements
|
||||||
oPara.CharKerning = oPara.CharKerning + 2
|
textExcerpt = textExcerpts.nextElement
|
||||||
|
If Not IsEmpty(textExcerpt.CharKerning) Then
|
||||||
|
If textExcerpt.CharKerning < initialCharKerning Then
|
||||||
|
initialCharKerning = textExcerpt.CharKerning
|
||||||
EndIf
|
EndIf
|
||||||
|
EndIf
|
||||||
|
Wend
|
||||||
|
Else
|
||||||
|
initialCharKerning = oPara.CharKerning
|
||||||
|
EndIf
|
||||||
|
oPara.CharKerning = initialCharKerning + 2
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Function lastLineIsNotBalanced(lineLen As Integer,minLastLineLength As Integer) As Boolean
|
Function lastLineIsNotBalanced(lineLen As Integer,minLastLineLength As Integer) As Boolean
|
||||||
|
|
Loading…
Add table
Reference in a new issue