]> code.delx.au - gnu-emacs/blobdiff - src/w32bdf.c
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-25
[gnu-emacs] / src / w32bdf.c
index 801c914d8d9a1632e19dcd452c54fd7e755864e7..5f073dc84787761c66c688edbd8f652ae9514088 100644 (file)
@@ -28,7 +28,7 @@ Boston, MA 02111-1307, USA.  */
 #endif
 
 #include "lisp.h"
-#include "charset.h"
+#include "character.h"
 #include "keyboard.h"
 #include "frame.h"
 #include "dispextern.h"
@@ -54,7 +54,7 @@ cache_bitmap *pcached_bitmap_latest = cached_bitmap_slots;
 
 #define FONT_CACHE_SLOT_OVER_P(p) ((p) >= cached_bitmap_slots + BDF_FONT_CACHE_SIZE)
 
-static int 
+static int
 search_file_line(char *key, char *start, int len, char **val, char **next)
 {
   unsigned int linelen;
@@ -73,7 +73,7 @@ search_file_line(char *key, char *start, int len, char **val, char **next)
       *val = start + strlen(key);
       return 1;
     }
-  
+
   return 0;
 }
 
@@ -201,7 +201,7 @@ set_bdf_font_info(bdffont *fontp)
     else if (search_file_line("CHARSET_ENCODING", start, len,
                              (char **)&p, (char **)&q) == 1)
       {
-        fontp->encoding = get_quoted_string(p, q);
+       fontp->encoding = get_quoted_string(p, q);
       }
     else if (search_file_line("SLANT", start, len,
                              (char **)&p, (char **)&q) == 1)
@@ -247,7 +247,7 @@ w32_init_bdf_font(char *filename)
     hbdf_bmp_heap = HeapCreate(0, BDF_BITMAP_HEAP_INITIAL_SIZE, 0);
 
   if (!hbdf_cp_heap || !hbdf_bmp_heap)
-    error("Fail to create heap for BDF.");
+    error("Fail to create heap for BDF");
 
   hfile = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
                     OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
@@ -257,13 +257,13 @@ w32_init_bdf_font(char *filename)
       (fileinfo.nFileSizeLow > BDF_FILE_SIZE_MAX))
     {
       CloseHandle(hfile);
-      error("Fail to open BDF file.");
+      error("Fail to open BDF file");
     }
   hfilemap = CreateFileMapping(hfile, NULL, PAGE_READONLY, 0, 0, NULL);
   if (hfilemap == INVALID_HANDLE_VALUE)
     {
       CloseHandle(hfile);
-      error("Can't map font.");
+      error("Can't map font");
     }
 
   font = MapViewOfFile(hfilemap, FILE_MAP_READ, 0, 0, 0);
@@ -272,11 +272,11 @@ w32_init_bdf_font(char *filename)
     {
       CloseHandle(hfile);
       CloseHandle(hfilemap);
-      error("Can't view font.");
+      error("Can't view font");
     }
 
   bdffontp = (bdffont *) xmalloc(sizeof(bdffont));
-  
+
   for(i = 0;i < BDF_FIRST_OFFSET_TABLE;i++)
     bdffontp->chtbl[i] = NULL;
   bdffontp->size = fileinfo.nFileSizeLow;
@@ -285,7 +285,7 @@ w32_init_bdf_font(char *filename)
   bdffontp->hfilemap = hfilemap;
   bdffontp->filename = (char*) xmalloc(strlen(filename) + 1);
   strcpy(bdffontp->filename, filename);
-  
+
   if (!set_bdf_font_info(bdffontp))
     {
       w32_free_bdf_font(bdffontp);
@@ -364,7 +364,7 @@ cache_char_offset(bdffont *fontp, int index, unsigned char *offset)
     {
       pch = fontp->chtbl[BDF_FIRST_OFFSET(index)] =
        (font_char*) HeapAlloc(hbdf_cp_heap,
-                              HEAP_ZERO_MEMORY, 
+                              HEAP_ZERO_MEMORY,
                               sizeof(font_char) *
                                BDF_SECOND_OFFSET_TABLE);
       if (!pch) return NULL;
@@ -578,7 +578,7 @@ get_bitmap_with_cache(bdffont *fontp, int index)
   pcb->row_byte_size = glyph.row_byte_size;
 
   pch->pcbmp = pcb;
-  
+
   pcached_bitmap_latest++;
   if (FONT_CACHE_SLOT_OVER_P(pcached_bitmap_latest))
     pcached_bitmap_latest = cached_bitmap_slots;
@@ -649,7 +649,7 @@ w32_BDF_TextOut(bdffont *fontp, HDC hdc, int left,
     return 0;
 
   textalign = GetTextAlign(hdc);
-  
+
   hFgBrush = CreateSolidBrush(GetTextColor(hdc));
   hOrgBrush = SelectObject(hdc, hFgBrush);
 
@@ -679,7 +679,7 @@ w32_BDF_TextOut(bdffont *fontp, HDC hdc, int left,
        {
          width = pcb->metric.bbw;
          height = pcb->metric.bbh;
-         
+
          if (!(hBMP
                && (DIBsection_hdc == hdc)
                && (DIBsection_width == width)
@@ -768,12 +768,16 @@ struct font_info *w32_load_bdf_font (struct frame *f, char *fontname,
 
   /* Now fill in the slots of *FONTP.  */
   BLOCK_INPUT;
+  bzero (fontp, sizeof (*fontp));
   fontp->font = font;
   fontp->font_idx = dpyinfo->n_fonts;
   fontp->name = (char *) xmalloc (strlen (fontname) + 1);
   bcopy (fontname, fontp->name, strlen (fontname) + 1);
   fontp->full_name = fontp->name;
-  fontp->size = FONT_WIDTH (font);
+  /* FIXME: look at BDF spec to see if there are better ways of finding
+     average_width and space_width, hopefully that don't involve working out
+     the values for ourselves from the data.  */
+  fontp->size = fontp->average_width = fontp->space_width = FONT_WIDTH (font);
   fontp->height = FONT_HEIGHT (font);
 
     /* The slot `encoding' specifies how to map a character
@@ -785,11 +789,18 @@ struct font_info *w32_load_bdf_font (struct frame *f, char *fontname,
        uses this font.  So, we set informatoin in fontp->encoding[1]
        which is never used by any charset.  If mapping can't be
        decided, set FONT_ENCODING_NOT_DECIDED.  */
-    fontp->encoding[1] = FONT_ENCODING_NOT_DECIDED;
+    fontp->encoding_type = FONT_ENCODING_NOT_DECIDED;
     fontp->baseline_offset = bdf_font->yoffset;
     fontp->relative_compose = bdf_font->relative_compose;
     fontp->default_ascent = bdf_font->default_ascent;
 
+    /* Set global flag fonts_changed_p to non-zero if the font loaded
+       has a character with a smaller width than any other character
+       before, or if the font loaded has a smaller height than any
+       other font loaded before.  If this happens, it will make a
+       glyph matrix reallocation necessary.  */
+    fonts_changed_p |= x_compute_min_glyph_bounds (f);
+
     UNBLOCK_INPUT;
     dpyinfo->n_fonts++;
     return fontp;
@@ -859,3 +870,6 @@ int w32_BDF_to_x_font (char *file, char* xstr, int len)
   CloseHandle (hfilemap);
   return retval;
 }
+
+/* arch-tag: 2e9a45de-0c54-4a0e-95c8-2d67b2b1fa32
+   (do not change this comment) */