Open Bug 726227 Opened 13 years ago Updated 2 years ago

Canvas ignores really small font size

Categories

(Core :: Graphics: Canvas2D, defect)

x86_64
macOS
defect

Tracking

()

People

(Reporter: yury, Unassigned)

Details

Attachments

(1 file)

The following fragment ignores or not properly sets the 2d context font: ctx.font = "0.2px serif"; ctx.scale(60,60); ctx.fillText("test", 10/60, 25/60); The actual result is the text is larger that 12px. The expected result is the text with size 12px. (see also https://github.com/mozilla/pdf.js/issues/1169)
I wonder whether we clamp font sizes to at least 1px somewhere...
(In reply to Boris Zbarsky (:bz) from comment #1) > I wonder whether we clamp font sizes to at least 1px somewhere... We definitely do this in some font backends, e.g.: http://mxr.mozilla.org/mozilla-central/source/gfx/thebes/gfxMacFont.cpp#248 But I don't know offhand how this interacts with canvas scaling. If we're instantiating a "tiny" font and then relying on scaling in the cairo context to make it bigger, I can imagine this would be a problem. (It'd remain something a problem, at least under GDI, even for larger sizes because we round the font size to integer pixels.) I note that the testcase doesn't work properly in Safari, Chrome, or Opera either.
> If we're instantiating a "tiny" font and then relying on scaling in the cairo context to > make it bigger That's exactly what the testcase is doing, yes.
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: