From: Akihiro Sagawa Subject: Re: [PATCH v2 7/7] gdi32: Improve the determine code whether the chracter is the fullwidth. Message-Id: <20190205001756.7843.375B48EC@gmail.com> Date: Tue, 05 Feb 2019 00:18:03 +0900 In-Reply-To: <850ba54d-6ff9-69a5-9ec6-312f18dcb71c@hanmail.net> References: <850ba54d-6ff9-69a5-9ec6-312f18dcb71c@hanmail.net> On Sat, 2 Feb 2019 05:11:58 +0900, Byeongsik Jeon wrote: > I looked at the behavior on Windows with a test font that manipulated > the OS/2 table(Panose, AvgCharWidth). It didn't work as I thought. IMO, > Windows seems to be doing something related to the following document. > Surprisingly, Wine already has the scripts needed for conversion, so I > can work easily. > > https://www.unicode.org/Public/11.0/udd/EasasianWidth.txt > > This is a temporary patch. Please review if possible. It is also good to > post more improved patch directly. I agree with that Windows uses some sort of fullwidth character table, but I'm not sure about EasAsianWidth.txt. At least, there are two issues, 1. We can't get an Unicode code point when GetGlyphOutline function called with GGO_GLYPH_INDEX flag. 2. There are ambiguous width characters. For instance, is U+20AC a fullwidth character or a halfwidth one? By the way, when I tested with Gulim on Windows, I got 19 px as gmCellIncX value at 19 ppem for U+C640 (see attachment for details). Gulium shares the embedded bitmap with GuliumChe. So, why don't you fix up base_advance when using embedded bitmaps? By doing so, the advance will be 19 (not 18) before calculating fixed_pitch_full. And, we don't have to update the formula. Akihiro Sagawa /* * test_gulium.c -- Test Gulim's advance width * * How to compile: * i686-w64-mingw32-gcc -o test_gulim.exe ./test_gulim.c -lgdi32 */ #include #include static void test_advance(HDC hdc, HFONT hfont) { HFONT hfont_old; MAT2 mat = {{0,1},{0,0},{0,0},{0,1}}; GLYPHMETRICS gm; char text[128]; int bufsize; char *buffer; hfont_old = SelectObject(hdc, hfont); GetTextFace(hdc, sizeof(text), text); printf("Face: %s\n", text); bufsize = GetGlyphOutlineW(hdc, 0xc640, GGO_GRAY4_BITMAP, &gm, 0, NULL, &mat); buffer = malloc(bufsize); bufsize = GetGlyphOutlineW(hdc, 0xc640, GGO_GRAY4_BITMAP, &gm, bufsize, buffer, &mat); if (bufsize != GDI_ERROR) printf("gmCellIncX: %hd\n", gm.gmCellIncX); printf("\n"); SelectObject(hdc, hfont_old); } int main(int argc, char* argv[]) { HDC hdc = GetDC(NULL); HFONT hfont_gulim, hfont_gulimche; LOGFONT lf; memset(&lf, 0, sizeof(lf)); lf.lfCharSet = HANGUL_CHARSET; lf.lfHeight = -19; lf.lfWeight = FW_NORMAL; strcpy(lf.lfFaceName, "Gulim"); hfont_gulim = CreateFontIndirect(&lf); test_advance(hdc, hfont_gulim); strcpy(lf.lfFaceName, "GulimChe"); hfont_gulimche = CreateFontIndirect(&lf); test_advance(hdc, hfont_gulimche); DeleteObject(hfont_gulim); DeleteObject(hfont_gulimche); ReleaseDC(NULL, hdc); return 0; }