6
// Creates boxes containing delimeter symbol that exists in different sizes.
7
internal static class DelimiterFactory
9
public static Box CreateBox(string symbol, double minHeight, TexEnvironment environment)
8
// Creates boxes containing delimeter symbol that exists in different sizes.
9
internal static class DelimiterFactory
11
var texFont = environment.TexFont;
12
var style = environment.Style;
13
var charInfo = texFont.GetCharInfo(symbol, style);
15
// Find first version of character that has at least minimum height.
16
var metrics = charInfo.Metrics;
17
var totalHeight = metrics.Height + metrics.Depth;
18
while (totalHeight < minHeight && texFont.HasNextLarger(charInfo))
20
charInfo = texFont.GetNextLargerCharInfo(charInfo, style);
21
metrics = charInfo.Metrics;
22
totalHeight = metrics.Height + metrics.Depth;
25
if (totalHeight >= minHeight)
27
// Character of sufficient height was found.
28
return new CharBox(environment, charInfo);
30
else if (texFont.IsExtensionChar(charInfo))
32
var resultBox = new VerticalBox();
34
// Construct box from extension character.
35
var extension = texFont.GetExtension(charInfo, style);
36
if (extension.Top != null)
37
resultBox.Add(new CharBox(environment, extension.Top));
38
if (extension.Middle != null)
39
resultBox.Add(new CharBox(environment, extension.Middle));
40
if (extension.Bottom != null)
41
resultBox.Add(new CharBox(environment, extension.Bottom));
43
// Insert repeatable part multiple times until box is high enough.
44
var repeatBox = new CharBox(environment, extension.Repeat);
47
if (extension.Top != null && extension.Bottom != null)
49
resultBox.Add(1, repeatBox);
50
if (extension.Middle != null)
51
resultBox.Add(resultBox.Children.Count - 1, repeatBox);
53
else if (extension.Bottom != null)
55
resultBox.Add(0, repeatBox);
59
resultBox.Add(repeatBox);
61
} while (resultBox.Height + resultBox.Depth < minHeight);
67
// No extensions available, so use tallest available version of character.
68
return new CharBox(environment, charInfo);
11
public static Box CreateBox(string symbol, double minHeight, WpfMath.TexEnvironment environment)
13
var texFont = environment.TexFont;
14
var style = environment.Style;
15
var charInfo = texFont.GetCharInfo(symbol, style);
17
// Find first version of character that has at least minimum height.
18
var metrics = charInfo.Metrics;
19
var totalHeight = metrics.Height + metrics.Depth;
20
while (totalHeight < minHeight && texFont.HasNextLarger(charInfo))
22
charInfo = texFont.GetNextLargerCharInfo(charInfo, style);
23
metrics = charInfo.Metrics;
24
totalHeight = metrics.Height + metrics.Depth;
27
if (totalHeight >= minHeight)
29
// Character of sufficient height was found.
30
return new CharBox(environment, charInfo);
32
else if (texFont.IsExtensionChar(charInfo))
34
var resultBox = new WpfMath.VerticalBox();
36
// Construct box from extension character.
37
var extension = texFont.GetExtension(charInfo, style);
38
if (extension.Top != null)
39
resultBox.Add(new CharBox(environment, extension.Top));
40
if (extension.Middle != null)
41
resultBox.Add(new CharBox(environment, extension.Middle));
42
if (extension.Bottom != null)
43
resultBox.Add(new CharBox(environment, extension.Bottom));
45
// Insert repeatable part multiple times until box is high enough.
46
var repeatBox = new CharBox(environment, extension.Repeat);
49
if (extension.Top != null && extension.Bottom != null)
51
resultBox.Add(1, repeatBox);
52
if (extension.Middle != null)
53
resultBox.Add(resultBox.Children.Count - 1, repeatBox);
55
else if (extension.Bottom != null)
57
resultBox.Add(0, repeatBox);
61
resultBox.Add(repeatBox);
63
} while (resultBox.Height + resultBox.Depth < minHeight);
69
// No extensions available, so use tallest available version of character.
70
return new CharBox(environment, charInfo);