@shopify/react-native-skia
Version:
High-performance React Native Graphics using Skia
59 lines (53 loc) • 4.12 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.JsiSkParagraphStyle = void 0;
var _types = require("../types");
class JsiSkParagraphStyle {
static toParagraphStyle(ck, value) {
var _value$strutStyle, _value$strutStyle2, _value$strutStyle3, _value$strutStyle4, _value$strutStyle5, _value$strutStyle6, _value$strutStyle6$fo, _value$strutStyle7, _value$strutStyle7$fo, _value$strutStyle8, _value$strutStyle8$fo, _value$strutStyle9, _value$strutStyle10;
// Seems like we need to provide the textStyle.color value, otherwise
// the constructor crashes.
const ps = new ck.ParagraphStyle({
textStyle: {
color: ck.BLACK
}
});
ps.disableHinting = value.disableHinting ?? ps.disableHinting;
ps.ellipsis = value.ellipsis ?? ps.ellipsis;
ps.heightMultiplier = value.heightMultiplier ?? ps.heightMultiplier;
ps.maxLines = value.maxLines ?? ps.maxLines;
ps.replaceTabCharacters = value.replaceTabCharacters ?? ps.replaceTabCharacters;
ps.textAlign = value.textAlign !== undefined ? {
value: value.textAlign
} : undefined ?? ps.textAlign;
ps.textDirection = value.textDirection !== undefined ? {
value: value.textDirection === _types.SkTextDirection.LTR ? 1 : 0
} : ps.textDirection;
ps.textHeightBehavior = value.textHeightBehavior !== undefined ? {
value: value.textHeightBehavior
} : ps.textHeightBehavior;
ps.strutStyle = ps.strutStyle ?? {};
ps.strutStyle.fontFamilies = ((_value$strutStyle = value.strutStyle) === null || _value$strutStyle === void 0 ? void 0 : _value$strutStyle.fontFamilies) ?? ps.strutStyle.fontFamilies;
ps.strutStyle.fontSize = ((_value$strutStyle2 = value.strutStyle) === null || _value$strutStyle2 === void 0 ? void 0 : _value$strutStyle2.fontSize) ?? ps.strutStyle.fontSize;
ps.strutStyle.heightMultiplier = ((_value$strutStyle3 = value.strutStyle) === null || _value$strutStyle3 === void 0 ? void 0 : _value$strutStyle3.heightMultiplier) ?? ps.strutStyle.heightMultiplier;
ps.strutStyle.leading = ((_value$strutStyle4 = value.strutStyle) === null || _value$strutStyle4 === void 0 ? void 0 : _value$strutStyle4.leading) ?? ps.strutStyle.leading;
ps.strutStyle.forceStrutHeight = ((_value$strutStyle5 = value.strutStyle) === null || _value$strutStyle5 === void 0 ? void 0 : _value$strutStyle5.forceStrutHeight) ?? ps.strutStyle.forceStrutHeight;
ps.strutStyle.fontStyle = ps.strutStyle.fontStyle ?? {};
ps.strutStyle.fontStyle.slant = ((_value$strutStyle6 = value.strutStyle) === null || _value$strutStyle6 === void 0 ? void 0 : (_value$strutStyle6$fo = _value$strutStyle6.fontStyle) === null || _value$strutStyle6$fo === void 0 ? void 0 : _value$strutStyle6$fo.slant) !== undefined ? {
value: value.strutStyle.fontStyle.slant
} : ps.strutStyle.fontStyle.slant;
ps.strutStyle.fontStyle.width = ((_value$strutStyle7 = value.strutStyle) === null || _value$strutStyle7 === void 0 ? void 0 : (_value$strutStyle7$fo = _value$strutStyle7.fontStyle) === null || _value$strutStyle7$fo === void 0 ? void 0 : _value$strutStyle7$fo.width) !== undefined ? {
value: value.strutStyle.fontStyle.width
} : ps.strutStyle.fontStyle.width;
ps.strutStyle.fontStyle.weight = ((_value$strutStyle8 = value.strutStyle) === null || _value$strutStyle8 === void 0 ? void 0 : (_value$strutStyle8$fo = _value$strutStyle8.fontStyle) === null || _value$strutStyle8$fo === void 0 ? void 0 : _value$strutStyle8$fo.weight) !== undefined ? {
value: value.strutStyle.fontStyle.weight
} : ps.strutStyle.fontStyle.weight;
ps.strutStyle.halfLeading = ((_value$strutStyle9 = value.strutStyle) === null || _value$strutStyle9 === void 0 ? void 0 : _value$strutStyle9.halfLeading) ?? ps.strutStyle.halfLeading;
ps.strutStyle.strutEnabled = ((_value$strutStyle10 = value.strutStyle) === null || _value$strutStyle10 === void 0 ? void 0 : _value$strutStyle10.strutEnabled) ?? ps.strutStyle.strutEnabled;
return ps;
}
}
exports.JsiSkParagraphStyle = JsiSkParagraphStyle;
//# sourceMappingURL=JsiSkParagraphStyle.js.map