- * Algorithms in LATEX language
-TotalCost(i) = min_{j}~TotalCost(j) + LineCost(j, i)~~~~j=0, 1, ..., i-1
-
-LineCost(j, i)= \begin{cases}
-\infty ~~~ if~~LineWidth - \sum_{k=j+1}^{i-1} OrigWidth(item[k]) - newLineWidth(item[i]) < 0 \\
-\infty~~if~~NOT~~breakable(item[i]) \\
-(LineWidth - \sum_{k=j+1}^{i-1} OrigWidth(item[k]) - newLineWidth(item[i]))^3 ~~elsewhere
-\end{cases} */
-/**check if a boeitem is BreakPoint Type */
-function isBreakPoint(item) {
- return item.newLined !== undefined;
-}
-/**check if a boeitem is BreakPoint Type */
-function isHGlue(item) {
- return item.stretchFactor !== undefined;
-}
-/** measuring original advance width */
-function origWidth(item) {
- if (isBreakPoint(item)) {
- console.log(item);
- return origWidth(item.original);
+ * Algorithms in LATEX-like language
+ */
+class BreakLineAlgorithm {
+ constructor() {
+ this.prevNodes = [];
+ this.totalCostAuxStorage = [];
+ this.lineCostStorage = [[]];