Skip to content

Commit ee95bc7

Browse files
authored
bugfix/macOSGraphicsFromHwndSystemNotSupportedException: adicionado rotina que substitui Graphics.FromHwnd() do Windows para Graphics.FromImage() no Unix ( macOS, FreeBSD, Linux ) e corrigir o exception ( System.NotSupportedException: Specified method is not supported. ) no metodo MedidasLinha.GetMedidas() em NFe.Danfe.Nativo/GraphicsPrinter/MedidasLinha.cs (#133)
1 parent 08b1bae commit ee95bc7

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

NFe.Danfe.Nativo/GraphicsPrinter/MedidasLinha.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ public static Medida GetMedidas(AdicionarTexto adicionarTexto)
1414

1515
public static Medida GetMedidas(string texto, Font fonte)
1616
{
17-
Graphics g = Graphics.FromHwnd(IntPtr.Zero);
17+
/*
18+
* macOS:
19+
* Graphics g = Graphics.FromHwnd(IntPtr.Zero);
20+
* System.NotSupportedException: Specified method is not supported.
21+
*/
22+
Bitmap bmp = new Bitmap(1, 1);
23+
Graphics g = Graphics.FromImage(bmp);
1824
SizeF tamanhoDaString = g.MeasureString(texto, fonte);
1925
int alturaLinha = Convert.ToInt32(tamanhoDaString.Height);
2026
int larguraLinha = Convert.ToInt32(tamanhoDaString.Width);

0 commit comments

Comments
 (0)