optFontWeight method

  1. @protected
FontWeight? optFontWeight(
  1. MarkupContext ctx, {
  2. bool enableTagAttr = true,
})

Implementation

@protected
FontWeight? optFontWeight(
  MarkupContext ctx, {
  bool enableTagAttr = true,
}) {
  FontWeight? weight = this.weight;

  int? w;
  if (enableTagAttr) {
    w = ctx.getIntBy(tags, 'weight');
  }
  w ??= ctx.getInt('weight');
  if (w != null) {
    weight = FontWeight.lerp(FontWeight.w100, FontWeight.w900, w / 900);
  }

  const weightAlias = {'bold': FontWeight.bold, 'normal': FontWeight.normal};
  weight ??= ctx.switchT(ctx.getBy(tags, 'weight'), weightAlias);
  print('weight:$weight');

  return weight;
}