Change default font roFontRegistry in Roku

一世执手 提交于 2019-12-13 06:07:12

问题


I have created a page with roImageCanvas ,and i am trying to change its default font with another one.bellow is my code but this won't work.Please help me to resolve this error.thanks in advance.

 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()

回答1:


Use

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

Insted of

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



回答2:


First, for the roImageCanvas, you should be using roFontRegistry.Get() instead of roFontRegistry.GetFont(). GetFont() is for use with the roScreen.

Second, are you sure the font family is actually "Univers"? After you've registered the font, you can call roFontRegistry.GetFamilies() to get a list of the registered font family names.



来源:https://stackoverflow.com/questions/30522848/change-default-font-rofontregistry-in-roku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!