Skip to content

Commit a007cfe

Browse files
author
Arthur
committed
fix sub, sup style not working
1 parent 45fa9a9 commit a007cfe

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

‎Source/Demo/Common/TestSamples/30.Misc.htm‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,9 @@
3434
<b/>
3535
<p><a href="&#109;&#97;&#x69;&#108;&#x74;&#x6f;:&#x74;&#x68;&#105;&#115;&#x2d;&#105;&#115;&#x2d;&#x61;&#x2d;&#116;&#x65;&#x73;&#x74;&#64;&#x65;&#x78;&#x61;&#x6d;&#x70;&#108;&#x65;&#46;&#x63;&#x6f;&#x6d;">&#x74;&#x68;&#105;&#115;&#x2d;&#105;&#115;&#x2d;&#x61;&#x2d;&#116;&#x65;&#x73;&#x74;&#64;&#x65;&#x78;&#x61;&#x6d;&#x70;&#108;&#x65;&#46;&#x63;&#x6f;&#x6d;</a></p>
3636
</div>
37+
<hr />
38+
<div>
39+
R<sup>1</sup>H<sub>2</sub>O
40+
</div>
3741
</body>
3842
</html>

‎Source/Demo/WPF/MainControl.xaml.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,9 @@ private void OnColoredCheckbox_click(object sender, RoutedEventArgs e)
326326
/// <summary>
327327
/// Show error raised from html renderer.
328328
/// </summary>
329-
private static void OnRenderError(object sender, RoutedEvenArgs<HtmlRenderErrorEventArgs> args)
329+
private void OnRenderError(object sender, RoutedEvenArgs<HtmlRenderErrorEventArgs> args)
330330
{
331-
MessageBox.Show(args.Data.Message + (args.Data.Exception != null ? "\r\n" + args.Data.Exception : null), "Error in Html Renderer", MessageBoxButton.OK);
331+
Dispatcher.BeginInvoke(new Action(() => MessageBox.Show(args.Data.Message + (args.Data.Exception != null ? "\r\n" + args.Data.Exception : null), "Error in Html Renderer", MessageBoxButton.OK)));
332332
}
333333

334334
/// <summary>

‎Source/HtmlRenderer/Core/Dom/CssLayoutEngine.cs‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public static void MeasureImageSize(CssRectImage imageWord)
100100
double ratio = imageWord.Width / imageWord.Image.Width;
101101
imageWord.Height = imageWord.Image.Height * ratio;
102102
}
103-
// If only the height was set in the html tag, ratio the width.
103+
// If only the height was set in the html tag, ratio the width.
104104
else if (hasImageTagHeight && !hasImageTagWidth)
105105
{
106106
// Divide the given tag height with the actual image height, to get the ratio.
@@ -151,9 +151,10 @@ public static void CreateLineBoxes(RGraphics g, CssBox blockBox)
151151
//Gets the rectangles for each line-box
152152
foreach (var linebox in blockBox.LineBoxes)
153153
{
154-
ApplyAlignment(g, linebox);
154+
ApplyHorizontalAlignment(g, linebox);
155155
ApplyRightToLeft(blockBox, linebox);
156156
BubbleRectangles(blockBox, linebox);
157+
ApplyVerticalAlignment(g, linebox);
157158
linebox.AssignRectanglesToBoxes();
158159
}
159160

@@ -419,7 +420,7 @@ private static void BubbleRectangles(CssBox box, CssLineBox line)
419420
/// </summary>
420421
/// <param name="g"></param>
421422
/// <param name="lineBox"></param>
422-
private static void ApplyAlignment(RGraphics g, CssLineBox lineBox)
423+
private static void ApplyHorizontalAlignment(RGraphics g, CssLineBox lineBox)
423424
{
424425
switch (lineBox.OwnerBox.TextAlign)
425426
{
@@ -436,8 +437,6 @@ private static void ApplyAlignment(RGraphics g, CssLineBox lineBox)
436437
ApplyLeftAlignment(g, lineBox);
437438
break;
438439
}
439-
440-
ApplyVerticalAlignment(g, lineBox);
441440
}
442441

443442
/// <summary>
@@ -536,7 +535,7 @@ private static void ApplyVerticalAlignment(RGraphics g, CssLineBox lineBox)
536535
switch (box.VerticalAlign)
537536
{
538537
case CssConstants.Sub:
539-
lineBox.SetBaseLine(g, box, baseline + lineBox.Rectangles[box].Height * .2f);
538+
lineBox.SetBaseLine(g, box, baseline + lineBox.Rectangles[box].Height * .5f);
540539
break;
541540
case CssConstants.Super:
542541
lineBox.SetBaseLine(g, box, baseline - lineBox.Rectangles[box].Height * .2f);

0 commit comments

Comments
 (0)