Skip to content

Commit

Permalink
Merge pull request #266 from lightning-js/dev
Browse files Browse the repository at this point in the history
Release 1.17.0
  • Loading branch information
michielvandergeest authored Jan 24, 2025
2 parents 922e473 + e8e85e4 commit 53ba6a4
Show file tree
Hide file tree
Showing 11 changed files with 495 additions and 129 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,14 @@ module.exports = {
},
],
},
parser: '@babel/eslint-parser',
parserOptions: {
parser: 'babel-eslint',
ecmaVersion: 2018,
sourceType: 'module',
babelOptions: {
plugins: ['@babel/plugin-syntax-import-assertions'],
},
},
globals: {
globalThis: false,
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## v1.17.0

_24 jan 2025_

- Deprecated `wordwrap`-attribute on Text component in favour of `maxwidth`
- Added documentation about text overflow
- Upgraded renderer to v2.9.1 and added `canvas` and `textureProcessingLimit` launch options

## v1.16.2

_21 jan 2025_
Expand Down
14 changes: 11 additions & 3 deletions docs/essentials/displaying_text.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ The Text-tag accepts the following attributes:
- `size` - the font size, defaults to `32`
- `color` - the color to display for the text, defaults to `white` and can be any of the supported Blits color formats (HTML, hexadecimal or rgb(a))
- `letterspacing` - letterspacing in pixels, defaults to `0`
- `align` - the alignment of the text, can be `left`, `right`, or `center`, defaults to `left`. Centering text and aligning text to the right requires the `wordwrap` attribute to be set as well.
- `wordwrap` - the max length of a line of text in pixels, words surpassing this length will be broken and wrapped onto the next line. This attribute is required when aligning center or right
- `align` - the alignment of the text, can be `left`, `right`, or `center`, defaults to `left`. Centering text and aligning text to the right requires the `maxwidth` attribute to be set as well.
- `maxwidth` - the max length of a line of text in pixels, words surpassing this length will be broken and wrapped onto the next line. This attribute is required when aligning center or right. Previously this attribute was `wordwrap`, which has now been deprecated in favour of `maxwidth`.
- `maxlines` - maximum number of lines that will be displayed
- `maxheight` - maximum height of a text block, lines that don't fit within this height will not be displayed
- `lineheight` - the spacing between lines in pixels
- `contain` - the strategy for containing text within the bounds, can be `none` (default), `width`, or `both`. In most cases, the value of this attribute will automatically be set by Blits, based on the other specified attributes
- `textoverflow` - the suffix to be added when text is cropped due to bounds limits, defaults to `...`
- `textoverflow` - the suffix to be added when text is cropped due to bounds limits, defaults to `...` (see more details [here](#text-overflow))

## Text dimensions

Expand Down Expand Up @@ -67,6 +67,14 @@ export default Blits.Component('MyComponent', {
}
```
## Text overflow
The text renderer offers the ability to display a _text overflow suffix_ when the text exceeds the bounds of the Text component.
This functionality is automatically enabled, but requires that both a _horizontal_ boundary (using `maxwidth`) and a _vertical_ boundary (using `maxlines` or `maxheight`) are specified on the Text component.
The `textoverflow`-attribute itself is not required, unless you want to use another suffix than the standard `...`. If you want _no suffix_ (and just a hard cutoff), the`textoverflow`-attribute should be set to `false` or an _empty string_.
## SDF and Canvas2d
Compared to Lightning 2, texts have improved a lot in Lightning 3, thanks to the SDF (Signed Distance Field) Text renderer.
Expand Down
16 changes: 15 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,21 @@ declare module '@lightningjs/blits' {
*
* Defaults to `50` (ms)
*/
holdTimeout?: number
holdTimeout?: number,
/**
* Custom canvas object used to render the App to.
*
* When not provided, the Lightning renderer will create a
* new Canvas element and inject it into the DOM
*/
canvas?: HTMLCanvasElement,
/**
* The maximum number of textures to process in a single frame. This is used to
* prevent the renderer from processing too many textures in a single frame.
*
* Defaults to `0` (meaning no limit)
*/
textureProcessingLimit?: number
}

interface State {
Expand Down
Loading

0 comments on commit 53ba6a4

Please sign in to comment.