Rinnegatamante / lpp-3ds

Lua Player Plus for 3DS
GNU General Public License v3.0
179 stars 32 forks source link

The Font.print doesn't work about the ttf font #58

Closed lualiliu closed 6 years ago

lualiliu commented 6 years ago

while true do -- Draw something on screen Screen.refresh() Screen.waitVblankStart() Screen.flip() my_font = Font.load("/font.tff"); Font.setPixelSizes(my_font,18); -- Writing something on screen Font.print(my_font, 5, 5, "hello world", Color.new(255,255,255), TOP_SCREEN) -- Sets up HomeMenu syscall if Controls.check(Controls.read(),KEY_HOME) or Controls.check(Controls.read(),KEY_POWER) then System.showHomeMenu() end -- Exit if HomeMenu calls APP_EXITING if System.checkStatus() == APP_EXITING then System.exit() end end

This is about ttf script ,and my 3ds forced exit,just like the Font.print doesn't work.

Rinnegatamante commented 6 years ago

You messed up the code, You shuld draw on screen between Screen.refresh and Screen.waitVblankStart calls.

lualiliu commented 6 years ago

my_font = Font.load("/arial.ttf") Font.setPixelSizes(my_font,18)

-- Main Loop while true do

-- Updating screens
Screen.refresh()

-- Writing something on screen
--Screen.debugPrint(0,0,"Hello World",Color.new(255,255,255),TOP_SCREEN)
Font.print(my_font, 5, 5, "Hello World!", Color.new(255,255,255), TOP_SCREEN)

Screen.waitVblankStart()
Screen.flip()

end

always black screen...I don't think I understand.What's wrong?

Rinnegatamante commented 6 years ago

Looks fine to me, swap positions for waitVblankStart and flip calls and try to add a Screen.clear(TOP_SCREEN) after Screen.refresh.

lualiliu commented 6 years ago

my_font = Font.load("/font.ttf") Font.setPixelSizes(my_font,18)

-- Main Loop while true do

-- Updating screens
--Screen.waitVblankStart()
Screen.refresh()
Screen.clear(TOP_SCREEN)
-- Writing something on screen
Screen.debugPrint(0,0,"Hello World",Color.new(255,255,255),TOP_SCREEN)
Font.print(my_font, 5, 5, "Hello World!", Color.new(255,255,255), TOP_SCREEN)

-- Flipping screen
Screen.flip()
Screen.waitVblankStart()

end

I tried many times in different codes.It still forces the exit. I'm using lpp-3ds_R5 and my 3ds a9lh. The text editor I'm using is sublime text

lualiliu commented 6 years ago

sorry ,I found the tff file should put in sdmc...Is not romfs