Subject: bug#77196: tab-line-mode 's close-button show white rectangle when adjusting height via set-face-attribute

From: Eli Zaretskii <[email-masked]>
Date: Sun, 23 Mar 2025 08:41:19 +0200

> From: Siyuan Chen <[email-masked]>
> Date: Sun, 23 Mar 2025 09:05:56 +0800
> 
> Reproduce steps:
> 
> 1. Emacs -Q 
> 2. M-x eval-expression `(set-face-attribute 'tab-line nil :height 1)`
> 3. M-x tab-line-mode
> 
> The tab-line-mode is enabled but the close-button shows a white rectangle.
> 
> Also the *Messages* buffer printed: Invalid image size (see ‘max-image-size’) [12 times]
> 
> Try `(insert (icon-string 'tab-line-close))` in a buffer and Evaluate Last S-expression, it can show the icon 'x'.
> 
> Background:
> 
> Emacs' default tab-line is too small, I used the method to adjust tab-line height in Emacs 29.3 and it works
> very well. 
> 
> This issue only occurs on Emacs 30.1. 
> 
> Environment 
> 
> Emacs 30.1 on Windows 10.

I confirm the issue in Emacs 30.  But when I try this in Emacs 31,
Emacs crashes.  The backtrace is below.  Cecilio, could you please
look at this?

  warning: DirectWrite HRESULT failed: (-2147024809) Failed to GetGdiCompatibleGlyphMetrics

  w32dwrite.c:514: Emacs fatal error: assertion failed: SUCCEEDED (hr)

  Thread 1 hit Breakpoint 1, terminate_due_to_signal (sig=22,
      backtrace_limit=2147483647) at emacs.c:425
  425       signal (sig, SIG_DFL);
  (gdb) bt
  #0  terminate_due_to_signal (sig=22, backtrace_limit=2147483647) at emacs.c:425
  #1  0x00e769e8 in die (msg=0x10c9935 <IID_IDWriteFactory+65> "SUCCEEDED (hr)",
      file=0x10c9929 <IID_IDWriteFactory+53> "w32dwrite.c", line=514)
      at alloc.c:7452
  #2  0x00febfc8 in verify_hr (hr=-2147024809,
      msg=0x10c9984 <IID_IDWriteFactory+144> "Failed to GetGdiCompatibleGlyphMetrics") at w32dwrite.c:514
  #3  0x00fec306 in text_extents_internal (dwrite_font_face=0x5f95ef8,
      font_size=0, code=0xbfd680, nglyphs=1, metrics=0xbfc9a6) at w32dwrite.c:613
  #4  0x00fecd0b in w32_dwrite_draw (hdc=0xe30117e7, x=0, y=38, glyphs=0xbfd680,
      len=1, color=33554432, font=0xaf2e738) at w32dwrite.c:891
  #5  0x00fc510b in w32font_draw (s=0xbfd8e0, from=0, to=1, x=0, y=53,
      with_background=false) at w32font.c:716
  #6  0x00fcffaf in w32_draw_glyph_string_foreground (s=0xbfd8e0)
      at w32term.c:1411
  #7  0x00fd4197 in w32_draw_glyph_string (s=0xbfd8e0) at w32term.c:2787
  #8  0x00cf23a4 in draw_glyphs (w=0xae7cc58, x=673, row=0xaed5ca8,
      area=TEXT_AREA, start=0, end=148, hl=DRAW_NORMAL_TEXT, overlaps=0)
      at xdisp.c:31581
  #9  0x00cf95e2 in gui_write_glyphs (w=0xae7cc58, updated_row=0xaed5ca8,
      start=0x8fea570, updated_area=TEXT_AREA, len=148) at xdisp.c:33728
  #10 0x00c5ec1f in update_text_area (w=0xae7cc58, updated_row=0xaed5ca8,
      vpos=0, partial_p=0xbfdc6e) at dispnew.c:4735
  #11 0x00c5f706 in update_window_line (w=0xae7cc58, vpos=0,
      mouse_face_overwritten_p=0xbfdca7) at dispnew.c:4993
  #12 0x00c5e2b3 in update_window (w=0xae7cc58) at dispnew.c:4533
  #13 0x00c5d6a4 in update_window_tree (w=0xae7cc58) at dispnew.c:4224
  #14 0x00c5c337 in update_window_frame (f=0xae7ca38) at dispnew.c:3856
  #15 0x00c5d21b in update_frame (f=0xae7ca38, inhibit_scrolling=false)
      at dispnew.c:4108
  #16 0x00cc0406 in redisplay_internal () at xdisp.c:17726
  #17 0x00cbdb51 in redisplay () at xdisp.c:16802
  #18 0x00dc3f17 in read_char (commandflag=1, map=XIL(0xc000000005eb7a50),
      prev_event=XIL(0), used_mouse_menu=0xbff31f, end_time=0x0)
      at keyboard.c:2672
  #19 0x00ddcd1e in read_key_sequence (keybuf=0xbff5f8, prompt=XIL(0),
      dont_downcase_last=false, can_return_switch_frame=true,
      fix_current_buffer=true, prevent_redisplay=false,
      disable_text_conversion_p=false) at keyboard.c:10848
  #20 0x00dbfaf2 in command_loop_1 () at keyboard.c:1424
  #21 0x00eb4a4f in internal_condition_case (bfun=0xdbf490 <command_loop_1>,
      handlers=XIL(0x90), hfun=0xdbe4e9 <cmd_error>) at eval.c:1620
  #22 0x00dbeef5 in command_loop_2 (handlers=XIL(0x90)) at keyboard.c:1163
  #23 0x00eb3bdb in internal_catch (tag=XIL(0x12840),
      func=0xdbeebe <command_loop_2>, arg=XIL(0x90)) at eval.c:1300
  #24 0x00dbee60 in command_loop () at keyboard.c:1141
  #25 0x00dbdf49 in recursive_edit_1 () at keyboard.c:749
  #26 0x00dbe1e7 in Frecursive_edit () at keyboard.c:832
  #27 0x00db9210 in main (argc=2, argv=0x5e525f8) at emacs.c:2560

  Lisp Backtrace:
  "redisplay_internal (C function)" (0x0)
  (gdb)