diff options
| author | Eli Zaretskii | 2019-06-01 19:44:10 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2019-06-01 19:44:10 +0300 |
| commit | eeb54aa3e90a23ccd9bf2581a864f949814d428d (patch) | |
| tree | db0b4d7882b833f5acdf5bd7a9f97a0aa489f16e /src | |
| parent | a1f26686d499fbd7363a5fd638252266e895a726 (diff) | |
| download | emacs-eeb54aa3e90a23ccd9bf2581a864f949814d428d.tar.gz emacs-eeb54aa3e90a23ccd9bf2581a864f949814d428d.zip | |
Implement the get_variation_glyphs method for HarfBuzz on MS-Windows
* src/w32uniscribe.c [HAVE_HARFBUZZ]: DEF_DLL_FN
hb_font_get_variation_glyph.
(hb_font_get_variation_glyph): New redirection macro.
(w32hb_get_variation_glyphs): New function.
(load_harfbuzz_funcs): Load hb_font_get_variation_glyph.
(syms_of_w32uniscribe_for_pdumper): Populate the
get_variation_glyphs method of harfbuzz_font_driver.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32uniscribe.c | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/src/w32uniscribe.c b/src/w32uniscribe.c index 5372eb15252..01f89f0d36c 100644 --- a/src/w32uniscribe.c +++ b/src/w32uniscribe.c | |||
| @@ -86,6 +86,8 @@ DEF_DLL_FN (void, hb_face_destroy, (hb_face_t *)); | |||
| 86 | DEF_DLL_FN (unsigned int, hb_face_get_upem, (hb_face_t *)); | 86 | DEF_DLL_FN (unsigned int, hb_face_get_upem, (hb_face_t *)); |
| 87 | DEF_DLL_FN (hb_bool_t, hb_font_get_nominal_glyph, | 87 | DEF_DLL_FN (hb_bool_t, hb_font_get_nominal_glyph, |
| 88 | (hb_font_t *, hb_codepoint_t, hb_codepoint_t *)); | 88 | (hb_font_t *, hb_codepoint_t, hb_codepoint_t *)); |
| 89 | DEF_DLL_FN (hb_bool_t, hb_font_get_variation_glyph, | ||
| 90 | (hb_font_t *, hb_codepoint_t, hb_codepoint_t, hb_codepoint_t *)); | ||
| 89 | 91 | ||
| 90 | #define hb_blob_create fn_hb_blob_create | 92 | #define hb_blob_create fn_hb_blob_create |
| 91 | #define hb_face_create_for_tables fn_hb_face_create_for_tables | 93 | #define hb_face_create_for_tables fn_hb_face_create_for_tables |
| @@ -95,6 +97,7 @@ DEF_DLL_FN (hb_bool_t, hb_font_get_nominal_glyph, | |||
| 95 | #define hb_face_destroy fn_hb_face_destroy | 97 | #define hb_face_destroy fn_hb_face_destroy |
| 96 | #define hb_face_get_upem fn_hb_face_get_upem | 98 | #define hb_face_get_upem fn_hb_face_get_upem |
| 97 | #define hb_font_get_nominal_glyph fn_hb_font_get_nominal_glyph | 99 | #define hb_font_get_nominal_glyph fn_hb_font_get_nominal_glyph |
| 100 | #define hb_font_get_variation_glyph fn_hb_font_get_variation_glyph | ||
| 98 | #endif | 101 | #endif |
| 99 | 102 | ||
| 100 | /* Used by uniscribe_otf_capability. */ | 103 | /* Used by uniscribe_otf_capability. */ |
| @@ -1377,6 +1380,50 @@ w32hb_begin_font (struct font *font, double *position_unit) | |||
| 1377 | *position_unit = uniscribe_font->scale; | 1380 | *position_unit = uniscribe_font->scale; |
| 1378 | return (hb_font_t *) uniscribe_font->cache; | 1381 | return (hb_font_t *) uniscribe_font->cache; |
| 1379 | } | 1382 | } |
| 1383 | |||
| 1384 | /* W32 implementation of get_variation_glyphs method for HarfBuzz. | ||
| 1385 | |||
| 1386 | Return the number of variation glyphs of character C supported by | ||
| 1387 | FONT. VARIATIONS is an array of 256 elements. If the variation | ||
| 1388 | selector N (1..256) defines a glyph, that glyph code is stored in | ||
| 1389 | the (N-1)th element of VARIATIONS. */ | ||
| 1390 | static int | ||
| 1391 | w32hb_get_variation_glyphs (struct font *font, int c, unsigned variations[256]) | ||
| 1392 | { | ||
| 1393 | struct uniscribe_font_info *uniscribe_font | ||
| 1394 | = (struct uniscribe_font_info *) font; | ||
| 1395 | eassert (uniscribe_font->w32_font.font.driver == &harfbuzz_font_driver); | ||
| 1396 | |||
| 1397 | /* First time we use this font with HarfBuzz, create the hb_font_t | ||
| 1398 | object and cache it. */ | ||
| 1399 | if (!uniscribe_font->cache) | ||
| 1400 | { | ||
| 1401 | double scale; | ||
| 1402 | uniscribe_font->cache = w32hb_get_font (font, &scale); | ||
| 1403 | eassert (scale > 0.0); | ||
| 1404 | uniscribe_font->scale = scale; | ||
| 1405 | } | ||
| 1406 | |||
| 1407 | int i, n = 0; | ||
| 1408 | hb_font_t *hb_font = uniscribe_font->cache; | ||
| 1409 | for (i = 0; i < 16; i++) | ||
| 1410 | { | ||
| 1411 | if (hb_font_get_variation_glyph (hb_font, c, 0xFE00 + i, &variations[i])) | ||
| 1412 | n++; | ||
| 1413 | else | ||
| 1414 | variations[i] = 0; | ||
| 1415 | } | ||
| 1416 | for ( ; i < 256; i++) | ||
| 1417 | { | ||
| 1418 | if (hb_font_get_variation_glyph (hb_font, c, 0xE0100 + (i - 16), | ||
| 1419 | &variations[i])) | ||
| 1420 | n++; | ||
| 1421 | else | ||
| 1422 | variations[i] = 0; | ||
| 1423 | } | ||
| 1424 | |||
| 1425 | return n; | ||
| 1426 | } | ||
| 1380 | #endif /* HAVE_HARFBUZZ */ | 1427 | #endif /* HAVE_HARFBUZZ */ |
| 1381 | 1428 | ||
| 1382 | #undef OTF_INT16_VAL | 1429 | #undef OTF_INT16_VAL |
| @@ -1439,6 +1486,7 @@ load_harfbuzz_funcs (HMODULE library) | |||
| 1439 | LOAD_DLL_FN (library, hb_face_get_upem); | 1486 | LOAD_DLL_FN (library, hb_face_get_upem); |
| 1440 | LOAD_DLL_FN (library, hb_face_destroy); | 1487 | LOAD_DLL_FN (library, hb_face_destroy); |
| 1441 | LOAD_DLL_FN (library, hb_font_get_nominal_glyph); | 1488 | LOAD_DLL_FN (library, hb_font_get_nominal_glyph); |
| 1489 | LOAD_DLL_FN (library, hb_font_get_variation_glyph); | ||
| 1442 | return hbfont_init_w32_funcs (library); | 1490 | return hbfont_init_w32_funcs (library); |
| 1443 | } | 1491 | } |
| 1444 | #endif /* HAVE_HARFBUZZ */ | 1492 | #endif /* HAVE_HARFBUZZ */ |
| @@ -1474,7 +1522,7 @@ syms_of_w32uniscribe_for_pdumper (void) | |||
| 1474 | 1522 | ||
| 1475 | #ifdef HAVE_HARFBUZZ | 1523 | #ifdef HAVE_HARFBUZZ |
| 1476 | /* Currently, HarfBuzz DLLs are always named libharfbuzz-0.dll, as | 1524 | /* Currently, HarfBuzz DLLs are always named libharfbuzz-0.dll, as |
| 1477 | the project keeps the ABI backeard-compatible. So we can | 1525 | the project keeps the ABI backward-compatible. So we can |
| 1478 | hard-code the name of the library here, for now. If they ever | 1526 | hard-code the name of the library here, for now. If they ever |
| 1479 | break ABI compatibility, we may need to load the DLL that | 1527 | break ABI compatibility, we may need to load the DLL that |
| 1480 | corresponds to the HarfBuzz version for which Emacs was built. */ | 1528 | corresponds to the HarfBuzz version for which Emacs was built. */ |
| @@ -1493,6 +1541,7 @@ syms_of_w32uniscribe_for_pdumper (void) | |||
| 1493 | harfbuzz_font_driver.match = w32hb_match; | 1541 | harfbuzz_font_driver.match = w32hb_match; |
| 1494 | harfbuzz_font_driver.encode_char = w32hb_encode_char; | 1542 | harfbuzz_font_driver.encode_char = w32hb_encode_char; |
| 1495 | harfbuzz_font_driver.shape = hbfont_shape; | 1543 | harfbuzz_font_driver.shape = hbfont_shape; |
| 1544 | harfbuzz_font_driver.get_variation_glyphs = w32hb_get_variation_glyphs; | ||
| 1496 | harfbuzz_font_driver.combining_capability = hbfont_combining_capability; | 1545 | harfbuzz_font_driver.combining_capability = hbfont_combining_capability; |
| 1497 | harfbuzz_font_driver.begin_hb_font = w32hb_begin_font; | 1546 | harfbuzz_font_driver.begin_hb_font = w32hb_begin_font; |
| 1498 | register_font_driver (&harfbuzz_font_driver, NULL); | 1547 | register_font_driver (&harfbuzz_font_driver, NULL); |