convert static method

String convert(
  1. String text,
  2. UnicodeFont fromFont,
  3. UnicodeFont toFont
)

Converts the given text from the given fromFont to the toFont.

Implementation

static String convert(
    final String text, final UnicodeFont fromFont, final UnicodeFont toFont) {
  final from = _fonts[fromFont]!;
  final to = _fonts[toFont]!;
  final buffer = StringBuffer();
  final characters = Characters(text);
  for (final element in characters) {
    final index = from.indexOf(element);
    if (index == -1) {
      buffer.write(element);
    } else {
      buffer.write(to[index]);
    }
  }
  return buffer.toString();
}