0

我用 roImageCanvas 创建了一个页面,我正在尝试用另一个更改其默认字体。下面是我的代码,但这不起作用。请帮我解决这个错误。提前谢谢。

 canvas = CreateObject("roImageCanvas")    
 port = CreateObject("roMessagePort")
 canvas.SetMessagePort(port)
 items = []

FontInterface=CreateObject("roFontRegistry") 'create global font access
Fontinterface.Register("pkg:/source/Univers.ttf")
Font=FontInterface.GetFont("Univers",36,false,false)
FontSmall=FontInterface.GetFont("Univers",15,false,false)


items.Push({
Text: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s"
TextAttrs:{ font: Font, color: "#a0a0a0"}
TargetRect: {x: 200, y: 75, w: 300, h: 500}
})

items.Push({
Text: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s"
TextAttrs:{ font: FontSmall, color: "#a0a0a0"}
TargetRect: {x: 600, y: 75, w: 300, h: 500}
})

canvas.SetLayer(0, { Color: "#00ff00", CompositionMode: "Source" })
canvas.SetLayer(1, items)
canvas.Show()
4

2 回答 2

1

首先,对于 roImageCanvas,您应该使用roFontRegistry.Get()而不是roFontRegistry.GetFont()。GetFont() 用于 roScreen。

其次,您确定字体系列实际上是“Univers”吗?注册字体后,您可以调用roFontRegistry.GetFamilies()来获取已注册字体系列名称的列表。

于 2015-05-29T19:46:57.700 回答
1

利用

Font=FontInterface.Get("Univers",36,false,false)
FontSmall=FontInterface.Get("Univers",15,false,false)

安装在

Font=FontInterface.GetFont("Univers",36,false,false)
FontSmall=FontInterface.GetFont("Univers",15,false,false)
于 2015-05-30T04:17:10.760 回答