@@ -83,6 +83,8 @@ sub _font_setup {
8383 $fref -> {texture } = PDL::float(1,1,1,1) * $texture -> dummy(0,1);
8484 my $widthpix = $rightbound -> numdiff; $widthpix -> slice(' 0' ) += 1;
8585 @{ $fref -> {widthpix } } = $widthpix -> list;
86+ $fref -> {widthflt } = $widthpix -> float;
87+ $fref -> {widthflt11 } = $fref -> {widthflt }-> t-> append([1,1])-> dummy(1);
8688 $fref -> {heightpix } = $texture -> dim(1);
8789 $fref -> {numchars } = my $numchars = $rightbound -> nelem;
8890 $fref -> {texwidthm1 } = my $texwidthm1 = $texture -> dim(0) - 1;
@@ -115,24 +117,21 @@ sub togl_setup {
115117 my $dwidth = $PDL::Graphics::TriD::Window::DEFAULT_WIDTH / 1.5;
116118 my $dheight = $PDL::Graphics::TriD::Window::DEFAULT_HEIGHT / 1.5;
117119 $vert_template *= PDL::float(1 / $dwidth , 1, $FONT {heightpix } / $dheight );
118- my ( @codes ) = map [map ord , split //], @{ $this -> {Strings } };
119- my ($total_chars , @i , @v , @tc ) = 0 ;
120+ my @codes = map [map ord , split //], @{ $this -> {Strings } };
121+ my ($v2 , @v1 , @v3 ) = PDL -> null ;
120122 for (0..$#codes ) {
121- my ($l , $point , $xoffset ) = ($codes [$_ ], $points -> dice_axis(1, $_ ), 0);
122- for (0..$# $l ) {
123- my $c = $l -> [$_ ];
124- PDL::barf " Codepoint $c >= $numchars " if $c >= $numchars ;
125- my $thiswidth = $FONT {widthpix }[$c ];
126- push @i , $FONT {idx } + 4*$total_chars ;
127- push @v , $point + PDL::float($xoffset ,0,0) + ($vert_template * PDL::float($thiswidth ,1,1));
128- push @tc , $FONT {texcoords }-> slice(" ,,($c )" );
129- $xoffset += $thiswidth / $dwidth ;
130- $total_chars ++;
131- }
123+ my ($l , $xoffset ) = ($codes [$_ ], 0);
124+ PDL::barf " Codepoint $_ >= $numchars " for grep $_ >= $numchars , @$l ;
125+ push @v1 , ($_ ) x @$l ;
126+ push @v3 , @$l ;
127+ $v2 = PDL::glue(0,$v2 ,$FONT {widthflt }-> dice_axis(0,$l )-> cumusumover);
132128 }
133- $this -> load_buffer(vert_buf => PDL::cat(@v )-> clump(1,2));
134- $this -> load_buffer(texc_buf => PDL::cat(@tc )-> clump(1,2));
135- $this -> load_idx_buffer(indx_buf => $this -> {Impl }{idx } = PDL::cat(@i )-> clump(1,2));
129+ my $v = $points -> dice_axis(1, \@v1 )-> dummy(1) +
130+ ($v2 -> t-> append([0,0])-> dummy(1) / $dwidth ) +
131+ $vert_template * $FONT {widthflt11 }-> dice_axis(2,\@v3 );
132+ $this -> load_buffer(vert_buf => $v -> clump(1,2));
133+ $this -> load_buffer(texc_buf => $FONT {texcoords }-> dice_axis(2,\@v3 )-> clump(1,2));
134+ $this -> load_idx_buffer(indx_buf => $this -> {Impl }{idx } = $FONT {idx }-> flat + 4 * PDL-> sequence(PDL::ulong,1,0+@v1 ));
136135 $this -> togl_unbind;
137136}
138137sub gdraw {
0 commit comments