Discussion:
[Libreoffice-bugs] [Bug 103322] New: Use floating point for glyph positioning in VCL
b***@bugs.documentfoundation.org
2016-10-18 22:52:47 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

Bug ID: 103322
Summary: Use floating point for glyph positioning in VCL
Product: LibreOffice
Version: 5.2.2.2 release
Hardware: All
OS: All
Status: UNCONFIRMED
Severity: enhancement
Priority: medium
Component: graphics stack
Assignee: libreoffice-***@lists.freedesktop.org
Reporter: ***@eglug.org

Currently we use integers and do lots of calculations and recalculations
resulting in rounding errors which mess up with text spacing specially at low
resolution screens.

We should switch to using floats to store glyph positions instead, which would
make the rounding errors less visible. It would also allow us to benefit from
sub-pixel positioning support in the graphics libraries we use.
--
You are receiving this mail because:
You are the assignee for the bug.
b***@bugs.documentfoundation.org
2016-10-18 22:52:58 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

Khaled Hosny <***@eglug.org> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--
You are receiving this mail because:
You are the assignee for the bug.
b***@bugs.documentfoundation.org
2016-10-18 22:53:11 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

Khaled Hosny <***@eglug.org> changed:

What |Removed |Added
----------------------------------------------------------------------------
Blocks| |71732


Referenced Bugs:

https://bugs.documentfoundation.org/show_bug.cgi?id=71732
[Bug 71732] [META] Bugs related to text rendering, typography and font features
in LO
--
You are receiving this mail because:
You are the assignee for the bug.
b***@bugs.documentfoundation.org
2016-10-19 09:19:33 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

Khaled Hosny <***@eglug.org> changed:

What |Removed |Added
----------------------------------------------------------------------------
Blocks| |88991


Referenced Bugs:

https://bugs.documentfoundation.org/show_bug.cgi?id=88991
[Bug 88991] VIEWING: Kerning issues with certain fonts like Arial
--
You are receiving this mail because:
You are the assignee for the bug.
b***@bugs.documentfoundation.org
2017-02-12 16:28:18 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

Buovjaga <***@suomi24.fi> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |***@mailinator.com

--- Comment #1 from Buovjaga <***@suomi24.fi> ---
*** Bug 105936 has been marked as a duplicate of this bug. ***
--
You are receiving this mail because:
You are the assignee for the bug.
b***@bugs.documentfoundation.org
2017-02-13 18:13:54 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

--- Comment #2 from DeepFlight5 <***@mailinator.com> ---
My Bug 105936 report was moved here. Probably the right place. But here I read
"earliest affected version 5.2.2.2 release".

Not true on MacOSX: All LO versions up to 5.2.5 have no problems with glyphs
positioning, all work excellent.

This problem begun only with LO 5.3, and there it is on MacOSX massively. I had
to downgrade to LO 5.2.5. It's not possible to work with this broken font
display.

(On Linux and Windows this might be different.)

The problem is HarfBuzz, which was only introduced in LO 5.3. I hope this gets
fixed soon.
--
You are receiving this mail because:
You are the assignee for the bug.
b***@bugs.documentfoundation.org
2017-02-13 22:41:53 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

Khaled Hosny <***@eglug.org> changed:

What |Removed |Added
----------------------------------------------------------------------------
Version|5.2.2.2 release |Inherited From OOo

--- Comment #3 from Khaled Hosny <***@eglug.org> ---
The underlying issue is as old as this code base, it started showing up on Mac
because we no longer use Core Text (which uses floats for glyph positions) and
share the same code on all platforms.
--
You are receiving this mail because:
You are the assignee for the bug.
b***@bugs.documentfoundation.org
2017-02-14 19:58:51 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

--- Comment #4 from DeepFlight5 <***@mailinator.com> ---
I assume the "float" problem lies in the Firefox code, since HarfBuzz is used
in Firefox and Chrome also, which have no problems with glyph display. Will
this "float" bug be fixed anywhere soon?
--
You are receiving this mail because:
You are the assignee for the bug.
b***@bugs.documentfoundation.org
2017-03-12 17:01:05 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

Khaled Hosny <***@eglug.org> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |***@gmail.com

--- Comment #5 from Khaled Hosny <***@eglug.org> ---
*** Bug 106495 has been marked as a duplicate of this bug. ***
--
You are receiving this mail because:
You are the assignee for the bug.
b***@bugs.documentfoundation.org
2017-03-20 05:12:04 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

V Stuart Foote <***@utsa.edu> changed:

What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://bugs.documentfounda
| |tion.org/show_bug.cgi?id=10
| |6653
--
You are receiving this mail because:
You are the assignee for the bug.
b***@bugs.documentfoundation.org
2017-03-20 13:33:53 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

Khaled Hosny <***@eglug.org> changed:

What |Removed |Added
----------------------------------------------------------------------------
See Also|https://bugs.documentfounda |
|tion.org/show_bug.cgi?id=10 |
|6653 |
--
You are receiving this mail because:
You are the assignee for the bug.
b***@bugs.documentfoundation.org
2017-04-07 19:12:46 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

--- Comment #6 from DeepFlight5 <***@mailinator.com> ---
Sorry, my commentary from February had an error. It should read:

"I assume the "float" problem lies in the LibreOffice code and not in HarfBuzz,
since HarfBuzz is used in Firefox and Chrome also, which have no problems with
accurate glyph display. Will this "float" bug of LibreOffice be fixed anywhere
soon?"
--
You are receiving this mail because:
You are the assignee for the bug.
b***@bugs.documentfoundation.org
2017-04-08 14:36:50 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

--- Comment #7 from Khaled Hosny <***@eglug.org> ---
No one is currently working on this, feel free to work on it yourself or
recruit someone to work on it.
--
You are receiving this mail because:
You are the assignee for the bug.
b***@bugs.documentfoundation.org
2017-07-05 22:53:07 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

V Stuart Foote <***@utsa.edu> changed:

What |Removed |Added
----------------------------------------------------------------------------
Blocks| |44267


Referenced Bugs:

https://bugs.documentfoundation.org/show_bug.cgi?id=44267
[Bug 44267] Two decimal digits are probably not enough to specify object
position and size
--
You are receiving this mail because:
You are the assignee for the bug.
b***@bugs.documentfoundation.org
2017-09-05 13:43:53 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

V Stuart Foote <***@utsa.edu> changed:

What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://bugs.documentfounda
| |tion.org/show_bug.cgi?id=10
| |7249
--
You are receiving this mail because:
You are the assignee for the bug.
b***@bugs.documentfoundation.org
2017-10-02 17:55:00 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

Yousuf Philips (jay) <***@hotmail.com> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |***@hotmail.com

--- Comment #8 from Yousuf Philips (jay) <***@hotmail.com> ---
Caolan may have fixed this here.

tdf#107249 round ascent/descent/extleading on conversion to int
http://cgit.freedesktop.org/libreoffice/core/commit/?id=0c8b749e602b6743857a9bc4efb24b6183690311
--
You are receiving this mail because:
You are the assignee for the bug.
b***@bugs.documentfoundation.org
2017-10-02 21:10:11 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

--- Comment #9 from Khaled Hosny <***@eglug.org> ---
(In reply to Yousuf Philips (jay) from comment #8)
Post by b***@bugs.documentfoundation.org
Caolan may have fixed this here.
tdf#107249 round ascent/descent/extleading on conversion to int
http://cgit.freedesktop.org/libreoffice/core/commit/
?id=0c8b749e602b6743857a9bc4efb24b6183690311
That is a different issue.
--
You are receiving this mail because:
You are the assignee for the bug.
b***@bugs.documentfoundation.org
2017-12-28 19:00:31 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

Buovjaga <***@suomi24.fi> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |lapsap7+***@gmail.com

--- Comment #10 from Buovjaga <***@suomi24.fi> ---
*** Bug 113665 has been marked as a duplicate of this bug. ***
--
You are receiving this mail because:
You are the assignee for the bug.
b***@bugs.documentfoundation.org
2018-02-04 22:47:59 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

V Stuart Foote <***@utsa.edu> changed:

What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://bugs.documentfounda
| |tion.org/show_bug.cgi?id=96
| |892
--
You are receiving this mail because:
You are the assignee for the bug.
b***@bugs.documentfoundation.org
2018-02-16 12:30:43 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

Telesto <***@surfxs.nl> changed:

What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://bugs.documentfounda
| |tion.org/show_bug.cgi?id=11
| |1631
--
You are receiving this mail because:
You are the assignee for the bug.
b***@bugs.documentfoundation.org
2018-03-01 20:12:18 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

V Stuart Foote <***@utsa.edu> changed:

What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://bugs.documentfounda
| |tion.org/show_bug.cgi?id=11
| |5939
--
You are receiving this mail because:
You are the assignee for the bug.
b***@bugs.documentfoundation.org
2018-07-24 07:22:46 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

--- Comment #11 from Mike Kaganski <***@hotmail.com> ---
Do we have a (compact) API subset that needs to be changed from int to double
to start the change?
--
You are receiving this mail because:
You are the assignee for the bug.
b***@bugs.documentfoundation.org
2018-07-24 09:47:12 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

--- Comment #12 from Khaled Hosny <***@eglug.org> ---
(In reply to Mike Kaganski from comment #11)
Post by b***@bugs.documentfoundation.org
Do we have a (compact) API subset that needs to be changed from int to
double to start the change?
I’d start with the “Text functions” section in include/vcl/outdev.hxx and go
down and up from there.

We will need to switch from tools::Point, tools::Rectangle etc. to
basegfx::B2DPoint, basegfx::B2DRectangle, not just int to float/double. May be
using basegfx::B2IPoint first since they are still int-based, so the first
round would focus on the difference in semantics and API between tools and
basegfx, then next round would tackle the actual floating pint conversion.
--
You are receiving this mail because:
You are the assignee for the bug.
b***@bugs.documentfoundation.org
2018-07-31 10:35:22 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

--- Comment #13 from Rachel Greenham <***@strangenoises.org> ---
For me it presents as a HiDPI bug, in that it's when desktop scaling is at
200%, 300%, text (any font) can be quite a reasonable editing size on screen
but show this poor positioning of glyphs within each word, making it
headache-inducing to look at, and actually a serious impediment to wanting to
use the software. Of course it was there before, HiDPI just amplifies it,
making it a problem at larger font sizes as displayed on screen.

As the worst problem is just the positioning of glyphs within words I looked
for the code that does that. It seems to be mostly in
vcl/source/gdi/CommonSalLayout.cxx, where the actual work is delegated to
Harfbuzz, which appears to work in integers, but I think at a very high
resolution (whatever a upem is). The values that then come out of that then
have a scale applied at double, rounded, and I suspect subject to more scaling
later, in particular with respect to the desktop scaling factor in HiDPI modes.
And that's probably where it's going wrong.

I had a play with trying to fix things locally in here and in
vcl/source/gdi/sallayout.cxx, changing all the glyph positioning code to use
doubles (and B2DPoint etc), including changing GlyphItem (sallayout.hxx) to use
those types for its positions, widths and offsets and rounding as necessary at
the edges of that, but I did rather get lost in the weeds, specifically, where
to find the edges of it, to minimise the disruption to the rest of the
codebase.

I suspect a fix can't really be confined like that, and it's probably
undesirable anyway. It looks like we'd probably want to make DeviceCoordinate a
double (as controlled in config_host/config_vcl.h.in showing this has been at
least partially prepared-for) and follow *everywhere* that leads, one such
place being the text functions in outdev.hxx of course.

Then final rounding to integers for actual pixels on screen would probably want
to happen in platform specific code. As absolutely late as possible, at the
moment of output, anyway. Then if and when there's a platform that takes double
coordinates that rounding simply doesn't have to happen there.

Regarding the suggestion of going via B2IPoint and friends as an intermediate
step towards B2DPoint and friends, I note that the B2I types are carefully
defined to use 32-bit ints (sal_Int32), whereas Point, Rectangle et al use long
(which let's face it *is* 64-bit almost everywhere that matters now) as does
much existing position-calculating code. So I'd worry that we'd be setting
ourselves up for a fight to resolve issues relating to that loss of range when
it's only needed as an intermediate step.

... All of which would be an absolutely gigantic changeset, no wonder no-one
who knows the code wants to do it! The more I poked around in this the more I
thought, "Oh God, no..." and "Can we *really* not localise this fix in
sallayout?" :-) But no, ultimately changing *all* the device coordinate code to
double is probably what has to happen one day.

Another thought I had, noticing that in OpenOffice.org Writer on a 4K screen of
course has no HiDPI awareness to speak of, so its user interface is unusable,
but zoom in on the text to an editing size and it looks fine - at 240% zoom you
would expect that, of course. Pretty much the same applies in LibreOffice
Writer if you set your desktop scaling to 100% on a 4K screen. So I wondered,
what if instead you just *not* apply desktop scaling on the document view
panes/frames whatever they're called here, and, um, *lie* on the user
interface, ie: multiply the user selected zoom by the desktop scaling factor?
:-)
--
You are receiving this mail because:
You are the assignee for the bug.
b***@bugs.documentfoundation.org
2018-08-04 12:18:00 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

--- Comment #14 from Khaled Hosny <***@eglug.org> ---
Another alternative to floating point, is to keep using integers but use a
scale, so instead of shaping at 10 pixels and drawing at the coordinates we
get, we shape at 10 * SCALE and shape ant coordinates / SCALE. Which is what
many other libraries do, and I vaguely remember that we have something similar
by may be we are not using it thoroughly. Worth investigating.
--
You are receiving this mail because:
You are the assignee for the bug.
b***@bugs.documentfoundation.org
2018-09-14 11:53:46 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

Telesto <***@surfxs.nl> changed:

What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://bugs.documentfounda
| |tion.org/show_bug.cgi?id=65
| |972
--
You are receiving this mail because:
You are the assignee for the bug.
b***@bugs.documentfoundation.org
2018-10-12 16:18:26 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

V Stuart Foote <***@utsa.edu> changed:

What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://bugs.documentfounda
| |tion.org/show_bug.cgi?id=11
| |9070
--
You are receiving this mail because:
You are the assignee for the bug.
b***@bugs.documentfoundation.org
2018-10-17 05:12:58 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

Mike Kaganski <***@hotmail.com> changed:

What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://bugs.documentfounda
| |tion.org/show_bug.cgi?id=11
| |9887
--
You are receiving this mail because:
You are the assignee for the bug.
b***@bugs.documentfoundation.org
2018-12-08 19:11:20 UTC
Permalink
https://bugs.documentfoundation.org/show_bug.cgi?id=103322

Mike Kaganski <***@hotmail.com> changed:

What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://bugs.documentfounda
| |tion.org/show_bug.cgi?id=12
| |1761,
| |https://bugs.documentfounda
| |tion.org/show_bug.cgi?id=12
| |1952
--
You are receiving this mail because:
You are the assignee for the bug.
Loading...