Windows 小工具字体错误

发布于 2024-08-18 10:21:05 字数 516 浏览 6 评论 0原文

我在Windows 7中编写了一个Sidebar小工具,并添加了ag:textObject,后来通过variable.value更改了值。

但在 Windows Vista 中运行时,文本似乎会奇怪地自行压缩。

这段代码有什么问题吗?

var clock = document.getElementById("background").addTextObject("Time", "Nyala", 18, "white", 110, 500);
//This correctly displays the word 'Time' in the proper font.

clock.value = clock.value+"s";
//This causes the text to become "Times" but shrink.
//appending more sporadically causes the textObject to shrink as well.

使用 .value 是错误的方法吗?

I've written a Sidebar gadget in Windows 7, and added a g:textObject, and later on change the value through variable.value.

But when run in Windows Vista, the text seems to compress itself strangely.

Is there anything wrong with this code?

var clock = document.getElementById("background").addTextObject("Time", "Nyala", 18, "white", 110, 500);
//This correctly displays the word 'Time' in the proper font.

clock.value = clock.value+"s";
//This causes the text to become "Times" but shrink.
//appending more sporadically causes the textObject to shrink as well.

Is using the .value the wrong way to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一梦浮鱼 2024-08-25 10:21:05

更改文本字符串不会更新 g:text 对象的宽度或高度。这是一个已知问题,出于兼容性目的可能不会得到修复。您必须手动重置宽度和高度更改值:

var clock = document.getElementById("background")
    .addTextObject("Time", "Nyala", 18, "white", 110, 500);

// Set the new value and reset the width and height by setting them to 0
clock.value  = clock.value+"s";  
clock.width  = 0;
clock.height = 0;

Changing the text string doesn't update the width or height of the g:text object. It's a known issue that probably won't be fixed for compatibility purposes. You have to manually reset the width and height changing the value:

var clock = document.getElementById("background")
    .addTextObject("Time", "Nyala", 18, "white", 110, 500);

// Set the new value and reset the width and height by setting them to 0
clock.value  = clock.value+"s";  
clock.width  = 0;
clock.height = 0;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文