[ANN] Stk 0.1.0 (SDL-based GUI toolkit) and Chamo 4.0


I am pleased to announce the first release of Stk, a SDL-based graphical user interface toolkit. Its interface is inspired by Gtk and should look familiar to developers using Lablgtk.
The project page: OCaml-stk: SDL-based GUI toolkit for OCaml

Chamo, a development-oriented text editor, is now based on Stk rather than Lablgtk since release 4.0.
Chamo homepage: Chamo : Chamo .


Hi, after installing chamo 4.0 with opam, when I run “chamo” it crashes immediately with
Fatal error: exception Unix.Unix_error(Unix.EMFILE, "opendir", "/usr/share/fonts/truetype/roboto/unhinted/RobotoTTF")

I do have the directory in question (“/usr/share/fonts/truetype/roboto/unhinted/RobotoTTF”)
but the error is EMFILE = Too many open files by the process
which is a bit weird

can you tell how many directories and how many .ttf files you have under /usr/share/fonts/truetype ?

At initialization, stk will lookup for available fonts, reading subdirectories and font files in parallel. Maybe it should be done sequentially instead. I’d like to test with the same numbers of dirs and files as you.

cd /usr/share/fonts/truetype
find -name *.ttf | wc -l

gives me 2671


$ find -type d | wc -l

That is a not a high number of directories, and each font file is supposed to be closed after being registered. :thinking:

Can you activate the debug level of logging, by setting environment variable STK_LOG_LEVEL=debug ?

And, are there any symbolink links under /usr/share/fonts/truetype which could create some cycle ?

the only symliks are in the directory /usr/share/fonts/truetype/msttcorefonts and then point to another file in the same dir

Mmm, today the error message is not the same:

$ chamo
Fatal error: exception Font not found: "Bitstream Vera Sans Mono" italic=false, bold=false [size=14]

BUT, if I try again:

$ chamo
Fatal error: exception Unix.Unix_error(Unix.EMFILE, "opendir", "/usr/share/fonts/truetype/roboto/unhinted/RobotoTTF")

same with debug:

$ STK_LOG_LEVEL=debug chamo
Fatal error: exception Unix.Unix_error(Unix.EMFILE, "opendir", "/usr/share/fonts/truetype/roboto/unhinted/RobotoTTF")

Thanks. Ok, the log reporter is installed after initialization, so there are no debug messages while reading available fonts.

Can you

opam pin add stk https://framagit.org/zoggy/ocaml-stk.git

I made a change so that available fonts are search sequentially rather than in parallel.

The Font not found exception seems to indicate that, on this run, fonts could be read without opendir error (maybe due to some delay to read directories, allowing to close some before opening others). But it seems that this font is not available. Stk has a theming mecanism but it does not yet read themes from external files (but it is possible to add theme programmatically when using Stk). If you can’t install this font, you may clone the repo and set another font here.

$ opam pin add stk https://framagit.org/zoggy/ocaml-stk.git
[stk.0.1.0] synchronised (git+https://framagit.org/zoggy/ocaml-stk.git)
stk is now pinned to git+https://framagit.org/zoggy/ocaml-stk.git (version 0.1.0)

The following actions will be performed:
  ↻ recompile stk   0.1.0*
  ↻ recompile chamo 4.0    [uses stk]
===== ↻ 2 =====
Do you want to continue? [Y/n] y

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
⬇ retrieved chamo.4.0  (cached)
[ERROR] The compilation of stk.0.1.0 failed at "dune build -p stk -j 3
        --promote-install-files=false @install".

#=== ERROR while compiling stk.0.1.0 ==========================================#
# context     2.1.2 | linux/x86_64 | ocaml-base-compiler.5.0.0 | pinned(git+https://framagit.org/zoggy/ocaml-stk.git#74f4791b)
# path        ~/.opam/5.0.0/.opam-switch/build/stk.0.1.0
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p stk -j 3 --promote-install-files=false @install
# exit-code   1
# env-file    ~/.opam/log/stk-33887-20cbc7.env
# output-file ~/.opam/log/stk-33887-20cbc7.out
### output ###
# File "test/dune", line 27, characters 11-22:
# 27 |   (modules test_bounds)
#                 ^^^^^^^^^^^
# Error: Module Test_bounds doesn't exist.

Sorry. I added the missing file.

1 Like

it works!
I appreciate the impressive work