Fabric.js如何在不拉伸文本的情况下水平调整IText的大小 [英] Fabric.js How to resize IText horizontally without stretching the text

查看:588
本文介绍了Fabric.js如何在不拉伸文本的情况下水平调整IText的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在父组对象中具有此IText对象.

I have this IText object within a parent Group object.

当我选择组"并在水平方向(以及垂直方向)上调整其大小时,IText的大小也将随之调整,这会使文本Strech看起来很糟糕.

When I select the Group and resize it horizontally (and vertically as well) the IText resizes as well which makes the text Strech and look awfull.

现在我想做的是在组中拥有IText中心本身(保持其纵横比).

Now what I would like to do is have the IText center itself (keeping its aspect ratio) within the Group.

我该怎么做.当对象缩放时,我尝试修改IText的Width和Left,但这没有用.

How can I do that. I tried modifying the Width and Left of the IText when the object is scaling, but that did not work.

推荐答案

我无法使最新的fabric.Textbox工作完全如我所愿.

I was not able to make the latest fabric.Textbox work exactly like I wanted.

幸运的是,我找到了一种在水平调整父fabric.Group大小时使fabric.IText水平居中的方法,并且还使相同的fabric.IText文本根据垂直调整大小而增大.没有丑陋的文字.

Luckily, I found a way of making the fabric.ITextcenter horizontally when the parent fabric.Group is resized horizontally and also make the same fabric.IText Text grow in size based on the vertical resize. No ugly text stretch.

这是解决方案:

https://jsfiddle.net/t44wyday/46/

这篇关于Fabric.js如何在不拉伸文本的情况下水平调整IText的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆