diff --git a/src/Toolkit/Toolkit.WPF/UI/Controls/PopupViewer/TextPopupElementView.cs b/src/Toolkit/Toolkit.WPF/UI/Controls/PopupViewer/TextPopupElementView.cs index aa9319a2f..43fa848d8 100644 --- a/src/Toolkit/Toolkit.WPF/UI/Controls/PopupViewer/TextPopupElementView.cs +++ b/src/Toolkit/Toolkit.WPF/UI/Controls/PopupViewer/TextPopupElementView.cs @@ -214,7 +214,14 @@ private static Inline VisitInline(MarkupNode node) var img = (Image)sender; var taggedUri = (Uri)img.Tag; var ri = new RuntimeImage(taggedUri); // Use Runtime's caching and authentication - img.Source = await ri.ToImageSourceAsync(); + try + { + img.Source = await ri.ToImageSourceAsync(); + } + catch + { + // Don't let one bad image take down the whole app. Better to ignore a failed image load. + } }; return new InlineUIContainer(imageElement); } diff --git a/src/Toolkit/Toolkit/Internal/HtmlUtility.cs b/src/Toolkit/Toolkit/Internal/HtmlUtility.cs index 38a69a078..dc95b733d 100644 --- a/src/Toolkit/Toolkit/Internal/HtmlUtility.cs +++ b/src/Toolkit/Toolkit/Internal/HtmlUtility.cs @@ -351,9 +351,9 @@ internal static MarkupNode BuildDocumentTree(string snippet) break; } - if (name is "div" or "td" or "th" or "tr") + if (name is "div" or "p" or "td" or "th" or "tr") { - if (!attr.TryGetValue("align", out var alignStr) && Enum.TryParse(alignStr, true, out var align)) + if (attr.TryGetValue("align", out var alignStr) && Enum.TryParse(alignStr, true, out var align)) newNode.Alignment = align; } @@ -461,11 +461,13 @@ private static bool TryParseCssFontSize(string fontSizeString, out double emValu return false; fontSizeString = fontSizeString.Trim().ToLowerInvariant(); - if (fontSizeString.EndsWith("px")) + if (fontSizeString.EndsWith("px") || fontSizeString.EndsWith("pt")) { - if (double.TryParse(fontSizeString.Substring(0, fontSizeString.Length - 2), out var pxValue)) + if (double.TryParse(fontSizeString.Substring(0, fontSizeString.Length - 2), out var pValue)) { - emValue = pxValue / 16d; // 1em == 16px (approx) + // Approximate conversion: 1em == 16px == 12pt + var conversionFactor = fontSizeString.EndsWith("px") ? 16 : 12; + emValue = pValue / conversionFactor; return true; } }