brailleapps / dotify.formatter.impl

Provides an implementation of the formatter interfaces in dotify.api
GNU Lesser General Public License v2.1
0 stars 6 forks source link

More possible issues with vertical-position #95

Open bertfrees opened 5 years ago

bertfrees commented 5 years ago

I have made the following test OBFL:

<obfl version="2011-1" xml:lang="en">
  <layout-master name="body" page-width="10" page-height="12" duplex="false">
    <default-template>
      <header/>
      <footer/>
    </default-template>
  </layout-master>
  <sequence master="body">
    <block>⠉⠉⠉⠉⠉</block>
    <block vertical-align="before" vertical-position="8">
      <block>⠿⠿⠿⠿⠿<br/>⠿⠿⠿⠿⠿<br/>⠿⠿⠿⠿⠿</block>
    </block>
  </sequence>
  <sequence master="body">
    <block>⠉⠉⠉⠉⠉</block>
    <block vertical-align="before" vertical-position="8" margin-bottom="1">
      <block>⠿⠿⠿⠿⠿<br/>⠿⠿⠿⠿⠿<br/>⠿⠿⠿⠿⠿</block>
    </block>
  </sequence>
  <sequence master="body">
    <block>⠉⠉⠉⠉⠉</block>
    <block margin-bottom="1">
      <block vertical-align="before" vertical-position="8" margin-bottom="1">
        <block>⠿⠿⠿⠿⠿<br/>⠿⠿⠿⠿⠿<br/>⠿⠿⠿⠿⠿</block>
      </block>
    </block>
  </sequence>
  <sequence master="body">
    <block>⠉⠉⠉⠉⠉</block>
    <block>
      <block vertical-align="before" vertical-position="8" margin-bottom="1">
        <block>⠿⠿⠿⠿⠿<br/>⠿⠿⠿⠿⠿<br/>⠿⠿⠿⠿⠿</block>
      </block>
      <block>⠉⠉⠉⠉⠉</block>
    </block>
  </sequence>
  <sequence master="body">
    <block>⠉⠉⠉⠉⠉</block>
    <block margin-bottom="1">
      <block vertical-align="before" vertical-position="8" margin-bottom="1">
        <block>⠿⠿⠿⠿⠿<br/>⠿⠿⠿⠿⠿<br/>⠿⠿⠿⠿⠿</block>
      </block>
      <block>⠉⠉⠉⠉⠉</block>
    </block>
  </sequence>
</obfl>

which results in this PEF:

<pef>
    <body>
        <volume cols="10" rows="12" rowgap="0" duplex="false">
            <section>
                <page>
                    <row>⠉⠉⠉⠉⠉</row>
                    <row/>
                    <row/>
                    <row/>
                    <row/>
                    <row>⠿⠿⠿⠿⠿</row>
                    <row>⠿⠿⠿⠿⠿</row>
                    <row>⠿⠿⠿⠿⠿</row>
                </page>
            </section>
            <section>
                <page>
                    <row>⠉⠉⠉⠉⠉</row>
                    <row/>
                    <row/>
                    <row/>
                    <row>⠿⠿⠿⠿⠿</row>
                    <row>⠿⠿⠿⠿⠿</row>
                    <row>⠿⠿⠿⠿⠿</row>
                    <row/>
                </page>
            </section>
            <section>
                <page>
                    <row>⠉⠉⠉⠉⠉</row>
                    <row/>
                    <row/>
                    <row>⠿⠿⠿⠿⠿</row>
                    <row>⠿⠿⠿⠿⠿</row>
                    <row>⠿⠿⠿⠿⠿</row>
                    <row/>
                </page>
            </section>
            <section>
                <page>
                    <row>⠉⠉⠉⠉⠉</row>
                    <row/>
                    <row/>
                    <row>⠿⠿⠿⠿⠿</row>
                    <row>⠿⠿⠿⠿⠿</row>
                    <row>⠿⠿⠿⠿⠿</row>
                    <row/>
                    <row>⠉⠉⠉⠉⠉</row>
                </page>
            </section>
            <section>
                <page>
                    <row>⠉⠉⠉⠉⠉</row>
                    <row/>
                    <row>⠿⠿⠿⠿⠿</row>
                    <row>⠿⠿⠿⠿⠿</row>
                    <row>⠿⠿⠿⠿⠿</row>
                    <row/>
                    <row>⠉⠉⠉⠉⠉</row>
                    <row/>
                </page>
            </section>
        </volume>
    </body>
</pef>

@joeha480 Could you change this PEF according to what is expected according to you. The spec is not entirely clear about this. I would think the position of the block with vertical-position should not be affected by the ⠉⠉⠉⠉⠉ block after it. But also the fact that the position is affected by margin-bottom seems a bit strange.

If you can fix the expected output I will try to fix the issue.

Note that my fix for https://github.com/brailleapps/dotify.formatter.impl/issues/92 did not fix this issue.

joeha480 commented 5 years ago

Counting things that comes after the block is incorrect. However, I do think that the entire block (including margins) should end on the specified line.

<?xml version="1.0" encoding="UTF-8"?>
<pef version="2008-1" xmlns="http://www.daisy.org/ns/2008/pef">
<head>
<meta xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:format>application/x-pef+xml</dc:format>
<dc:identifier>identifier?</dc:identifier>
<dc:date>2019-05-10</dc:date>
</meta>
</head>
<body>
<volume cols="10" rows="12" rowgap="0" duplex="false">
<section>
<page>
<row>⠉⠉⠉⠉⠉</row>
<row/>
<row/>
<row/>
<row/>
<row>⠿⠿⠿⠿⠿</row>
<row>⠿⠿⠿⠿⠿</row>
<row>⠿⠿⠿⠿⠿</row>
</page>
</section>
<section>
<page>
<row>⠉⠉⠉⠉⠉</row>
<row/>
<row/>
<row/>
<row>⠿⠿⠿⠿⠿</row>
<row>⠿⠿⠿⠿⠿</row>
<row>⠿⠿⠿⠿⠿</row>
<row/>
</page>
</section>
<section>
<page>
<row>⠉⠉⠉⠉⠉</row>
<row/>
<row/>
<row/>
<row>⠿⠿⠿⠿⠿</row>
<row>⠿⠿⠿⠿⠿</row>
<row>⠿⠿⠿⠿⠿</row>
<row/>
</page>
</section>
<section>
<page>
<row>⠉⠉⠉⠉⠉</row>
<row/>
<row/>
<row/>
<row>⠿⠿⠿⠿⠿</row>
<row>⠿⠿⠿⠿⠿</row>
<row>⠿⠿⠿⠿⠿</row>
<row/>
<row>⠉⠉⠉⠉⠉</row>
</page>
</section>
<section>
<page>
<row>⠉⠉⠉⠉⠉</row>
<row/>
<row/>
<row/>
<row>⠿⠿⠿⠿⠿</row>
<row>⠿⠿⠿⠿⠿</row>
<row>⠿⠿⠿⠿⠿</row>
<row/>
<row>⠉⠉⠉⠉⠉</row>
<row/>
</page>
</section>
</volume>
</body>
</pef>
bertfrees commented 5 years ago

Thanks. What about collapsed margins? How to count these?

<sequence master="body">
    <block>⠉⠉⠉⠉⠉</block>
    <block margin-bottom="2">
      <block vertical-align="before" vertical-position="8" margin-bottom="1">
        <block>⠿⠿⠿⠿⠿<br/>⠿⠿⠿⠿⠿<br/>⠿⠿⠿⠿⠿</block>
      </block>
    </block>
    <block>⠉⠉⠉⠉⠉</block>
  </sequence>

Like this?

<page>
   <row>⠉⠉⠉⠉⠉</row>
   <row/>
   <row/>
   <row/>
   <row>⠿⠿⠿⠿⠿</row>
   <row>⠿⠿⠿⠿⠿</row>
   <row>⠿⠿⠿⠿⠿</row>
   <row/>
   <row/>
   <row>⠉⠉⠉⠉⠉</row>
</page>
bertfrees commented 4 years ago

@kalaspuffar Joel said that at least part of this reported behavior is wrong, in other words a bug in Dotify, so maybe interesting for you to look at.

How exactly vertical-position interacts with margins and collapsing of margins needs to be cleared up. I can work on this (OBFL issue https://github.com/braillespecs/obfl/issues/69). I think the solution I will propose is to position the block including the margins at the specified position. Basically what Joel said. This is apparently also how it works in CSS for absolute positioning (specification here). Collapsing margins would work normally, like in the example in my comment above.