Ignore:
Timestamp:
2013-01-15T22:49:23+13:00 (11 years ago)
Author:
davidb
Message:

Can now successfully obtain font size, font weight, font colour and font family information about each piece of text on a web page and convert to a corresponding text item on an Expeditee frame. Still need to account for text nodes with parents such as bold elements or heading elements.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs3-extensions/html-to-expeditee/trunk/src/perllib/CssStyleToExpAttr.pm

    r26727 r26728  
    353353
    354354   
    355     #if ($css_font_size =~ m/^(\d+(?:\.\d*))px$/) {
    356     #   $exp_font_size = int($1);
    357     #}
    358    
    359     $css_font_size =~ s/[^0-9]//g;
    360    
    361     if(defined $css_font_size){
    362         $exp_font_size = $css_font_size;
     355    if ($css_font_size =~ m/^(\d+(?:\.\d*))px$/) {
     356        $exp_font_size = int($1);
     357    }
     358   
     359    return $exp_font_size;
     360}
     361
     362sub convert_font_face
     363{
     364    my ($css_font_face) = @_;
     365    my $exp_font_face = undef;
     366   
     367    if(lc($css_font_face) eq "bold"){
     368            $exp_font_face = "b";
     369    }else{      #for now - also need to take into account italic and italic bold.
     370        $exp_font_face = "r";
    363371    }
    364372
    365     return $exp_font_size;
     373    return $exp_font_face;
    366374}
    367375
     
    405413    if(defined $font_specific_family_lookup->{lc($css_font_family)}){
    406414        $exp_font_family = $css_font_family."_";
     415    }else{
     416   
     417        #to account for instances where a list of fonts is stored as the font family, e.g. "Arial,Segoe...Sans-Serif".
     418        #just extract the first font name from this list.
     419        my @font_family_vals = split(',',$css_font_family);
     420       
     421        if(scalar(@font_family_vals) > 0){
     422            $exp_font_family = $font_family_vals[0]."_";
     423        }
     424   
    407425    }
    408    
    409     print STDERR "**** TESTING TESTING ".$font_specific_family_lookup->{"georgia"}."\n";
    410     print STDERR "**** TESTING TESTING ".$font_specific_family_lookup->{lc($css_font_family)}."\n";
    411     print STDERR "**** TESTING TESTING ".$font_specific_family_lookup->{$css_font_family}."\n";
    412     print STDERR "In CssStyleToExpAttr: font family attribute: $exp_font_family ******* \n";
    413426   
    414427    return $exp_font_family;
Note: See TracChangeset for help on using the changeset viewer.