Skip to content

Need more useful error messages when loading invalid fonts. #75

@milanbt

Description

@milanbt

In the example project generated by nicoboot, I can't change the default font even though I replaced the .png and .png.dat files.

If I change the index in loadFont and setFont, it compiles and then shows an error:

Error: unhandled exception: No font selected [Exception] Error: execution of an external program failed: '/Users/******/Code/nicotest/nicotest ' stack trace: (most recent call last) /private/var/folders/3d/70xtvzmj457d129np6fy7jjm0000gn/T/nimblecache-903273217/nimscriptapi_463822526.nim(187, 16) /Users/******/Code/nicotest/nicotest.nimble(20, 7) runrTask /opt/homebrew/Cellar/nim/1.6.2/nim/lib/system/nimscript.nim(273, 7) exec /opt/homebrew/Cellar/nim/1.6.2/nim/lib/system/nimscript.nim(273, 7) Error: unhandled exception: FAILED: nim c -r -d:danger -o:nicotest src/main.nim [OSError] Error: Exception raised during nimble script execution

I also tried renaming the file (to fonty.png) with no luck.

My code:

import nico

const orgName = "flkdsa"
const appName = "Working Title"

var buttonDown = false

proc gameInit() =
  loadFont(0, "fonty.png")
  loadSpriteSheet(0, "icon.png", 32, 32)

proc gameUpdate(dt: float32) =
  buttonDown = btn(pcLeft)

proc gameDraw() =
  cls()
  setColor(if buttonDown: 7 else: 3)
  setFont(0)
  printc("welcome to " & appName, screenWidth div 2, screenHeight div 2)

nico.init(orgName, appName)
nico.createWindow(appName, 320, 240, 4, false)
nico.run(gameInit, gameUpdate, gameDraw)

My 'fonty.png.dat':
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890

The png is attached.
fonty

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions