Fabric JS文本间距 - 字符宽度

时间:2016-06-05 01:28:00

标签: javascript canvas fabricjs

我有一个使用Fabric JS画布的项目需要实现文本间距 - 为此我使用了以下代码(found here)。

def __init__(self, *args, **kwargs):
    user = kwargs.pop('user', None)
    super(EnergyUsageForm, self).__init__(*args, **kwargs)

    # today is a function!
    td = datetime.date.today()
    account = Account.objects.get(holder__user=user)
    cycle_dates = CycleDate.objects.filter(cycle_ref=account.cycle,
                                           begin_date__lte=td)
                                   .order_by('begin_date')

    self.fields['cycle'] = CycleModelChoiceField(queryset=cycle_dates,
                                                 required=False,
                                                 widget=forms.Select(attrs={"onChange":'changeCalendar()'}),
                                                 label = "Choose a billing cycle")

不幸的是,当文本居中时似乎存在问题:正如您在this jsfiddle中看到的那样,大写的I和小写L没有给出正确的间距。 (它在我的项目所需的某些字体中更为明显,但在Arial中也非常明显)

我花了几个小时踩过代码并进行测量,代码看似正确,但输出并不匹配。我很困惑,有什么想法吗?

0 个答案:

没有答案