Skip to content

Add more tex-output tests #1179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/xdv/examples/xdvdump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
25 changes: 14 additions & 11 deletions crates/xetex_layout/layout/xetex-XeTeXLayoutInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,14 @@
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));

Check warning on line 500 in crates/xetex_layout/layout/xetex-XeTeXLayoutInterface.cpp

View check run for this annotation

Codecov / codecov/patch

crates/xetex_layout/layout/xetex-XeTeXLayoutInterface.cpp#L500

Added line #L500 was not covered by tests
} else {
return 0;
}
}

uint32_t
getGraphiteFeatureDefaultSetting(XeTeXLayoutEngine engine, uint32_t featureID)
Expand Down Expand Up @@ -595,17 +602,15 @@
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;
Expand All @@ -627,17 +632,15 @@
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;
Expand Down
Binary file added tests/assets/Inconsolatazi4-Regular.otf
Binary file not shown.
Binary file added tests/assets/LinLibertine_R_G.ttf
Binary file not shown.
25 changes: 25 additions & 0 deletions tests/tex-outputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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()
Expand Down Expand Up @@ -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()
}
3 changes: 3 additions & 0 deletions tests/tex-outputs/graphite_basic.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**
(graphite_basic.tex [1] )
Output written on graphite_basic.xdv (1 page, 372 bytes).
5 changes: 5 additions & 0 deletions tests/tex-outputs/graphite_basic.tex
Original file line number Diff line number Diff line change
@@ -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
Binary file added tests/tex-outputs/graphite_basic.xdv
Binary file not shown.
13 changes: 13 additions & 0 deletions tests/tex-outputs/utf8_chars.log
Original file line number Diff line number Diff line change
@@ -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).
8 changes: 8 additions & 0 deletions tests/tex-outputs/utf8_chars.tex
Original file line number Diff line number Diff line change
@@ -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
Binary file added tests/tex-outputs/utf8_chars.xdv
Binary file not shown.
3 changes: 3 additions & 0 deletions tests/tex-outputs/xetex_g_builtins.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**
(xetex_g_builtins.tex [1] )
Output written on xetex_g_builtins.xdv (1 page, 760 bytes).
Binary file added tests/tex-outputs/xetex_g_builtins.pdf
Binary file not shown.
33 changes: 33 additions & 0 deletions tests/tex-outputs/xetex_g_builtins.tex
Original file line number Diff line number Diff line change
@@ -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
Binary file added tests/tex-outputs/xetex_g_builtins.xdv
Binary file not shown.
3 changes: 3 additions & 0 deletions tests/tex-outputs/xetex_ot_builtins.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**
(xetex_ot_builtins.tex [1] )
Output written on xetex_ot_builtins.xdv (1 page, 664 bytes).
Binary file added tests/tex-outputs/xetex_ot_builtins.pdf
Binary file not shown.
28 changes: 28 additions & 0 deletions tests/tex-outputs/xetex_ot_builtins.tex
Original file line number Diff line number Diff line change
@@ -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
Binary file added tests/tex-outputs/xetex_ot_builtins.xdv
Binary file not shown.