Skip to content

Right to Left languages add a space at the beginning of a line #96

@gbreen12

Description

@gbreen12

Not sure if I'm doing right to left correctly but when I render a multi line text, any line that isn't the end of the paragraph has an extra space at the beginning of the line. Here are a few examples:

In this example you can see the first 4 lines there is a slight space at the beginning but the last line is more right.

Image

In this example the first line of the second paragraph has a slight space but the second line is flush with the other lines.

Image

Here's the code I'm using to create the string:

public void DrawText(
    SKCanvas canvas,
    string text,
    SkiaTextLayoutOptions layoutOptions
)
{
    if (string.IsNullOrWhiteSpace(text))
    {
        return;
    }

    var richString = new RichString
    {
        MaxWidth = layoutOptions.MaxWidthPixels,
        MaxHeight = layoutOptions.MaxHeightPixels,
    };

    var margin = layoutOptions.MarginPixels;
    richString.MarginTop(margin).MarginBottom(margin).MarginLeft(margin).MarginRight(margin);

    richString.Add(text, layoutOptions.FontFamily, fontSize: DefaultFontSize);
    richString.Alignment(TextAlignment.Right);

    var options = new TextPaintOptions
    {
        Edging = SKFontEdging.Antialias,
    };

    var startingPoint = new SKPoint(layoutOptions.StartingX, layoutOptions.StartingY);
    richString.Paint(canvas, startingPoint, options);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions