mirror of
https://github.com/lovell/sharp.git
synced 2025-12-18 23:05:04 +01:00
Ensure text.wrap property can accept word-char as value (#4028)
This commit is contained in:
@@ -166,7 +166,7 @@ const debuglog = util.debuglog('sharp');
|
||||
* @param {number} [options.text.dpi=72] - the resolution (size) at which to render the text. Does not take effect if `height` is specified.
|
||||
* @param {boolean} [options.text.rgba=false] - set this to true to enable RGBA output. This is useful for colour emoji rendering, or support for pango markup features like `<span foreground="red">Red!</span>`.
|
||||
* @param {number} [options.text.spacing=0] - text line height in points. Will use the font line height if none is specified.
|
||||
* @param {string} [options.text.wrap='word'] - word wrapping style when width is provided, one of: 'word', 'char', 'charWord' (prefer char, fallback to word) or 'none'.
|
||||
* @param {string} [options.text.wrap='word'] - word wrapping style when width is provided, one of: 'word', 'char', 'word-char' (prefer word, fallback to char) or 'none'.
|
||||
* @returns {Sharp}
|
||||
* @throws {Error} Invalid parameters
|
||||
*/
|
||||
|
||||
4
lib/index.d.ts
vendored
4
lib/index.d.ts
vendored
@@ -1017,7 +1017,7 @@ declare namespace sharp {
|
||||
rgba?: boolean;
|
||||
/** Text line height in points. Will use the font line height if none is specified. (optional, default `0`) */
|
||||
spacing?: number;
|
||||
/** Word wrapping style when width is provided, one of: 'word', 'char', 'charWord' (prefer char, fallback to word) or 'none' */
|
||||
/** Word wrapping style when width is provided, one of: 'word', 'char', 'word-char' (prefer word, fallback to char) or 'none' */
|
||||
wrap?: TextWrap;
|
||||
}
|
||||
|
||||
@@ -1613,7 +1613,7 @@ declare namespace sharp {
|
||||
|
||||
type TextAlign = 'left' | 'centre' | 'center' | 'right';
|
||||
|
||||
type TextWrap = 'word' | 'char' | 'charWord' | 'none';
|
||||
type TextWrap = 'word' | 'char' | 'word-char' | 'none';
|
||||
|
||||
type TileContainer = 'fs' | 'zip';
|
||||
|
||||
|
||||
@@ -345,10 +345,10 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
|
||||
}
|
||||
}
|
||||
if (is.defined(inputOptions.text.wrap)) {
|
||||
if (is.string(inputOptions.text.wrap) && is.inArray(inputOptions.text.wrap, ['word', 'char', 'wordChar', 'none'])) {
|
||||
if (is.string(inputOptions.text.wrap) && is.inArray(inputOptions.text.wrap, ['word', 'char', 'word-char', 'none'])) {
|
||||
inputDescriptor.textWrap = inputOptions.text.wrap;
|
||||
} else {
|
||||
throw is.invalidParameterError('text.wrap', 'one of: word, char, wordChar, none', inputOptions.text.wrap);
|
||||
throw is.invalidParameterError('text.wrap', 'one of: word, char, word-char, none', inputOptions.text.wrap);
|
||||
}
|
||||
}
|
||||
delete inputDescriptor.buffer;
|
||||
|
||||
Reference in New Issue
Block a user