On Fri, Apr 26, 2013 at 12:59 PM, Vincent Hennebert <[email protected]>wrote:
> On 25/04/13 22:33, Glenn Adams wrote: > > On Thu, Apr 25, 2013 at 1:08 PM, Vincent Hennebert <[email protected] > >wrote: > > > >> On 25/04/13 17:48, Glenn Adams wrote: > >>> On Thu, Apr 25, 2013 at 2:31 AM, Vincent Hennebert < > [email protected] > >>> wrote: > >>> > >>>> > >>>> It doesn’t shock me to store text as text in the IF and to re-do the > >>>> glyph mapping when rendering it to the final output format. This is > >>>> actually how it is done ATM. > >>>> > >>> > >>> I think this a bad idea for the reasons that Alexios mentioned, and > that > >> I > >>> previously mentioned about recreating sufficient layout context to > repeat > >>> the process reliably. > >> > >> What exactly do you mean by ‘sufficient layout context’? What would be > >> missing from the IF that would prevent to re-do the glyph mapping? > >> > > > > Off hand, we would need: > > > > - language > > - script > > - font features to be applied (with parameters) > > - letter-spacing settings > > Apart from the font features, they are already available in the file. > Regarding font features, they could be added to the font element, but > AFAIK this is not customizable in the FO file is it? So I guess the > default set of features is applied. So that default set can also be > applied to text coming from the IF. > I don't believe language and script are specifiable at a per-text level in IF. <xs:element name="text"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="x" use="required" type="mf:lengthType"/> <xs:attribute name="y" use="required" type="mf:lengthType"/> <xs:attribute name="letter-spacing" type="mf:lengthType"/> <xs:attribute name="word-spacing" type="mf:lengthType"/> <xs:attribute name="dx" type="mf:lengthListType"/> <xs:attribute name="dp" type="mf:dpListType"/> <xs:attribute name="hyphenated" type="xs:boolean"/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> Yes, at present, the default features apply. However, I added code already to allow an extension property to specify features, such as defined by [1], which is on my short list of planned upgrades. [1] http://www.w3.org/TR/css3-fonts/#font-feature-settings-prop I agree in principle that these could be added to the IF data as well, so we would need to add at least the following attributes: language script font-feature-settings > > > > There are probably others. I just don't see any reason to use this > approach. > > > > > >> > >> > >>>> Sure it may become more costly when you start using complex scripts, > >>>> but > >>>> that would have to be confirmed with some profiling first and > foremost. > >>>> We might be surprised. > >>>> > >>>> We should keep in mind that it’s a perfectly reasonable use case to > add > >>>> text to the IF as part of a post-processing step. That text will have > to > >>>> go through the glyph mapping code anyway. > >>>> > >>>> Also, to have copy-paste work properly from PDF the original text must > >>>> be present in the IF. > >>>> > >>> > >>> Agreed, but this is a different requirement. And doesn't entail > >>> reconstructing part of the layout context and repeating the character > to > >>> glyph mapping and positioning process. > >> > >> You’ll have to do that for text added at post-process time anyway? > >> > > > > I don't understand what this means. > > The IF can be manipulated in many ways by the user and, among other > things, text can be added to it, which will have to be rendered into the > final output. > > This is an important reason why I think glyph mapping should be redone. > Hmm, without re-layout? Seems risky, but I agree its possible. > >>>> Storing information about the private use area in the IF is > >>>> exposing > >>>> internal implementation details of FOP. > >>> > >>> > >>> I disagree. In fact, it is working around a bug that exists in certain > >>> fonts which forces FOP to make use of synthesized PUA mappings. The bug > >> is > >>> that the font designer did not fully populate the original CMAP, i.e., > >>> include a mapping for every accessible glyph. > >> > >> I still don’t get it I’m afraid. Where in the TrueType spec is it stated > >> that every glyph should have an entry in the cmap? > > > > > > It doesn't. But if someone uses a font, wants to present a glyph that has > > no mapping, and must use character codes, then it won't work. > > That’s this ‘must use character codes’ requirement that seems buggy to > me. > > > >> Why can’t FOP just > >> use the glyph ID? Surely that information is enough? > >> > > > > Well, for one thing, the IF interface for renderText uses a character > > string, not a glyph index string, > > No, it uses Unicode code points. It must probably be extended to pass > information about the glyph mapping as well. > character string = (Unicode code point)* These are not glyph codes. > > > > and the IF XML format uses Unicode code > > points. > > > > > >> > >> > >>>> When going the direct FO to PDF > >>>> route, mapping glyphs to character codes to re-map them again into > >>>> glyphs when creating the PDF is sub-optimal. We might as well work > with > >>>> the glyph indices all the way through. > >>>> > >>> > >>> This is possible, but wouldn't it require two separate paths through > the > >> IF > >>> layer, and would it not work for non-PDF output? > >> > >> I don’t think so. The original text should be passed through anyway to > >> create the ToUnicode cmap. > > > > > > Why? > > For copy/pasting to work in PDF. The original text must be returned. > This is also important for accessibility (reading the text aloud). > I've already agreed that having the original text is important, and its not there at present, so this is a bug waiting to be solved. > > > >> So PDF can use the glyph mapping to generate > >> the text operators and the original text for the ToUnicode cmap. The IF > >> renderer just streams out the original text. And the other renderers > >> just deal with the glyph mapping. > >> > > > > Since the technique I suggests will work and does not require this, then > > this (repeating the character to glyph mapping, positioning, and layout > > process) isn't necessary. I have agreed, however, that embedding the > > original UC text for performing copy and find operations will be useful, > > for which there is already an open bug [1]. > > > > [1] https://issues.apache.org/jira/browse/FOP-2204 > > > To summarize: (1) I agree it is desirable to include the original unicode text so that copy/find/accessibility can work; (2) I agree that it is possible to re-perform the character/glyph mapping process provided new attributes are added to the IF text element; (3) I am not (yet) convinced in the wisdom of supporting modification to the IF text, but I'm open to learn about use cases; (4) I know that it is possible to satisfy (1) above without having to re-perform the mapping; (5) I know that the present problem can be solved without doing (1) or (2), e.g., by adding pua children to the font element;
