Displaying special extended characters with PHP -


so i've been working on couple hours , i'm close keep getting stuck on these special characters.

my client type foundry. majority of fonts have extended characters. requirement upload 1 otf file per each font, convert eot, woff, etc... allow font downloaded , purchased.

i've done of , noticed when conversion fontforge, creates .afm file appears adobe file.

after poking , prodding, afm file contains list of characters in font. awesome!

now i'm trying embed otf file in page display characters comes , can't figure out character encoding use.

a sample of afm file:

c 251 ; wx 965 ; n ucircumflex ; b 90 -10 869 691 ; c 252 ; wx 965 ; n udieresis ; b 90 -10 869 675 ; c 253 ; wx 856 ; n yacute ; b 11 -182 845 678 ; c 254 ; wx 947 ; n thorn ; b 96 -172 899 668 ; c 255 ; wx 856 ; n ydieresis ; b 11 -182 845 675 ; c -1 ; wx 1090 ; n amacron ; b 0 0 1090 820 ; c -1 ; wx 927 ; n amacron ; b 65 0 861 655 ; c -1 ; wx 1090 ; n abreve ; b 0 0 1090 851 ; c -1 ; wx 927 ; n abreve ; b 65 0 861 686 ; c -1 ; wx 1090 ; n aogonek ; b 0 -182 1090 668 ; c -1 ; wx 927 ; n aogonek ; b 65 -182 861 496 ; c -1 ; wx 1093 ; n cacute ; b 63 -10 1040 843 ; c -1 ; wx 917 ; n cacute ; b 48 -10 883 678 ; 

and how i'm trying display characters php

if($row['afm']) {     $in = 0;     $file_handle = fopen($row['afm'], "r");     while (!feof($file_handle))      {         $line = fgets($file_handle);         if(substr($line, 0, 16) == "startcharmetrics")         {             $in = 1;         }          if(substr($line, 0, 14) == "endcharmetrics")         {             $in = 0;         }          if($in == 1)         {             list($c, $wx, $n, $b) = explode(";", $line);             list($a, $b) = explode(" ", trim($c));             echo "<div class='box' style='font-family: sample; width: 150px; height: 50px; border: 1px #c4c4c4 solid; float: left; padding: 10px; font-family: sample; font-size: 44px;'>";             //echo $b . "<br>";             if($b == "-1")             {                 list($nn, $nnn) = explode(" ", trim($n));                 //echo "<!entity " . $nnn . " \&" . $nnn . ";>";                 echo unichr($nnn);                 //echo htmlspecialchars_decode("&" . $nnn . ";");             }             else             {                 echo unichr($b);             }     //      echo $line . "<br>";             echo "</div>";          }      }     fclose($file_handle); } function unichr($u) {     return mb_convert_encoding('&#' . intval($u) . ';', 'utf-8', 'html_entities'); } 

if $c contains recognized character (ie: not -1) use that, otherwise, use whats in $n - $n can't display - characters "aogonek"

i've tried utf-8 in meta , header, various iso formats, etc...

finally figured out!

i remember seeing fontforge can export svg file. on wim, converted otf file svg , opened in text editor - plain human readable text looks

<glyph glyph-name="ff" unicode="ff" horiz-adv-x="1001"  d="m26 496h74v58c0 67 56 114 139 114h267v-131h-101c-25 0 -37 -13 -37 -41h85v-135h-85v-361h-268v361h-74v135zm512 496h74v58c0 67 56 114 139 114h267v-131h-101c-25 0 -37 -13 -37 -41h85v-135h-85v-361h-268v361h-74v135z" /> 

after saw that, matter of using simple html dom parser , echoing unicode character line.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -