
# -*- mode: Perl -*-
# /=====================================================================\ #
# |  pifont                                                             | #
# | Implementation for LaTeXML                                          | #
# |=====================================================================| #
# | 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::Package::Pool;
use strict;
use warnings;
use LaTeXML::Package;

# Uses pzd fontmap.

DefPrimitive('\Pisymbol{}{Number}', sub {
    my ($document, $pifont, $code) = @_;
    return Box(FontDecode($code->valueOf, ToString($pifont)), undef, undef, Invocation(T_CS('\char'), $code)); });

DefPrimitive('\lx@Picountersymbol{}{}{Number}', sub {
    my ($document, $pifont, $counter, $codebase) = @_;
    my $code = $codebase->valueOf + LookupRegister('\c@' . ToString($counter))->valueOf - 1;
    return Box(FontDecode($code, ToString($pifont))); });

DefMacro('\Pilist{}{}', '\list{\Pisymbol{#1}{#2}}{}');
DefMacro('\endPilist',  '\endlist');

DefMacro('\lx@defpiautolabel{}{}', sub {
    my ($gullet, $font, $base) = @_;
    my $level   = (LookupValue('enumlevel') || 0) + 1;
    my $postfix = ToString(Tokens(roman($level)));
    DefMacroI('\theenum' . $postfix, undef,
      '\lx@Picountersymbol{' . ToString($font) . '}{enum' . $postfix . '}{' . ToString($base) . '}');
    DefMacroI('\p@enum' . $postfix,    undef, '');
    DefMacroI('\labelenum' . $postfix, undef, '\theenum' . $postfix);
    return; });

DefMacro('\Piautolist{}{}', '\lx@defpiautolabel{#1}{#2}\enumerate');
DefMacro('\endPiautolist',  '\endenumerate');

# Don't know what to do with these.
DefPrimitive('\Piline{}{Number}', undef);
DefPrimitive('\Pifill{}{Number}', undef);

DefMacro('\ding{}', '\Pisymbol{pzd}{#1}');

DefMacro('\dinglist',        '\Pilist{pzd}');
DefMacro('\enddinglist',     '\endPilist');
DefMacro('\dingautolist',    '\Piautolist{pzd}');
DefMacro('\enddingautolist', '\endPiautolist');

# Don't know what to do with these.
DefPrimitive('\dingline{Number}', undef);
DefPrimitive('\dingfill{Number}', undef);

1;
