msink / kotlin-libui

Kotlin/Native interop to libui: a portable GUI library
MIT License
648 stars 49 forks source link

Add bindings to set font without using font button and updated drawte… #21

Closed illiapoplawski closed 5 years ago

illiapoplawski commented 5 years ago

…xt sample to demonstrate usage.

This might not be necessary but I could not find a way in kotlin-libui to specify a font other than using a fontButton as I couldn't find kotlin bindings to the uiFontDescriptor struct that allowed setting:

char *Family;
double Size;
uiTextWeight Weight;
uiTextItalic Italic;
uiTextStretch Stretch;

I created a binding to allow creating a font that specifies those properties however this is my first time using kotlin native and I am receiving an error upon close of the sample due to leaked data as shown below:

** (drawtext.kexe:9779): CRITICAL **: 13:48:33.189: [libui] /home/travis/build/msink/libui/unix/alloc.c:42:uiprivUninitAlloc() You have a bug: Some data was leaked; either you left a uiControl lying around or there's a bug in libui itself. Leaked data:
0x105fb20 uiAttribute
0x105fb80 char[] (uiAttribute)

Any assistance in how to better define the bindings for uiFontDescriptor or fixing the memory leak would be appreciated.

msink commented 5 years ago

Sorry for delayed answer, was away from computer. Will try to fix somehow tomorrow.

But in general, support for formatted text is bad and mostly untested, sorry. There may be other bugs...

illiapoplawski commented 5 years ago

Not a problem. I'm just starting to play around with libui and see what it can do and learn a bit more in the process.

msink commented 5 years ago

Is https://github.com/msink/kotlin-libui/commit/58cd964972bb5e720f7ae7f23dbfe496156e7d32 what you want? Maybe imperfect but works.

illiapoplawski commented 5 years ago

That's exactly what I was looking for but wasn't sure exactly how to do. Definitely learned a few things from your commit too! Thanks for responding and the help!