Skip to content

Commit 19654bf

Browse files
authored
Merge pull request #1179 from CraftSpider/output-tests
Add more tex-output tests
2 parents 1520823 + 3037b2c commit 19654bf

19 files changed

+136
-11
lines changed

crates/xdv/examples/xdvdump.rs

+1
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ fn main() {
154154
)
155155
.arg(
156156
Arg::new("PATH")
157+
.value_parser(clap::value_parser!(PathBuf))
157158
.help("The path to the XDV or SPX file")
158159
.required(true)
159160
.index(1),

crates/xetex_layout/layout/xetex-XeTeXLayoutInterface.cpp

+14-11
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,14 @@ getGraphiteFeatureSettingCode(XeTeXLayoutEngine engine, uint32_t featureID, uint
494494
return rval;
495495
}
496496

497-
#define tag_from_lang(x) hb_tag_from_string(hb_language_to_string(x), strlen(hb_language_to_string(x)))
497+
hb_tag_t tag_from_lang(hb_language_t lang) {
498+
const char* str = hb_language_to_string(lang);
499+
if (str) {
500+
return hb_tag_from_string(str, strlen(str));
501+
} else {
502+
return 0;
503+
}
504+
}
498505

499506
uint32_t
500507
getGraphiteFeatureDefaultSetting(XeTeXLayoutEngine engine, uint32_t featureID)
@@ -595,17 +602,15 @@ findGraphiteFeatureNamed(XeTeXLayoutEngine engine, const char* name, int namelen
595602
gr_face* grFace = hb_graphite2_face_get_gr_face(hbFace);
596603

597604
if (grFace != NULL) {
605+
hb_tag_t tag = hb_tag_from_string(name, namelength);
598606
for (int i = 0; i < gr_face_n_fref(grFace); i++) {
599607
const gr_feature_ref* feature = gr_face_fref(grFace, i);
600608
uint32_t len = 0;
601609
uint16_t langID = 0x409;
602610

603-
// the first call is to get the length of the string
604-
gr_fref_label(feature, &langID, gr_utf8, &len);
605-
char* label = (char*) xmalloc(len);
606-
label = (char*) gr_fref_label(feature, &langID, gr_utf8, &len);
611+
char* label = (char*)gr_fref_label(feature, &langID, gr_utf8, &len);
607612

608-
if (strncmp(label, name, namelength) == 0) {
613+
if (gr_fref_id(feature) == tag || strncmp(label, name, namelength) == 0) {
609614
rval = gr_fref_id(feature);
610615
gr_label_destroy(label);
611616
break;
@@ -627,17 +632,15 @@ findGraphiteFeatureSettingNamed(XeTeXLayoutEngine engine, uint32_t id, const cha
627632
gr_face* grFace = hb_graphite2_face_get_gr_face(hbFace);
628633

629634
if (grFace != NULL) {
635+
hb_tag_t tag = hb_tag_from_string(name, namelength);
630636
const gr_feature_ref* feature = gr_face_find_fref(grFace, id);
631637
for (int i = 0; i < gr_fref_n_values(feature); i++) {
632638
uint32_t len = 0;
633639
uint16_t langID = 0x409;
634640

635-
// the first call is to get the length of the string
636-
gr_fref_value_label(feature, i, &langID, gr_utf8, &len);
637-
char* label = (char*) xmalloc(len);
638-
label = (char*) gr_fref_value_label(feature, i, &langID, gr_utf8, &len);
641+
char* label = (char*)gr_fref_value_label(feature, i, &langID, gr_utf8, &len);
639642

640-
if (strncmp(label, name, namelength) == 0) {
643+
if (gr_fref_id(feature) == tag || strncmp(label, name, namelength) == 0) {
641644
rval = gr_fref_value(feature, i);
642645
gr_label_destroy(label);
643646
break;
36.5 KB
Binary file not shown.

tests/assets/LinLibertine_R_G.ttf

2.45 MB
Binary file not shown.

tests/tex-outputs.rs

+25
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,16 @@ fn file_encoding() {
199199
.go()
200200
}
201201

202+
// Works around an issue where old (~2.7) Harfbuzz lays out glyphs differently.
203+
// Remove this once all external Harfbuzz versions don't exhibit the glyph-swapping behavior.
204+
#[cfg(not(any(feature = "external-harfbuzz", target_arch = "x86")))]
205+
#[test]
206+
fn utf8_chars() {
207+
TestCase::new("utf8_chars")
208+
.expect(Ok(TexOutcome::Warnings))
209+
.go();
210+
}
211+
202212
/// An issue triggered by a bug in how the I/O subsystem reported file offsets
203213
/// after an ungetc() call.
204214
#[test]
@@ -225,6 +235,11 @@ fn otf_basic() {
225235
.go()
226236
}
227237

238+
#[test]
239+
fn graphite_basic() {
240+
TestCase::new("graphite_basic").go()
241+
}
242+
228243
#[test]
229244
fn prim_creationdate() {
230245
TestCase::new("prim_creationdate").go()
@@ -338,3 +353,13 @@ fn tectoniccodatokens_ok() {
338353
fn the_letter_a() {
339354
TestCase::new("the_letter_a").check_pdf(true).go()
340355
}
356+
357+
#[test]
358+
fn xetex_g_builtins() {
359+
TestCase::new("xetex_g_builtins").check_pdf(true).go()
360+
}
361+
362+
#[test]
363+
fn xetex_ot_builtins() {
364+
TestCase::new("xetex_ot_builtins").check_pdf(true).go()
365+
}

tests/tex-outputs/graphite_basic.log

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**
2+
(graphite_basic.tex [1] )
3+
Output written on graphite_basic.xdv (1 page, 372 bytes).

tests/tex-outputs/graphite_basic.tex

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
\font\g="[LinLibertine_R_G]/GR:ss05=True"
2+
3+
% The LinLibertine ss05 W is the same style as Wikipedia - this just makes sure the feature is enabled correctly.
4+
\g Wikipedia
5+
\bye

tests/tex-outputs/graphite_basic.xdv

372 Bytes
Binary file not shown.

tests/tex-outputs/utf8_chars.log

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
**
2+
(utf8_chars.tex
3+
Missing character: There is no א (U+05D0) in font [lmroman12-regular]!
4+
Missing character: There is no ֳ (U+05B3) in font [lmroman12-regular]!
5+
Missing character: There is no ר (U+05E8) in font [lmroman12-regular]!
6+
Missing character: There is no ָ (U+05B8) in font [lmroman12-regular]!
7+
Missing character: There is no נ (U+05E0) in font [lmroman12-regular]!
8+
Missing character: There is no ִ (U+05B4) in font [lmroman12-regular]!
9+
Missing character: There is no י (U+05D9) in font [lmroman12-regular]!
10+
Missing character: There is no ם (U+05DD) in font [lmroman12-regular]!
11+
Missing character: There is no ֳ (U+05B3) in font [lmroman12-regular]!
12+
[1] )
13+
Output written on utf8_chars.xdv (1 page, 728 bytes).

tests/tex-outputs/utf8_chars.tex

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
% Examples of non-ASCII/Latin text
2+
\font\r="[lmroman12-regular]"
3+
4+
% Missing in font - intentional
5+
\r Hebrew: אֳרָנִים
6+
\r Hebrew modifier on Latin: 9ֳ9
7+
8+
\bye

tests/tex-outputs/utf8_chars.xdv

728 Bytes
Binary file not shown.
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**
2+
(xetex_g_builtins.tex [1] )
3+
Output written on xetex_g_builtins.xdv (1 page, 760 bytes).
8.18 KB
Binary file not shown.
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
\font\g="[LinLibertine_R_G]/GR"
2+
3+
Features: \the\XeTeXcountfeatures \g
4+
5+
- Code: \the\XeTeXfeaturecode \g 0
6+
7+
- Name: \XeTeXfeaturename \g 1664250723
8+
9+
- Code: \the\XeTeXfeaturecode \g 1
10+
11+
- Name: \XeTeXfeaturename \g 1667330917
12+
13+
- Code: \the\XeTeXfeaturecode \g 2
14+
15+
- Name: \XeTeXfeaturename \g 1684826471
16+
17+
- Code: \the\XeTeXfeaturecode \g 3
18+
19+
- Name: \XeTeXfeaturename \g 1718185569
20+
21+
- Selectors: \the\XeTeXcountselectors \g 1718185569
22+
23+
- - Default is False: \the\XeTeXisdefaultselector \g 1718185569 0
24+
25+
- - Code: \the\XeTeXselectorcode \g 1718185569 0
26+
27+
- - Name: \XeTeXselectorname \g 1718185569 0
28+
29+
- - Code: \the\XeTeXselectorcode \g 1718185569 1
30+
31+
- - Name: \XeTeXselectorname \g 1718185569 1
32+
33+
\bye
760 Bytes
Binary file not shown.
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**
2+
(xetex_ot_builtins.tex [1] )
3+
Output written on xetex_ot_builtins.xdv (1 page, 664 bytes).
6.24 KB
Binary file not shown.
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
\font\i="[Inconsolatazi4-Regular.otf]/OT"
2+
Scripts: \the\XeTeXOTcountscripts \i
3+
4+
Script 0: \the\XeTeXOTscripttag \i 0
5+
6+
- Languages: \the\XeTeXOTcountlanguages \i 1145457748
7+
8+
- - Features: \the\XeTeXOTcountfeatures \i 1145457748 0
9+
10+
- - Feature 0: \the\XeTeXOTfeaturetag \i 1145457748 0 0
11+
12+
- - Feature 1: \the\XeTeXOTfeaturetag \i 1145457748 0 1
13+
14+
- - Feature 2: \the\XeTeXOTfeaturetag \i 1145457748 0 2
15+
16+
Script 1: \the\XeTeXOTscripttag \i 1
17+
18+
- Languages: \the\XeTeXOTcountlanguages \i 1
19+
20+
- - Features: \the\XeTeXOTcountfeatures \i 1818326126 0
21+
22+
- - Feature 0: \the\XeTeXOTfeaturetag \i 1818326126 0 0
23+
24+
- - Feature 1: \the\XeTeXOTfeaturetag \i 1818326126 0 1
25+
26+
- - Feature 2: \the\XeTeXOTfeaturetag \i 1818326126 0 2
27+
28+
\bye
664 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)