We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Support for copying the font metadata from fontTable.xml

Hi,
MS Word stores font metadata in “word/fontTable.xml” file for a docx document.

Referring to http://openxmldeveloper.org/discussions/formats/f/13/p/1074/2697.aspx - my understanding is that, fontTable.xml is an important piece of information… The fontTable.xml contains the information about each of the fonts used by the content in the Word document. When displaying/processing a Word document, if a particular font used by the content is not available in the consuming application (i guess MS Word tool or any other Wordprocessing tool), then it uses the corresponding font metadata from the fontTable.xml and uses the corresponding font as a substitute font to display the content or for processing… Even the theme1.xml refers to fonts for their major and minor font settings (tags <a:majorFont> and <a:minorFont>). Beyond this not sure on any other significances of this fontTable.xml data.

So when copying styles (from styles.xml) or themes from one document to another, it also make sense to copy the corresponding font metadata (from fontTable.xml) used by those styles or themes.

Please correct me if am wrong…


So we need Aspose API support for copying fonts (from fontTable.xml) one document to another document.

Currently I don’t see Aspose has something like addFont() API method. There is font retrieval method Document.getFontInfos() which returns FontInfoCollection, But not API for font copying unless I miss something.

Can you please add this functionality to copy fonts as well to take care of copying fonttable.xml metadata from one document to another document.

Thanks
-Satya

Hi Satya,


Thanks for your inquiry. Please note that Aspose.Words mimics the same behavior as MS Word does. If you copy style information from one document into another, the style information will be available in styles.xml.

Could you please share input documents along with expected output document here for our reference? We will then provide you more information on this along with code.

Hi Tahir,
Looking at <!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><span style=“font-size:11.0pt;font-family:“Calibri”,sans-serif;
mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-bidi-font-family:
“Times New Roman”;mso-ansi-language:EN-US;mso-fareast-language:EN-US;
mso-bidi-language:AR-SA”>http://openxmldeveloper.org/discussions/formats/f/13/p/1074/2697.aspx<!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman",serif;}

<![endif]–> - my understanding is that, MS Word uses fontTable.xml as a fallback mechanism.

Following is mentioned in the above URL:

"[An instance of this part type contains information about each of the fonts used by content in the document. When a consumer reads a WordprocessingML document, it shall use this information to determine which fonts to use to display the document when the specified fonts are not available on the consumer’s system.]

This part has an implicit relationship with the main document part.

The details will be stored in the fontTable.xml part…"

So my understanding on the fontTable.xml is that, it can used by a consuming WordprocessingML application, when consumer’s system don’t have specified fonts… as a fallback mechanism.

Said that, when we copying styles from one document to another document, it also sets certain font names from the source document into target document for the copied styles… During this process, i am not sure if fontTable.xml metadata also needs to be carried forward or not into the target document… I am not sure… So i can’t describe the requirement details here… Can you please check this with the MS Word documentation or Microsoft open xml specification in order to understand this…

Here I just thought to bring this to your notice about the fontTable.xml file inside MS Word docx archive (because I see Aspose doesn’t touch it)… Said that, currently we are not specifically seeing any problem with fontTable.xml thing during styles copy, if any we will let you know…

Thanks,
-Satya

Hi Satya,


Thanks for your inquiry. StyleCollection.AddCopy method does the followings:

  • Copies a style into this collection.
  • Copies linked style
  • Does not copy base styles.

Please note that Aspose.Words mimics the same behavior as MS Word does. MS Word does not copy information from fontTable.xml into target document. However, you can find the copied styles in styles.xml.