Giter Site home page Giter Site logo

Comments (6)

nakst avatar nakst commented on August 17, 2024

Could you set a breakpoint at luigi2.h:4539 and check that cPath, size, font->glyphWidth, font->glyphHeight look reasonable each time the breakpoint is reached?

from gf.

omcaif avatar omcaif commented on August 17, 2024

EDIT: Forgot to check height.. For the terminus font it was 0 and for liberation mono, it was 22. So I guess that's unreasonable.

They look reasonable:

$ gdb ./gf2 
GNU gdb (Gentoo 13.2 vanilla) 13.2
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://bugs.gentoo.org/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./gf2...
(gdb) b luigi2.h:4539
Breakpoint 1 at 0x158e2: file /tmp/nakst_gf/luigi2.h, line 4539.
(gdb) r
Starting program: /tmp/nakst_gf/gf2 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[Detaching after vfork from child process 28812]

Breakpoint 1, UIFontCreate (cPath=0x5555555d22d0 "/usr/share/fonts/terminus/ter-u12n.otb", size=13) at /tmp/nakst_gf/luigi2.h:4539
4539                            font->isFreeType = true;
(gdb) display cPath
1: cPath = 0x5555555d22d0 "/usr/share/fonts/terminus/ter-u12n.otb"
(gdb) display size
2: size = 13
(gdb) display font->glyphWidth 
3: font->glyphWidth = 8
(gdb) c
Continuing.

Breakpoint 1, UIFontCreate (cPath=0x5555555d22d0 "/usr/share/fonts/terminus/ter-u12n.otb", size=11) at /tmp/nakst_gf/luigi2.h:4539
4539                            font->isFreeType = true;
1: cPath = 0x5555555d22d0 "/usr/share/fonts/terminus/ter-u12n.otb"
2: size = 11
3: font->glyphWidth = 8
(gdb) 
Continuing.
[New Thread 0x7ffff74af6c0 (LWP 28821)]
[Detaching after vfork from child process 28822]
[Detaching after vfork from child process 28823]
E247: No registered server named "GVIM": Send expression failed.

Thread 1 "gf2" received signal SIGFPE, Arithmetic exception.
0x0000555555560df6 in _UICodeMessage (element=0x5555555d9340, message=UI_MSG_PAINT, di=0, dp=0x7fffffffa150) at /tmp/nakst_gf/luigi2.h:2647
2647                    lineBounds.t -= (int64_t) code->vScroll->position % lineHeight;

I tried changing to another font and things worked:

$ gdb ./gf2 
GNU gdb (Gentoo 13.2 vanilla) 13.2
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://bugs.gentoo.org/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./gf2...
(gdb) b luigi2.h:4539
Breakpoint 1 at 0x158e2: file /tmp/nakst_gf/luigi2.h, line 4539.
(gdb) c
The program is not being run.
(gdb) r
Starting program: /tmp/nakst_gf/gf2 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[Detaching after vfork from child process 29333]

Breakpoint 1, UIFontCreate (cPath=0x5555555d22d0 "/usr/share/fonts/liberation-fonts/LiberationMono-Regular.ttf", size=13) at /tmp/nakst_gf/luigi2.h:4539
4539                            font->isFreeType = true;
(gdb) display cPath
1: cPath = 0x5555555d22d0 "/usr/share/fonts/liberation-fonts/LiberationMono-Regular.ttf"
(gdb) display size
2: size = 13
(gdb) display font->glyphWidth
3: font->glyphWidth = 11
(gdb) c
Continuing.

Breakpoint 1, UIFontCreate (cPath=0x5555555d22d0 "/usr/share/fonts/liberation-fonts/LiberationMono-Regular.ttf", size=11) at /tmp/nakst_gf/luigi2.h:4539
4539                            font->isFreeType = true;
1: cPath = 0x5555555d22d0 "/usr/share/fonts/liberation-fonts/LiberationMono-Regular.ttf"
2: size = 11
3: font->glyphWidth = 9
(gdb) c
Continuing.
[New Thread 0x7ffff74116c0 (LWP 29340)]
[Detaching after vfork from child process 29341]
[Detaching after vfork from child process 29342]
E247: No registered server named "GVIM": Send expression failed.

I guess the issue is with bitmap fonts.

from gf.

nakst avatar nakst commented on August 17, 2024

Yes, it looks like FreeType is not rendering the glyphs in this font as expected. The bitmaps it returns have a width and height of 0. I'm not familiar enough with FreeType to know why this is happening.

from gf.

omcaif avatar omcaif commented on August 17, 2024

I looked into it a bit. It looks like the FT_Set_Char_Size() call in UIFontCreate() is failing. It fails because Terminus font is a bitmap font with fixed sizes and the size provided is not an available size (see second to last paragraph of section 5 of the FreeType Tutorial).

The FT_HAS_FIXED_SIZES macro can be used to determine if specific, fixed sizes are needed. Then, the available_sizes "array" (length determined by num_fixed_sizes) in the FreeType face structure can be used check the available heights/font sizes. (Maybe loop through that array and find the closest match?)

I tried changing font size to an available size (and also changed from FT_Set_Char_Size() to FT_Set_Pixel_Sizes() because FT_Set_Char_Size() was still failing... maybe something to do with DPI), and I get no crash (and the glyphWidth and glyphHeight look ok), but the font is all garbled (see attached screenshot), so probably something else should also be changed/fixed to work with bitmap fonts.

image

from gf.

nakst avatar nakst commented on August 17, 2024

Does 9eb99d5 fix this?

from gf.

omcaif avatar omcaif commented on August 17, 2024

Thanks. It works for me now.

from gf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.