title: Sporadical weird text while writing on bitmap
body: <p>I am looking for some explanation about some weird texts that appears when I write on a bitmap and then upload it to azure blob.</p>
  <p>Sometimes when I create an imagem, it comes with theses weird texts where there should be accents. But I recreate it right after and it works...</p>
  <p>Here is the imagem gone wrong: <a href="https://www.dropbox.com/s/8an62ygys5nnwow/uploaded-image-636488352376069747.png?dl=0" rel="nofollow noreferrer">https://www.dropbox.com/s/8an62ygys5nnwow/uploaded-image-636488352376069747.png?dl=0</a></p>
  <p>And here is the correct image:
  <a href="https://www.dropbox.com/s/q3sdsqo3d05skz8/uploaded-image-636493880034621618.png?dl=0" rel="nofollow noreferrer">https://www.dropbox.com/s/q3sdsqo3d05skz8/uploaded-image-636493880034621618.png?dl=0</a></p>
  <p>I convert the image url to bitmap:</p>
  <pre><code>var request = System.Net.WebRequest.Create(url);
  var response = request.GetResponse();
      
  using (var responseStream = response.GetResponseStream())
  {
      var bitmap = new Bitmap(responseStream);
      
      return bitmap;
  }
  </code></pre>
  <p>And then I write the text on it:</p>
  <pre><code>private void AddText(System.Drawing.Image image, string text, int x, int y, int width, int height, int fontSize, Color fontColor, Color borderColor, FontFamily fontFamily, FontStyle fontStyle, StringAlignment horizontalAligment, StringAlignment verticalAligment, bool autoFit, int shadowOffsetX, int shadowOffsetY, Color shadowColor, int? maxHeight, out float finalHeight, out float finalWidth)
      {
          var graphics = Graphics.FromImage(image);
  
          graphics.SmoothingMode = SmoothingMode.AntiAlias;
          graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
          graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
  
          var rect = new Rectangle(x, y, width, height);
  
          StringFormat stringFormat = new StringFormat
          {
              Alignment = horizontalAligment,
              LineAlignment = verticalAligment
          };
  
          var font = new System.Drawing.Font(fontFamily, graphics.DpiY * fontSize / 72, fontStyle);
  
          if (autoFit)
          {
              font = FindFont(graphics, text, rect.Size, font);
          }
  
          var hasShadow = shadowOffsetX &gt; 0 &amp;&amp; shadowOffsetY &gt; 0;
          var hasMaxHeight = maxHeight != null &amp;&amp; maxHeight.Value &gt; 0;
  
          if (hasShadow)
          {
              var shadowGraphicsPath = new GraphicsPath();
              var shadowRect = new Rectangle(x + shadowOffsetX, y + shadowOffsetY, width, height);
              shadowGraphicsPath.AddString(text, fontFamily, (int)fontStyle, font.Size, shadowRect, stringFormat);
  
              if (hasMaxHeight)
              {
                  shadowGraphicsPath = GetTextWithMaxHeight(text, fontFamily, fontStyle, shadowRect, stringFormat, shadowGraphicsPath, font, maxHeight.Value, out float newFontSize);
  
                  font = new System.Drawing.Font(font.FontFamily, newFontSize);
              }
              
              graphics.FillPath(new SolidBrush(shadowColor), shadowGraphicsPath);
              graphics.Flush();
              shadowGraphicsPath.Dispose();
          }
  
          var graphicsPath = new GraphicsPath();
          
          graphicsPath.AddString(text, fontFamily, (int)fontStyle, font.Size, rect, stringFormat);
  
          if (hasMaxHeight &amp;&amp; !hasShadow)
          {
              graphicsPath = GetTextWithMaxHeight(text, fontFamily, fontStyle, rect, stringFormat, graphicsPath, font, maxHeight.Value, out float newFontSize);
          }
  
          graphics.DrawPath(new Pen(borderColor), graphicsPath);
          graphics.FillPath(new SolidBrush(fontColor), graphicsPath);
  
          finalHeight = graphicsPath.GetBounds().Height;
          finalWidth = graphicsPath.GetBounds().Width;
  
          graphics.Flush();
          graphicsPath.Dispose();
      }
  </code></pre>
  <p>And then I upload to azure blob</p>
  <pre><code>var container = _blobClient.GetContainerReference(_imageConfiguration.BlobContainer);
  
          var blockBlob = container.GetBlockBlobReference($&quot;uploaded-image-{DateTime.Now.ToUniversalTime().Ticks}.png&quot;);
  
          using (var imageStream = ConvertToStream(image, ImageFormat.Png))
          {
              blockBlob.UploadFromStream(imageStream);
  
              var uri = blockBlob.Uri;
  
              return uri;
          }
  </code></pre>
  <p>Can someone help me find an explanation for this?</p>