-
Notifications
You must be signed in to change notification settings - Fork 100
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
Rearrangements #2387
Rearrangements #2387
Changes from all commits
67d4198
e216ff0
8144738
32a185e
892b625
bfadb1b
8b60aa0
ad34ec6
5298d1e
289f3c2
cb8721e
4059925
4283924
895e80b
f4e6559
1669a34
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,44 +60,53 @@ my $FLAG_EMPH = 0x10; | |
# NOTE: This probably doesn't really belong in here... | ||
|
||
my %font_family = ( | ||
cmr => { family => 'serif' }, cmss => { family => 'sansserif' }, | ||
cmtt => { family => 'typewriter' }, cmvtt => { family => 'typewriter' }, | ||
cmt => { family => 'serif' }, # for cmti "text italic" | ||
cmfib => { family => 'serif' }, cmfr => { family => 'serif' }, | ||
cmdh => { family => 'serif' }, cm => { family => 'serif' }, | ||
ptm => { family => 'serif' }, ppl => { family => 'serif' }, | ||
pnc => { family => 'serif' }, pbk => { family => 'serif' }, | ||
phv => { family => 'sansserif' }, pag => { family => 'serif' }, | ||
pcr => { family => 'typewriter' }, pzc => { family => 'script' }, | ||
put => { family => 'serif' }, bch => { family => 'serif' }, | ||
psy => { family => 'symbol' }, pzd => { family => 'dingbats' }, | ||
ccr => { family => 'serif' }, ccy => { family => 'symbol' }, | ||
cmbr => { family => 'sansserif' }, cmtl => { family => 'typewriter' }, | ||
cmbrs => { family => 'symbol' }, ul9 => { family => 'typewriter' }, | ||
txr => { family => 'serif' }, txss => { family => 'sansserif' }, | ||
txtt => { family => 'typewriter' }, txms => { family => 'symbol' }, | ||
txsya => { family => 'symbol' }, txsyb => { family => 'symbol' }, | ||
pxr => { family => 'serif' }, pxms => { family => 'symbol' }, | ||
pxsya => { family => 'symbol' }, pxsyb => { family => 'symbol' }, | ||
futs => { family => 'serif' }, | ||
uaq => { family => 'serif' }, ugq => { family => 'sansserif' }, | ||
eur => { family => 'serif' }, eus => { family => 'script' }, | ||
euf => { family => 'fraktur' }, euex => { family => 'symbol' }, | ||
cmr => { family => 'serif' }, | ||
cmss => { family => 'sansserif' }, | ||
cmssq => { family => 'sansserif' }, # quote style? | ||
cmssqi => { family => 'sansserif', shape => 'italic' }, # quote style? | ||
cmtt => { family => 'typewriter' }, cmvtt => { family => 'typewriter' }, | ||
cmt => { family => 'serif' }, # for cmti "text italic" | ||
cmfib => { family => 'serif' }, | ||
cmfr => { family => 'serif' }, | ||
cm => { family => 'serif' }, | ||
cmdh => { family => 'serif' }, | ||
cmr => { family => 'serif' }, | ||
cmdunh => { family => 'serif' }, # like cmr10 but with tall body heights | ||
cmu => { family => 'serif' }, # unslanted italic ?? | ||
ptm => { family => 'serif' }, ppl => { family => 'serif' }, | ||
pnc => { family => 'serif' }, pbk => { family => 'serif' }, | ||
phv => { family => 'sansserif' }, pag => { family => 'serif' }, | ||
pcr => { family => 'typewriter' }, pzc => { family => 'script' }, | ||
put => { family => 'serif' }, bch => { family => 'serif' }, | ||
psy => { family => 'symbol' }, pzd => { family => 'dingbats' }, | ||
ccr => { family => 'serif' }, ccy => { family => 'symbol' }, | ||
cmbr => { family => 'sansserif' }, cmtl => { family => 'typewriter' }, | ||
cmbrs => { family => 'symbol' }, ul9 => { family => 'typewriter' }, | ||
txr => { family => 'serif' }, txss => { family => 'sansserif' }, | ||
txtt => { family => 'typewriter' }, txms => { family => 'symbol' }, | ||
txsya => { family => 'symbol' }, txsyb => { family => 'symbol' }, | ||
pxr => { family => 'serif' }, pxms => { family => 'symbol' }, | ||
pxsya => { family => 'symbol' }, pxsyb => { family => 'symbol' }, | ||
futs => { family => 'serif' }, | ||
uaq => { family => 'serif' }, ugq => { family => 'sansserif' }, | ||
eur => { family => 'serif' }, eus => { family => 'script' }, | ||
euf => { family => 'fraktur' }, euex => { family => 'symbol' }, | ||
# The following are actually math fonts. | ||
ms => { family => 'symbol' }, | ||
ccm => { family => 'serif', shape => 'italic' }, | ||
cmm => { family => 'italic', encoding => 'OML' }, | ||
cmex => { family => 'symbol', encoding => 'OMX' }, # Not really symbol, but... | ||
cmsy => { family => 'symbol', encoding => 'OMS' }, | ||
ccitt => { family => 'typewriter', shape => 'italic' }, | ||
cmbrm => { family => 'sansserif', shape => 'italic' }, | ||
futm => { family => 'serif', shape => 'italic' }, | ||
futmi => { family => 'serif', shape => 'italic' }, | ||
txmi => { family => 'serif', shape => 'italic' }, | ||
pxmi => { family => 'serif', shape => 'italic' }, | ||
bbm => { family => 'blackboard' }, | ||
bbold => { family => 'blackboard' }, | ||
bbmss => { family => 'blackboard' }, | ||
ms => { family => 'symbol' }, | ||
ccm => { family => 'serif', shape => 'italic' }, | ||
cmm => { family => 'math', shape => 'italic', encoding => 'OML' }, | ||
cmex => { family => 'symbol', encoding => 'OMX' }, # Not really symbol, but... | ||
cmsy => { family => 'symbol', encoding => 'OMS' }, | ||
ccitt => { family => 'typewriter', shape => 'italic' }, | ||
cmsltt => { family => 'typewriter', shape => 'slanted' }, | ||
cmbrm => { family => 'sansserif', shape => 'italic' }, | ||
futm => { family => 'serif', shape => 'italic' }, | ||
futmi => { family => 'serif', shape => 'italic' }, | ||
txmi => { family => 'serif', shape => 'italic' }, | ||
pxmi => { family => 'serif', shape => 'italic' }, | ||
bbm => { family => 'blackboard' }, | ||
bbold => { family => 'blackboard' }, | ||
bbmss => { family => 'blackboard' }, | ||
# some ams fonts | ||
cmmib => { family => 'italic', series => 'bold' }, | ||
cmbsy => { family => 'symbol', series => 'bold' }, | ||
|
@@ -177,16 +186,17 @@ sub decodeFontname { | |
if (my $ffam = lookupFontFamily($fam)) { map { $props{$_} = $$ffam{$_} } keys %$ffam; } | ||
if (my $fser = lookupFontSeries($ser)) { map { $props{$_} = $$fser{$_} } keys %$fser; } | ||
if (my $fsh = lookupFontShape($shp)) { map { $props{$_} = $$fsh{$_} } keys %$fsh; } | ||
$size = 1 unless $size; # Yes, also if 0, "" (from regexp) | ||
$size = $at if defined $at; | ||
$size *= $scaled if defined $scaled; | ||
$size = 1 unless $size; # Yes, also if 0, "" (from regexp) | ||
$size = $at if defined $at; | ||
$size = $size * $scaled if defined $scaled; | ||
$props{name} = $name; | ||
$props{size} = $size; | ||
# Experimental Hack !?!?!? | ||
$props{encoding} = 'OT1' unless defined $props{encoding}; | ||
$props{at} = $at . "pt" if defined $at; | ||
return %props; } | ||
else { | ||
return; } } | ||
Info('unrecognized', 'font', undef, "Unrecognized fontname '$name'"); | ||
return (family => $name, size => DEFSIZE()); } } | ||
|
||
sub lookupTeXFont { | ||
my ($fontname, $seriescode, $shapecode) = @_; | ||
|
@@ -266,6 +276,7 @@ sub stringify { | |
no warnings 'recursion'; | ||
my ($self) = @_; | ||
my ($fam, $ser, $shp, $siz, $col, $bkg, $opa, $enc, $lang, $mstyle, $flags) = @$self; | ||
# !!!!! | ||
$fam = 'serif' if $fam && ($fam eq 'math'); | ||
return 'Font[' . join(',', map { Stringify($_) } grep { $_ } | ||
(isDiff($fam, $DEFFAMILY) ? ($fam) : ()), | ||
|
@@ -280,6 +291,16 @@ sub stringify { | |
) | ||
. ']'; } | ||
|
||
# Return a Fontinfo-like hash | ||
# Eventually a more integrated representation of Fonts that accommodates | ||
# both low-level TeX-like commands, and higher-level CSS-like ones. | ||
sub asFontinfo { | ||
my ($self) = @_; | ||
my ($fam, $ser, $shp, $siz, $col, $bkg, $opa, $enc, $lang, $mstyle, $flags) = @$self; | ||
return { family => $fam, series => $ser, shape => $shp, size => $siz, | ||
color => $col, background => $bkg, opacity => $opa, | ||
encoding => $enc || 'OT1', language => $lang, mathstyle => $mstyle }; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think they'll only show up in the CSS style of specifying fonts, so shouldn't be needed for "fontinfo", but the whole synthesization idea is a bit up-in-the-air. |
||
|
||
sub equals { | ||
my ($self, $other) = @_; | ||
return (defined $other) && ((ref $self) eq (ref $other)) | ||
|
@@ -328,6 +349,7 @@ sub relativeTo { | |
my ($self, $other) = @_; | ||
my ($fam, $ser, $shp, $siz, $col, $bkg, $opa, $enc, $lang, $mstyle, $flags) = @$self; | ||
my ($ofam, $oser, $oshp, $osiz, $ocol, $obkg, $oopa, $oenc, $olang, $omstyle, $oflags) = @$other; | ||
# !!!! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [2] What could be some words to describe that exclamation? |
||
$fam = 'serif' if $fam && ($fam eq 'math'); | ||
$ofam = 'serif' if $ofam && ($ofam eq 'math'); | ||
## my $emph = 0; | ||
|
@@ -358,6 +380,9 @@ sub relativeTo { | |
(isDiff($opa, $oopa) | ||
? (opacity => { value => $opa, properties => { opacity => $opa } }) | ||
: ()), | ||
(isDiff($enc, $oenc) | ||
? (encoding => { value => $enc, properties => { encoding => $enc } }) | ||
: ()), | ||
(isDiff($lang, $olang) | ||
? ('xml:lang' => { value => $lang, properties => { language => $lang } }) | ||
: ()), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,13 +47,17 @@ sub invoke { | |
my $mathglyph = $$self{mathglyph}; | ||
# A dilemma: If the \chardef were in a style file, you're prefer to revert to the $cs | ||
# but if defined in the document source, better to use \char ###\relax, so it still "works" | ||
if (defined $mathglyph) { # Must be a math char | ||
my $src = $$self{locator} && $$self{locator}->toString; | ||
my $local = $src && $src !~ /\.(?:sty|ltxml|ltxmlc)/; # Dumps currently have undefined src! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exactly for dumps and your naming suggestion sounds good |
||
if (defined $mathglyph) { # Must be a math char | ||
return Box($mathglyph, undef, undef, | ||
Tokens(T_CS('\mathchar'), $value->revert, T_CS('\relax')), | ||
($local ? Tokens(T_CS('\mathchar'), $value->revert, T_CS('\relax')) : $$self{cs}), | ||
role => $$self{role}); } | ||
else { # else text; but note defered font/encoding till digestion! | ||
return Box(LaTeXML::Package::FontDecode($value->valueOf), undef, undef, | ||
Tokens(T_CS('\char'), $value->revert, T_CS('\relax'))); } } | ||
else { # else text; but note defered font/encoding till digestion! | ||
my ($char, %props) = LaTeXML::Package::FontDecode($value->valueOf); | ||
return Box($char, undef, undef, | ||
($local ? Tokens(T_CS('\char'), $value->revert, T_CS('\relax')) : $$self{cs}), | ||
%props); } } | ||
|
||
sub equals { | ||
my ($self, $other) = @_; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,19 @@ DefConstructorI('\noindent', undef, sub { | |
# Otherwise ignore. | ||
return; }); | ||
|
||
sub alignLine { | ||
my ($document, $line, $alignment) = @_; | ||
if ($document->isOpenable('ltx:p')) { | ||
$document->insertElement('ltx:p', $line, class => 'ltx_align_' . $alignment); } | ||
elsif ($document->isOpenable('ltx:text')) { | ||
$document->insertElement('ltx:text', $line, class => 'ltx_align_' . $alignment); | ||
$document->insertElement('ltx:break'); } | ||
else { | ||
Info('unexpected', 'alignment', $document, | ||
"Lost requested alignment '$alignment'; no suitable element"); | ||
$document->absorb($line); } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this case emit an Info or Warning message? Silently absorbing while dropping the alignment may be worth logging. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not a bad idea... |
||
return; } | ||
|
||
# <ltx:para> represents a Logical Paragraph, whereas <ltx:p> is a `physical paragraph'. | ||
# A para can contain both p and displayed equations and such. | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What could be some words to describe that exclamation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that got added? Hmm...