forked from brucemiller/LaTeXML
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* New Definition class FontDef for font selecting commands defined by \font; modify \font accordingly * Rename parameter type FontToken to FontDef for cs explicitly defined by \font (ie FontDef); update font info accessors which use this token ( \fontdimen, \fontname, \hyphenchar, \skewchar) * Update \meaning to recognize new FontDef font commands * Update \the to recognize FontDef commands defined by \font and process them correctly; remove badly named Register Parameter type which was only used for \the * Moved decodeMathChar to Package.pm, updating it to more correctly decode mathcodes and recognize the \fam font family for the class=7 special case, and more reliably lookup the codepoint in the encoding appropriate to the selected font; Initialize \fam (font_family) when entering math mode, and use decodeMathChar when digesting simple tokens in math. * Note that \mit doesn't REQUIRE math, but ony has effect in math (sets \fam) * Consistent use of font decoding makes apparent misuse of T_OTHER when reconstructing duals in siunitx * Fix mangled renesting of if/else * \cal also does not require math and does nothing in text * Add test case for plain style font manipulations * Improve decoding of font filenames into family/series/shape and IMPORTANTLY encoding; rearrange lists * Update FontMap to provide options for alphanumerics to remain ASCII in math, but with (semantic) font styling which is post-processed as before; BUT while allowing those same chars to map to Unicode when in text mode, since these cases are often rather exotic fonts not easily covered by pure CSS. * Make FontDecode in math keep alphanumerics in math as ASCII w/font change, but unicode in text, Now returns BOTH the glyph and font; corresponding changes to decodeMathChar * Update all callers of FontDecode * Make \cal return a Box so that it can revert * Enhance and correct plain fonts test cases * Code cleanup suggested by D.Ginev
- Loading branch information
1 parent
c4fb7cf
commit 0140936
Showing
24 changed files
with
727 additions
and
306 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# /=====================================================================\ # | ||
# | LaTeXML::Core::Definition::FontDef | # | ||
# | Representation of definitions of Fonts | # | ||
# |=====================================================================| # | ||
# | Part of LaTeXML: | # | ||
# | Public domain software, produced as part of work done by the | # | ||
# | United States Government & not subject to copyright in the US. | # | ||
# |---------------------------------------------------------------------| # | ||
# | Bruce Miller <bruce.miller@nist.gov> #_# | # | ||
# | http://dlmf.nist.gov/LaTeXML/ (o o) | # | ||
# \=========================================================ooo==U==ooo=/ # | ||
package LaTeXML::Core::Definition::FontDef; | ||
use strict; | ||
use warnings; | ||
use LaTeXML::Global; | ||
use LaTeXML::Common::Object; | ||
use LaTeXML::Common::Error; | ||
use LaTeXML::Core::Token; | ||
use LaTeXML::Core::Tokens; | ||
use LaTeXML::Core::Box; | ||
use base qw(LaTeXML::Core::Definition::Primitive); | ||
|
||
# A CharDef is a specialized register; | ||
# You can't assign it; when you invoke the control sequence, it returns | ||
# the result of evaluating the character (more like a regular primitive). | ||
# When $mathglyph is provided, it is the unicode corresponding to the \mathchar of $value | ||
sub new { | ||
my ($class, $cs, $fontid, %traits) = @_; | ||
return bless { cs => $cs, parameters => undef, | ||
fontID => $fontid, | ||
locator => $STATE->getStomach->getGullet->getMouth->getLocator, | ||
%traits }, $class; } | ||
|
||
# Return the "font info" associated with the (TeX) font that this command selects (See \font) | ||
sub isFontDef { | ||
my ($self) = @_; | ||
return $STATE->lookupValue($$self{fontID}); } | ||
|
||
sub invoke { | ||
my ($self, $stomach) = @_; | ||
if (my $fontinfo = $STATE->lookupValue($$self{fontID})) { | ||
# Temporary hack for \the\font; remember the last font def executed | ||
$STATE->assignValue(current_FontDef => $$self{cs}, 'local'); | ||
$STATE->assignValue(font => $STATE->lookupValue('font')->merge(%$fontinfo), 'local'); | ||
} | ||
return Box(undef, undef, undef, $$self{cs}); } | ||
|
||
#=============================================================================== | ||
1; | ||
|
||
__END__ | ||
=pod | ||
=head1 NAME | ||
C<LaTeXML::Core::Definition::FontDef> - Control sequence definitions for font symbols defined by \font. | ||
=head1 DESCRIPTION | ||
Representation for control sequences defined by \font. | ||
It extends L<LaTeXML::Core::Definition::Primitive>. | ||
=head1 AUTHOR | ||
Bruce Miller <bruce.miller@nist.gov> | ||
=head1 COPYRIGHT | ||
Public domain software, produced as part of work done by the | ||
United States Government & not subject to copyright in the US. | ||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.