use strict;
use vars qw($omegadb_path
- $opt_protrude $opt_order
+ $opt_protrude %opt_order
$opt_in_cs $opt_out_cs
$opt_help $usage
$in_cs $out_cs $i @chars
- @order %order
+ %order %order_map
$char $char_id $out_char
$ids $ids_argc %ids $idsdb
$idsdata_file $ids_start $font_start
### Options ###
-#$opt_order='jcgk';
-$opt_order='jGcgkHC';
+#$opt_order{'UniMulti'}='jcgk';
+$opt_order{'UniMulti'}='jGcgkHC';
+$opt_order{'UniGB'}='g';
+$opt_order{'UniCNS'}='c';
+$opt_order{'UniJIS'}='j';
+$opt_order{'UniKS'}='k';
+
$opt_protrude=0;# 1=true, 0=false.
-###
+### End ###
+
my $strictly_forbidden_after = '「【『[(〈“‘‘(〔{《{\[\(\x{3016}{「';
# \x{3016} | # white 【
$ids="";
@GT=(#"=gt","=gt-k",
- "=gt-pj-1","=gt-pj-2","=gt-pj-3","=gt-pj-4","=gt-pj-5","=gt-pj-6","=gt-pj-7","=gt-pj-8","=gt-pj-9","=gt-pj-10","=gt-pj-11"
+ "=gt-pj-1","=gt-pj-2","=gt-pj-3","=gt-pj-4","=gt-pj-5",
+ "=gt-pj-6","=gt-pj-7","=gt-pj-8","=gt-pj-9","=gt-pj-10",
+ "=gt-pj-11"
#,"=gt-pj-k1","=gt-pj-k2"
);
-@HZK=("=hanziku-1","=hanziku-2","=hanziku-3","=hanziku-4","=hanziku-5","=hanziku-6","=hanziku-7","=hanziku-8","=hanziku-9","=hanziku-10","=hanziku-11","=hanziku-12");
+@HZK=("=hanziku-1","=hanziku-2","=hanziku-3","=hanziku-4",
+ "=hanziku-5","=hanziku-6","=hanziku-7","=hanziku-8",
+ "=hanziku-9","=hanziku-10","=hanziku-11","=hanziku-12");
@CDP=("=big5-cdp");
-%order=('c'=>'UniCNS',
- 'g'=>'UniGB',
- 'j'=>'UniJIS',
- 'k'=>'UniKS',
- 'G'=>'GT',
- 'H'=>'HZK',
- 'C'=>'CDP',
- );
-
-if(defined($opt_order)){
- if($opt_order=~/^[cgjkGHC]*$/){
- @order=split(//,$opt_order);
- @order=map {$order{$_}} @order;
- }else{
- print STDERR "Invalid order!\n";
- exit 1;
+%order_map=('c'=>'UniCNS',
+ 'g'=>'UniGB',
+ 'j'=>'UniJIS',
+ 'k'=>'UniKS',
+ 'G'=>'GT',
+ 'H'=>'HZK',
+ 'C'=>'CDP',
+ );
+
+foreach $out_cs ('UniGB','UniCNS','UniJIS','UniKS','UniMulti'){
+ if(defined($opt_order{$out_cs})){
+ if($opt_order{$out_cs}=~/^[cgjkGHC]*$/){
+ @{$order{$out_cs}}=map {$order_map{$_}}
+ (split(//,$opt_order{$out_cs}));
+ }else{
+ print STDERR "Invalid order for $out_cs!\n";
+ exit 1;
+ }
}
}
sub get_output_char{
# argument: <char-id>
- # return: character in output coding system or TeX macro.
+ # return: character in output coding system or TeX macro or undef.
my($char_id,$out_cs)=@_;
my($char,$out_char_id,$suffix);
my($gt,$hzk,$cdp);
$char=pack('U',$char_id);
- if($out_cs eq 'UniJIS'
- and &get_char_attribute($char,"vnd-adobe-cid-unijis-utf16-h")){
- if($out_char_id=&get_char_attribute($char,'=ucs@jis')
- or $out_char_id=&get_char_attribute($char,'=ucs')
- or $out_char_id=&get_char_attribute($char,'=>ucs@jis')
- or $out_char_id=&get_char_attribute($char,'=>ucs')
- ){
- return pack("U",$out_char_id);
- }
- }elsif($out_cs eq 'UniGB'
- and &get_char_attribute($char,"vnd-adobe-cid-unigb-ucs2-h")){
- if($out_char_id=&get_char_attribute($char,'=ucs@gb')
- or $out_char_id=&get_char_attribute($char,'=ucs')
- or $out_char_id=&get_char_attribute($char,'=>ucs@gb')
- or $out_char_id=&get_char_attribute($char,'=>ucs')
- ){
- return pack("U",$out_char_id);
- }
- }elsif($out_cs eq 'UniCNS'
- and &get_char_attribute($char,"vnd-adobe-cid-unicns-ucs2-h")){
- if($out_char_id=&get_char_attribute($char,'=ucs@cns')
- or $out_char_id=&get_char_attribute($char,'=ucs')
- or $out_char_id=&get_char_attribute($char,'=>ucs@cns')
- or $out_char_id=&get_char_attribute($char,'=>ucs')
- ){
- return pack("U",$out_char_id);
- }
- }elsif($out_cs eq 'UniKS'
- and &get_char_attribute($char,"vnd-adobe-cid-uniks-ucs2-h")){
- if($out_char_id=&get_char_attribute($char,'=ucs@ks')
- or $out_char_id=&get_char_attribute($char,'=ucs')
- or $out_char_id=&get_char_attribute($char,'=>ucs@ks')
- or $out_char_id=&get_char_attribute($char,'=>ucs')
- ){
- return pack("U",$out_char_id);
- }
- }elsif($out_cs eq 'UniMulti'){
- foreach $out_cs (@order){
-
- if($out_cs eq 'UniJIS'
- and &get_char_attribute($char,"vnd-adobe-cid-unijis-utf16-h")){
- if($out_char_id=&get_char_attribute($char,'=ucs@jis')
- or $out_char_id=&get_char_attribute($char,'=ucs')
- or $out_char_id=&get_char_attribute($char,'=>ucs@jis')
- or $out_char_id=&get_char_attribute($char,'=>ucs')
- ){
- return '{\selectjisfont\char'.$out_char_id.'}';
- }
- }elsif($out_cs eq 'UniGB'
- and &get_char_attribute($char,"vnd-adobe-cid-unigb-ucs2-h")){
- if($out_char_id=&get_char_attribute($char,'=ucs@gb')
- or $out_char_id=&get_char_attribute($char,'=ucs')
- or $out_char_id=&get_char_attribute($char,'=>ucs@gb')
- or $out_char_id=&get_char_attribute($char,'=>ucs')
- ){
- return '{\selectgbsfont\char'.$out_char_id.'}';
- }
- }elsif($out_cs eq 'UniCNS'
- and &get_char_attribute($char,"vnd-adobe-cid-unicns-ucs2-h")){
- if($out_char_id=&get_char_attribute($char,'=ucs@cns')
- or $out_char_id=&get_char_attribute($char,'=ucs')
- or $out_char_id=&get_char_attribute($char,'=>ucs@cns')
- or $out_char_id=&get_char_attribute($char,'=>ucs')
- ){
- return '{\selectcnsfont\char'.$out_char_id.'}';
- }
- }elsif($out_cs eq 'UniKS'
- and &get_char_attribute($char,"vnd-adobe-cid-uniks-ucs2-h")){
- if($out_char_id=&get_char_attribute($char,'=ucs@ks')
- or $out_char_id=&get_char_attribute($char,'=ucs')
- or $out_char_id=&get_char_attribute($char,'=>ucs@ks')
- or $out_char_id=&get_char_attribute($char,'=>ucs')
- ){
- return '{\selectksxfont\char'.$out_char_id.'}';
- }
- }elsif($out_cs eq 'GT'){
- return $gt if($gt=&get_macro_for_GT($char_id));
- }elsif($out_cs eq 'HZK'){
- return $hzk if($hzk=&get_macro_for_HZK($char_id));
- }elsif($out_cs eq 'CDP'){
- return $cdp if($cdp=&get_macro_for_CDP($char_id));
+ foreach $out_cs (@{$order{$out_cs}}){
+ if($out_cs eq 'UniJIS'
+ and &get_char_attribute($char,"vnd-adobe-cid-unijis-utf16-h")){
+ if($out_char_id=&get_char_attribute($char,'=ucs@jis')
+ or $out_char_id=&get_char_attribute($char,'=ucs')
+ or $out_char_id=&get_char_attribute($char,'=>ucs@jis')
+ or $out_char_id=&get_char_attribute($char,'=>ucs')
+ ){
+ return '{\selectjisfont\char'.$out_char_id.'}';
}
+ }elsif($out_cs eq 'UniGB'
+ and &get_char_attribute($char,"vnd-adobe-cid-unigb-ucs2-h")){
+ if($out_char_id=&get_char_attribute($char,'=ucs@gb')
+ or $out_char_id=&get_char_attribute($char,'=ucs')
+ or $out_char_id=&get_char_attribute($char,'=>ucs@gb')
+ or $out_char_id=&get_char_attribute($char,'=>ucs')
+ ){
+ return '{\selectgbsfont\char'.$out_char_id.'}';
+ }
+ }elsif($out_cs eq 'UniCNS'
+ and &get_char_attribute($char,"vnd-adobe-cid-unicns-ucs2-h")){
+ if($out_char_id=&get_char_attribute($char,'=ucs@cns')
+ or $out_char_id=&get_char_attribute($char,'=ucs')
+ or $out_char_id=&get_char_attribute($char,'=>ucs@cns')
+ or $out_char_id=&get_char_attribute($char,'=>ucs')
+ ){
+ return '{\selectcnsfont\char'.$out_char_id.'}';
+ }
+ }elsif($out_cs eq 'UniKS'
+ and &get_char_attribute($char,"vnd-adobe-cid-uniks-ucs2-h")){
+ if($out_char_id=&get_char_attribute($char,'=ucs@ks')
+ or $out_char_id=&get_char_attribute($char,'=ucs')
+ or $out_char_id=&get_char_attribute($char,'=>ucs@ks')
+ or $out_char_id=&get_char_attribute($char,'=>ucs')
+ ){
+ return '{\selectksxfont\char'.$out_char_id.'}';
+ }
+ }elsif($out_cs eq 'GT'){
+ return $gt if($gt=&get_macro_for_GT($char_id));
+ }elsif($out_cs eq 'HZK'){
+ return $hzk if($hzk=&get_macro_for_HZK($char_id));
+ }elsif($out_cs eq 'CDP'){
+ return $cdp if($cdp=&get_macro_for_CDP($char_id));
}
}
return undef;
sub get_char_id_for_ids{
# argument: <ideographic description sequence>
- # return: char-id
+ # return: char-id or undef.
my($ids)=@_;
my($output_char);
sub get_macro_for_GT{
# argument: <char-id>
- # return: TeX macro for GT fonts.
+ # return: TeX macro for GT fonts or undef.
my($char_id)=@_;
my($char,$gt,$GT);
$char=pack("U",$char_id);
}
sub get_macro_for_HZK{
+ # argument: <char-id>
+ # return: TeX macro for Hanziku fonts or undef.
my($char_id)=@_;
my($char,$hzk,$HZK);
$char=pack("U",$char_id);
}
sub get_macro_for_CDP{
+ # argument: <char-id>
+ # return: TeX macro for CDP fonts or undef.
my($char_id)=@_;
my($char,$cdp,$ucs);
$char=pack("U",$char_id);