diagramTextRunStyle function

TextStyle diagramTextRunStyle(
  1. TextRun run,
  2. TextRole role,
  3. DiagramColor foreground, {
  4. double defaultFontSize = diagramDefaultFontSize,
})

Implementation

TextStyle diagramTextRunStyle(
  TextRun run,
  TextRole role,
  DiagramColor foreground, {
  double defaultFontSize = diagramDefaultFontSize,
}) {
  final appearance = run.appearance(role);
  return TextStyle(
    color: (run.color ?? foreground).toColor(),
    fontFamily: run.fontFamily,
    fontSize: run.fontSize ?? defaultFontSize,
    height: diagramDefaultTextHeight,
    fontWeight: appearance.fontWeight == 700
        ? FontWeight.w700
        : FontWeight.w400,
    fontStyle: appearance.italic ? FontStyle.italic : FontStyle.normal,
    decoration: appearance.underline
        ? TextDecoration.combine([
            TextDecoration.underline,
            if (appearance.strikethrough) TextDecoration.lineThrough,
          ])
        : appearance.strikethrough
        ? TextDecoration.lineThrough
        : TextDecoration.none,
    fontFeatures: [
      for (final feature in appearance.fontFeatures.entries)
        FontFeature(feature.key, feature.value),
    ],
  );
}