iddan / react-native-canvas

A Canvas component for React Native
MIT License
981 stars 172 forks source link

Not able to add fontFamily with font #318

Open piyushsinghdev opened 1 year ago

piyushsinghdev commented 1 year ago

I am trying to add diffrent fontFamily Conditionally but not able to add it this is my code can you tell me what is the issue const handleCanvas = async (canvas: any, fontFamily: string) => { const FONT_SIZE = 200; if (canvas) { canvas.width = 1000; canvas.height =200; const ctx = canvas.getContext('2d'); ctx.textAlign = 'center'; ctx.textBaseline = 'top'; // ctx.font = ${FONT_SIZE}px "${font}" ctx.font = ${FONT_SIZE}px "${fontFamily}";

  ctx.fillStyle = penColor;
  ctx.fillText(txtInputSignPickState, 550,1);
  canvas.toDataURL().then(async (data: any) => {
    setpickSignListState(data);
  });
}

};