#include #include #include #define expect(var, val) if ((var) != (val)) { printf("[0x%x] " #var " = %d, expected " #val " (%d)\n", ch, (var), (val)); } void test_char(HDC hdc, WCHAR ch, BOOL test, int expected_glyphs) { WCHAR chars[2] = { ch, 0 }; SCRIPT_CACHE sc = NULL; SCRIPT_ITEM items[20]; OPENTYPE_TAG tags[20]; HRESULT hr; WORD wLogClust[2] = { 0 }; SCRIPT_CHARPROP charProps[2] = { 0 }; WORD wGlyphs[20] = { 0 }; SCRIPT_GLYPHPROP glyphProps[20] = { 0 }; int cGlyphs = _countof(wGlyphs); int cItems = _countof(items); hr = ScriptItemizeOpenType(chars, 1, _countof(items), NULL, NULL, items, tags, &cItems); if (FAILED(hr)) { printf("ScriptItemizeOpenType(0x%x) failed with %lx\n", ch, hr); return; } if (!test) { printf("[0x%x] cItems: %d\n", ch, cItems); printf("[0x%x] items[0].a.fLogicalOrder: %d\n", ch, items[0].a.fLogicalOrder); printf("[0x%x] items[0].a.fRTL: %d\n", ch, items[0].a.fRTL); } else { expect(cItems, 1); expect(items[0].a.fLogicalOrder, 0); expect(items[0].a.fRTL, 0); } hr = ScriptShapeOpenType(hdc, &sc, &items[0].a, 'iaht', 0, NULL, NULL, 0, chars, 1, _countof(wGlyphs), wLogClust, charProps, wGlyphs, glyphProps, &cGlyphs); if (FAILED(hr)) { printf("ScriptShapeOpenType(0x%x) failed with %lx\n", ch, hr); return; } if (!test) { printf("[0x%x] cGlyphs: %d\n", ch, cGlyphs); printf("[0x%x] charProps[0].fCanGlyphAlone: %d\n", ch, charProps[0].fCanGlyphAlone); printf("[0x%x] wLogClust[0]: %d\n", ch, wLogClust[0]); for (int i = 0; i < cGlyphs; i++) { printf("[0x%x] glyphProps[%d].sva.uJustification: %d\n", ch, i, glyphProps[i].sva.uJustification); printf("[0x%x] glyphProps[%d].sva.fClusterStart: %d\n", ch, i, glyphProps[i].sva.fClusterStart); printf("[0x%x] glyphProps[%d].sva.fDiacritic: %d\n", ch, i, glyphProps[i].sva.fDiacritic); printf("[0x%x] glyphProps[%d].sva.fZeroWidth: %d\n", ch, i, glyphProps[i].sva.fZeroWidth); } } else { expect(cGlyphs, expected_glyphs); expect(charProps[0].fCanGlyphAlone, 0); expect(wLogClust[0], 0); if (cGlyphs == 1) { expect(glyphProps[0].sva.uJustification, SCRIPT_JUSTIFY_CHARACTER); expect(glyphProps[0].sva.fClusterStart, 1); expect(glyphProps[0].sva.fDiacritic, 0); expect(glyphProps[0].sva.fZeroWidth, 0); } else { expect(glyphProps[0].sva.uJustification, SCRIPT_JUSTIFY_NONE); expect(glyphProps[0].sva.fClusterStart, 1); expect(glyphProps[0].sva.fDiacritic, 0); expect(glyphProps[0].sva.fZeroWidth, 1); expect(glyphProps[1].sva.uJustification, SCRIPT_JUSTIFY_NONE); expect(glyphProps[1].sva.fClusterStart, 0); expect(glyphProps[1].sva.fDiacritic, 1); expect(glyphProps[1].sva.fZeroWidth, 0); } } } void do_test(BOOL test) { HDC hdcTest; LOGFONTW lf; HFONT hfont, hfontPrev; WCHAR wszFontFace[128]; hdcTest = CreateCompatibleDC(NULL); if (hdcTest == NULL) { puts("CreateCompatibleDC(NULL) failed"); goto Exit; } memset(&lf, 0, sizeof(lf)); wcsncpy(lf.lfFaceName, L"Fixedsys Excelsior 3.01", _countof(lf.lfFaceName)); lf.lfCharSet = DEFAULT_CHARSET; hfont = CreateFontIndirectW(&lf); if (hfont == NULL) { puts("CreateFontIndirectW failed"); goto Exit; } hfontPrev = SelectObject(hdcTest, hfont); if (GetTextFaceW(hdcTest, _countof(wszFontFace), wszFontFace) != 0) { printf("Font face: %ls\n", wszFontFace); } else { puts("GetTextFaceW failed\n"); } test_char(hdcTest, 0xe31, test, 2); test_char(hdcTest, 0xe32, test, 1); test_char(hdcTest, 0xe33, test, 1); test_char(hdcTest, 0xe34, test, 2); test_char(hdcTest, 0xe35, test, 2); test_char(hdcTest, 0xe36, test, 2); test_char(hdcTest, 0xe37, test, 2); test_char(hdcTest, 0xe38, test, 2); test_char(hdcTest, 0xe39, test, 2); test_char(hdcTest, 0xe3a, test, 2); test_char(hdcTest, 0xe47, test, 2); test_char(hdcTest, 0xe48, test, 2); test_char(hdcTest, 0xe49, test, 2); test_char(hdcTest, 0xe4a, test, 2); Exit: if (hdcTest != NULL) { if (hfontPrev != NULL) { SelectObject(hdcTest, hfontPrev); } DeleteDC(hdcTest); } } int main(int argc, char **argv) { if (argc >= 2 && !strcmp(argv[1], "/p")) { do_test(FALSE); } else { do_test(TRUE); } return 0; } /* Font face: Fixedsys Excelsior 3.01 [0xe31] cItems: 1 [0xe31] items[0].a.fLogicalOrder: 0 [0xe31] items[0].a.fRTL: 0 [0xe31] cGlyphs: 2 [0xe31] charProps[0].fCanGlyphAlone: 0 [0xe31] wLogClust[0]: 0 [0xe31] glyphProps[0].sva.uJustification: 0 [0xe31] glyphProps[0].sva.fClusterStart: 1 [0xe31] glyphProps[0].sva.fDiacritic: 0 [0xe31] glyphProps[0].sva.fZeroWidth: 1 [0xe31] glyphProps[1].sva.uJustification: 0 [0xe31] glyphProps[1].sva.fClusterStart: 0 [0xe31] glyphProps[1].sva.fDiacritic: 1 [0xe31] glyphProps[1].sva.fZeroWidth: 0 [0xe32] cItems: 1 [0xe32] items[0].a.fLogicalOrder: 0 [0xe32] items[0].a.fRTL: 0 [0xe32] cGlyphs: 1 [0xe32] charProps[0].fCanGlyphAlone: 0 [0xe32] wLogClust[0]: 0 [0xe32] glyphProps[0].sva.uJustification: 2 [0xe32] glyphProps[0].sva.fClusterStart: 1 [0xe32] glyphProps[0].sva.fDiacritic: 0 [0xe32] glyphProps[0].sva.fZeroWidth: 0 [0xe33] cItems: 1 [0xe33] items[0].a.fLogicalOrder: 0 [0xe33] items[0].a.fRTL: 0 [0xe33] cGlyphs: 1 [0xe33] charProps[0].fCanGlyphAlone: 0 [0xe33] wLogClust[0]: 0 [0xe33] glyphProps[0].sva.uJustification: 2 [0xe33] glyphProps[0].sva.fClusterStart: 1 [0xe33] glyphProps[0].sva.fDiacritic: 0 [0xe33] glyphProps[0].sva.fZeroWidth: 0 [0xe34] cItems: 1 [0xe34] items[0].a.fLogicalOrder: 0 [0xe34] items[0].a.fRTL: 0 [0xe34] cGlyphs: 2 [0xe34] charProps[0].fCanGlyphAlone: 0 [0xe34] wLogClust[0]: 0 [0xe34] glyphProps[0].sva.uJustification: 0 [0xe34] glyphProps[0].sva.fClusterStart: 1 [0xe34] glyphProps[0].sva.fDiacritic: 0 [0xe34] glyphProps[0].sva.fZeroWidth: 1 [0xe34] glyphProps[1].sva.uJustification: 0 [0xe34] glyphProps[1].sva.fClusterStart: 0 [0xe34] glyphProps[1].sva.fDiacritic: 1 [0xe34] glyphProps[1].sva.fZeroWidth: 0 [0xe35] cItems: 1 [0xe35] items[0].a.fLogicalOrder: 0 [0xe35] items[0].a.fRTL: 0 [0xe35] cGlyphs: 2 [0xe35] charProps[0].fCanGlyphAlone: 0 [0xe35] wLogClust[0]: 0 [0xe35] glyphProps[0].sva.uJustification: 0 [0xe35] glyphProps[0].sva.fClusterStart: 1 [0xe35] glyphProps[0].sva.fDiacritic: 0 [0xe35] glyphProps[0].sva.fZeroWidth: 1 [0xe35] glyphProps[1].sva.uJustification: 0 [0xe35] glyphProps[1].sva.fClusterStart: 0 [0xe35] glyphProps[1].sva.fDiacritic: 1 [0xe35] glyphProps[1].sva.fZeroWidth: 0 [0xe36] cItems: 1 [0xe36] items[0].a.fLogicalOrder: 0 [0xe36] items[0].a.fRTL: 0 [0xe36] cGlyphs: 2 [0xe36] charProps[0].fCanGlyphAlone: 0 [0xe36] wLogClust[0]: 0 [0xe36] glyphProps[0].sva.uJustification: 0 [0xe36] glyphProps[0].sva.fClusterStart: 1 [0xe36] glyphProps[0].sva.fDiacritic: 0 [0xe36] glyphProps[0].sva.fZeroWidth: 1 [0xe36] glyphProps[1].sva.uJustification: 0 [0xe36] glyphProps[1].sva.fClusterStart: 0 [0xe36] glyphProps[1].sva.fDiacritic: 1 [0xe36] glyphProps[1].sva.fZeroWidth: 0 [0xe37] cItems: 1 [0xe37] items[0].a.fLogicalOrder: 0 [0xe37] items[0].a.fRTL: 0 [0xe37] cGlyphs: 2 [0xe37] charProps[0].fCanGlyphAlone: 0 [0xe37] wLogClust[0]: 0 [0xe37] glyphProps[0].sva.uJustification: 0 [0xe37] glyphProps[0].sva.fClusterStart: 1 [0xe37] glyphProps[0].sva.fDiacritic: 0 [0xe37] glyphProps[0].sva.fZeroWidth: 1 [0xe37] glyphProps[1].sva.uJustification: 0 [0xe37] glyphProps[1].sva.fClusterStart: 0 [0xe37] glyphProps[1].sva.fDiacritic: 1 [0xe37] glyphProps[1].sva.fZeroWidth: 0 [0xe38] cItems: 1 [0xe38] items[0].a.fLogicalOrder: 0 [0xe38] items[0].a.fRTL: 0 [0xe38] cGlyphs: 2 [0xe38] charProps[0].fCanGlyphAlone: 0 [0xe38] wLogClust[0]: 0 [0xe38] glyphProps[0].sva.uJustification: 0 [0xe38] glyphProps[0].sva.fClusterStart: 1 [0xe38] glyphProps[0].sva.fDiacritic: 0 [0xe38] glyphProps[0].sva.fZeroWidth: 1 [0xe38] glyphProps[1].sva.uJustification: 0 [0xe38] glyphProps[1].sva.fClusterStart: 0 [0xe38] glyphProps[1].sva.fDiacritic: 1 [0xe38] glyphProps[1].sva.fZeroWidth: 0 [0xe39] cItems: 1 [0xe39] items[0].a.fLogicalOrder: 0 [0xe39] items[0].a.fRTL: 0 [0xe39] cGlyphs: 2 [0xe39] charProps[0].fCanGlyphAlone: 0 [0xe39] wLogClust[0]: 0 [0xe39] glyphProps[0].sva.uJustification: 0 [0xe39] glyphProps[0].sva.fClusterStart: 1 [0xe39] glyphProps[0].sva.fDiacritic: 0 [0xe39] glyphProps[0].sva.fZeroWidth: 1 [0xe39] glyphProps[1].sva.uJustification: 0 [0xe39] glyphProps[1].sva.fClusterStart: 0 [0xe39] glyphProps[1].sva.fDiacritic: 1 [0xe39] glyphProps[1].sva.fZeroWidth: 0 [0xe3a] cItems: 1 [0xe3a] items[0].a.fLogicalOrder: 0 [0xe3a] items[0].a.fRTL: 0 [0xe3a] cGlyphs: 2 [0xe3a] charProps[0].fCanGlyphAlone: 0 [0xe3a] wLogClust[0]: 0 [0xe3a] glyphProps[0].sva.uJustification: 0 [0xe3a] glyphProps[0].sva.fClusterStart: 1 [0xe3a] glyphProps[0].sva.fDiacritic: 0 [0xe3a] glyphProps[0].sva.fZeroWidth: 1 [0xe3a] glyphProps[1].sva.uJustification: 0 [0xe3a] glyphProps[1].sva.fClusterStart: 0 [0xe3a] glyphProps[1].sva.fDiacritic: 1 [0xe3a] glyphProps[1].sva.fZeroWidth: 0 [0xe47] cItems: 1 [0xe47] items[0].a.fLogicalOrder: 0 [0xe47] items[0].a.fRTL: 0 [0xe47] cGlyphs: 2 [0xe47] charProps[0].fCanGlyphAlone: 0 [0xe47] wLogClust[0]: 0 [0xe47] glyphProps[0].sva.uJustification: 0 [0xe47] glyphProps[0].sva.fClusterStart: 1 [0xe47] glyphProps[0].sva.fDiacritic: 0 [0xe47] glyphProps[0].sva.fZeroWidth: 1 [0xe47] glyphProps[1].sva.uJustification: 0 [0xe47] glyphProps[1].sva.fClusterStart: 0 [0xe47] glyphProps[1].sva.fDiacritic: 1 [0xe47] glyphProps[1].sva.fZeroWidth: 0 [0xe48] cItems: 1 [0xe48] items[0].a.fLogicalOrder: 0 [0xe48] items[0].a.fRTL: 0 [0xe48] cGlyphs: 2 [0xe48] charProps[0].fCanGlyphAlone: 0 [0xe48] wLogClust[0]: 0 [0xe48] glyphProps[0].sva.uJustification: 0 [0xe48] glyphProps[0].sva.fClusterStart: 1 [0xe48] glyphProps[0].sva.fDiacritic: 0 [0xe48] glyphProps[0].sva.fZeroWidth: 1 [0xe48] glyphProps[1].sva.uJustification: 0 [0xe48] glyphProps[1].sva.fClusterStart: 0 [0xe48] glyphProps[1].sva.fDiacritic: 1 [0xe48] glyphProps[1].sva.fZeroWidth: 0 [0xe49] cItems: 1 [0xe49] items[0].a.fLogicalOrder: 0 [0xe49] items[0].a.fRTL: 0 [0xe49] cGlyphs: 2 [0xe49] charProps[0].fCanGlyphAlone: 0 [0xe49] wLogClust[0]: 0 [0xe49] glyphProps[0].sva.uJustification: 0 [0xe49] glyphProps[0].sva.fClusterStart: 1 [0xe49] glyphProps[0].sva.fDiacritic: 0 [0xe49] glyphProps[0].sva.fZeroWidth: 1 [0xe49] glyphProps[1].sva.uJustification: 0 [0xe49] glyphProps[1].sva.fClusterStart: 0 [0xe49] glyphProps[1].sva.fDiacritic: 1 [0xe49] glyphProps[1].sva.fZeroWidth: 0 [0xe4a] cItems: 1 [0xe4a] items[0].a.fLogicalOrder: 0 [0xe4a] items[0].a.fRTL: 0 [0xe4a] cGlyphs: 2 [0xe4a] charProps[0].fCanGlyphAlone: 0 [0xe4a] wLogClust[0]: 0 [0xe4a] glyphProps[0].sva.uJustification: 0 [0xe4a] glyphProps[0].sva.fClusterStart: 1 [0xe4a] glyphProps[0].sva.fDiacritic: 0 [0xe4a] glyphProps[0].sva.fZeroWidth: 1 [0xe4a] glyphProps[1].sva.uJustification: 0 [0xe4a] glyphProps[1].sva.fClusterStart: 0 [0xe4a] glyphProps[1].sva.fDiacritic: 1 [0xe4a] glyphProps[1].sva.fZeroWidth: 0 */