【问题标题】:FONET/FOP superscript; inline-container not showing up at allFONET/FOP 上标;内联容器根本没有出现
【发布时间】:2023-03-28 12:47:01
【问题描述】:

我正在开发一个 FONET 应用程序来生成一些简单的 PDF 报告;除了客户希望将注册商标符号正确提升到上标级别之外,一切正常。

我在一个内联元素上尝试了text-altitude,但没有成功,所以在搜索了互联网上糟糕的 XSL:FO 文档之后,我认为我需要将它包装在一个 fo:inline-container 中。但是,这根本没有出现。

我已经用这个basic example减少了它:

<?xml version="1.0" encoding="utf-8"?>
<!-- inline-container-Converts-Block-to-Inline.fo
 - Copyright (c) 2016, HerongYang.com, All Rights Reserved.
-->
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
 <fo:layout-master-set>
  <fo:simple-page-master master-name="page" 
   margin="0.1in" page-height="4in" page-width="3in">
   <fo:region-body region-name="body" background-color="#eeeeee"/>
  </fo:simple-page-master>
 </fo:layout-master-set>
 <fo:page-sequence master-reference="page">
  <fo:flow flow-name="body">
   <fo:block margin="0.1in" padding="0.2in"
    border-width="1px" border-style="solid"
    background-color="#eeffff" color="#000000" 
    font-family="sans-serif" font-size="10pt">
    Once upon a time
    <fo:inline-container width="0.7in" margin="0in" 
     alignment-baseline="middle">
    <fo:block background-color="#eeeeee" margin="0in"
     border-width="1px" border-style="solid"
     padding="4px">there were three little pigs</fo:block>
    </fo:inline-container>
    who lived with their Mother.
    Early one morning they woke up and their mother said, 
    "<fo:inline font-style="italic" color="#ff22ff">you're too big
    for this house and its time you left home.</fo:inline>"
   </fo:block>
  </fo:flow>
 </fo:page-sequence>
</fo:root>

并尝试运行它,但这也不会显示来自inline-container 的任何内容;在this online processor 中尝试过,但也没有显示容器中的任何内容,所以不仅仅是 FONET 问题。

FONET 是 FOP 0.2 的端口,should have basic support 用于 text-altitudeinline-container

我错过了什么?这个版本的FOP是否可以得到上标效果?

【问题讨论】:

    标签: pdf xsl-fo apache-fop


    【解决方案1】:

    您链接到的一致性页面显示 fo:inline-container 不受支持。它在最新的 FOP (https://xmlgraphics.apache.org/fop/compliance.html) 中仍然只有部分支持。

    我认为这是因为您正在尝试使其发挥作用,但是将“有三只小猪”放在 0.7 英寸宽的空间中会导致fo:inline-container 的区域又高又窄。

    好消息是您不需要fo:inline-container 来制作上标。只需将fo:inlinebaseline-shift="super" 一起使用(请参阅https://www.w3.org/TR/xsl11/#baseline-shift)。

    您可能还需要考虑同时减少上标文本的 font-size(因为 FO 格式化程序不会假设您也需要)并在祖先 FO 上添加 line-height-shift-adjustment="disregard-shifts"(请参阅https://www.w3.org/TR/xsl11/#line-height-shift-adjustment),所以上标不会改变你的行高:

    <fo:block line-height-shift-adjustment="disregard-shifts"
          margin="0.1in" padding="0.2in"
          border-width="1px" border-style="solid"
          background-color="#eeffff" color="#000000" 
          font-family="sans-serif" font-size="10pt">
      Once upon a time<fo:inline
        baseline-shift="super" font-size="0.8em">®</fo:inline>
      there were three little pigs<fo:inline
        baseline-shift="super" font-size="0.8em">®</fo:inline>
      who lived with their Mother.
      Early one morning they woke up and their mother said, 
      "<fo:inline font-style="italic" color="#ff22ff">you're too big
      for this house and its time you left home.</fo:inline>"
    </fo:block>
    

    另请参阅https://www.antennahouse.com/antenna1/comprehensive-xsl-fo-tutorials-and-samples-collection/“综合 XSL-FO 教程和示例合集”中的“字符样式设置”


    当您的 FO 格式化程序未实现 baseline-shift 时,最后的手段是查找具有上标外观的注册商标符号的字体。通过 Windows 'Character Map' 实用程序快速搜索显示,'Calibri' 有一个。

    【讨论】:

    • 不幸的是,虽然基线移位在该在线 FOP 1.0 处理器中完美运行,但它不在 .NET 库是其端口的 FOP 0.2 中,因此它在我的代码中不起作用。你还有其他上标技巧吗?
    • 对不起,没有。 baseline-shift 是为实现上标而设计的属性。您唯一的希望是找到一种带有上标外观的注册商标符号的字体。通过 Windows 'Character Map' 实用程序的快速搜索显示,'Calibri' 有一个。可能还有其他人。或者,您可以尝试实现更多 XSL 1.1 的其他 FO 格式化程序。
    • Apache FOP 0,2.5 于 2003 年 7 月 18 日发布。那是 14 多年前的事了。你会为自己使用可能在过去几年而不是十年或两年前开发的软件提供真正的服务。
    • @KevinBrown 大量的旧软件完全可以满足您的需求,除了上标之外,它可以满足我目前需要的所有功能。我仅限于 0.2,因为 .NET 端口在该版本停止。
    • @TonyGraham - 使用 Calibri 有效,谢谢!让您的评论成为答案,我会这样标记它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-20
    相关资源
    最近更新 更多