Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion MuPDF.NET.Test/WidgetTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void Test4505()

text1_flags_before[_w.Xref] = _w.FieldFlags;
}
Assert.That(text1_flags_before, Is.EqualTo(new Dictionary<int, int>{{ 8, 1 },{ 10, 0 },{ 33, 0 }}));
Assert.That(text1_flags_before, Is.EqualTo(new Dictionary<int, int> { { 8, 1 }, { 10, 0 }, { 33, 0 } }));

Widget w = page.LoadWidget(8); // first of these widgets
// give all connected widgets that field flags value
Expand Down Expand Up @@ -98,5 +98,24 @@ public void Checkbox()
//Assert.Pass();
}
*/

[TestCase("/Cour 5 Tf 0 g", "Cour", 5)]
[TestCase("/Cour 6 Tf 0 g", "Cour", 6)]
[TestCase("/TiRo \t 8 \n \r \f \v Tf 0 g", "TiRo", 8)]
public void ShouldParseDa(string textDa, string expectedFont, float expectedFontSize)
{
var doc = new Document();
var page = doc.NewPage();

var widget = new Widget(page) { TextDa = textDa };

Assert.That(widget.TextFont, Is.EqualTo("Helv"));
Assert.That(widget.TextFontSize, Is.EqualTo(0));

Assert.DoesNotThrow(() => widget.ParseDa());

Assert.That(widget.TextFont, Is.EqualTo(expectedFont));
Assert.That(widget.TextFontSize, Is.EqualTo(expectedFontSize));
}
}
}
2 changes: 1 addition & 1 deletion MuPDF.NET/Widget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public void ParseDa()
string font = "Helv";
float fontSize = 0;
float[] col = { 0, 0, 0 };
string[] dat = TextDa.Split(' '); // split on any whitespace
string[] dat = TextDa.Split(null as char[], StringSplitOptions.RemoveEmptyEntries); // split on any whitespace-character
for (int i = 0; i < dat.Length; i++)
{
string item = dat[i];
Expand Down