4

So I'm not sure what the issue is and have exhausted just about every option I can think of. I am targeting dotnet core 3.0 on Ubuntu 18.04 LTS. On a windows environment it works fine but in this Ubuntu environment text just does not render the way it is support to and comes out looking something like this

How it is supposed to be displayed

How it is supposed to be displayed

How it is displaying on Ubuntu

How it is displaying on Ubuntu

I am using the font Arial and I have the MS TrueType Fonts package installed, I've tried Font families native to Ubuntu and still the same thing.

Simply Ged
  • 8,250
  • 11
  • 32
  • 40
Tonic
  • 51
  • 2
  • The placeholders are fixed width, so I am guessing that the data is never properly retreived and this is simply the padding. – Christopher Oct 28 '19 at 03:48
  • The Match Type, Champion and Ratio things are 2 Characters to short. Morgana also has the a at teh wrong spot. Most KDA ratios have the proper amount of Characters, except for Bard, Thresh and Nautilus, wich are only 3 charactesr (5-7 in the original). Have you tried outputting it in a console, Message box or similar simple output System? One where little can be messed up by secondary things? – Christopher Oct 28 '19 at 03:52
  • Well the thing is even if I use just a hard-coded string like "Test" it still comes out the same way. If I use a single character it renders the character just fine. – Tonic Oct 28 '19 at 18:45
  • The question was what happens with a simple textbox or console output. The GUI code is complicated as heck and before you try to debug it, you should verify that it actually *is* the GUI code, not the data retreival. – Christopher Oct 29 '19 at 09:45
  • I've checked to make sure the information being received is correct. To further test this I created a separate app using basic code to draw an image and write text and it still comes out the same way (https://pastebin.com/XpeB9c6v) still just returns the boxes. Works perfectly fine on a windows environment but not in my Ubuntu environment. – Tonic Nov 01 '19 at 01:34
  • The odd thing is if I draw a single character with DrawString it will display that single character just fine. – Tonic Nov 01 '19 at 01:44
  • if it works on windows but not your Ubuntu, maybe there is something wrong with that Ubuntu? Could you test both on another Ubuntu, including ones in a Virtual Machine? Maybe even just on a Life DVD Linux? – Christopher Nov 01 '19 at 14:48
  • Got any solution? I'm having the same issue once upgraded to .net core 3.0... It was working in 2.2 – vinayak hegde Nov 21 '19 at 08:15
  • 1
    Ah forgot to update this, yes eventually I figured out the issue and it was related to having Windows Compatibility Pack (Microsoft.Windows.Compatibility) referenced, the pack was for 2.x and phased out with 3.0 – Tonic Nov 22 '19 at 13:00

1 Answers1

3

I experienced the same issue on Fedora 34.

I used this example file to reproduce the problem:

using System.Drawing;

Bitmap bmp = new Bitmap(200, 100);
using var gfx = Graphics.FromImage(bmp);
gfx.Clear(Color.Navy);
Font fnt = new Font("Arial", 18);
gfx.DrawString("test123", fnt, Brushes.Yellow, 10, 10);
bmp.Save("test.bmp");

(Note that the code above compiles and runs with .NET 5 and C# 9.0 since it supports top-level statements, https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/tutorials/top-level-statements.)

However, the result looked like this:

enter image description here

What I did to fix this, was to run the following terminal command:

$ dotnet add package system.drawing.common

After that, re-building and running the program yields this image instead:

enter image description here

With this change, my .csproj file now looks like this:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="system.drawing.common" Version="5.0.2" />
  </ItemGroup>

</Project>

Just for reference; the reason I stumbled upon this problem was when I tried to use ScottPlot, and I filed this bug about it: https://github.com/ScottPlot/ScottPlot/issues/1079

Daniel Jonsson
  • 3,261
  • 5
  • 45
  • 66