lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

lynx-dev [PATCH 2.8.4dev.19] display-charset switch and window resize


From: Ilya Zakharevich
Subject: lynx-dev [PATCH 2.8.4dev.19] display-charset switch and window resize
Date: Sun, 11 Mar 2001 20:56:11 -0500
User-agent: Mutt/1.2.5i

Resizing a window on a console may lead to a switch of the
character-cell size.  The "downloaded font" loaded during an
auto-switch of display-charset may be no longer valid.

The patch below causes a re-download of the suitable font for the current
charcell size.

Enjoy,
Ilya

--- ./src/LYUtils.c-pre-charset Thu Mar  8 21:40:14 2001
+++ ./src/LYUtils.c     Sun Mar 11 20:02:38 2001
@@ -3506,6 +3506,15 @@ PUBLIC void size_change ARGS1(
        recent_sizechange = TRUE;
        CTRACE((tfp, "Window size changed from (%d,%d) to (%d,%d)\n",
                old_lines, old_cols, LYlines, LYcols));
+#if defined(CAN_SWITCH_DISPLAY_CHARSET) && 
defined(CAN_AUTODETECT_DISPLAY_CHARSET)
+       /* May need to reload the font due to different char-box size */
+       if (current_char_set != auto_display_charset) {
+           int old = current_char_set;
+
+           Switch_Display_Charset(auto_display_charset, 1);
+           Switch_Display_Charset(old, 1);
+       }
+#endif
     }
 #ifdef SIGWINCH
     LYExtSignal (SIGWINCH, size_change);
--- ./src/UCAuto.c-pre-charset  Thu Mar  8 21:40:14 2001
+++ ./src/UCAuto.c      Sun Mar 11 20:03:40 2001
@@ -543,7 +543,7 @@ PRIVATE int _Switch_Display_Charset ARGS
 {
     CONST char *name;
     unsigned short cp;
-    static int font_loaded_for = -1;
+    static int font_loaded_for = -1, old_h, old_w;
     int rc, ord1;
     UCHAR msgbuf[MAXPATHLEN + 80];
 
@@ -581,10 +581,7 @@ PRIVATE int _Switch_Display_Charset ARGS
     }
 
     /* Not a "prepared" codepage.  Need to load the user font. */
-    if (ord1 == font_loaded_for) {     /* The same as the previous font */
-       if ((rc = VioSetCp(0, -1, 0)))  /* -1: User font */
-           goto err;
-    } else if (charsets_directory) {
+    if (charsets_directory) {
        TIB *tib;                       /* Can't load font in a windowed-VIO */
        PIB *pib;
        VIOFONTINFO f[2];
@@ -597,7 +594,8 @@ PRIVATE int _Switch_Display_Charset ARGS
        long i, j;
 
        /* 0 means a FS protected-mode session */
-       if (DosGetInfoBlocks(&tib, &pib) || pib->pib_ultype != 0) {
+       if ( font_loaded_for == -1              /* Did not try it yet */
+            && (DosGetInfoBlocks(&tib, &pib) || pib->pib_ultype != 0) ) {
            ord = ord1 = auto_display_charset;
            goto retry;
        }
@@ -619,6 +617,13 @@ PRIVATE int _Switch_Display_Charset ARGS
            ord = ord1 = auto_display_charset;
            goto retry;
        }
+       if ( ord1 == font_loaded_for
+            && old_h == font->cyCell && old_w == font->cxCell ) {
+           /* The same as the previous font */
+           if ((rc = VioSetCp(0, -1, 0)))      /* -1: User font */
+               goto err;
+           goto report;
+       } 
        sprintf(fnamebuf, "%s/%dx%d/%s.fnt",
                charsets_directory, font->cyCell, font->cxCell, name);
        file = fopen(fnamebuf,"rb");
@@ -645,9 +650,12 @@ PRIVATE int _Switch_Display_Charset ARGS
            sprintf(msgbuf, "Can't set font: err=%#lx=%ld", rc, rc);
            HTInfoMsg(msgbuf);
            ord = ord1 = auto_display_charset;
+           font_loaded_for = -1;
            goto retry;
        }
        font_loaded_for = ord1;
+       old_h = font->cyCell;
+       old_w = font->cxCell;
     }
   report:
     CTRACE((tfp, "Display font set to '%s'.\n", name));

; To UNSUBSCRIBE: Send "unsubscribe lynx-dev" to address@hidden

reply via email to

[Prev in Thread] Current Thread [Next in Thread]