To: vim-dev@vim.org Subject: Patch 6.1.303 (extra) Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.303 (extra) Problem: The Top/Bottom/All text does not always fit in the ruler when translated to Japanese. Problem with a character being wider when in a bold font. Solution: Use ETO_PDY to specify the width of each character. (Yasuhiro Matsumoto) Files: src/gui_w32.c *** ../vim61.302/src/gui_w32.c Sun Jan 19 21:22:53 2003 --- src/gui_w32.c Thu Jan 23 14:55:54 2003 *************** *** 268,273 **** --- 268,276 ---- #ifndef ETO_IGNORELANGUAGE # define ETO_IGNORELANGUAGE 0x1000 #endif + #ifndef ETO_PDY + # define ETO_PDY 0x2000 + #endif /* * Return TRUE when running under Windows NT 3.x or Win32s, both of which have *************** *** 1601,1606 **** --- 1604,1610 ---- UINT foptions = 0; #ifdef FEAT_MBYTE static WCHAR *unicodebuf = NULL; + static int *unicodepdy = NULL; int unibuflen = 0; int n; #endif *************** *** 1736,1741 **** --- 1740,1754 ---- { vim_free(unicodebuf); unicodebuf = (WCHAR *)alloc(len * sizeof(WCHAR)); + + vim_free(unicodepdy); + unicodepdy = (int *)alloc(len * sizeof(int) * 2); + if (unicodepdy == NULL) + { + vim_free(unicodebuf); + unicodebuf = NULL; + } + unibuflen = len; } *************** *** 1746,1762 **** int i = 0; int clen; /* string length up to composing char */ int cells; /* cell width of string up to composing char */ cells = 0; for (clen = 0; i < len; ) { unicodebuf[clen] = utf_ptr2char(text + i); ! cells += utf_char2cells(unicodebuf[clen]); i += utfc_ptr2len_check_len(text + i, len - i); ++clen; } ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row), ! foptions, pcliprect, unicodebuf, clen, NULL); len = cells; /* used for underlining */ } else if (is_funky_dbcs) --- 1759,1782 ---- int i = 0; int clen; /* string length up to composing char */ int cells; /* cell width of string up to composing char */ + int cw; /* width of current cell */ cells = 0; + /* Add ETO_PDY to make characters fit as we expect, even when the font + * uses different widths (e.g., bold character is wider). */ + foptions |= ETO_PDY; for (clen = 0; i < len; ) { unicodebuf[clen] = utf_ptr2char(text + i); ! cw = utf_char2cells(unicodebuf[clen]); ! unicodepdy[clen * 2] = cw * gui.char_width; ! unicodepdy[clen * 2 + 1] = 0; ! cells += cw; i += utfc_ptr2len_check_len(text + i, len - i); ++clen; } ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row), ! foptions, pcliprect, unicodebuf, clen, unicodepdy); len = cells; /* used for underlining */ } else if (is_funky_dbcs) *** ../vim61.302/src/version.c Sun Jan 26 22:42:25 2003 --- src/version.c Tue Jan 28 21:20:02 2003 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 303, /**/ -- hundred-and-one symptoms of being an internet addict: 63. You start using smileys in your snail mail. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///