Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect equation Width #239

Open
vxdguy opened this issue Feb 5, 2025 · 0 comments
Open

Incorrect equation Width #239

vxdguy opened this issue Feb 5, 2025 · 0 comments
Labels
Status/0. New This issue is new and is awaiting confirmation from the maintainers. Type/Bug

Comments

@vxdguy
Copy link

vxdguy commented Feb 5, 2025

Describe the bug

MathPainter generates an image that cuts off the right side of the equation.

To Reproduce

Compiled on Ubuntu 24.04.1
.NET 8.0.405

CSProj contents:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <SelfContained>true</SelfContained>
    <PublishSingleFile>true</PublishSingleFile>
    <PublishTrimmed>true</PublishTrimmed>
    <IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
    <DebugType>embedded</DebugType>
    <ReadyToRun>true</ReadyToRun>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="CSharpMath.SkiaSharp" Version="0.5.1" />
    <PackageReference Include="SkiaSharp" Version="3.116.1" />
    <PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="3.116.1" />
  </ItemGroup>
</Project>

main.cs contents:

using CSharpMath.SkiaSharp;
using SkiaSharp;


// Render LaTeX to PNG
var painter = new MathPainter
{
    LaTeX = @"\begin{aligned}
\nabla \cdot \vec{\bf E} & = \frac {\rho} {\varepsilon_0} \\
\nabla \cdot \vec{\bf B} & = 0 \\
\nabla \times \vec{\bf E} &= - \frac{\partial\vec{\bf B}}{\partial t} \\
\nabla \times \vec{\bf B} & = \mu_0\vec{\bf J} + \mu_0\varepsilon_0 \frac{\partial\vec{\bf E}}{\partial t}
\end{aligned}",
    AntiAlias = true,
    TextColor = SKColors.Green,
    FontSize = 48,
    PaintStyle = CSharpMath.Rendering.FrontEnd.PaintStyle.Fill,
    GlyphBoxColor = (SKColors.Red, SKColors.Azure),
};

using var png = painter.DrawAsStream(format: SKEncodedImageFormat.Png, quality: 100); 

if (png == null)
{
    throw new InvalidOperationException("Failed to create PNG stream.");
}

using var file = File.OpenWrite("equation.png");

png.CopyTo(file);

Compile, execute, and open the resulting equation.png and you can see the image of the equation.

The canvas is not wide enough for the generated latex image.

Expected behavior

Width of canvas should be as large as the latex image.

Environment (please complete the following information):

  • Platform: CSharpMath.SkiaSharp
  • Package Version or Commit: 0.5.11
  • Device: Desktop PC, Ubuntu 24.04.1

Additional context

See attached image result.

Image

@vxdguy vxdguy added Status/0. New This issue is new and is awaiting confirmation from the maintainers. Type/Bug labels Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status/0. New This issue is new and is awaiting confirmation from the maintainers. Type/Bug
Projects
None yet
Development

No branches or pull requests

1 participant