[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

[MD:801]BDF font manager



椿本@シセン堂と申します。

In message "[MD:800]BDF font manager"
    <19980723012707P.yamagus@xxxxxxxxxxxxxxxxxx> on 98/07/23,
    "YAMAGUCHI, Shuhei" <yamagus@xxxxxxxxxxxxxxxxxx> wrote:
> 
> temacs-980718.exe.gzを試してみたのですが、Win95でおかしな現象が起きて
> いるのですが、私のWin95がおかしくなった可能性も高いので、同じ現象にあっ
> た人がいないか確認したいです。
> #NT4.0SP1では起きていないです。
(略)
> ので、フォントは、せっかくなので全てBDFという状態です。

 私の所でも同じ現象が出ました。
 また、Select fontでフォントを何回も切り替えると同様の症状が出るようです。

 ソースを見たところ、一部リソースのリークがあるのと、最大5000個のBITMAPは
Win95には辛い様です。^_^;;

 主な原因は後者の様でした。キャッシュの最大数を5分の1にしたら現象は収まり
ました。

 とりあえず、パッチ作ってみました。

キャッシュの最大数、リソースのリークの修正の他に、
・white spaceの判定(ミス?)。
・BITMAPのSelectを表示毎に行う。
の変更も入ってます。
 後者は、タイミングによってはまだSelectされているBITMAPがDeleteされる
可能性がある為です。

--------------v-----------------ここから--------------v----------------
*** mw32bdf.h.orig	Fri Jul 17 01:39:14 1998
--- mw32bdf.h	Wed Jul 22 18:44:18 1998
***************
*** 7,14 ****
  #define BDF_SECOND_OFFSET(x) ((x) & 0x7f)
  #define BDF_FIRST_OFFSET(x) (((x) >> 8) | (((x) & 0x80) << 1))
  
! #define BDF_FONT_CACHE_SIZE 5000
! #define BDF_FONT_CLEAR_SIZE 1000
  
  /* Structure of glyph information of one character.  */
  typedef struct
--- 7,14 ----
  #define BDF_SECOND_OFFSET(x) ((x) & 0x7f)
  #define BDF_FIRST_OFFSET(x) (((x) >> 8) | (((x) & 0x80) << 1))
  
! #define BDF_FONT_CACHE_SIZE 1000
! #define BDF_FONT_CLEAR_SIZE 200
  
  /* Structure of glyph information of one character.  */
  typedef struct
*** mw32bdf.c.orig	Fri Jul 17 02:26:06 1998
--- mw32bdf.c	Wed Jul 22 17:58:10 1998
***************
*** 46,52 ****
    if (!p) return -1;
    for (;start < p;start++)
      {
!       if ((*start != ' ') || (*start != '\t')) break;
      }
    linelen = p - start + 1;
    *next = p + 1;
--- 46,52 ----
    if (!p) return -1;
    for (;start < p;start++)
      {
!       if ((*start != ' ') && (*start != '\t')) break;
      }
    linelen = p - start + 1;
    *next = p + 1;
***************
*** 276,282 ****
  	  for (j = 0;j < BDF_SECOND_OFFSET_TABLE;j++)
  	    {
  	      pcb = pch[j].pcbmp;
! 	      if (pcb) pcb->psrc = NULL;
  	    }
  	  xfree(pch);
  	}
--- 276,286 ----
  	  for (j = 0;j < BDF_SECOND_OFFSET_TABLE;j++)
  	    {
  	      pcb = pch[j].pcbmp;
! 	      if (pcb)
! 		{
! 		  DeleteObject(pcb->hbmp);
! 		  pcb->psrc = NULL;
! 		}
  	    }
  	  xfree(pch);
  	}
***************
*** 592,607 ****
  	  textp += 2;
  	}
        pcb = get_bitmap_with_cache(fontp, index);
!       if (!pcb)
! 	{
! 	  if (horgobj)
! 	    {
! 	      SelectObject(hCompatDC, horgobj);
! 	      DeleteObject(hBMP);
! 	    }
! 	  DeleteDC(hCompatDC);
! 	  return 0;
! 	}
        hBMP = pcb->hbmp;
  
        if (textalign & TA_BASELINE)
--- 596,602 ----
  	  textp += 2;
  	}
        pcb = get_bitmap_with_cache(fontp, index);
!       if (!pcb) break;
        hBMP = pcb->hbmp;
  
        if (textalign & TA_BASELINE)
***************
*** 611,636 ****
        else
  	btop = top;
  
-       if (horgobj)
- 	SelectObject(hCompatDC, hBMP);
-       else
  	horgobj = SelectObject(hCompatDC, hBMP);
  #if 0
        BitBlt(hdc, left, btop, pcb->metric.bbw, pcb->metric.bbh, hCompatDC, 0, 0, SRCCOPY);
  #else
        BitBlt(hdc, left, btop, pcb->metric.bbw, pcb->metric.bbh, hCompatDC, 0, 0, 0xB8074A);
  #endif
        if (fixed_pitch_size)
  	left += fixed_pitch_size;
        else
  	left += pcb->metric.dwidth;
      }
  
-   SelectObject(hCompatDC, horgobj);
    SelectObject(hdc, hOrgBrush);
    DeleteObject(hFgBrush);
    DeleteDC(hCompatDC);
    RestoreDC(hdc, -1);
  
    return 1;
  }
--- 606,629 ----
        else
  	btop = top;
  
        horgobj = SelectObject(hCompatDC, hBMP);
  #if 0
        BitBlt(hdc, left, btop, pcb->metric.bbw, pcb->metric.bbh, hCompatDC, 0, 0, SRCCOPY);
  #else
        BitBlt(hdc, left, btop, pcb->metric.bbw, pcb->metric.bbh, hCompatDC, 0, 0, 0xB8074A);
  #endif
+       SelectObject(hCompatDC, horgobj);
        if (fixed_pitch_size)
  	left += fixed_pitch_size;
        else
  	left += pcb->metric.dwidth;
      }
  
    SelectObject(hdc, hOrgBrush);
    DeleteObject(hFgBrush);
    DeleteDC(hCompatDC);
    RestoreDC(hdc, -1);
  
+   if (bytelen > 0) return 0;
    return 1;
  }
--------------^-----------------ここまで--------------^----------------
-- 
椿本 浩也 (Hiroya Tsubakimoto)
Office: <zorac@xxxxxxxxxxxx> 有限会社シセン堂
Home: <zorac@xxxxxxxxxxxxxxxxxxxxx>