Page 1 of 1

Formating of table

Posted: Fri Oct 29, 2021 8:20 am
by hellroger
Good morning everybody,
I have the problem if I add datas to a table, the Font of the cell will change. Here is the example code:

for Column := 0 to 3 do
begin
TableCell := Table.Cells[Column,Zaehler];

with MainForm.ChildFormsArr as ICalibration do
begin

TableCell.Paras.Last.ClearText;
TableCell.Paras.Last.AppendFormattedText('\F"Arial"\s10' + Resolution[Column]);
end;
end;

I set that the cell should be in Font 'Arial', but it will show in 'Times New Roman'??? It would be grat, if there is any solution.
Regards, Roger

Re: Formating of table

Posted: Thu Nov 04, 2021 9:29 am
by larsa
Hello

I can't find any problems. Here is an example I used (assuming the first item in the doc is a table):

Code: Select all

var
  T: TAXWTable;
  C: TAXWTableCell;
begin
  T := DOCX.Editor.Paras.Tables[0];
  C := T.Cells[0,0];
  C.Paras.Last.ClearText;
  C.Paras.Last.AppendFormattedText('\F"Courier New"\s10 My Text');
end;

Re: Formating of table

Posted: Fri Nov 05, 2021 10:42 am
by hellroger
Dear Larsa,
Thanks for your reply. Unfortunately I have no success. I used exact your example (copy paste) and I get 'My text' in 'Arial' and not in 'Courier New'. Did you ahve any idea?

Regards,
Roger

Re: Formating of table

Posted: Tue Nov 09, 2021 2:57 pm
by cniccolo
I work with hellroger and have been investigating the issue further:

Your example code produces the following xml representation

Code: Select all

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<w:document xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml">
  <w:body>
    <w:p>
      <w:r />
      ...
         <w:r>
        <w:rPr>
          <w:rFonts w:eastAsia="Arial" w:cs="Courier New" />
          <w:b w:val="off" />
          <w:sz w:val="28" />
          <w:u w:val="none" />
        </w:rPr>
        <w:t xml:space="preserve">consectetur </w:t>
      </w:r>
    </w:p>
    <w:sectPr>
      <w:pgSz w:w="11906" w:h="16838" w:orient="portrait" />
      <w:pgMar w:top="1417" w:right="1417" w:bottom="1134" w:left="1417" w:header="708" w:footer="708" w:gutter="0" />
    </w:sectPr>
  </w:body>
</w:document>
I formatted the same document in Word and for the font definition we got the following line:

Code: Select all

<w:rFonts w:ascii="Courier New" w:eastAsia="Arial" w:hAnsi="Courier New" w:cs="Courier New" />
If I copy the font definition from word into the original document. The font is displayed correctly.

Checking the styles I have found the following style definition:

Code: Select all

<w:rFonts w:cs="Arial" w:eastAsia="Lucida Sans Unicode" w:hAnsi="Arial" w:ascii="Arial"/>
That explains why the original definition is not being displayed in courier. How can we ensure that all font definition properties are set? Is there another modifier than \F for that?

Re: Formating of table

Posted: Wed Nov 10, 2021 2:36 pm
by larsa
Hello

Do you use a chinese word/windows? The eastAsia font is used for chinese text.

Re: Formating of table

Posted: Wed Nov 10, 2021 4:27 pm
by hellroger
Dear Larsa,
We use normal Word (365) / Windows from Europe (Switzerland) in German Language.
We hope, you have an idea.
Regards Roger

Re: Formating of table

Posted: Thu Nov 11, 2021 12:08 pm
by cniccolo
I have removed the font definition from the file

Code: Select all

      
      <w:r>
        <w:rPr>
          <w:b w:val="off" />
          <w:sz w:val="28" />
          <w:u w:val="none" />
        </w:rPr>
        <w:t xml:space="preserve">consectetur </w:t>
      </w:r>
According to word it is now displayed as Arial. If it was using the w:eastAsia it would have to be in Lucida Sans Unicode with the definition coming from the style. Would you like the file?