diff --git a/crates/xdv/examples/xdvdump.rs b/crates/xdv/examples/xdvdump.rs index 7252cfee26..a585d4d5cd 100644 --- a/crates/xdv/examples/xdvdump.rs +++ b/crates/xdv/examples/xdvdump.rs @@ -154,6 +154,7 @@ fn main() { ) .arg( Arg::new("PATH") + .value_parser(clap::value_parser!(PathBuf)) .help("The path to the XDV or SPX file") .required(true) .index(1), diff --git a/crates/xetex_layout/layout/xetex-XeTeXLayoutInterface.cpp b/crates/xetex_layout/layout/xetex-XeTeXLayoutInterface.cpp index 89c1de6a10..e73af34714 100644 --- a/crates/xetex_layout/layout/xetex-XeTeXLayoutInterface.cpp +++ b/crates/xetex_layout/layout/xetex-XeTeXLayoutInterface.cpp @@ -494,7 +494,14 @@ getGraphiteFeatureSettingCode(XeTeXLayoutEngine engine, uint32_t featureID, uint return rval; } -#define tag_from_lang(x) hb_tag_from_string(hb_language_to_string(x), strlen(hb_language_to_string(x))) +hb_tag_t tag_from_lang(hb_language_t lang) { + const char* str = hb_language_to_string(lang); + if (str) { + return hb_tag_from_string(str, strlen(str)); + } else { + return 0; + } +} uint32_t getGraphiteFeatureDefaultSetting(XeTeXLayoutEngine engine, uint32_t featureID) @@ -595,17 +602,15 @@ findGraphiteFeatureNamed(XeTeXLayoutEngine engine, const char* name, int namelen gr_face* grFace = hb_graphite2_face_get_gr_face(hbFace); if (grFace != NULL) { + hb_tag_t tag = hb_tag_from_string(name, namelength); for (int i = 0; i < gr_face_n_fref(grFace); i++) { const gr_feature_ref* feature = gr_face_fref(grFace, i); uint32_t len = 0; uint16_t langID = 0x409; - // the first call is to get the length of the string - gr_fref_label(feature, &langID, gr_utf8, &len); - char* label = (char*) xmalloc(len); - label = (char*) gr_fref_label(feature, &langID, gr_utf8, &len); + char* label = (char*)gr_fref_label(feature, &langID, gr_utf8, &len); - if (strncmp(label, name, namelength) == 0) { + if (gr_fref_id(feature) == tag || strncmp(label, name, namelength) == 0) { rval = gr_fref_id(feature); gr_label_destroy(label); break; @@ -627,17 +632,15 @@ findGraphiteFeatureSettingNamed(XeTeXLayoutEngine engine, uint32_t id, const cha gr_face* grFace = hb_graphite2_face_get_gr_face(hbFace); if (grFace != NULL) { + hb_tag_t tag = hb_tag_from_string(name, namelength); const gr_feature_ref* feature = gr_face_find_fref(grFace, id); for (int i = 0; i < gr_fref_n_values(feature); i++) { uint32_t len = 0; uint16_t langID = 0x409; - // the first call is to get the length of the string - gr_fref_value_label(feature, i, &langID, gr_utf8, &len); - char* label = (char*) xmalloc(len); - label = (char*) gr_fref_value_label(feature, i, &langID, gr_utf8, &len); + char* label = (char*)gr_fref_value_label(feature, i, &langID, gr_utf8, &len); - if (strncmp(label, name, namelength) == 0) { + if (gr_fref_id(feature) == tag || strncmp(label, name, namelength) == 0) { rval = gr_fref_value(feature, i); gr_label_destroy(label); break; diff --git a/tests/assets/Inconsolatazi4-Regular.otf b/tests/assets/Inconsolatazi4-Regular.otf new file mode 100644 index 0000000000..a735537603 Binary files /dev/null and b/tests/assets/Inconsolatazi4-Regular.otf differ diff --git a/tests/assets/LinLibertine_R_G.ttf b/tests/assets/LinLibertine_R_G.ttf new file mode 100644 index 0000000000..78ca7b0ed9 Binary files /dev/null and b/tests/assets/LinLibertine_R_G.ttf differ diff --git a/tests/tex-outputs.rs b/tests/tex-outputs.rs index 9b42140a7c..27f64b33aa 100644 --- a/tests/tex-outputs.rs +++ b/tests/tex-outputs.rs @@ -199,6 +199,16 @@ fn file_encoding() { .go() } +// Works around an issue where old (~2.7) Harfbuzz lays out glyphs differently. +// Remove this once all external Harfbuzz versions don't exhibit the glyph-swapping behavior. +#[cfg(not(any(feature = "external-harfbuzz", target_arch = "x86")))] +#[test] +fn utf8_chars() { + TestCase::new("utf8_chars") + .expect(Ok(TexOutcome::Warnings)) + .go(); +} + /// An issue triggered by a bug in how the I/O subsystem reported file offsets /// after an ungetc() call. #[test] @@ -225,6 +235,11 @@ fn otf_basic() { .go() } +#[test] +fn graphite_basic() { + TestCase::new("graphite_basic").go() +} + #[test] fn prim_creationdate() { TestCase::new("prim_creationdate").go() @@ -338,3 +353,13 @@ fn tectoniccodatokens_ok() { fn the_letter_a() { TestCase::new("the_letter_a").check_pdf(true).go() } + +#[test] +fn xetex_g_builtins() { + TestCase::new("xetex_g_builtins").check_pdf(true).go() +} + +#[test] +fn xetex_ot_builtins() { + TestCase::new("xetex_ot_builtins").check_pdf(true).go() +} diff --git a/tests/tex-outputs/graphite_basic.log b/tests/tex-outputs/graphite_basic.log new file mode 100644 index 0000000000..d2f8d27b46 --- /dev/null +++ b/tests/tex-outputs/graphite_basic.log @@ -0,0 +1,3 @@ +** +(graphite_basic.tex [1] ) +Output written on graphite_basic.xdv (1 page, 372 bytes). diff --git a/tests/tex-outputs/graphite_basic.tex b/tests/tex-outputs/graphite_basic.tex new file mode 100644 index 0000000000..c1d5c392e7 --- /dev/null +++ b/tests/tex-outputs/graphite_basic.tex @@ -0,0 +1,5 @@ +\font\g="[LinLibertine_R_G]/GR:ss05=True" + +% The LinLibertine ss05 W is the same style as Wikipedia - this just makes sure the feature is enabled correctly. +\g Wikipedia +\bye \ No newline at end of file diff --git a/tests/tex-outputs/graphite_basic.xdv b/tests/tex-outputs/graphite_basic.xdv new file mode 100644 index 0000000000..0343856a59 Binary files /dev/null and b/tests/tex-outputs/graphite_basic.xdv differ diff --git a/tests/tex-outputs/utf8_chars.log b/tests/tex-outputs/utf8_chars.log new file mode 100644 index 0000000000..6f82d0d2d4 --- /dev/null +++ b/tests/tex-outputs/utf8_chars.log @@ -0,0 +1,13 @@ +** +(utf8_chars.tex +Missing character: There is no א (U+05D0) in font [lmroman12-regular]! +Missing character: There is no ֳ (U+05B3) in font [lmroman12-regular]! +Missing character: There is no ר (U+05E8) in font [lmroman12-regular]! +Missing character: There is no ָ (U+05B8) in font [lmroman12-regular]! +Missing character: There is no נ (U+05E0) in font [lmroman12-regular]! +Missing character: There is no ִ (U+05B4) in font [lmroman12-regular]! +Missing character: There is no י (U+05D9) in font [lmroman12-regular]! +Missing character: There is no ם (U+05DD) in font [lmroman12-regular]! +Missing character: There is no ֳ (U+05B3) in font [lmroman12-regular]! + [1] ) +Output written on utf8_chars.xdv (1 page, 728 bytes). diff --git a/tests/tex-outputs/utf8_chars.tex b/tests/tex-outputs/utf8_chars.tex new file mode 100644 index 0000000000..1801231239 --- /dev/null +++ b/tests/tex-outputs/utf8_chars.tex @@ -0,0 +1,8 @@ +% Examples of non-ASCII/Latin text +\font\r="[lmroman12-regular]" + +% Missing in font - intentional +\r Hebrew: אֳרָנִים +\r Hebrew modifier on Latin: 9ֳ9 + +\bye \ No newline at end of file diff --git a/tests/tex-outputs/utf8_chars.xdv b/tests/tex-outputs/utf8_chars.xdv new file mode 100644 index 0000000000..82aabed0c7 Binary files /dev/null and b/tests/tex-outputs/utf8_chars.xdv differ diff --git a/tests/tex-outputs/xetex_g_builtins.log b/tests/tex-outputs/xetex_g_builtins.log new file mode 100644 index 0000000000..2bbd9f85f2 --- /dev/null +++ b/tests/tex-outputs/xetex_g_builtins.log @@ -0,0 +1,3 @@ +** +(xetex_g_builtins.tex [1] ) +Output written on xetex_g_builtins.xdv (1 page, 760 bytes). diff --git a/tests/tex-outputs/xetex_g_builtins.pdf b/tests/tex-outputs/xetex_g_builtins.pdf new file mode 100644 index 0000000000..356b52489f Binary files /dev/null and b/tests/tex-outputs/xetex_g_builtins.pdf differ diff --git a/tests/tex-outputs/xetex_g_builtins.tex b/tests/tex-outputs/xetex_g_builtins.tex new file mode 100644 index 0000000000..901c05b953 --- /dev/null +++ b/tests/tex-outputs/xetex_g_builtins.tex @@ -0,0 +1,33 @@ +\font\g="[LinLibertine_R_G]/GR" + +Features: \the\XeTeXcountfeatures \g + +- Code: \the\XeTeXfeaturecode \g 0 + +- Name: \XeTeXfeaturename \g 1664250723 + +- Code: \the\XeTeXfeaturecode \g 1 + +- Name: \XeTeXfeaturename \g 1667330917 + +- Code: \the\XeTeXfeaturecode \g 2 + +- Name: \XeTeXfeaturename \g 1684826471 + +- Code: \the\XeTeXfeaturecode \g 3 + +- Name: \XeTeXfeaturename \g 1718185569 + +- Selectors: \the\XeTeXcountselectors \g 1718185569 + +- - Default is False: \the\XeTeXisdefaultselector \g 1718185569 0 + +- - Code: \the\XeTeXselectorcode \g 1718185569 0 + +- - Name: \XeTeXselectorname \g 1718185569 0 + +- - Code: \the\XeTeXselectorcode \g 1718185569 1 + +- - Name: \XeTeXselectorname \g 1718185569 1 + +\bye diff --git a/tests/tex-outputs/xetex_g_builtins.xdv b/tests/tex-outputs/xetex_g_builtins.xdv new file mode 100644 index 0000000000..5ecf1ad610 Binary files /dev/null and b/tests/tex-outputs/xetex_g_builtins.xdv differ diff --git a/tests/tex-outputs/xetex_ot_builtins.log b/tests/tex-outputs/xetex_ot_builtins.log new file mode 100644 index 0000000000..47a8ac8f12 --- /dev/null +++ b/tests/tex-outputs/xetex_ot_builtins.log @@ -0,0 +1,3 @@ +** +(xetex_ot_builtins.tex [1] ) +Output written on xetex_ot_builtins.xdv (1 page, 664 bytes). diff --git a/tests/tex-outputs/xetex_ot_builtins.pdf b/tests/tex-outputs/xetex_ot_builtins.pdf new file mode 100644 index 0000000000..4abd873fef Binary files /dev/null and b/tests/tex-outputs/xetex_ot_builtins.pdf differ diff --git a/tests/tex-outputs/xetex_ot_builtins.tex b/tests/tex-outputs/xetex_ot_builtins.tex new file mode 100644 index 0000000000..24694ecefc --- /dev/null +++ b/tests/tex-outputs/xetex_ot_builtins.tex @@ -0,0 +1,28 @@ +\font\i="[Inconsolatazi4-Regular.otf]/OT" +Scripts: \the\XeTeXOTcountscripts \i + +Script 0: \the\XeTeXOTscripttag \i 0 + +- Languages: \the\XeTeXOTcountlanguages \i 1145457748 + +- - Features: \the\XeTeXOTcountfeatures \i 1145457748 0 + +- - Feature 0: \the\XeTeXOTfeaturetag \i 1145457748 0 0 + +- - Feature 1: \the\XeTeXOTfeaturetag \i 1145457748 0 1 + +- - Feature 2: \the\XeTeXOTfeaturetag \i 1145457748 0 2 + +Script 1: \the\XeTeXOTscripttag \i 1 + +- Languages: \the\XeTeXOTcountlanguages \i 1 + +- - Features: \the\XeTeXOTcountfeatures \i 1818326126 0 + +- - Feature 0: \the\XeTeXOTfeaturetag \i 1818326126 0 0 + +- - Feature 1: \the\XeTeXOTfeaturetag \i 1818326126 0 1 + +- - Feature 2: \the\XeTeXOTfeaturetag \i 1818326126 0 2 + +\bye diff --git a/tests/tex-outputs/xetex_ot_builtins.xdv b/tests/tex-outputs/xetex_ot_builtins.xdv new file mode 100644 index 0000000000..dbfe527acc Binary files /dev/null and b/tests/tex-outputs/xetex_ot_builtins.xdv differ