Fix chars scaling for standard fonts.
This commit is contained in:
parent
2f1a626d6a
commit
8200f099a3
@ -1421,16 +1421,22 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
scaledY = 0;
|
scaledY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (font.remeasure && width > 0 && this.isFontSubpixelAAEnabled) {
|
if (font.remeasure && width > 0) {
|
||||||
// some standard fonts may not have the exact width, trying to
|
// Some standard fonts may not have the exact width: rescale per
|
||||||
// rescale per character
|
// character if measured width is greater than expected glyph width
|
||||||
|
// and subpixel-aa is enabled, otherwise just center the glyph.
|
||||||
var measuredWidth = ctx.measureText(character).width * 1000 /
|
var measuredWidth = ctx.measureText(character).width * 1000 /
|
||||||
fontSize * fontSizeScale;
|
fontSize * fontSizeScale;
|
||||||
var characterScaleX = width / measuredWidth;
|
if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
|
||||||
restoreNeeded = true;
|
var characterScaleX = width / measuredWidth;
|
||||||
ctx.save();
|
restoreNeeded = true;
|
||||||
ctx.scale(characterScaleX, 1);
|
ctx.save();
|
||||||
scaledX /= characterScaleX;
|
ctx.scale(characterScaleX, 1);
|
||||||
|
scaledX /= characterScaleX;
|
||||||
|
} else if (width !== measuredWidth) {
|
||||||
|
scaledX += (width - measuredWidth) / 2000 *
|
||||||
|
fontSize / fontSizeScale;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (simpleFillText && !accent) {
|
if (simpleFillText && !accent) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user