Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
TwIStOy committed Dec 7, 2023
1 parent c9023a0 commit ca436b1
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/graphics/widgets/text/text.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { BuildContext, Widget, _WidgetOption } from "@glib/widget";
import { AnyColor, Color, normalizeColor } from "../_utils";
import { FlexibleSize, PixelPosition } from "@glib/base";
import { Box, InputItem, adjustmentRatios, breakLines } from "./line-break";
import {
Box,
Glue,
InputItem,
adjustmentRatios,
breakLines,
} from "./line-break";
import { FontExtents } from "ht.clib.cairo";
import { info } from "@core/utils/logger";

Expand Down Expand Up @@ -201,8 +207,14 @@ class _Text extends Widget {
p !== start &&
p !== breakpoints[b + 1]
) {
let te = context.renderer.ctx.text_extents(" ");
x += te.x_advance + te.x_advance * ratios[b];
let item = inputItems[p] as Glue;
let gap;
if (ratios[b] < 0) {
gap = item.width + ratios[b] * item.shrink;
} else {
gap = item.width + ratios[b] * item.stretch;
}
x += gap;
}
}
x = initPosition.x;
Expand Down

0 comments on commit ca436b1

Please sign in to comment.