package Font::TTF::OS_2;

=head1 NAME

Font::TTF::OS_2 - the OS/2 table in a TTF font

=head1 DESCRIPTION

The OS/2 table has two versions and forms, one an extension of the other. This
module supports both forms and the switching between them.

=head1 INSTANCE VARIABLES

No other variables than those in table and those in the standard:

    Version
    xAvgCharWidth
    usWeightClass
    usWidthClass
    fsType
    ySubscriptXSize
    ySubScriptYSize
    ySubscriptXOffset
    ySubscriptYOffset
    ySuperscriptXSize
    ySuperscriptYSize
    ySuperscriptXOffset
    ySuperscriptYOffset
    yStrikeoutSize
    yStrikeoutPosition
    sFamilyClass
    bFamilyType
    bSerifStyle
    bWeight
    bProportion
    bContrast
    bStrokeVariation
    bArmStyle
    bLetterform
    bMidline
    bXheight
    ulUnicodeRange1
    ulUnicodeRange2
    ulUnicodeRange3
    ulUnicodeRange4
    achVendID
    fsSelection
    usFirstCharIndex
    usLastCharIndex
    sTypoAscender
    sTypoDescender
    sTypoLineGap
    usWinAscent
    usWinDescent
    ulCodePageRange1
    ulCodePageRange2
    xHeight
    CapHeight
    defaultChar
    breakChar
    maxLookups

Notice that versions 0, 1, 2 & 3 of the table are supported. Notice also that the
Panose variable has been broken down into its elements.

=head1 METHODS

=cut

use strict;
use vars qw(@ISA @fields @lens @field_info @weights @ranges @codepages);
use Font::TTF::Table;

@ISA = qw(Font::TTF::Table);
@field_info = (
    'xAvgCharWidth' => 's',
    'usWeightClass' => 'S',
    'usWidthClass' => 'S',
    'fsType' => 's',
    'ySubscriptXSize' => 's',
    'ySubScriptYSize' => 's',
    'ySubscriptXOffset' => 's',
    'ySubscriptYOffset' => 's',
    'ySuperscriptXSize' => 's',
    'ySuperscriptYSize' => 's',
    'ySuperscriptXOffset' => 's',
    'ySuperscriptYOffset' => 's',
    'yStrikeoutSize' => 's',
    'yStrikeoutPosition' => 's',
    'sFamilyClass' => 's',
    'bFamilyType' => 'C',
    'bSerifStyle' => 'C',
    'bWeight' => 'C',
    'bProportion' => 'C',
    'bContrast' => 'C',
    'bStrokeVariation' => 'C',
    'bArmStyle' => 'C',
    'bLetterform' => 'C',
    'bMidline' => 'C',
    'bXheight' => 'C',
    'ulUnicodeRange1' => 'L',
    'ulUnicodeRange2' => 'L',
    'ulUnicodeRange3' => 'L',
    'ulUnicodeRange4' => 'L',
    'achVendID' => 'L',
    'fsSelection' => 'S',
    'usFirstCharIndex' => 'S',
    'usLastCharIndex' => 'S',
    'sTypoAscender' => 'S',
    'sTypoDescender' => 's',
    'sTypoLineGap' => 'S',
    'usWinAscent' => 'S',
    'usWinDescent' => 'S',
    '' => '',
    'ulCodePageRange1' => 'L',
    'ulCodePageRange2' => 'L',
    '' => '',
    'xHeight' => 's',
    'CapHeight' => 's',
    'defaultChar' => 'S',
    'breakChar' => 'S',
    'maxLookups' => 's',
    '' => '',            # i.e. v3 is basically same as v2
    '' => ''             # i.e. v4 is structurally identical to v3
    );

@weights = qw(64 14 27 35 100 20 14 42 63 3 6 35 20 56 56 17 4 49 56 71 31 10 18 3 18 2 166);

use Font::TTF::Utils;

sub init
{
    my ($k, $v, $c, $n, $i, $t, $j);

    $n = 0;
    @lens = (76, 84, 94, 94, 94);
    for ($j = 0; $j < $#field_info; $j += 2)
    {
        if ($field_info[$j] eq '')
        {
            $n++;
            next;
        }
        ($k, $v, $c) = TTF_Init_Fields($field_info[$j], $c, $field_info[$j+1]);
        next unless defined $k && $k ne "";
        for ($i = $n; $i < 5; $i++)
        { $fields[$i]{$k} = $v; }
    }
}


=head2 $t->read

Reads in the various values from disk (see details of OS/2 table)

=cut

sub read
{
    my ($self) = @_;
    my ($dat, $ver);

    $self->SUPER::read or return $self;

    init unless defined $fields[2]{'xAvgCharWidth'};
    $self->{' INFILE'}->read($dat, 2);
    $ver = unpack("n", $dat);
    $self->{'Version'} = $ver;
    if ($ver < 5)
    {
        $self->{' INFILE'}->read($dat, $lens[$ver]);
        TTF_Read_Fields($self, $dat, $fields[$ver]);
    }
    $self;
}


=head2 $t->out($fh)

Writes the table to a file either from memory or by copying.

=cut

sub out
{
    my ($self, $fh) = @_;
    my ($ver);

    return $self->SUPER::out($fh) unless $self->{' read'};

    $ver = $self->{'Version'};
    $fh->print(pack("n", $ver));
    $fh->print(TTF_Out_Fields($self, $fields[$ver], $lens[$ver]));
    $self;
}


=head2 $t->XML_element($context, $depth, $key, $value)

Tidies up the hex values to output them in hex

=cut

sub XML_element
{
    my ($self) = shift;
    my ($context, $depth, $key, $value) = @_;
    my ($fh) = $context->{'fh'};

    if ($key =~ m/^ul(?:Unicode|CodePage)Range\d$/o)
    { $fh->printf("%s<%s>%08X</%s>\n", $depth, $key, $value, $key); }
    elsif ($key eq 'achVendID')
    { $fh->printf("%s<%s name='%s'/>\n", $depth, $key, pack('N', $value)); }
    else
    { return $self->SUPER::XML_element(@_); }
    $self;
}


=head2 $t->XML_end($context, $tag, %attrs)

Now handle them on the way back in

=cut

sub XML_end
{
    my ($self) = shift;
    my ($context, $tag, %attrs) = @_;

    if ($tag =~ m/^ul(?:Unicode|CodePage)Range\d$/o)
    { return hex($context->{'text'}); }
    elsif ($tag eq 'achVendID')
    { return unpack('N', $attrs{'name'}); }
    else
    { return $self->SUPER::XML_end(@_); }
}

=head2 $t->minsize()

Returns the minimum size this table can be. If it is smaller than this, then the table
must be bad and should be deleted or whatever.

=cut

sub minsize
{
    return 78;
}

=head2 $t->update

Updates the OS/2 table by getting information from other sources:

Updates the C<firstChar> and C<lastChar> values based on the MS table in the
cmap.

Updates the sTypoAscender, sTypoDescender & sTypoLineGap to be the same values
as Ascender, Descender and Linegap from the hhea table (assuming it is dirty)
and also sets usWinAscent to be the sum of Ascender+Linegap and usWinDescent to
be the negative of Descender.

=cut

sub update
{
    my ($self) = @_;
    my ($map, @keys, $table, $i, $avg, $hmtx);

    return undef unless ($self->SUPER::update);

    $self->{' PARENT'}{'cmap'}->update;
    $map = $self->{' PARENT'}{'cmap'}->find_ms || return undef;
    $hmtx = $self->{' PARENT'}{'hmtx'}->read;

    @keys = sort {$a <=> $b} grep {$_ < 0x10000} keys %{$map->{'val'}};

    $self->{'usFirstCharIndex'} = $keys[0];
    $self->{'usLastCharIndex'} = $keys[-1];

    $table = $self->{' PARENT'}{'hhea'}->read;
    
    # try any way we can to get some real numbers passed around!
    if (($self->{'fsSelection'} & 128) != 0)
    {
        # assume the user knows what they are doing and has sensible values already
    }
    elsif ($table->{'Ascender'} != 0 || $table->{'Descender'} != 0)
    {
        $self->{'sTypoAscender'} = $table->{'Ascender'};
        $self->{'sTypoDescender'} = $table->{'Descender'};
        $self->{'sTypoLineGap'} = $table->{'LineGap'};
        $self->{'usWinAscent'} = $self->{'sTypoAscender'} + $self->{'sTypoLineGap'};
        $self->{'usWinDescent'} = -$self->{'sTypoDescender'};
    }
    elsif ($self->{'sTypoAscender'} != 0 || $self->{'sTypoDescender'} != 0)
    {
        $table->{'Ascender'} = $self->{'sTypoAscender'};
        $table->{'Descender'} = $self->{'sTypoDescender'};
        $table->{'LineGap'} = $self->{'sTypoLineGap'};
        $self->{'usWinAscent'} = $self->{'sTypoAscender'} + $self->{'sTypoLineGap'};
        $self->{'usWinDescent'} = -$self->{'sTypoDescender'};
    } 
    elsif ($self->{'usWinAscent'} != 0 || $self->{'usWinDescent'} != 0)
    {
        $self->{'sTypoAscender'} = $table->{'Ascender'} = $self->{'usWinAscent'};
        $self->{'sTypoDescender'} = $table->{'Descender'} = -$self->{'usWinDescent'};
        $self->{'sTypoLineGap'} = $table->{'LineGap'} = 0;
    }

    if ($self->{'Version'} < 3)
    {
        for ($i = 0; $i < 26; $i++)
        { $avg += $hmtx->{'advance'}[$map->{'val'}{$i + 0x0061}] * $weights[$i]; }
        $avg += $hmtx->{'advance'}[$map->{'val'}{0x0020}] * $weights[-1];
        $self->{'xAvgCharWidth'} = $avg / 1000;
    }
    elsif ($self->{'Version'} > 2)
    {
        $i = 0; $avg = 0;
        foreach (@{$hmtx->{'advance'}})
        {
            next unless ($_);
            $i++;
            $avg += $_;
        }
        $avg /= $i if ($i);
        $self->{'xAvgCharWidth'} = $avg;
    }

    $self->{'ulUnicodeRange2'} &= ~0x2000000;
    foreach $i (keys %{$map->{'val'}})
    {
        if ($i >= 0x10000)
        {
            $self->{'ulUnicodeRange2'} |= 0x2000000;
            last;
        }
    }

    $self->{'Version'} = 1 if (defined $self->{'ulCodePageRange1'} && $self->{'Version'} < 1);
    $self->{'Version'} = 2 if (defined $self->{'maxLookups'} && $self->{'Version'} < 2);
    
    if ((exists $self->{' PARENT'}{'GPOS'} && $self->{' PARENT'}{'GPOS'}{' read'}) ||
        (exists $self->{' PARENT'}{'GSUB'} && $self->{' PARENT'}{'GSUB'}{' read'}))
    {
        # one or both of GPOS & GSUB exist and have been read or modified; so update usMaxContexts
        my ($lp, $ls);
        $lp = $self->{' PARENT'}{'GPOS'}->maxContext if exists $self->{' PARENT'}{'GPOS'};
        $ls = $self->{' PARENT'}{'GSUB'}->maxContext if exists $self->{' PARENT'}{'GSUB'};
        $self->{'maxLookups'} = $lp > $ls ? $lp : $ls;
    }
    
    $self;
}


=head2 $t->guessRangeBits (\%map, [$cp_threshold, [%u_threshold]])

Set the ulCodePageRange and ulUnicodeRange fields based on characters actually present in the font.

%map is a hash keyed by USV returning non-zero for characters present (e.g. use {'val'} 
a from Unicode cmap).

The two optional parameters are percentage of characters within the codepage or unicode range that need
to be present to constitute coverage. A threshold of 0 causes corresponding range bits to 
be set if any characters are present at all, while a negative value causes the corresponding
range bits to be unchanged. Defaults are 50 and 0, respectively.

For codepage bits, the threshold is percentage of characters between 0xC0 and 0xFF that need
to be present to constitute coverage). For codepages other than 1252, 
characters (e.g., punctuation) that are defined identically to cp1252 are ignored
for the purposes of this percentage calculation. Looks only for SBCS codepages, not DBCS.

For Unicode range bits that represent multiple ranges, e.g., bit 29 represents:

  Latin Extended Additional  1E00-1EFF
  Latin Extended-C           2C60-2C7F
  Latin Extended-D           A720-A7FF

the bit will be set if any of these ranges meet the threshold requirement.

=cut

sub guessRangeBits
{
    my ($self, $ucmap, $cp_threshold, $u_threshold) = @_; 
    $cp_threshold = 50 unless defined ($cp_threshold); 
    $u_threshold  =  0 unless defined ($u_threshold);
    my $j;  # index into codepages or ranges
    my $u;  # USV

    unless (ref($codepages[0]))
    {
        # One-time work to convert range data
        
        # unpack codepages. But first make sure we have Zlib
        eval {require Compress::Zlib} || croak("Cannot unpack codepage data Compress::Zlib not available");

        for ($j = 0; $j <= $#codepages; $j++)
        {
            next unless $codepages[$j];
            $codepages[$j] = [unpack("n*", Compress::Zlib::uncompress(unpack("u", $codepages[$j])))];
            warn ("Got nothing for codepage # $j\n") if $#{$codepages[$j]} < 128;
        }
        
        # convert Unicode array data to hash
        my @newRanges;
        for ($j = 0; $j <= $#ranges; $j++)
        {
            next unless $ranges[$j][2] =~ m/^([0-9a-f]{4,6})-([0-9a-f]{4,6})$/oi;
            my $s = hex ($1);
            my $e = hex ($2);
            next unless $e > $s;
            push @newRanges, {start => $s, end => $e, bit => $ranges[$j][0], name => $ranges[$j][1]};
        }
        @ranges = sort {$a->{'end'} <=> $b->{'end'}} (@newRanges);
    }

    if ($cp_threshold >= 0)
    {
        my $cpr;    # codepage range vector
        $cp_threshold = 100 if $cp_threshold > 100;
        vec($cpr, 63 ,1) = 0;   # Get all 64 bits into the vector
        for $j (0 .. $#codepages)   # For each codepage
        {
            # Count the number of chars from @range part of codepage that are present in the font
            my $present = 0;
            my $total = 0;
            foreach (0x20 .. 0xFF)
            {
                $u = $codepages[$j][$_];
                next if $u == 0xFFFD;   # Ignore undefined things in codepage
                # For codepage 1252, ignore upper ansi altogether
                # For other codepages, ignore characters that are same as in 1252.
                next if $j > 0 ? $u == $codepages[0][$_] : $u > 0x007F;
                $total++;
                $present++ if exists $ucmap->{$u} && $ucmap->{$u} > 0;
            }
            #printf STDERR "DBG: Got $present / $total (%0.3f%%) in codepage bit $j\n", $present * 100 / $total;
            #print STDERR "DBG: setting bit $j\n" if $cp_threshold == 0 ? ($present > 0) : (($present * 100 / $total) >= $cp_threshold);
            vec($cpr, $j, 1) = 1 if $cp_threshold == 0 ? ($present > 0) : (($present * 100 / $total) >= $cp_threshold);
            #print STDERR "\n";
        }
        ($self->{'ulCodePageRange1'}, $self->{'ulCodePageRange2'}) = unpack ('V2', $cpr);
    } 

    if ($u_threshold >= 0)
    {
        my $ucr;    # Unicode range vector
        my @count;  # Count of chars present in each range
        $u_threshold  = 100 if $u_threshold  > 100;
        vec($ucr, 127,1) = 0;   # Get all 128 bits into the vector
        $j = 0;  
CHAR:   for $u (sort {$a <=> $b} keys %{$ucmap})
        {
            while ($u > $ranges[$j]{'end'})
            {
                last CHAR if ++$j > $#ranges;
            }
            next if $u < $ranges[$j]{'start'};
            $count[$j]++ if $ucmap->{$u};
        }
        foreach $j (0 .. $#ranges)
        {
            vec($ucr, $ranges[$j]{'bit'}, 1) = 1 if $u_threshold == 0 ? 
                ($count[$j] > 0) :
                (($count[$j] * 100 / ($ranges[$j]{'end'} - $ranges[$j]{'start'} + 1)) >= $u_threshold);
        }
        ($self->{'ulUnicodeRange1'},$self->{'ulUnicodeRange2'},$self->{'ulUnicodeRange3'},$self->{'ulUnicodeRange4'}) =
            unpack ('V4', $ucr);
    }
}

BEGIN {

@codepages = (
<<'EOT',    # Bit 0: cp1252
M>)P-R>-B%E```-#S+1O+O%NU;-MVRURV[7?H"3*7;2_;M6S;K=7Y>Q`1)8VT
MTDDO@XPRR2R+K++)+H><<LDM6AYYY9-?`0454E@111537!`C5@DEE1*GM#+*
M*J>\"BJJI+(JJJJFNAIJJJ6V.NJJI[X&&FJDL2:::J:Y%EIJI;4VVFJGO0XZ
MZJ2S+KKJ)EYW/?342V]]]-5/?P,,-$B"P888:ICA1AAIE-'&&&N<\2:8:)+)
MIIAJFNEFF&F6V>:8:Y[Y%E@8$E-30J'(HE`LQ(408J*20I5(0J@;Z9::$IF?
MFO)_"X2"H4@H&F)#=,@3E1P3&QD<ZD7B__^"R"R++;'4,LNML-(JJZVQUCJ)
MUMM@HTTVVV*K;;;;8:===MMCKWWV.^"@0PX[XJACCDMRPDFGG';&6>><=\%%
MEU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%9$4<445T))I906KXRRRBDO004559*H
MLBJ"),FJJJ:Z%#745$MM==153WT---1(8TTTU4QS+;342FMMM-5.>QUTU$EG
M773537<]]-1+;WWTU4]_`PPT2*HT@PTQU###C3#2**.-,=8XXTTPT22333'5
M--/-,-,LL\TQUSSS+;#0(HLML=0RZ99;8:555EMC;=B9FQ,J1.M"Y9`20DB*
MRPH-_TJK*#4WYW^A?$@(E4)B2`ZE0WQ<=E+R7VL=I?U[4;H,F=;;8*---MMB
MJVVVVV&G77;;8Z]]]CO@H$,..^*H8XX[X:133COCK'/.1W$NN"C+)9==<=6U
M&-?=<#,JX5:LH-ON1!GNNN>^!QYZ)#O:$XMY[(FGGD4QS[WPTBNOO?'6NUCD
@O0\^1B5]BE7UV9<HTU???/?#3[_\CO:&'7+_`."G?R``
EOT

undef,      # Bit 9: Reserved
undef,      # Bit 10: Reserved
undef,      # Bit 11: Reserved
undef,      # Bit 12: Reserved
undef,      # Bit 13: Reserved
undef,      # Bit 14: Reserved
undef,      # Bit 15: Reserved

<<'EOT',    # Bit 16: cp874
M>)Q=C=52&U``!1?W11(@@00N`8*[4\'=W>KN[OHK_8#^8J=]Z.0!9E_.S,Z<
M!;+()H=<\LBG@$****:$4LJ0<BJHI(H(4:JIH988<>JH)T&2!AH)-)&BF19:
M2=-&.QUTTD4W/?321S\###+$,".,,L8X$TQRB<M<X2I33#/#+'/,L\`B2RRS
MPBIKK+/!)EMLL\,N>^QSP"%'''/"*6=<XSHWN,DM;G.'N]SC/@]XR",>\X2G
M/.,Y+WC)*U[SAK>\XST?^,@G/O.%KWSC.S_X&7[__?.?D,ZL\X18B(=$2(94
MB(3H1<LOL\PVQUSSS+?`0HLLML12R]1R*ZRTRHA1JZVQUIAQZZPW8=(&&PTV
MF;+9%EM-VV:['7;:9;<]]MIGOP,..N2P(XXZYK@33F;J3CGMC+/..>^"BRZY
@[(JKKKGNAIMNN>V.N^ZY[X&''GGLB:>>91[^`:-3=+0`
EOT

undef,      # Bit 17: Reserved
undef,      # Bit 18: Reserved
undef,      # Bit 19: Reserved
undef,      # Bit 20: Reserved
undef,      # Bit 21: Reserved
undef,      # Bit 22: Reserved
undef,      # Bit 23: Reserved
undef,      # Bit 24: Reserved
undef,      # Bit 25: Reserved
undef,      # Bit 26: Reserved
undef,      # Bit 27: Reserved
undef,      # Bit 28: Reserved
undef,      # Bit 29: Reserved
undef,      # Bit 30: Reserved
undef,      # Bit 31: Reserved
undef,      # Bit 32: Reserved
undef,      # Bit 33: Reserved
undef,      # Bit 34: Reserved
undef,      # Bit 35: Reserved
undef,      # Bit 36: Reserved
undef,      # Bit 37: Reserved
undef,      # Bit 38: Reserved
undef,      # Bit 39: Reserved
undef,      # Bit 40: Reserved
undef,      # Bit 41: Reserved
undef,      # Bit 42: Reserved
undef,      # Bit 43: Reserved
undef,      # Bit 44: Reserved
undef,      # Bit 45: Reserved
undef,      # Bit 46: Reserved
undef,      # Bit 47: Reserved

<<'EOT',    # Bit 48: cp869
M>)Q%R>=7#0`<Q^&/OLB(0G%3N.K^LK*S0U;#+$5$1$141E967I03IZ-QB13=
M3EHJ&@C)WN(_ZN0<;YSGY0,,P@LQF"$,Q9MA#&<$(_%A%*/QQ8\QC&4<_@0P
MG@DX"&0B000SB<E,P<E40@C%A1'&-*8S@YG,(IS9S&$N\YC/`A82P2(6LX2E
M+&,Y*XAD):M8311K6,LZUK.!:&*()8Z-;&(S6]C*-N))8#N))+&#G22SB]VD
ML(>]I+*/_:1Q@(.D<XC#9'"$HV1RC.-DD4T.)SC)*4Z3RQG.<H[S7""/BUSB
M,E>X2OY`_W^Z/M!/-ZTT.!W.0!4Y`W1#-_58Q?_VEEIH5@F==*F5.K7IB9[J
MITK5I]\J4[G<NJT[JM!=>G5/E;308V56;F[S,I?NJTK5>F#IEF#)EJJ'JC$_
M\[<("[=@PR+E4:VE6))E6H:E6;QEJ4Z/5*\&-:I)S>I0I[K,83Y69`5ZIN=V
M32_4K9=ZI=?JT1OUZJW>Z;T^Z),^ZK,*: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in-1 Supplement",   "0080-00FF" ],
    [ 2,    "Latin Extended-A",     "0100-017F" ],
    [ 3,    "Latin Extended-B",     "0180-024F" ],
    [ 4,    "IPA Extensions",   "0250-02AF" ],
    [ 4,    "Phonetic Extensions",  "1D00-1D7F" ],
    [ 4,    "Phonetic Extensions Supplement",   "1D80-1DBF" ],
    [ 5,    "Spacing Modifier Letters",     "02B0-02FF" ],
    [ 5,    "Modifier Tone Letters",    "A700-A71F" ],
    [ 6,    "Combining Diacritical Marks",  "0300-036F" ],
    [ 6,    "Combining Diacritical Marks Supplement",   "1DC0-1DFF" ],
    [ 7,    "Greek and Coptic",     "0370-03FF" ],
    [ 8,    "Coptic",   "2C80-2CFF" ],
    [ 9,    "Cyrillic",     "0400-04FF" ],
    [ 9,    "Cyrillic Supplement",  "0500-052F" ],
    [ 9,    "Cyrillic Extended-A",  "2DE0-2DFF" ],
    [ 9,    "Cyrillic Extended-B",  "A640-A69F" ],
    [ 10,   "Armenian",     "0530-058F" ],
    [ 11,   "Hebrew",   "0590-05FF" ],
    [ 12,   "Vai",  "A500-A63F" ],
    [ 13,   "Arabic",   "0600-06FF" ],
    [ 13,   "Arabic Supplement",    "0750-077F" ],
    [ 14,   "NKo",  "07C0-07FF" ],
    [ 15,   "Devanagari",   "0900-097F" ],
    [ 16,   "Bengali",  "0980-09FF" ],
    [ 17,   "Gurmukhi",     "0A00-0A7F" ],
    [ 18,   "Gujarati",     "0A80-0AFF" ],
    [ 19,   "Oriya",    "0B00-0B7F" ],
    [ 20,   "Tamil",    "0B80-0BFF" ],
    [ 21,   "Telugu",   "0C00-0C7F" ],
    [ 22,   "Kannada",  "0C80-0CFF" ],
    [ 23,   "Malayalam",    "0D00-0D7F" ],
    [ 24,   "Thai",     "0E00-0E7F" ],
    [ 25,   "Lao",  "0E80-0EFF" ],
    [ 26,   "Georgian",     "10A0-10FF" ],
    [ 26,   "Georgian Supplement",  "2D00-2D2F" ],
    [ 27,   "Balinese",     "1B00-1B7F" ],
    [ 28,   "Hangul Jamo",  "1100-11FF" ],
    [ 29,   "Latin Extended Additional",    "1E00-1EFF" ],
    [ 29,   "Latin Extended-C",     "2C60-2C7F" ],
    [ 29,   "Latin Extended-D",     "A720-A7FF" ],
    [ 30,   "Greek Extended",   "1F00-1FFF" ],
    [ 31,   "General Punctuation",  "2000-206F" ],
    [ 31,   "Supplemental Punctuation",     "2E00-2E7F" ],
    [ 32,   "Superscripts And Subscripts",  "2070-209F" ],
    [ 33,   "Currency Symbols",     "20A0-20CF" ],
    [ 34,   "Combining Diacritical Marks For Symbols",  "20D0-20FF" ],
    [ 35,   "Letterlike Symbols",   "2100-214F" ],
    [ 36,   "Number Forms",     "2150-218F" ],
    [ 37,   "Arrows",   "2190-21FF" ],
    [ 37,   "Supplemental Arrows-A",    "27F0-27FF" ],
    [ 37,   "Supplemental Arrows-B",    "2900-297F" ],
    [ 37,   "Miscellaneous Symbols and Arrows",     "2B00-2BFF" ],
    [ 38,   "Mathematical Operators",   "2200-22FF" ],
    [ 38,   "Supplemental Mathematical Operators",  "2A00-2AFF" ],
    [ 38,   "Miscellaneous Mathematical Symbols-A",     "27C0-27EF" ],
    [ 38,   "Miscellaneous Mathematical Symbols-B",     "2980-29FF" ],
    [ 39,   "Miscellaneous Technical",  "2300-23FF" ],
    [ 40,   "Control Pictures",     "2400-243F" ],
    [ 41,   "Optical Character Recognition",    "2440-245F" ],
    [ 42,   "Enclosed Alphanumerics",   "2460-24FF" ],
    [ 43,   "Box Drawing",  "2500-257F" ],
    [ 44,   "Block Elements",   "2580-259F" ],
    [ 45,   "Geometric Shapes",     "25A0-25FF" ],
    [ 46,   "Miscellaneous Symbols",    "2600-26FF" ],
    [ 47,   "Dingbats",     "2700-27BF" ],
    [ 48,   "CJK Symbols And Punctuation",  "3000-303F" ],
    [ 49,   "Hiragana",     "3040-309F" ],
    [ 50,   "Katakana",     "30A0-30FF" ],
    [ 50,   "Katakana Phonetic Extensions",     "31F0-31FF" ],
    [ 51,   "Bopomofo",     "3100-312F" ],
    [ 51,   "Bopomofo Extended",    "31A0-31BF" ],
    [ 52,   "Hangul Compatibility Jamo",    "3130-318F" ],
    [ 53,   "Phags-pa",     "A840-A87F" ],
    [ 54,   "Enclosed CJK Letters And Months",  "3200-32FF" ],
    [ 55,   "CJK Compatibility",    "3300-33FF" ],
    [ 56,   "Hangul Syllables",     "AC00-D7AF" ],
    [ 57,   "Non-Plane 0 * ",   "D800-DFFF" ],
    [ 58,   "Phoenician",   "10900-1091F" ],
    [ 59,   "CJK Unified Ideographs",   "4E00-9FFF" ],
    [ 59,   "CJK Radicals Supplement",  "2E80-2EFF" ],
    [ 59,   "Kangxi Radicals",  "2F00-2FDF" ],
    [ 59,   "Ideographic Description Characters",   "2FF0-2FFF" ],
    [ 59,   "CJK Unified Ideographs Extension A",   "3400-4DBF" ],
    [ 59,   "CJK Unified Ideographs Extension B",   "20000-2A6DF" ],
    [ 59,   "Kanbun",   "3190-319F" ],
    [ 60,   "Private Use Area (plane 0)",   "E000-F8FF" ],
    [ 61,   "CJK Strokes",  "31C0-31EF" ],
    [ 61,   "CJK Compatibility Ideographs",     "F900-FAFF" ],
    [ 61,   "CJK Compatibility Ideographs Supplement",  "2F800-2FA1F" ],
    [ 62,   "Alphabetic Presentation Forms",    "FB00-FB4F" ],
    [ 63,   "Arabic Presentation Forms-A",  "FB50-FDFF" ],
    [ 64,   "Combining Half Marks",     "FE20-FE2F" ],
    [ 65,   "Vertical Forms",   "FE10-FE1F" ],
    [ 65,   "CJK Compatibility Forms",  "FE30-FE4F" ],
    [ 66,   "Small Form Variants",  "FE50-FE6F" ],
    [ 67,   "Arabic Presentation Forms-B",  "FE70-FEFF" ],
    [ 68,   "Halfwidth And Fullwidth Forms",    "FF00-FFEF" ],
    [ 69,   "Specials",     "FFF0-FFFF" ],
    [ 70,   "Tibetan",  "0F00-0FFF" ],
    [ 71,   "Syriac",   "0700-074F" ],
    [ 72,   "Thaana",   "0780-07BF" ],
    [ 73,   "Sinhala",  "0D80-0DFF" ],
    [ 74,   "Myanmar",  "1000-109F" ],
    [ 75,   "Ethiopic",     "1200-137F" ],
    [ 75,   "Ethiopic Supplement",  "1380-139F" ],
    [ 75,   "Ethiopic Extended",    "2D80-2DDF" ],
    [ 76,   "Cherokee",     "13A0-13FF" ],
    [ 77,   "Unified Canadian Aboriginal Syllabics",    "1400-167F" ],
    [ 78,   "Ogham",    "1680-169F" ],
    [ 79,   "Runic",    "16A0-16FF" ],
    [ 80,   "Khmer",    "1780-17FF" ],
    [ 80,   "Khmer Symbols",    "19E0-19FF" ],
    [ 81,   "Mongolian",    "1800-18AF" ],
    [ 82,   "Braille Patterns",     "2800-28FF" ],
    [ 83,   "Yi Syllables",     "A000-A48F" ],
    [ 83,   "Yi Radicals",  "A490-A4CF" ],
    [ 84,   "Tagalog",  "1700-171F" ],
    [ 85,   "Hanunoo",  "1720-173F" ],
    [ 85,   "Buhid",    "1740-175F" ],
    [ 85,   "Tagbanwa",     "1760-177F" ],
    [ 85,   "Old Italic",   "10300-1032F" ],
    [ 86,   "Gothic",   "10330-1034F" ],
    [ 87,   "Deseret",  "10400-1044F" ],
    [ 88,   "Byzantine Musical Symbols",    "1D000-1D0FF" ],
    [ 88,   "Musical Symbols",  "1D100-1D1FF" ],
    [ 88,   "Ancient Greek Musical Notation",   "1D200-1D24F" ],
    [ 89,   "Mathematical Alphanumeric Symbols",    "1D400-1D7FF" ],
    [ 90,   "Private Use (plane 15)",   "FF000-FFFFD" ],
    [ 90,   "Private Use (plane 16)",   "100000-10FFFD" ],
    [ 91,   "Variation Selectors",  "FE00-FE0F" ],
    [ 91,   "Variation Selectors Supplement",   "E0100-E01EF" ],
    [ 92,   "Tags",     "E0000-E007F" ],
    [ 93,   "Limbu",    "1900-194F" ],
    [ 94,   "Tai Le",   "1950-197F" ],
    [ 95,   "New Tai Lue",  "1980-19DF" ],
    [ 96,   "Buginese",     "1A00-1A1F" ],
    [ 97,   "Glagolitic",   "2C00-2C5F" ],
    [ 98,   "Tifinagh",     "2D30-2D7F" ],
    [ 99,   "Yijing Hexagram Symbols",  "4DC0-4DFF" ],
    [ 100,  "Syloti Nagri",     "A800-A82F" ],
    [ 101,  "Linear B Syllabary",   "10000-1007F" ],
    [ 101,  "Linear B Ideograms",   "10080-100FF" ],
    [ 101,  "Aegean Numbers",   "10100-1013F" ],
    [ 102,  "Ancient Greek Numbers",    "10140-1018F" ],
    [ 103,  "Ugaritic",     "10380-1039F" ],
    [ 104,  "Old Persian",  "103A0-103DF" ],
    [ 105,  "Shavian",  "10450-1047F" ],
    [ 106,  "Osmanya",  "10480-104AF" ],
    [ 107,  "Cypriot Syllabary",    "10800-1083F" ],
    [ 108,  "Kharoshthi",   "10A00-10A5F" ],
    [ 109,  "Tai Xuan Jing Symbols",    "1D300-1D35F" ],
    [ 110,  "Cuneiform",    "12000-123FF" ],
    [ 110,  "Cuneiform Numbers and Punctuation",    "12400-1247F" ],
    [ 111,  "Counting Rod Numerals",    "1D360-1D37F" ],
    [ 112,  "Sundanese",    "1B80-1BBF" ],
    [ 113,  "Lepcha",   "1C00-1C4F" ],
    [ 114,  "Ol Chiki",     "1C50-1C7F" ],
    [ 115,  "Saurashtra",   "A880-A8DF" ],
    [ 116,  "Kayah Li",     "A900-A92F" ],
    [ 117,  "Rejang",   "A930-A95F" ],
    [ 118,  "Cham",     "AA00-AA5F" ],
    [ 119,  "Ancient Symbols",  "10190-101CF" ],
    [ 120,  "Phaistos Disc",    "101D0-101FF" ],
    [ 121,  "Carian",   "102A0-102DF" ],
    [ 121,  "Lycian",   "10280-1029F" ],
    [ 121,  "Lydian",   "10920-1093F" ],
    [ 122,  "Domino Tiles",     "1F030-1F09F" ],
    [ 122,  "Mahjong Tiles",    "1F000-1F02F" ],
    [ 123-127,  "Reserved",     "" ],
);

}


1;

=head1 BUGS

None known

=head1 AUTHOR

Martin Hosken L<http://scripts.sil.org/FontUtils>. 


=head1 LICENSING

Copyright (c) 1998-2014, SIL International (http://www.sil.org) 

This module is released under the terms of the Artistic License 2.0. 
For details, see the full text of the license in the file LICENSE.



=cut

