10000 Better subpixel positioning? · matplotlib/matplotlib@5bcd22e · GitHub
[go: up one dir, main page]

Skip to content

Commit 5bcd22e

Browse files
committed
Better subpixel positioning?
1 parent 1670dde commit 5bcd22e

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

lib/matplotlib/mathtext.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,21 +190,23 @@ def get_results(self, box, used_characters):
190190
orig_height = box.height
191191
orig_depth = box.depth
192192
ship(0, 0, box)
193-
xmin = self._xmin - 1
194-
xmax = self._xmax + 1
195-
ymin = self._ymin - 1
196-
ymax = self._ymax + 1
197-
image = FT2Image(np.ceil(xmax - xmin), np.ceil(ymax - ymin))
193+
xmin = np.floor(self._xmin)
194+
xmax = np.ceil(self._xmax)
195+
ymin = np.floor(self._ymin)
196+
ymax = np.ceil(self._ymax)
197+
dxmin = self._xmin - xmin
198+
dymin = self._ymin - ymin
199+
image = FT2Image(np.ceil(xmax - xmin) + 1, np.ceil(ymax - ymin) + 1)
198200

199201
for ox, oy, info in self._glyphs:
200202
info.font.draw_glyph_to_bitmap(
201-
image, ox + 1, oy - info.metrics.iceberg + 1,
203+
image, ox + dxmin, oy - info.metrics.iceberg + dymin,
202204
info.glyph, antialiased=rcParams['text.antialiased'])
203205
for x1, y1, x2, y2 in self._rects:
204-
x1 += 1
205-
x2 += 1
206-
y1 += 1
207-
y2 += 1
206+
x1 += dxmin
207+
x2 += dymin
208+
y1 += dxmin
209+
y2 += dymin
208210
height = max(int(y2 - y1) - 1, 0)
209211
if height == 0:
210212
center = (y2 + y1) / 2

0 commit comments

Comments
 (0)
0