Fonts 如何找出OOXML中段落使用的字体系列?
假设一个特定的样式应用于一个段落。我想知道这种风格的字体系列是什么。我尝试打开docx中的Fonts 如何找出OOXML中段落使用的字体系列?,fonts,ms-word,apache-poi,docx,xwpf,Fonts,Ms Word,Apache Poi,Docx,Xwpf,假设一个特定的样式应用于一个段落。我想知道这种风格的字体系列是什么。我尝试打开docx中的style.xml文件。我找不到许多样式的w:ascii属性集。例如,考虑样式标题1>代码>。与此样式对应的OOXML是 <w:style w:type="paragraph" w:styleId="Heading1"> <w:name w:val="heading 1"/> <w:basedOn w:val="Normal"/> <w:ne
style.xml
文件。我找不到许多样式的w:ascii
属性集。例如,考虑样式<代码>标题1>代码>。与此样式对应的OOXML是
<w:style w:type="paragraph" w:styleId="Heading1">
<w:name w:val="heading 1"/>
<w:basedOn w:val="Normal"/>
<w:next w:val="Normal"/>
<w:link w:val="Heading1Char"/>
<w:uiPriority w:val="9"/>
<w:qFormat/>
<w:rsid w:val="00FB3E81"/>
<w:pPr>
<w:keepNext/>
<w:keepLines/>
<w:spacing w:before="240"/>
<w:outlineLvl w:val="0"/>
</w:pPr>
<w:rPr>
<w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi"/>
<w:color w:val="2E74B5" w:themeColor="accent1" w:themeShade="BF"/>
<w:sz w:val="32"/>
<w:szCs w:val="32"/>
</w:rPr>
</w:style>
在
w:rFonts
标记中,没有w:ascii
属性来提取字体系列。此样式的字体系列详细信息存储在何处,以及如何提取它以在java应用程序中使用?我正在使用ApachePOI解析文档。检查w:rFonts
。在您引用的示例中,w:asciiTheme=“majorHAnsi”
告诉您它使用的字体在主题中定义为majorHAnsi
,这是用于标题的主题字体。因此,您需要确定主题文件中指定的字体系列,它可能是theme1.xml
编辑:
在主题文件中,您将找到fontScheme,它定义了两种字体,majorFont
和minorFont
。这些对应于majorHAnsi
和minorHAnsi
,如果使用的主题是Office附带的标准主题之一,则可能会有大量条目,具体取决于使用的语言脚本
<a:fontScheme name="Office Theme">
<a:majorFont>
<a:latin typeface="Calibri Light" panose="020F0302020204030204" />
<a:ea typeface="" />
<a:cs typeface="" />
<a:font script="Jpan" typeface="游ゴシック Light" />
<a:font script="Hang" typeface="맑은 고딕" />
<a:font script="Hans" typeface="等线 Light" />
<a:font script="Hant" typeface="新細明體" />
<a:font script="Arab" typeface="Times New Roman" />
<a:font script="Hebr" typeface="Times New Roman" />
<a:font script="Thai" typeface="Angsana New" />
<a:font script="Ethi" typeface="Nyala" />
<a:font script="Beng" typeface="Vrinda" />
<a:font script="Gujr" typeface="Shruti" />
<a:font script="Khmr" typeface="MoolBoran" />
<a:font script="Knda" typeface="Tunga" />
<a:font script="Guru" typeface="Raavi" />
<a:font script="Cans" typeface="Euphemia" />
<a:font script="Cher" typeface="Plantagenet Cherokee" />
<a:font script="Yiii" typeface="Microsoft Yi Baiti" />
<a:font script="Tibt" typeface="Microsoft Himalaya" />
<a:font script="Thaa" typeface="MV Boli" />
<a:font script="Deva" typeface="Mangal" />
<a:font script="Telu" typeface="Gautami" />
<a:font script="Taml" typeface="Latha" />
<a:font script="Syrc" typeface="Estrangelo Edessa" />
<a:font script="Orya" typeface="Kalinga" />
<a:font script="Mlym" typeface="Kartika" />
<a:font script="Laoo" typeface="DokChampa" />
<a:font script="Sinh" typeface="Iskoola Pota" />
<a:font script="Mong" typeface="Mongolian Baiti" />
<a:font script="Viet" typeface="Times New Roman" />
<a:font script="Uigh" typeface="Microsoft Uighur" />
<a:font script="Geor" typeface="Sylfaen" />
</a:majorFont>
<a:minorFont>
<a:latin typeface="Calibri" panose="020F0502020204030204" />
<a:ea typeface="" />
<a:cs typeface="" />
<a:font script="Jpan" typeface="游ゴシック" />
<a:font script="Hang" typeface="맑은 고딕" />
<a:font script="Hans" typeface="等线" />
<a:font script="Hant" typeface="新細明體" />
<a:font script="Arab" typeface="Arial" />
<a:font script="Hebr" typeface="Arial" />
<a:font script="Thai" typeface="Cordia New" />
<a:font script="Ethi" typeface="Nyala" />
<a:font script="Beng" typeface="Vrinda" />
<a:font script="Gujr" typeface="Shruti" />
<a:font script="Khmr" typeface="DaunPenh" />
<a:font script="Knda" typeface="Tunga" />
<a:font script="Guru" typeface="Raavi" />
<a:font script="Cans" typeface="Euphemia" />
<a:font script="Cher" typeface="Plantagenet Cherokee" />
<a:font script="Yiii" typeface="Microsoft Yi Baiti" />
<a:font script="Tibt" typeface="Microsoft Himalaya" />
<a:font script="Thaa" typeface="MV Boli" />
<a:font script="Deva" typeface="Mangal" />
<a:font script="Telu" typeface="Gautami" />
<a:font script="Taml" typeface="Latha" />
<a:font script="Syrc" typeface="Estrangelo Edessa" />
<a:font script="Orya" typeface="Kalinga" />
<a:font script="Mlym" typeface="Kartika" />
<a:font script="Laoo" typeface="DokChampa" />
<a:font script="Sinh" typeface="Iskoola Pota" />
<a:font script="Mong" typeface="Mongolian Baiti" />
<a:font script="Viet" typeface="Arial" />
<a:font script="Uigh" typeface="Microsoft Uighur" />
<a:font script="Geor" typeface="Sylfaen" />
</a:minorFont>
</a:fontScheme>
这就是我现在正在做的事情。向上移动层次结构,直到不再有w:basedOn
,然后如果我仍然没有找到字体,我将手动设置默认字体。这适用于office附带的主题。但是没有办法获得第三方主题。不,它也适用于用户主题,在这种情况下,主题中的数据会更少。如果主题已被覆盖,则字体数据将在样式中。如果样式数据已被覆盖,则字体数据将与文档中的段落一起保留。我建议您花些时间熟悉文档的xml,我明白了。我找到了我想要的。现在,如何使用ApachePOI读取这个theme1.xml文件?我试着查看XWPF文档中的方法,但找不到任何我无法帮助您的东西。我建议你提出另一个问题,询问你需要的具体帮助。