Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions examples/tests/text-dimensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ export default async function test(settings: ExampleSettings) {
text1.text = 'SDF 2nd';
text1.textRendererOverride = 'sdf';
},
() => {
// Test when text ends with space for correct width
text1.text = 'Canvas ';
text1.textRendererOverride = 'canvas';
},
() => {
// Test when text ends with space for correct width
text1.text = 'SDF ';
text1.textRendererOverride = 'sdf';
},
];
/**
* Run the next mutation in the list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,18 @@ export function layoutText(
xStart: -1,
};

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const shaper = trFontFace.shaper;

const shaperProps: FontShaperProps = {
letterSpacing: vertexLSpacing,
};

// HACK: The space is used as a word boundary. When a text ends with a space, we need to
// add an extra space to ensure the space is included in the line width calculation.
if (text.endsWith(' ')) {
text += ' ';
}

// Get glyphs
let glyphs = shaper.shapeText(
shaperProps,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading