pixi-glyphs 4.2.1 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/pixi-glyphs.js +15 -2
- package/dist/pixi-glyphs.js.map +1 -1
- package/dist/pixi-glyphs.m.js +15 -2
- package/dist/pixi-glyphs.m.js.map +1 -1
- package/dist/pixi-glyphs.modern.js +16 -2
- package/dist/pixi-glyphs.modern.js.map +1 -1
- package/dist/pixi-glyphs.umd.js +15 -2
- package/dist/pixi-glyphs.umd.js.map +1 -1
- package/dist/types.d.ts +4 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -83,6 +83,7 @@ The style objects are modified versions (supersets) of `PIXI.TextStyle` (referre
|
|
|
83
83
|
- `fontScaleWidth` - Percentage to scale the font e.g. `0.5` = 50%
|
|
84
84
|
- `fontScaleHeight` - Percentage to scale the font e.g. `1.25` = 125%
|
|
85
85
|
- `letterSpacing` - Additional horizontal spacing between each character in pixels. Can be positive to spread letters apart or negative to bring them closer together. Default is `0`.
|
|
86
|
+
- `wordSpacing` - Additional horizontal spacing for word separators (spaces) in pixels. Adjusts the width of spaces between words. Can be positive to increase spacing or negative to decrease spacing. Default is `0`.
|
|
86
87
|
- `lineSpacing` - Additional vertical spacing between lines of text in pixels. This spacing is added between all lines within a paragraph. Default is `0`.
|
|
87
88
|
- `paragraphSpacing` - Additional spacing between paragraphs that is added when you use an explicit carriage return rather than letting the text wrap at the end of a line. Default is `0`. Can also be negative.
|
|
88
89
|
- `breakLines` - When `breakLines` is `false`, the text in the tag will ignore the `wordWrapWidth` property and never wrap to the next line unless you explicitly include a newline character. It essentially treats the whole tag as a single word. If a nested tag overrides this, only the text inside the nested tag will wrap. Default is `true`.
|
package/dist/pixi-glyphs.js
CHANGED
|
@@ -890,9 +890,17 @@ const verticalAlignInLines = (lines, lineSpacing, overrideValign) => {
|
|
|
890
890
|
let baseHeight = tallestToken.bounds?.height ?? 0;
|
|
891
891
|
let baseTallestAscent = 0;
|
|
892
892
|
let baseTallestDescent = 0;
|
|
893
|
+
let tallestSpriteHeight = 0;
|
|
893
894
|
const hasRealContent = line.flat(2).some(seg => !isWhitespaceToken(seg) && !isNewlineToken(seg));
|
|
894
895
|
for (const word of line) {
|
|
895
896
|
for (const segment of word) {
|
|
897
|
+
if (isSpriteToken(segment)) {
|
|
898
|
+
const spriteHeight = segment.bounds?.height ?? 0;
|
|
899
|
+
if (spriteHeight > tallestSpriteHeight) {
|
|
900
|
+
tallestSpriteHeight = spriteHeight;
|
|
901
|
+
}
|
|
902
|
+
continue;
|
|
903
|
+
}
|
|
896
904
|
let segAscent = segment.fontProperties?.ascent ?? 0;
|
|
897
905
|
const segDescent = segment.fontProperties?.descent ?? 0;
|
|
898
906
|
const style = segment.style;
|
|
@@ -920,7 +928,8 @@ const verticalAlignInLines = (lines, lineSpacing, overrideValign) => {
|
|
|
920
928
|
}
|
|
921
929
|
}
|
|
922
930
|
}
|
|
923
|
-
|
|
931
|
+
const textBasedHeight = baseTallestAscent + baseTallestDescent;
|
|
932
|
+
baseHeight = Math.max(textBasedHeight, tallestSpriteHeight);
|
|
924
933
|
if (baseHeight === 0 && baseTallestAscent === 0) {
|
|
925
934
|
baseHeight = lastNonEmptyTallestToken.bounds?.height ?? 0;
|
|
926
935
|
baseTallestAscent = lastNonEmptyTallestToken.fontProperties?.ascent ?? 0;
|
|
@@ -1267,7 +1276,8 @@ const calculateTokens = (styledTokens, splitStyle = "words", scaleIcons = true,
|
|
|
1267
1276
|
const baselineAdjustment = getBaselineAdjustment(style, adjustFontBaseline, fontProperties.ascent);
|
|
1268
1277
|
fontProperties.ascent += baselineAdjustment;
|
|
1269
1278
|
const {
|
|
1270
|
-
letterSpacing
|
|
1279
|
+
letterSpacing,
|
|
1280
|
+
wordSpacing
|
|
1271
1281
|
} = style;
|
|
1272
1282
|
if (letterSpacing) {
|
|
1273
1283
|
bounds.width += letterSpacing;
|
|
@@ -1280,6 +1290,9 @@ const calculateTokens = (styledTokens, splitStyle = "words", scaleIcons = true,
|
|
|
1280
1290
|
fontProperties,
|
|
1281
1291
|
textDecorations
|
|
1282
1292
|
};
|
|
1293
|
+
if (wordSpacing && isOnlyWhitespace(str)) {
|
|
1294
|
+
convertedToken.bounds.width += wordSpacing;
|
|
1295
|
+
}
|
|
1283
1296
|
return convertedToken;
|
|
1284
1297
|
});
|
|
1285
1298
|
output = output.concat(textTokens);
|