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.

9
  • The placeholders are fixed width, so I am guessing that the data is never properly retreived and this is simply the padding. Commented Oct 28, 2019 at 3: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? Commented Oct 28, 2019 at 3: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. Commented Oct 28, 2019 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. Commented Oct 29, 2019 at 9:45
  • 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 Commented Nov 22, 2019 at 13:00

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.