Download (as "text2gds.pm") text2gds.pm
#!/usr/bin/perl
# -----------------------------------------
# 1. 自分の手続きと同じ Folder に、このファイルを置く
# 2. 自分の手続きの中の初めの方に、次のように書いておいて
# require "./text2gds.pm";
# -----------------------------------------
# 3. 自分の手続の中で、次のどちらかの文を書く、 と文字を描くことが出来ます。
# -----------------------------------------
# 文字を含む structure を作る
# text2gds::text (Layer, Dot size, Structure name, Text, FileHandle);
# (この場合は、その Structure name を置きたい座標に printSref します)
# 文字を直接 x, y 座標に置く
# text2gds::text_flat(x, y, Layer, Dot size, Text, FileHandle);
# -----------------------------------------
#
package text2gds;
sub text {
my($layer, $dotsize, $structure, $text, $gds2File) = @_;
&bdfinit();
$gds2File -> printBgnstr(-name=> $structure);
# border
# &gds::box(255, 0,8*$dotsize, 6*$dotsize*length($text), 0);
for($i=0; $i<length($text); $i++){
$code = ord(substr($text, $i, 1));
;#
for($iy=0; $iy<7; $iy++){
$y0 = (8 - $iy) * $dotsize;
$y1 = $y0 - $dotsize;
for($ix=0; $ix<5; $ix++){
$x0 = ($ix * $dotsize) + ($i * 6 * $dotsize);
$x1 = $x0 + $dotsize;
if(substr(${'c'.$code}[$iy],$ix,1) eq '@'){
$gds2File -> printBoundary(
-layer => $layer,
-datType => 0,
-xy => [$x0, $y0, $x0, $y1, $x1, $y1, $x1, $y0],);
# &gds::box($layer, $x0,$y0, $x1,$y1);
}
}
}
}
$gds2File -> printEndstr;
}
sub text_flat ($$$$$$){
my($x, $y, $layer, $dotsize, $text, $gds2File) = @_;
&bdfinit();
# my ($offset_x, $offset_y);
# $offset_x = -1 * length($text) * $dotsize * 4;
# $offset_y = - $dotsize * 4;
$x -= length($text) * $dotsize * 3.5; # 7 x 0.5;
$y -= $dotsize * 4.5; # 9 x 0.5
# border
# &gds::box(255, 0,8*$dotsize, 6*$dotsize*length($text), 0);
for($i=0; $i<length($text); $i++){
$code = ord(substr($text, $i, 1));
;#
for($iy=0; $iy<7; $iy++){
$y0 = (8 - $iy) * $dotsize;
$y1 = $y0 - $dotsize;
for($ix=0; $ix<5; $ix++){
$x0 = ($ix * $dotsize) + ($i * 6 * $dotsize);
$x1 = $x0 + $dotsize;
if(substr(${'c'.$code}[$iy],$ix,1) eq '@'){
$gds2File -> printBoundary(
-layer => $layer,
-dataType => 0,
-xy => [$x0 + $x, $y0 + $y,
$x0 + $x, $y1 + $y,
$x1 + $x, $y1 + $y,
$x1 + $x, $y0 + $y],);
# &gds::box($layer, $x0,$y0, $x1,$y1);
}
}
}
}
}
# 90 degree cw,
sub text_flat_r ($$$$$$){
my($x, $y, $layer, $dotsize, $text, $gds2File) = @_;
&bdfinit();
# my $L = 10;
# $gds2File -> printPath( -xy => [ $x - $L, $y, $x + $L, $y], -layer => 55);
# $gds2File -> printPath( -xy => [ $x, $y - $L, $x, $y + $L], -layer => 56);
$x += $dotsize * 4.5 ;
$y += length($text) * $dotsize * 3.0 ;
for($i=0; $i<length($text); $i++){
$code = ord(substr($text, $i, 1));
;#
for($ix=6; $ix>-1; $ix--){
$x0 = (0 - $ix) * $dotsize;
$x1 = $x0 - $dotsize;
for($iy=0; $iy< 5; $iy++){
$y0 = ((0 - $iy )* $dotsize) + ((0 - $i ) * 6 * $dotsize);
$y1 = $y0 + $dotsize;
if(substr(${'c'.$code}[$ix],$iy,1) eq '@'){
$gds2File -> printBoundary(
-layer => $layer,
-dataType => 0,
-xy => [$x0 + $x, $y0 + $y,
$x0 + $x, $y1 + $y,
$x1 + $x, $y1 + $y,
$x1 + $x, $y0 + $y],);
# &gds::box($layer, $x0,$y0, $x1,$y1);
}
}
}
}
}
########
# Negative tone
sub text_n {
my($layer,$dotsize,$structure,$text)=@_;
&bdfinit();
$gds2File -> printBgnstr(-name=> $structure);
# border
# &gds::box(255, 0,7*$dotsize, 6*$dotsize*length($text), 0);
for($i=0; $i<length($text); $i++){
$code = ord(substr($text, $i, 1));
;#
for($iy=0; $iy<7; $iy++){
$y0 = (7 - $iy) * $dotsize;
$y1 = $y0 - $dotsize;
for($ix=0; $ix<6; $ix++){
$x0 = ($ix * $dotsize) + ($i * 6 * $dotsize);
$x1 = $x0 + $dotsize;
if(substr(${'c'.$code}[$iy],$ix,1) ne '@'){
&gds::box($layer, $x0,$y0, $x1,$y1);
}
}
}
}
$gds2File -> printEndstr;
}
sub bdfinit {
# define bitmap font same as BIT format (BDF)
@c32 = ('.....' ,
'.....' ,
'.....' ,
'.....' ,
'.....' ,
'.....' ,
'.....' );
@c33 = ('..@..' ,
'..@..' ,
'..@..' ,
'..@..' ,
'.....' ,
'.....' ,
'..@..' );
@c34 = ('.@.@.' ,
'.@.@.' ,
'.@.@.' ,
'.....' ,
'.....' ,
'.....' ,
'.....' );
@c35 = ('.@.@.' ,
'.@.@.' ,
'@@@@@' ,
'.@.@.' ,
'@@@@@' ,
'.@.@.' ,
'.@.@.' );
@c36 = ('..@..' ,
'.@@@@' ,
'@.@..' ,
'.@@@.' ,
'..@.@' ,
'@@@@.' ,
'..@..' );
@c37 = ('@@...' ,
'@@..@' ,
'...@.' ,
'..@..' ,
'.@...' ,
'@..@@' ,
'...@@' );
@c38 = ('.@@..' ,
'@..@.' ,
'@.@..' ,
'.@...' ,
'@.@.@' ,
'@..@.' ,
'.@@.@' );
@c39 = ('.@@..' ,
'..@..' ,
'.@...' ,
'.....' ,
'.....' ,
'.....' ,
'.....' );
@c40 = ('...@.' ,
'..@..' ,
'.@...' ,
'.@...' ,
'.@...' ,
'..@..' ,
'...@.' );
@c41 = ('.@...' ,
'..@..' ,
'...@.' ,
'...@.' ,
'...@.' ,
'..@..' ,
'.@...' );
@c42 = ('.....' ,
'..@..' ,
'@.@.@' ,
'.@@@.' ,
'@.@.@' ,
'..@..' ,
'.....' );
@c43 = ('.....' ,
'..@..' ,
'..@..' ,
'@@@@@' ,
'..@..' ,
'..@..' ,
'.....' );
@c44 = ('.....' ,
'.....' ,
'.....' ,
'.....' ,
'.@@..' ,
'..@..' ,
'.@...' );
@c45 = ('.....' ,
'.....' ,
'.....' ,
'@@@@@' ,
'.....' ,
'.....' ,
'.....' );
@c46 = ('.....' ,
'.....' ,
'.....' ,
'.....' ,
'.....' ,
'.@@..' ,
'.@@..' );
@c47 = ('.....' ,
'....@' ,
'...@.' ,
'..@..' ,
'.@...' ,
'@.....' ,
'.....' );
@c48 = ('.@@@.' ,
'@...@' ,
'@..@@' ,
'@.@.@' ,
'@@..@' ,
'@...@' ,
'.@@@.' );
@c49 = ('..@..' ,
'.@@..' ,
'..@..' ,
'..@..' ,
'..@..' ,
'..@..' ,
'.@@@.' );
@c50 = ('.@@@.' ,
'@...@' ,
'....@' ,
'...@.' ,
'..@..' ,
'.@...' ,
'@@@@@' );
@c51 = ('@@@@@' ,
'...@.' ,
'..@..' ,
'...@.' ,
'....@' ,
'@...@' ,
'.@@@.' );
@c52 = ('...@.' ,
'..@@.' ,
'.@.@.' ,
'@..@.' ,
'@@@@@' ,
'...@.' ,
'...@.' );
@c53 = ('@@@@@' ,
'@....' ,
'@@@@.' ,
'....@' ,
'....@' ,
'@...@' ,
'.@@@.' );
@c54 = ('..@@.' ,
'.@...' ,
'@....' ,
'@@@@.' ,
'@...@' ,
'@...@' ,
'.@@@.' );
@c55 = ('@@@@@' ,
'....@' ,
'...@.' ,
'..@..' ,
'.@...' ,
'.@...' ,
'.@...' );
@c56 = ('.@@@.' ,
'@...@' ,
'@...@' ,
'.@@@.' ,
'@...@' ,
'@...@' ,
'.@@@.' );
@c57 = ('.@@@.' ,
'@...@' ,
'@...@' ,
'.@@@@' ,
'....@' ,
'...@.' ,
'.@@..' );
@c58 = ('.....' ,
'.@@..' ,
'.@@..' ,
'.....' ,
'.@@..' ,
'.@@..' ,
'.....' );
@c59 = ('.....' ,
'.@@..' ,
'.@@..' ,
'.....' ,
'.@@..' ,
'..@..' ,
'.@...' );
@c60 = ('...@.' ,
'..@..' ,
'.@...' ,
'@....' ,
'.@...' ,
'..@..' ,
'...@.' );
@c61 = ('.....' ,
'.....' ,
'@@@@@' ,
'.....' ,
'@@@@@' ,
'.....' ,
'.....' );
@c62 = ('.@...' ,
'..@..' ,
'...@.' ,
'....@' ,
'...@.' ,
'..@..' ,
'.@...' );
@c63 = ('.@@@.' ,
'@...@' ,
'....@' ,
'...@.' ,
'..@..' ,
'.....' ,
'..@..' );
@c64 = ('.@@@.' ,
'@...@' ,
'....@' ,
'.@@.@' ,
'@.@.@' ,
'@.@.@' ,
'.@@@.' );
@c65 = ('.@@@.' ,
'@...@' ,
'@...@' ,
'@@@@@' ,
'@...@' ,
'@...@' ,
'@...@' );
@c66 = ('@@@@.' ,
'@...@' ,
'@...@' ,
'@@@@.' ,
'@...@' ,
'@...@' ,
'@@@@.' );
@c67 = ('.@@@.' ,
'@...@' ,
'@....' ,
'@....' ,
'@....' ,
'@...@' ,
'.@@@.' );
@c68 = ('@@@..' ,
'@..@.' ,
'@...@' ,
'@...@' ,
'@...@' ,
'@..@.' ,
'@@@..' );
@c69 = ('@@@@@' ,
'@....' ,
'@....' ,
'@@@@.' ,
'@....' ,
'@....' ,
'@@@@@' );
@c70 = ('@@@@@' ,
'@....' ,
'@....' ,
'@@@@.' ,
'@....' ,
'@....' ,
'@....' );
@c71 = ('.@@@.' ,
'@...@' ,
'@....' ,
'@.@@@' ,
'@...@' ,
'@...@' ,
'.@@@@' );
@c72 = ('@...@' ,
'@...@' ,
'@...@' ,
'@@@@@' ,
'@...@' ,
'@...@' ,
'@...@' );
@c73 = ('.@@@.' ,
'..@..' ,
'..@..' ,
'..@..' ,
'..@..' ,
'..@..' ,
'.@@@.' );
@c74 = ('..@@@' ,
'...@.' ,
'...@.' ,
'...@.' ,
'...@.' ,
'@..@.' ,
'.@@..' );
@c75 = ('@...@' ,
'@..@.' ,
'@.@..' ,
'@@...' ,
'@.@..' ,
'@..@.' ,
'@...@' );
@c76 = ('@....' ,
'@....' ,
'@....' ,
'@....' ,
'@....' ,
'@....' ,
'@@@@@' );
@c77 = ('@...@' ,
'@@.@@' ,
'@.@.@' ,
'@.@.@' ,
'@...@' ,
'@...@' ,
'@...@');
@c78 = ('@...@' ,
'@...@' ,
'@@..@' ,
'@.@.@' ,
'@..@@' ,
'@...@' ,
'@...@' );
@c79 = ('.@@@.' ,
'@...@' ,
'@...@' ,
'@...@' ,
'@...@' ,
'@...@' ,
'.@@@.' );
@c80 = ('@@@@.' ,
'@...@' ,
'@...@' ,
'@@@@.' ,
'@....' ,
'@....' ,
'@....' );
@c81 = ('.@@@.' ,
'@...@' ,
'@...@' ,
'@...@' ,
'@.@.@' ,
'@..@.' ,
'.@@.@' );
@c82 = ('@@@@.' ,
'@...@' ,
'@...@' ,
'@@@@.' ,
'@.@..' ,
'@..@.' ,
'@...@' );
@c83 = ('.@@@@' ,
'@....' ,
'@....' ,
'.@@@.' ,
'....@' ,
'....@' ,
'@@@@.' );
@c84 = ('@@@@@' ,
'..@..' ,
'..@..' ,
'..@..' ,
'..@..' ,
'..@..' ,
'..@..' );
@c85 = ('@...@' ,
'@...@' ,
'@...@' ,
'@...@' ,
'@...@' ,
'@...@' ,
'.@@@.' );
@c86 = ('@...@' ,
'@...@' ,
'@...@' ,
'@...@' ,
'@...@' ,
'.@.@.' ,
'..@..' );
@c87 = ('@...@' ,
'@...@' ,
'@...@' ,
'@.@.@' ,
'@.@.@' ,
'@.@.@' ,
'.@.@.' );
@c88 = ('@...@' ,
'@...@' ,
'.@.@.' ,
'..@..' ,
'.@.@.' ,
'@...@' ,
'@...@' );
@c89 = ('@...@' ,
'@...@' ,
'@...@' ,
'.@.@.' ,
'..@..' ,
'..@..' ,
'..@..' );
@c90 = ('@@@@@' ,
'....@' ,
'...@.' ,
'..@..' ,
'.@...' ,
'@....' ,
'@@@@@' );
@c91 = ('.@@@.' ,
'.@...' ,
'.@...' ,
'.@...' ,
'.@...' ,
'.@...' ,
'.@@@.' );
@c92 = ('.....' ,
'@....' ,
'.@...' ,
'..@..' ,
'...@.' ,
'....@' ,
'.....' );
@c93 = ('.@@@.' ,
'...@.' ,
'...@.' ,
'...@.' ,
'...@.' ,
'...@.' ,
'.@@@.' );
@c94 = ('..@..' ,
'.@.@.' ,
'@...@' ,
'.....' ,
'.....' ,
'.....' ,
'.....' );
@c95 = ('.....' ,
'.....' ,
'.....' ,
'.....' ,
'.....' ,
'.....' ,
'@@@@@' );
@c96 = ('.@...' ,
'..@..' ,
'...@.' ,
'.....' ,
'.....' ,
'.....' ,
'.....' );
@c97 = ('.....' ,
'.....' ,
'.@@@.' ,
'....@' ,
'.@@@@' ,
'@...@' ,
'.@@@@' );
@c98 = ('@....' ,
'@....' ,
'@.@@.' ,
'@@..@' ,
'@...@' ,
'@...@' ,
'@@@@.' );
@c99 = ('.....' ,
'.....' ,
'.@@@.' ,
'@....' ,
'@....' ,
'@...@' ,
'.@@@.' );
@c100 = ('....@' ,
'....@' ,
'.@@.@' ,
'@..@@' ,
'@...@' ,
'@...@' ,
'.@@@@' );
@c101 = ('.....' ,
'.....' ,
'.@@@.' ,
'@...@' ,
'@@@@@' ,
'@....' ,
'.@@@.' );
@c102 = ('..@@.' ,
'.@..@' ,
'.@...' ,
'@@@..' ,
'.@...' ,
'.@...' ,
'.@...' );
@c103 = ('.....' ,
'.@@@@' ,
'@...@' ,
'@...@' ,
'.@@@@' ,
'....@' ,
'.@@@.' );
@c104 = ('@....' ,
'@....' ,
'@.@@.' ,
'@@..@' ,
'@...@' ,
'@...@' ,
'@...@' );
@c105 = ('..@..' ,
'.....' ,
'.@@..' ,
'..@..' ,
'..@..' ,
'..@..' ,
'.@@@.' );
@c106 = ('...@.' ,
'.....' ,
'..@@.' ,
'...@.' ,
'...@.' ,
'@..@.' ,
'.@@..' );
@c107 = ('@....' ,
'@....' ,
'@..@.' ,
'@.@..' ,
'@@...' ,
'@.@..' ,
'@..@.' );
@c108 = ('.@@..' ,
'..@..' ,
'..@..' ,
'..@..' ,
'..@..' ,
'..@..' ,
'.@@@.' );
@c109 = ('.....' ,
'.....' ,
'@@.@.' ,
'@.@.@' ,
'@.@.@' ,
'@...@' ,
'@...@' );
@c110 = ('.....' ,
'.....' ,
'@.@@.' ,
'@@..@' ,
'@...@' ,
'@...@' ,
'@...@' );
@c111 = ('.....' ,
'.....' ,
'.@@@.' ,
'@...@' ,
'@...@' ,
'@...@' ,
'.@@@.' );
@c112 = ('.....' ,
'.....' ,
'@@@@.' ,
'@...@' ,
'@@@@.' ,
'@....' ,
'@....' );
@c113 = ('.....' ,
'.....' ,
'.@@.@' ,
'@..@@' ,
'.@@@@' ,
'....@' ,
'....@' );
@c114 = ('.....' ,
'.....' ,
'@.@@.' ,
'@@..@' ,
'@....' ,
'@....' ,
'@....' );
@c115 = ('.....' ,
'.....' ,
'.@@@.' ,
'@....' ,
'.@@@.' ,
'....@' ,
'@@@@.' );
@c116 = ('.@...' ,
'.@...' ,
'@@@..' ,
'.@...' ,
'.@...' ,
'.@..@' ,
'..@@.' );
@c117 = ('.....' ,
'.....' ,
'@...@' ,
'@...@' ,
'@...@' ,
'@..@@' ,
'.@@.@' );
@c118 = ('.....' ,
'.....' ,
'@...@' ,
'@...@' ,
'@...@' ,
'.@.@.' ,
'..@..' );
@c119 = ('.....' ,
'.....' ,
'@...@' ,
'@...@' ,
'@...@' ,
'@.@.@' ,
'.@.@.' );
@c120 = ('.....' ,
'.....' ,
'@...@' ,
'.@.@.' ,
'..@..' ,
'.@.@.' ,
'@...@' );
@c121 = ('.....' ,
'.....' ,
'@...@' ,
'@...@' ,
'.@@@@' ,
'....@' ,
'.@@@.' );
@c122 = ('.....' ,
'.....' ,
'@@@@@' ,
'...@.' ,
'..@..' ,
'.@...' ,
'@@@@@' );
@c123 = ('...@.' ,
'..@..' ,
'..@..' ,
'.@...' ,
'..@..' ,
'..@..' ,
'...@.' );
@c124 = ('..@..' ,
'..@..' ,
'..@..' ,
'..@..' ,
'..@..' ,
'..@..' ,
'..@..' );
@c125 = ('.@...' ,
'..@..' ,
'..@..' ,
'...@.' ,
'..@..' ,
'..@..' ,
'.@...' );
@c126 = ('.....' ,
'.....' ,
'.@...' ,
'@.@.@' ,
'...@.' ,
'.....' ,
'.....' );
#
}
1;
### EOF
|