Fix: CheckIfAllTextGlyphsAreAvailable and Fallback break hyperlinks

This commit is contained in:
MarcinZiabek
2022-10-11 10:31:31 +02:00
parent 6c8867e1b3
commit ec31c9b063
2 changed files with 17 additions and 7 deletions
+16 -6
View File
@@ -121,7 +121,11 @@ namespace QuestPDF.Elements.Text
{
foreach (var textBlockItem in textBlockItems)
{
if (textBlockItem is TextBlockSpan textBlockSpan and not TextBlockPageNumber)
if (textBlockItem is TextBlockPageNumber or TextBlockElement)
{
yield return textBlockItem;
}
else if (textBlockItem is TextBlockSpan textBlockSpan)
{
if (!Settings.CheckIfAllTextGlyphsAreAvailable && textBlockSpan.Style.Fallback == null)
{
@@ -130,19 +134,25 @@ namespace QuestPDF.Elements.Text
}
var textRuns = textBlockSpan.Text.SplitWithFontFallback(textBlockSpan.Style);
foreach (var textRun in textRuns)
{
yield return new TextBlockSpan
var newElement = textBlockSpan switch
{
Text = textRun.Content,
Style = textRun.Style
TextBlockHyperlink hyperlink => new TextBlockHyperlink { Url = hyperlink.Url },
TextBlockSectionLink sectionLink => new TextBlockSectionLink { SectionName = sectionLink.SectionName },
TextBlockSpan => new TextBlockSpan()
};
newElement.Text = textRun.Content;
newElement.Style = textRun.Style;
yield return newElement;
}
}
else
{
yield return textBlockItem;
throw new NotSupportedException();
}
}
}
@@ -15,7 +15,7 @@ namespace QuestPDF.Elements.Text.Items
{
public string Text { get; set; }
public TextStyle Style { get; set; } = TextStyle.Default;
public TextShapingResult? TextShapingResult { get; set; }
private TextShapingResult? TextShapingResult { get; set; }
private Dictionary<(int startIndex, float availableWidth), TextMeasurementResult?> MeasureCache = new ();
protected virtual bool EnableTextCache => true;