optTextDecoration method

  1. @protected
FontTextDecoration? optTextDecoration(
  1. MarkupContext ctx, {
  2. String attrPrefix = '',
  3. bool enableTagAttr = true,
})

Implementation

@protected
FontTextDecoration? optTextDecoration(
  MarkupContext ctx, {
  String attrPrefix = '',
  bool enableTagAttr = true,
}) {
  // TODO: 支持TextDecoration.combine
  TextDecoration? decoration;
  if (enableTagAttr) {
    final decor = ctx.getBy(tags, 'decor');
    decoration ??= ctx.switchT(decor, mpTextDecoration) ??
        ctx.whenExist(mpTextDecoration);
  }
  decoration ??= ctx.switchT(ctx.get('decor'), mpTextDecoration);
  decoration ??= this.decoration;

  var style = ctx.switchT(
    ctx.get('${attrPrefix}style'),
    mpTextDecorationStyle,
  );
  style ??= decorationStyle;

  var color = Pigment.fromString(
    ctx.get('${attrPrefix}color'),
    ctx.colorMapper,
  );
  color ??= decorationColor;

  final thickness = ctx.getDouble('thickness') ?? decorationThickness;

  if (decoration == null &&
      style == null &&
      color == null &&
      thickness == null) {
    return null;
  }
  return (
    decoration: decoration,
    style: style,
    color: color,
    thickness: thickness,
  );
}