简体   繁体   English

jcanvas按宽度和高度调整文本大小

[英]jcanvas resize text by width and height

I'm using jcanvas and I need to resize text by width and height. 我正在使用jcanvas,我需要按宽度和高度调整文本大小。 Actually the library offers an option to scale by X and Y but I need to do the same with the width and height properties. 实际上,库提供了按X和Y缩放的选项,但我需要对width和height属性进行相同的操作。

Is it possible? 可能吗?

The only way to resize text in jCanvas is with the scaleX , scaleY , or scale property. 在jCanvas中调整文本大小的唯一方法是使用scaleXscaleYscale属性。 The width and height properties (for text drawings) are read-only, so you can't change them yourself. widthheight属性(用于文本绘图)是只读的,因此您无法自行更改它们。

$("canvas").drawText({
    fillStyle: "#000",
    x: 100, y: 100,
    fontFamily: "sans-serif",
    fontSize: 36,
    text: "This text is squished",
    scaleX: 0.5
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 动态调整textarea的宽度和高度以包含文本 - Dynamically resize textarea width and height to contain text jCanvas-拉伸图像以适合高度,并使其在宽度上流动 - jCanvas - Stretching image to fit height, and letting it flow over in width 如何使用JavaScript动态调整SVG中文本元素的高度和宽度 - How to resize height and width of text element in SVG dynamically using JavaScript KonvaJS:如何在调整大小时更改文本类的属性(fontSize,height和width)? - KonvaJS: How to change the text class properties (fontSize, height & width) on resize in? JCanvas文本中的增量整数 - Incremental Integer in JCanvas text 按比例调整窗口大小调整时div的宽度和高度 - Proportionally resize width and height of div on window resize jQuery插件或JavaScript方法来自动调整文本输入的大小(非textarea)(固定宽度)可变高度 - jquery plugin or javascript method to auto resize text input(not textarea) (fixed width ) variable height 根据javascript中的最小宽度/高度和最大宽度/高度调整图像大小 - resize image respecting a min width / height and max width / height in javascript 调整任意长度的文本大小以适应可变宽度,固定高度容器 - Resize Any-Length Text to fit a Variable Width, Fixed Height Container 根据视口宽度动态调整图像高度 - Resize an image height dynamically according to viewport width
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM