Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Support for vector hrule rendering #26337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
15 changes: 8 additions & 7 deletions lib/matplotlib/_mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ def __init__(self, box):
self.rects = [] # (x1, y1, x2, y2)

def to_vector(self):
w, h, d = map(
np.ceil, [self.box.width, self.box.height, self.box.depth])
w = self.box.width
h = self.box.height
d = self.box.depth
gs = [(info.font, info.fontsize, info.num, ox, h - oy + info.offset)
for ox, oy, info in self.glyphs]
rs = [(x1, h - y2, x2 - x1, y2 - y1)
Expand All @@ -116,11 +117,12 @@ def to_raster(self, antialiased=None):
xmax = max([*[ox + info.metrics.xmax for ox, oy, info in self.glyphs],
*[x2 for x1, y1, x2, y2 in self.rects], 0]) + 1
ymax = max([*[oy - info.metrics.ymin for ox, oy, info in self.glyphs],
*[y2 for x1, y1, x2, y2 in self.rects], 0]) + 1
w = xmax - xmin
*[y2 for x1, y1, x2, y2 in self.rects], 0]) + 1.5

w = self.box.width
h = ymax - ymin - self.box.depth
d = ymax - ymin - self.box.height
image = FT2Image(np.ceil(w), np.ceil(h + max(d, 0)))
image = FT2Image(w, h + max(d, 0))

# Ideally, we could just use self.glyphs and self.rects here, shifting
# their coordinates by (-xmin, -ymin), but this yields slightly
Expand Down Expand Up @@ -2449,7 +2451,6 @@ def _genfrac(self, ldelim, rdelim, rule, style, num, den):
cnum.hpack(width, 'exactly')
cden.hpack(width, 'exactly')
vlist = Vlist([cnum, # numerator
Vbox(0, thickness * 2.0), # space
Hrule(state, rule), # rule
Vbox(0, thickness * 2.0), # space
cden # denominator
Expand All @@ -2462,7 +2463,7 @@ def _genfrac(self, ldelim, rdelim, rule, style, num, den):
'=', state.fontsize, state.dpi)
shift = (cden.height -
((metrics.ymax + metrics.ymin) / 2 -
thickness * 3.0))
thickness * 1.5))
vlist.shift_amount = shift

result = [Hlist([vlist, Hbox(thickness * 2.)])]
Expand Down