Changeset 26727


Ignore:
Timestamp:
2013-01-15T20:53:38+13:00 (9 years ago)
Author:
davidb
Message:

Working on obtaining the correct font information for text elements on an html page.

Location:
gs3-extensions/html-to-expeditee/trunk/src/perllib
Files:
2 edited

Legend:

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

    r24944 r26727  
    5555  "tahoma"          => "sans-serif",
    5656  "geneva"          => "sans-serif",
     57  "georgia"         => "serif",
    5758  "times"           => "serif",
    5859  "times new roman"     => "serif",
     
    351352    my $exp_font_size = undef;
    352353
    353     if ($css_font_size =~ m/^(\d+(?:\.\d*))px$/) {
    354     $exp_font_size = int($1);
    355     }
     354   
     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;
     363    }
    356364
    357365    return $exp_font_size;
     
    384392    return $exp_color;
    385393}
     394
     395sub convert_font_family
     396{
     397    my ($css_font_family) = @_;
     398       
     399    print STDERR "*** PASSING PARAMETER css font family: ".$css_font_family."\n";
     400   
     401    my $exp_font_family;
     402   
     403    #use $font_specific_family_lookup and $font_generic_family_lookup
     404    #to find the appropriate font family tag to output to expeditee.
     405    if(defined $font_specific_family_lookup->{lc($css_font_family)}){
     406        $exp_font_family = $css_font_family."_";
     407    }
     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";
     413   
     414    return $exp_font_family;
     415}
     416
     417sub convert_font_style
     418{
     419    my ($css_font_style) = @_;
     420
     421    my $exp_font_style;
     422   
     423    return $exp_font_style;
     424}
    386425   
    3874261;
    388    
  • gs3-extensions/html-to-expeditee/trunk/src/perllib/ExpediteeFrameIO.pm

    r26695 r26727  
    7777    my $exp_font_family = "s"; # t
    7878    my $exp_font_face = "r";
    79     my $exp_font_size = "14";
     79    my $exp_font_size = "18";
    8080
    8181#    if (defined $css_attr->{'font-family'}) {
     
    8484
    8585    if (defined $css_attr->{'font-size'}) {
    86     my $css_font_size = $css_attr->{'font-size'};
    87     $exp_font_size = CssStyleToExpAttr::convert_font_size($css_font_size);
    88     }
    89 
     86       
     87        my $css_font_size = $css_attr->{'font-size'};
     88        $exp_font_size = CssStyleToExpAttr::convert_font_size($css_font_size);
     89       
     90        print STDERR "CSS Font Size is defined: ".$css_font_size."\n";
     91        print STDERR "Equivalent expeditee font size: ".$exp_font_size."\n";
     92    }
     93   
     94    if(defined $css_attr->{'font-family'}){
     95        my $obtain_font_family = $css_attr->{'font-family'};
     96        print STDERR "Font family attribute found: ".$obtain_font_family."\n";
     97        my $new_exp_font_family = CssStyleToExpAttr::convert_font_family($obtain_font_family); 
     98
     99        if(defined $new_exp_font_family){
     100            $exp_font_family = $new_exp_font_family;
     101        }
     102    }
     103   
     104    if(defined $css_attr->{'font-face'}){
     105        print STDERR "Font face attribute found: ".$css_attr->{'font-face'}."\n";
     106       
     107        #now need to call a method from CssStyleToExpAttr.pm to extract the matching
     108        #font symbol
     109        #s -
     110    }
     111   
     112    if(defined $css_attr->{'font-weight'}){
     113        print STDERR "Font weight attribute found: ".$css_attr->{'font-weight'}."\n";
     114    }
     115   
    90116#    if (defined $css_attr->{'font-face'}) {
    91117#   $font = conver_font_face($css_attr->{'font-face'});
    92118#    }
    93119
    94 #    $exp_attr->{'f'} = $exp_font_family.$exp_font_face.$exp_font_size;
    95 
     120     $exp_attr->{'f'} = $exp_font_family.$exp_font_face.$exp_font_size;
     121     
     122     print STDERR "**** final converted Expeditee font: ".$exp_attr->{'f'};
     123     
    96124    # background color
    97125
    98126
    99127    if (defined $css_attr->{'background-color'}) {
    100     my $css_color = $css_attr->{'background-color'};
    101 
    102     my $exp_color = CssStyleToExpAttr::convert_color($css_color);
    103 
    104     $exp_attr->{'e'} = $exp_color;
     128        my $css_color = $css_attr->{'background-color'};
     129
     130        my $exp_color = CssStyleToExpAttr::convert_color($css_color);
     131
     132        $exp_attr->{'e'} = $exp_color;
    105133    }
    106134
     
    550578        }
    551579    }
     580   
     581    #don't want to add font information to non-text items!
     582    my $deleted = delete $attr->{'f'};
     583   
     584    print STDERR "**** DELETED: $deleted \n";
    552585
    553586    $self->addRect($xl,$yt,$xr,$yb,$attr);
     
    578611    }
    579612    elsif ($type eq "text") {
     613   
    580614    my $text = $html_node->{'text'};
    581615
     
    584618    my $w = $html_node->{'xr'} - $x +1;
    585619
     620    print STDERR "**** CHECKING STYLE NODE: ".$html_node->{'style'}."\n";
    586621    my $attr = convertStyleToAttr($html_node->{'style'});
    587 
     622   
     623    #DEBUGGING
     624    if(defined $attr->{'f'}){
     625        print STDERR "***** Checking text attributes:".$attr->{'f'}."\n";
     626        print STDERR "****************************************\n";
     627    }
     628   
    588629    # fudge factor for now (based on default font size used)
    589630    $y += 16; # y-value of text item in Expeditee is it's base line
Note: See TracChangeset for help on using the changeset viewer.