rtf-html-php icon indicating copy to clipboard operation
rtf-html-php copied to clipboard

Add Handling for font names in double quotes

Open lm-cmxkonzepte opened this issue 3 years ago • 0 comments

I came across a RTF file generated by Microsoft Outlook (inside a winmail.dat/TNEF-file which came attached to a mail), that encloses font names in double Quotes, which makes sense if the font names has multiple words (which it didn't in this case but it's possible). The HTML produced was wrong as a result:

<span style="font-style:italic;font-family:"Arial" sans-serif;font-size:16px;">

I added code which replaces double quotes at the beginning and end of the font name string with single quotes, and seperates font name and family with a comma, which results in this HTML:

<span style="font-style:italic;font-family:'Arial', sans-serif;font-size:16px;">

This was already fixed in #70, and reverted in #88. The latter PR has no description and doesn't make sense to me.

This is the RTF file I was using:

{\rtf1\ansi\ansicpg1252\fromhtml1 \fbidis \deff0{\fonttbl

{\f0\fswiss\fcharset0 Arial;}

{\f1\fmodern Courier New;}

{\f2\fnil\fcharset2 Symbol;}

{\f3\fmodern\fcharset0 Courier New;}

{\f4\fswiss\fcharset0 "Arial";}

{\f5\fswiss\fcharset129 "Arial";}}

{\colortbl\red0\green0\blue0;\red5\green99\blue193;}

\uc1\pard\plain\deftab360 \f0\fs24 

{\*\htmltag19 <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">}

{\*\htmltag34 <head>}

{\*\htmltag161 <meta name=Generator content="Microsoft Word 15 (filtered medium)">}

{\*\htmltag241 <style>}

{\*\htmltag241 <!--\par /* Font Definitions */\par @font-face\par \tab \{font-family:"Cambria Math";\par \tab panose-1:2 4 5 3 5 4 6 3 2 4;\}\par @font-face\par \tab \{font-family:Calibri;\par \tab panose-1:2 15 5 2 2 2 4 3 2 4;\}\par /* Style Definitions */\par p.MsoNormal, li.MsoNormal, div.MsoNormal\par \tab \{margin:0cm;\par \tab font-size:11.0pt;\par \tab font-family:"Calibri",sans-serif;\par \tab mso-fareast-language:EN-US;\}\par span.E-MailFormatvorlage18\par \tab \{mso-style-type:personal-compose;\par \tab font-family:"Calibri",sans-serif;\par \tab color:windowtext;\}\par .MsoChpDefault\par \tab \{mso-style-type:export-only;\par \tab font-size:10.0pt;\}\par @page WordSection1\par \tab \{size:612.0pt 792.0pt;\par \tab margin:70.85pt 70.85pt 2.0cm 70.85pt;\}\par div.WordSection1\par \tab \{page:WordSection1;\}\par -->}

{\*\htmltag249 </style>}

{\*\htmltag241 <!--[if gte mso 9]><xml>\par <o:shapedefaults v:ext="edit" spidmax="1026" />\par </xml><![endif]-->}

{\*\htmltag241 <!--[if gte mso 9]><xml>\par <o:shapelayout v:ext="edit">\par <o:idmap v:ext="edit" data="1" />\par </o:shapelayout></xml><![endif]-->}

{\*\htmltag41 </head>}

{\*\htmltag50 <body lang=DE link="#0563C1" vlink="#954F72" style='word-wrap:break-word'>}\htmlrtf \lang1031 \htmlrtf0 

{\*\htmltag96 <div class=WordSection1>}\htmlrtf {\htmlrtf0 

{\*\htmltag64 <p class=MsoNormal>}\htmlrtf {\htmlrtf0 Das ist die Beschreibung f\'fcr meinen Termin. 

{\*\htmltag84 <i>}\htmlrtf {\i \htmlrtf0 

{\*\htmltag148 <span style='font-size:10.5pt;font-family:"Arial",sans-serif;color:black'>}\htmlrtf {\f4 \htmlrtf0 \'d9\htmlrtf{\f5\fs24\htmlrtf0 \'a8\'ae\u-1280 ?-\u8312 ?.\htmlrtf\f4}\htmlrtf0  

{\*\htmltag156 </span>}\htmlrtf }\htmlrtf0 

{\*\htmltag92 </i>}\htmlrtf }\htmlrtf0 

{\*\htmltag84 <b>}\htmlrtf {\b \htmlrtf0 

{\*\htmltag148 <span style='font-size:10.5pt;font-family:"Arial",sans-serif;color:black'>}\htmlrtf {\f4 \htmlrtf0 Da ist sogar HTML drin.

{\*\htmltag244 <o:p>}

{\*\htmltag252 </o:p>}

{\*\htmltag156 </span>}\htmlrtf }\htmlrtf0 

{\*\htmltag92 </b>}\htmlrtf }\htmlrtf0 \htmlrtf\par}\htmlrtf0

\htmlrtf \par

\htmlrtf0 

{\*\htmltag72 </p>}

{\*\htmltag64 <p class=MsoNormal>}\htmlrtf {\htmlrtf0 

{\*\htmltag84 <b>}\htmlrtf {\b \htmlrtf0 

{\*\htmltag148 <span style='font-size:10.5pt;font-family:"Arial",sans-serif;color:black'>}\htmlrtf {\f4 \htmlrtf0 

{\*\htmltag244 <o:p>}

{\*\htmltag84 &nbsp;}\htmlrtf \'a0\htmlrtf0 

{\*\htmltag252 </o:p>}

{\*\htmltag156 </span>}\htmlrtf }\htmlrtf0 

{\*\htmltag92 </b>}\htmlrtf }\htmlrtf0 \htmlrtf\par}\htmlrtf0

\htmlrtf \par

\htmlrtf0 

{\*\htmltag72 </p>}

{\*\htmltag64 <p class=MsoNormal>}\htmlrtf {\htmlrtf0 

{\*\htmltag84 <b>}\htmlrtf {\b \htmlrtf0 

{\*\htmltag148 <span style='font-size:10.5pt;font-family:"Arial",sans-serif;color:black'>}\htmlrtf {\f4 \htmlrtf0 Und es gibt mehrere Zeilen.

{\*\htmltag156 </span>}\htmlrtf }\htmlrtf0 

{\*\htmltag92 </b>}\htmlrtf }\htmlrtf0 

{\*\htmltag244 <o:p>}

{\*\htmltag252 </o:p>}\htmlrtf\par}\htmlrtf0

\htmlrtf \par

\htmlrtf0 

{\*\htmltag72 </p>}

{\*\htmltag104 </div>}\htmlrtf }\htmlrtf0 

{\*\htmltag58 </body>}

{\*\htmltag27 </html>}}

lm-cmxkonzepte avatar Apr 27 '22 13:04 lm-cmxkonzepte