style static method

PosStyles style(
  1. FontSize size, {
  2. bool bold = false,
  3. PosAlign align = PosAlign.left,
})

Menghasilkan PosStyles berdasarkan FontSize

Parameters:

  • size: Ukuran font dalam point (6pt-32pt)
  • bold: Apakah teks bold
  • align: Alignment teks (left, center, right)

Returns: PosStyles yang dikonfigurasi sesuai ukuran font

Implementation

static PosStyles style(
  FontSize size, {
  bool bold = false,
  PosAlign align = PosAlign.left,
}) {
  final widthMultiplier = size.getWidthMultiplier();
  final heightMultiplier = size.getHeightMultiplier();

  // Konversi multiplier ke PosTextSize
  final PosTextSize posWidth;
  final PosTextSize posHeight;

  switch (widthMultiplier) {
    case 1:
      posWidth = PosTextSize.size1;
      break;
    case 2:
      posWidth = PosTextSize.size2;
      break;
    case 3:
      posWidth = PosTextSize.size3;
      break;
    case 4:
    default:
      posWidth = PosTextSize.size4;
      break;
  }

  switch (heightMultiplier) {
    case 1:
      posHeight = PosTextSize.size1;
      break;
    case 2:
      posHeight = PosTextSize.size2;
      break;
    case 3:
      posHeight = PosTextSize.size3;
      break;
    case 4:
    default:
      posHeight = PosTextSize.size4;
      break;
  }

  return PosStyles(
    bold: bold,
    align: align,
    height: posHeight,
    width: posWidth,
  );
}