-
Notifications
You must be signed in to change notification settings - Fork 8
Incorrect optical size in generated database #398
Comments
I think this is a duplicate of #389 |
I think it is an issue introduced by that and related patch. The For example, LMRoman10-Regular has a design size In the particular case of LMRoman, I believe the |
If I unsderstand correctly, The current formula in the source is for converting value in |
Oh ok, sorry... maybe you could build a pull request? |
2017-02-01 (Wednesday), [email protected] (Yan Zhou):
If I unsderstand correctly, The current formula in the source
is for converting value in `pt` to value in `bp` and `dd`, while
what was really needed was the other way around.
You’re right, I messed up the conversions with the refactoring :/
Looks like we’ll be having a bugfix release soon.
Thanks for double-checking!
Philipp
|
2017-02-01 (Wednesday), [email protected] (Yan Zhou):
(I recall that `luaotfload` used to select font by regarding
the optical size as an Closed-Open interval, while OpenType use
an Open-Closed interval, and thus I used font size very slightly
smaller than the upper bound of the intended use)
This would be a bug in any case. The present issue aside, do you
think the behavior you were observing was a consequence of
treating the design sizes in the font as if they were Knuth
points instead of DTP points?
|
I think the Open-Close interval issue was fixed a long time ago. I was just been cautious. I think treating the design size either as US point or PS point is OK. It will only make a difference in marginal case. The difference at 20pt is less than 0.1 point. however, if we need to make a difference, and converted it the wrong way, basically we squared the ratio and the difference become slighted bigger. However, that difference is still very small (would be a lot worse for didot point) It is only an issue when the size in question happened to be on the boundary, in which case any margin or error will cause a change of font. However, even in that case I still don't think it is a big problem. For example, say a design size is 18 point and upper bound is 24 point, and the next range is design size 30 point (lower bound 24 point). It is purely academia to argue around 24 point which shall be better. The only real effect is for fonts such as LM, Arno, which has a few very narrow intervals (top -bottom < 2pt). In this case, it does make a difference when switch between a 10 point font and a 12 point font. Personally, at text size, I usually use font at its design size, which avoids all these problems. For example use Arno at either 10point or 12 point. And if I want 11point, I switch to Minion. |
I am afraid my last pull request did not really fix the problem. I think I misunderstood the source. Before I make an even bigger mess (very sorry about that), please correct me if I understood the following correctly,
If this understanding is correct, then original Instead, the real problem is that in
inside The following is an example with more rigorous test of the marginal case,
And I get the expected output, that is the first three choose LM10 and the last choose LM12. (Note that, the second one also choose LM10, while the asked size is bigger than 11bp is that, Another test with Arno pro, which has a boundary at 10.9, which in
If this time my understanding is correct. I will create a new pull request to fix my mess (sorry again) |
Not directly related: did you test the Open-Closed vs Closed-Open interval? |
Yes, the Arno example has one exactly at the upper bound and it behaves correctly. That is, a Open-Closed interval.
However, it is still a rounded number. It is difficult to find a case where the `bp` value will be exactly at the boundary and exactly an integer in `sp`.
|
Well, as long as the conversion is the same in both cases:
then everything's fine! Thank you for inspecting |
Regarding the Open-Closed interval, I artificially patched the generated database such that Arno-Subhead shall be I will do some more testing and create new pull request after some more testing. |
I created three separated PR. Each are related but I feel yet independent enough to allow merging only some of them Below are test results when #400 and #401 are applied, For all three configurations test-bp.pdf The source that created these results are,
|
As discussed in issue lualatex#398. Ad futuram rei memoriam the gist of it: - For the index, all values are scaled (decipoints * sp) / 10 * (7227 / 7200). - The ``bp`` case (the default, OT-standard), needs no conversion because it matches how values are stored in the index. - The ``pt`` case essentially reverts the bp→pt part of scaling done for the database by scaling the asked size by the same factor, i. e. by 7227 / 7200. - The ``dd`` needs an extra 1238 / 1157. Requesting a font at 10pt will then: - ask for a size of 655360 for ``bp`` / default; - ask for 657817 for ``pt``; - ask for 703870 for ``dd``.
2017-02-01 (Wednesday), [email protected] (Yan Zhou):
* The `design_size_dimension` function (on Line 1045) is only
used when loading a font.
* The `get_size_info` function (on Line 1356) is what used for
generating the database.
* The configuration for choose among `pt`, `dd`, `bp` only
affects fonts loading instead of database generating.
That is accurate. In the first revision I stored the values
retrieved from the size table as-is. Since font definition deals
in TeX scaled points this would mean one extra conversion
sp→decipoints per request.
The current design, at least before I messed it up, eliminates
that step by storing the values in sp in the index. Then unless
the user configures a different conversion, we can use the input
directly (just one no-op funcall overhead). When a pt or dd
conversion is chosen, the value needs scaling.
If this understanding is correct, then original
`design_size_dimension` was correct. That is, we do want to
convert from TeX point to DTP point and then multiple the value
by 2^16. That is the value shall be shrieked by a ratio 7200 /
7227. My fix in the pull request was incorrect.
It’s wrong differently but that’s my fault ;) May I ask you to
review this fix?
phi-gamma@529578f
The following is an example with more rigorous test of the marginal case,
Thanks for coming up with a test. I will have a closer look at it
and maybe add it to the semi-official test repo:
https://bitbucket.org/phg/lua-la-tex-tests
|
I think it is correct for |
2017-02-02 (Thursday), [email protected] (Yan Zhou):
> May I ask you to
> review this fix?
> ***@***.***
I think it is correct for `bp` and `pt`, but incorrect for `dd`. I found that one's head can easily get confused when thinking of these ratios only in head. So I wrote down the logic below, please review, (also see #400)
[test.pdf](https://github.com/lualatex/luaotfload/files/749512/test.pdf)
Thanks for taking the time to write it up. I took the liberty of
adding that in full as a comment:
phi-gamma@6971d4a
|
No problem at all. I am working on a slightly improved test that take into account of the rounding error. The default behavior, I think yours is better then #400 in the sense that, #400 will introduce rounding for both, even though both will be within 1ULP. In your fix, there's no rounding error whatsoever for asked size, while the values in database will have a potentially larger error due to that they are written in textual form. However, the lack of error for the asked size, I believe shall make things more predictable and easier to reason with. I will update a new test once your fix and #401 are merged. |
I worked out a new test in plain TeX (depends on nothing but It includes test settings for most optical fonts out there, excluding those with optical sizing in design but not in OpenType features, such as some hoefler & co fonts. Free fonts: Latin Modern family, EB Garamond (need a separate download, the one included in TeXLive only have 12 points design) Commercial fonts: Adobe optical fonts and Minion Math Full list
Note that without manual patching of the database (see #363, an issue that I don't believe can ever be fixed entirely given the mess of font foundries' naming schemes and ID fields, etc. And frankly, I don't think worth anyone's energy to try. I merely patch the database manually after Without any intervention, the following faces will fail the tests,
Sanvito and EB Garamond fail mainly because bugs in font. There are gaps between ranges in their reported values. Others fail the tests because of #363, which is unrelated (those pass the tests may select incorrect width and weights, also #363, again unrelated to issues here, and the founders are to blame). In the new test, no conversion of dimension is done in Lua side. Instead, the returned design size, actual loaded size, etc., are taken literally and comparisons are done in TeX instead in Lua. The basic logic is that, if one ask for a size in TeX, and get a range selected correctly in the eye of TeX, then it should be considered to be OK, even if in real there might be some rounding errors within Lua that can make a difference in marginal case. |
I just tried phi-gamma/luaotfload@7308f84b with the new test file, and everything works out well. |
2017-02-03 (Friday), [email protected] (Yan Zhou):
I worked out a new test script (attached).
[testsize.zip](https://github.com/lualatex/luaotfload/files/750896/testsize.zip)
Thanks. I’m currently deep into two other issues but I’ll get
back to the material.
Note that without manual patching of the database (see #363,
an issue that I don't believe can ever be fixed entirely given
the mess of font foundries' naming schemes and ID fields, etc.),
many tests will fail.
I spent some time on that a while ago and it’s even worse. The
same font would end up having different strings in the name
table for different versions. For instance, I was writing an
extensive test for the files of Arno Pro that I have along the
likes of the Garamond test:
https://bitbucket.org/phg/lua-la-tex-tests/src/3ef71447d31a884b2b904a11563a1b18e017ddce/lua/tla-names-1-adobe-garamond.lua
Turns out the files, despite being the Adobe originals, are an
older version that on account of a weird bug has distorted
(non-standard) values in the size table. I believe Hans added a
hack for that case in the meantime but hours of testing were
simply for nothing …
|
2017-02-03 (Friday), [email protected] (Yan Zhou):
I just tried ***@***.*** with the new test file, and
everything works out well.
Great news. Does that include the subject of rounding errors?
|
In a sense, yes. Say one load font at "x bp", and the numerical values of the ranges is (a, b]. Then we compare if the asked size fall in (a bp, b bp] using TeX's \ifdim instead of doing any calculation in Lua side. So the test will not introduce any error and would be the same as how people use the luaotfload or fontspec, or latex \fontsize. Thus there should be any false positive or negative test results, from a user perspective.
… On Feb 4, 2017, at 04:37, Philipp Gesang ***@***.***> wrote:
2017-02-03 (Friday), ***@***.*** (Yan Zhou):
> I just tried ***@***.*** with the new test file, and
> everything works out well.
Great news. Does that include the subject of rounding errors?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Exactly. After raised that issue myself, I spent considerable time trying to put together a PR. And it came to nothing. In the end, I simply alter the generated database manually (actually through a script). It give perfect results also allow me to use some non-optical fonts in a similar fashion. For example, semi-bold for small size.
The only downside is that if luaotfload changes the format of the database, things need to be reworked a bit. But let's just consider it an opportunity to testing the changes (that's how I started this issue in the first place)
… On Feb 4, 2017, at 04:35, Philipp Gesang ***@***.***> wrote:
2017-02-03 (Friday), ***@***.*** (Yan Zhou):
> I worked out a new test script (attached).
>
> [testsize.zip](https://github.com/lualatex/luaotfload/files/750896/testsize.zip)
Thanks. I’m currently deep into two other issues but I’ll get
back to the material.
> Note that without manual patching of the database (see #363,
> an issue that I don't believe can ever be fixed entirely given
> the mess of font foundries' naming schemes and ID fields, etc.),
> many tests will fail.
I spent some time on that a while ago and it’s even worse. The
same font would end up having different strings in the name
table for different versions. For instance, I was writing an
extensive test for the files of Arno Pro that I have along the
likes of the Garamond test:
https://bitbucket.org/phg/lua-la-tex-tests/src/3ef71447d31a884b2b904a11563a1b18e017ddce/lua/tla-names-1-adobe-garamond.lua
Turns out the files, despite being the Adobe originals, are an
older version that on account of a weird bug has distorted
(non-standard) values in the size table. I believe Hans added a
hack for that case in the meantime but hours of testing were
simply for nothing …
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I wasn't quite able to express what I aimed in the test before. Basically, I think if user ask for |
Just a simple example of how I patch the database and an idea I am thinking about for properly test all edge cases of interest.
By altering the database manually, we can artificially create situations of ranges that we want to test, without looking for a specific font that happened to have the edge case of interest. It would be better if there's a way to dynamically place a hook such that it can be altered dynamically after the database is loaded, instead of having to go through the generate-patch-test cycle. |
I'm closing the issue. @zhouyan if you think that there are open questions here, please open a new issue at https://github.com/u-fischer/luaotfload/issues. |
I recently noticed that the generated database, by default, record the optical size in
sp
. However, it seems that the sizes are calculated incorrectly. (Or maybe I misunderstood the behavior of luaotfload)(I don't have any configuration file, so everything is in its default setting)
Consider the entry for Latin Modern Roman, in particular the line,
within the
r
table (regular). This line corresponding to LMRoman10-Regular,The reported optical size through
otfinfo
isIf I understand correctly, these values are PostScript points, that is, the
sp
value shall be,While in the table, the corresponding value
718202.73972603
is actually,In particular, this cause problems when selecting font when the size is specified according to
bp
instead ofpt
. For example,The output is
(I recall that
luaotfload
used to select font by regarding the optical size as an Closed-Open interval, while OpenType use an Open-Closed interval, and thus I used font size very slightly smaller than the upper bound of the intended use)In the above example, for
11bp
, the 10 point fonts shall be used, but the 12 point one is used instead.After patching the database by using the values
723599.36
etc, the expected output is obtainedThe text was updated successfully, but these errors were encountered: