X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/264f0aa7ed3df3e078f077e23765bbf71a8a5faf..8030369ccb5c871d3ce11b96c220f318bc741ed8:/src/w32bdf.c diff --git a/src/w32bdf.c b/src/w32bdf.c index f9a717a26a..5bb5ba72bb 100644 --- a/src/w32bdf.c +++ b/src/w32bdf.c @@ -22,9 +22,14 @@ Boston, MA 02111-1307, USA. */ MULE for W32). */ #include -#include "config.h" + +#ifdef HAVE_CONFIG_H +#include +#endif + #include "lisp.h" #include "charset.h" +#include "keyboard.h" #include "frame.h" #include "dispextern.h" #include "fontset.h" @@ -33,9 +38,6 @@ Boston, MA 02111-1307, USA. */ #include "w32term.h" #include "w32bdf.h" -#define min(a, b) ((a) < (b) ? (a) : (b)) -#define max(a, b) ((a) > (b) ? (a) : (b)) - /* 10 planes */ #define BDF_CODEPOINT_HEAP_INITIAL_SIZE (96 * 10) /* about 96 characters */ @@ -55,16 +57,16 @@ cache_bitmap *pcached_bitmap_latest = cached_bitmap_slots; static int search_file_line(char *key, char *start, int len, char **val, char **next) { - int linelen; - unsigned char *p, *q; + unsigned int linelen; + unsigned char *p; p = memchr(start, '\n', len); if (!p) return -1; - for (;start < p;start++) + for (;(unsigned char *)start < p;start++) { if ((*start != ' ') && (*start != '\t')) break; } - linelen = p - start + 1; + linelen = (char *) p - start + 1; *next = p + 1; if (strncmp(start, key, min(strlen(key), linelen)) == 0) { @@ -129,15 +131,16 @@ set_bdf_font_info(bdffont *fontp) fontp->slant = NULL; /* fontp->width = NULL; */ - flag = proceed_file_line("FONTBOUNDINGBOX", start, &len, &p, &q); + flag = proceed_file_line("FONTBOUNDINGBOX", start, &len, + (char **)&p, (char **)&q); if (!flag) return 0; - bbw = strtol(p, &start, 10); + bbw = strtol(p, (char **)&start, 10); p = start; - bbh = strtol(p, &start, 10); + bbh = strtol(p, (char **)&start, 10); p = start; - bbx = strtol(p, &start, 10); + bbx = strtol(p, (char **)&start, 10); p = start; - bby = strtol(p, &start, 10); + bby = strtol(p, (char **)&start, 10); fontp->llx = bbx; fontp->lly = bby; @@ -146,71 +149,84 @@ set_bdf_font_info(bdffont *fontp) fontp->width = bbw; fontp->height = bbh; start = q; - flag = proceed_file_line("STARTPROPERTIES", start, &len, &p, &q); + flag = proceed_file_line("STARTPROPERTIES", start, &len, + (char **)&p, (char **)&q); if (!flag) return 1; flag = 0; do { start = q; - if (search_file_line("PIXEL_SIZE", start, len, &p, &q) == 1) + if (search_file_line("PIXEL_SIZE", start, len, + (char **)&p, (char **)&q) == 1) { val1 = atoi(p); fontp->pixsz = val1; } - else if (search_file_line("FONT_ASCENT", start, len, &p, &q) == 1) + else if (search_file_line("FONT_ASCENT", start, len, + (char **)&p, (char **)&q) == 1) { val1 = atoi(p); fontp->ury = val1; } - else if (search_file_line("FONT_DESCENT", start, len, &p, &q) == 1) + else if (search_file_line("FONT_DESCENT", start, len, + (char **)&p, (char **)&q) == 1) { val1 = atoi(p); fontp->lly = -val1; } - else if (search_file_line("_MULE_BASELINE_OFFSET", start, len, &p, &q) == 1) + else if (search_file_line("_MULE_BASELINE_OFFSET", start, len, + (char **)&p, (char **)&q) == 1) { val1 = atoi(p); fontp->yoffset = -val1; } - else if (search_file_line("_MULE_RELATIVE_COMPOSE", start, len, &p, &q) == 1) + else if (search_file_line("_MULE_RELATIVE_COMPOSE", start, len, + (char **)&p, (char **)&q) == 1) { val1 = atoi(p); fontp->relative_compose = val1; } - else if (search_file_line("_MULE_DEFAULT_ASCENT", start, len, &p, &q) == 1) + else if (search_file_line("_MULE_DEFAULT_ASCENT", start, len, + (char **)&p, (char **)&q) == 1) { val1 = atoi(p); fontp->default_ascent = val1; } - else if (search_file_line("CHARSET_REGISTRY", start, len, &p, &q) == 1) + else if (search_file_line("CHARSET_REGISTRY", start, len, + (char **)&p, (char **)&q) == 1) { fontp->registry = get_quoted_string(p, q); } - else if (search_file_line("CHARSET_ENCODING", start, len, &p, &q) == 1) + else if (search_file_line("CHARSET_ENCODING", start, len, + (char **)&p, (char **)&q) == 1) { fontp->encoding = get_quoted_string(p, q); } - else if (search_file_line("SLANT", start, len, &p, &q) == 1) + else if (search_file_line("SLANT", start, len, + (char **)&p, (char **)&q) == 1) { fontp->slant = get_quoted_string(p, q); } /* - else if (search_file_line("SETWIDTH_NAME", start, len, &p, &q) == 1) + else if (search_file_line("SETWIDTH_NAME", start, len, + (char **)&p, (char **)&q) == 1) { fontp->width = get_quoted_string(p, q); } */ else { - flag = search_file_line("ENDPROPERTIES", start, len, &p, &q); + flag = search_file_line("ENDPROPERTIES", start, len, + (char **)&p, (char **)&q); } if (flag == -1) return 0; len -= (q - start); }while(flag == 0); start = q; - flag = proceed_file_line("CHARS", start, &len, &p, &q); + flag = proceed_file_line("CHARS", start, &len, (char **)&p, (char **)&q); if (!flag) return 0; + fontp->nchars = atoi(p); fontp->seeked = q; return 1; @@ -227,7 +243,7 @@ w32_init_bdf_font(char *filename) if (hbdf_cp_heap == INVALID_HANDLE_VALUE) hbdf_cp_heap = HeapCreate(0, BDF_CODEPOINT_HEAP_INITIAL_SIZE, 0); - if (hbdf_bmp_heap = INVALID_HANDLE_VALUE) + if (hbdf_bmp_heap == INVALID_HANDLE_VALUE) hbdf_bmp_heap = HeapCreate(0, BDF_BITMAP_HEAP_INITIAL_SIZE, 0); if (!hbdf_cp_heap || !hbdf_bmp_heap) @@ -320,7 +336,6 @@ static font_char* get_cached_font_char(bdffont *fontp, int index) { font_char *pch, *result; - int i; if (!BDF_CODEPOINT_RANGE_COVER_P(index)) return NULL; @@ -340,7 +355,6 @@ static font_char* cache_char_offset(bdffont *fontp, int index, unsigned char *offset) { font_char *pch, *result; - int i; if (!BDF_CODEPOINT_RANGE_COVER_P(index)) return NULL; @@ -376,7 +390,8 @@ seek_char(bdffont *fontp, int index) len = fontp->size - (start - fontp->font); do { - flag = proceed_file_line("ENCODING", start, &len, &p, &q); + flag = proceed_file_line("ENCODING", start, &len, + (char **)&p, (char **)&q); if (!flag) { fontp->seeked = NULL; @@ -447,27 +462,27 @@ w32_get_bdf_glyph(bdffont *fontp, int index, int size, glyph_struct *glyph) len = fontp->size - (start - fontp->font); - flag = proceed_file_line("DWIDTH", start, &len, &p, &q); + flag = proceed_file_line("DWIDTH", start, &len, (char **)&p, (char **)&q); if (!flag) return 0; glyph->metric.dwidth = atoi(p); start = q; - flag = proceed_file_line("BBX", start, &len, &p, &q); + flag = proceed_file_line("BBX", start, &len, (char **)&p, (char **)&q); if (!flag) return 0; - glyph->metric.bbw = strtol(p, &start, 10); + glyph->metric.bbw = strtol(p, (char **)&start, 10); p = start; - glyph->metric.bbh = strtol(p, &start, 10); + glyph->metric.bbh = strtol(p, (char **)&start, 10); p = start; - glyph->metric.bbox = strtol(p, &start, 10); + glyph->metric.bbox = strtol(p, (char **)&start, 10); p = start; - glyph->metric.bboy = strtol(p, &start, 10); + glyph->metric.bboy = strtol(p, (char **)&start, 10); if (size == 0) return 1; start = q; - flag = proceed_file_line("BITMAP", start, &len, &p, &q); + flag = proceed_file_line("BITMAP", start, &len, (char **)&p, (char **)&q); if (!flag) return 0; @@ -489,11 +504,14 @@ w32_get_bdf_glyph(bdffont *fontp, int index, int size, glyph_struct *glyph) if (!q) return 0; for(j = 0;((q > p) && (j < rowbytes));j++) { - val1 = GET_HEX_VAL(*p); - if (val1 == -1) return 0; + int ival = GET_HEX_VAL(*p); + + if (ival == -1) return 0; + val1 = ival; p++; - val2 = GET_HEX_VAL(*p); - if (val2 == -1) return 0; + ival = GET_HEX_VAL(*p); + if (ival == -1) return 0; + val2 = ival; p++; val = (unsigned char)((val1 << 4) | val2); if (val) flag = 1; @@ -571,7 +589,6 @@ get_bitmap_with_cache(bdffont *fontp, int index) static HBITMAP create_offscreen_bitmap(HDC hdc, int width, int height, unsigned char **bitsp) { - HBITMAP hBMP; struct { BITMAPINFOHEADER h; RGBQUAD c[2]; @@ -649,7 +666,7 @@ w32_BDF_TextOut(bdffont *fontp, HDC hdc, int left, { bytelen -= 2; if (bytelen < 0) break; - index = MAKELENDSHORT(textp[1], textp[0]); + index = MAKELENDSHORT(textp[0], textp[1]); textp += 2; } pcb = get_bitmap_with_cache(fontp, index); @@ -717,12 +734,16 @@ struct font_info *w32_load_bdf_font (struct frame *f, char *fontname, if (!bdf_font) return NULL; font = (XFontStruct *) xmalloc (sizeof (XFontStruct)); + bzero (font, sizeof (*font)); font->bdf = bdf_font; font->hfont = 0; - /* NTEMACS_TODO: Recognize DBCS fonts. */ - font->double_byte_p = 0; + /* NTEMACS_TODO: Better way of determining if a font is double byte + or not. */ + font->double_byte_p = bdf_font->nchars > 255 ? 1 : 0; + + w32_cache_char_metrics (font); /* Do we need to create the table? */ if (dpyinfo->font_table_size == 0) @@ -769,12 +790,19 @@ struct font_info *w32_load_bdf_font (struct frame *f, char *fontname, 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; } -/* Check a file for an XFLD string describing it. */ +/* Check a file for an XLFD string describing it. */ int w32_BDF_to_x_font (char *file, char* xstr, int len) { HANDLE hfile, hfilemap;