Skip to content

Commit 1cc817a

Browse files
committed
Support for Dumping Font and Color objects, mainly to quiet the process
1 parent 598d91d commit 1cc817a

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

lib/LaTeXML/Common/Font.pm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ my %font_family = (
113113
pxmi => { family => 'serif', shape => 'italic' },
114114
pxsya => { encoding => 'AMSa' },
115115
pxsyb => { encoding => 'AMSb' },
116+
# Pretend to recognize plain & latex's extra fonts (currently no encoding set up)
117+
manfnt => { family => 'graphic', encoding=>'manfnt' },
118+
line => { family => 'graphic', encoding=>'line' },
119+
linew => { family => 'graphic', encoding=>'line', series=>'bold' },
120+
lcircle => { family => 'graphic', encoding=>'lcircle' },
121+
lcirclew => { family => 'graphic', encoding=>'lcircle', series=>'bold' },
116122
# Pretend to recognize xy's fonts
117123
xydash => { family => 'graphic' },
118124
xyatip => { family => 'graphic' },

lib/LaTeXML/Core/Dumper.pm

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ our @EXPORT_OK = (
2929
qw($D0 $G0 $MD0 $MG0 $N0),
3030
qw($PPLAIN),
3131
qw($TA $TB $TE $TM $TP $TS $TSB $TSP),
32-
qw(&Dump &_Exp &_CDef &_Reg &_Par &_Pars &_FDef),
32+
qw(&Dump &_Exp &_CDef &_Reg &_Par &_Pars &_FDef &_Font &_RGB),
3333
);
3434
our %EXPORT_TAGS = (
3535
load => [
3636
qw($D0 $G0 $MD0 $MG0 $N0),
3737
qw($PPLAIN),
3838
qw($TA $TB $TE $TM $TP $TS $TSB $TSP),
39-
qw(&_Exp &_CDef &_Reg &_Par &_Pars &_FDef),
39+
qw(&_Exp &_CDef &_Reg &_Par &_Pars &_FDef &_Font &_RGB),
4040
],
4141
);
4242

@@ -92,6 +92,13 @@ sub _FDef {
9292
my ($cs, $fontID) = @_;
9393
return LaTeXML::Core::Definition::FontDef->new($cs, $fontID); }
9494

95+
sub _Font {
96+
return LaTeXML::Common::Font->new_internal(@_); }
97+
98+
sub _RGB {
99+
my($r,$g,$b)=@_;
100+
return bless ['rgb', $r, $g, $b], 'LaTeXML::Common::Color::rgb'; }
101+
95102
#======================================================================
96103
our %transchar = (
97104
'@' => '\\@', '$' => '\\\$', "'" => '\\\'', '"' => '\\"', '\\' => "\\\\", # Slashify
@@ -202,8 +209,15 @@ sub dump_rec {
202209
return '_FDef(' . dump_rec($$object{cs}) . ')'; }
203210
else {
204211
return; } }
212+
elsif ($object->isa('LaTeXML::Common::Font')) {
213+
# Likely never shows in dump file, but need for bookkeeping (compare predump to dump)
214+
return '_Font(' . join(',', map { dump_rec($_); } @$object) . ')'; }
215+
elsif ($object->isa('LaTeXML::Common::Color')) {
216+
# Likely never shows in dump file, but need for bookkeeping (compare predump to dump)
217+
return '_RGB(' . join(',', map { dump_rec($_); } $object->rgb->components) . ')'; }
205218
else {
206-
Warn('unexpected', $type, undef, "Trying to dump $object within $LaTeXML::DUMPING_KEY")
219+
Warn('unexpected', $type, undef, "Trying to dump $object within $LaTeXML::DUMPING_KEY",
220+
'Object is '.Stringify($object))
207221
if $LaTeXML::DUMPING_KEY;
208222
return;
209223
}

0 commit comments

Comments
 (0)