Adjusted code related to subscript/superscript

This commit is contained in:
MarcinZiabek
2022-05-06 20:55:18 +02:00
parent eeca67e5bc
commit 1af7c0a144
4 changed files with 113 additions and 45 deletions
+66 -18
View File
@@ -38,12 +38,11 @@ namespace QuestPDF.Examples
}
[Test]
public void SuperscriptSubscript()
public void SuperscriptSubscript_General()
{
RenderingTest
.Create()
.PageSize(500, 300)
.PageSize(500, 500)
.ProduceImages()
.ShowResults()
.Render(container =>
@@ -55,28 +54,77 @@ namespace QuestPDF.Examples
.Padding(10)
.Text(text =>
{
text.Span("E=mc");
text.DefaultTextStyle(x => x.FontSize(20));
text.ParagraphSpacing(2);
text.Span("In physics, massenergy equivalence is the relationship between mass and energy in a system's rest frame, where the two values differ only by a constant and the units of measurement.");
text.Span("[1][2]").Superscript();
text.Span(" The principle is described by the physicist Albert Einstein's famous formula: E = mc");
text.Span("2").Superscript();
text.Span(". ");
text.Span("[3]").Superscript();
text.EmptyLine();
text.Span("H");
text.Span("2").Subscript();
text.Span("O is the chemical formula for water, meaning that each of its molecules contains one oxygen and two hydrogen atoms.");
text.EmptyLine();
text.Span("H");
text.Span("2").Subscript();
text.Span("O");
text.EmptyLine();
text.ParagraphSpacing(2);
var style = TextStyle.Default.Underline();
text.Span("Subscript").Style(style).Subscript().BackgroundColor(Colors.Green.Medium);
text.Span("Normal").Style(style).NormalPosition().BackgroundColor(Colors.Blue.Medium);
text.Line("Superscript").Style(style).Superscript().BackgroundColor(Colors.Red.Medium);
text.Line("Superscript").Style(style).Superscript().BackgroundColor(Colors.Green.Medium);
text.Line("Normal").Style(style).NormalPosition().BackgroundColor(Colors.Blue.Medium);
text.Line("Subscript").Style(style).Subscript().BackgroundColor(Colors.Red.Medium);
});
});
}
[Test]
public void SuperscriptSubscript_Effects()
{
RenderingTest
.Create()
.PageSize(800, 400)
.ProduceImages()
.ShowResults()
.Render(container =>
{
container
.Padding(25)
.DefaultTextStyle(x => x.FontSize(30))
.Column(column =>
{
column.Spacing(25);
column.Item().Text(text =>
{
text.DefaultTextStyle(x => x.Underline());
text.Span("Underline of the superscript (E = mc");
text.Span("2").Superscript();
text.Span(") should be at the same height as for normal text.");
});
column.Item().Text(text =>
{
text.DefaultTextStyle(x => x.Underline());
text.Span("Underline of the subscript(H");
text.Span("2").Subscript();
text.Span("O) should be slightly lower than a normal text.");
});
column.Item().Text(text =>
{
text.DefaultTextStyle(x => x.Strikethrough());
text.Span("Strikethrough of both superscript (E=mc");
text.Span("2").Superscript();
text.Span(") and subscript(H");
text.Span("2").Subscript();
text.Span("O) should be visible in the middle of the text.");
});
});
});
}