#!/usr/local/bin/perl

package common;
# for each ratio block 
sub letters($$){
    my $w = shift;
    my $gds2File = shift;
    my @set = 0..9;
    push(@set,  qw (n m u :));
    foreach my $c (@set){
    text2gds::text(0, $w, 'char-'. $w.'-'.$c, $c, $gds2File );
    }
}
sub place_text($$$$$$$){
    my ($string) = shift;

    my ($x)     = shift;
    my ($y)     = shift;
    my ($pitch) = shift;

    my ($size)  = shift;
    my ($vertical) = shift; # 0 horizontal, 1 vertical
    my ($gds2File) = shift;

    my ($char_count) = length ($string);
    my ($name);
    my (@Chars);

    for my $loc ( 0 .. $char_count - 1) {
	my $size_str  = $size;
        $name = 'char-'  . $size_str. '-' .substr($string, $loc, 1);

	if ($vertical) {
        $gds2File -> printSref(
            -name => $name,
            -xy   =>[$x, $y + $pitch * $loc ],
	    -angle => 90
            );
	} else {
        $gds2File -> printSref(
            -name => $name,
            -xy   =>[$x + $pitch * $loc, $y],
            );

	}
	push(@Chars, $name);
    }
    return @Chars;
}

# prepare structure of each character with specified size
sub letters_by_name($$$$){
    my($prefix, $width, $c, $gds2File) = @_;
#    print STDERR sprintf("%04d ", __LINE__). ' prefix: '. $prefix . ' width '. $width . ' c: '. $c . "\n";
                  #layer dotsize, structure name text
    my ($dotsize) = int($width/50*1000)/1000;
    if ($dotsize > 100 ) { $dotsize = 100;}
    text2gds::text(0, $dotsize , $prefix . $width .'-'.$c, $c, $gds2File );
}


1;
