Commit Graph

54 Commits

Author SHA1 Message Date
Behdad Esfahbod 8c29dcaee4 s/HBFixed/F16DOT16/g 2022-10-13 12:06:15 -06:00
Behdad Esfahbod ad28f973f3 Rename offset types to be explicit about their size
Add Offset16To<>, Offset24To<>, and Offset32To<> for most use-cases.
2021-03-31 13:00:07 -06:00
Ebrahim Byagowi 08428a15c3 minor, spacing 2020-04-24 23:45:17 +04:30
Ebrahim Byagowi 47f5a86036 minor, use NN on every OffsetTo<UnsizedArrayOf<>> 2020-03-10 13:57:46 +03:30
Ebrahim Byagowi ce114d6b27 minor, tweak spaces 2019-12-31 15:53:02 +03:30
Behdad Esfahbod 229ef1d29d Rename Fixed to HBFixed
Fixes(!!) https://github.com/harfbuzz/harfbuzz/issues/1966
2019-09-10 10:31:07 -07:00
Ebrahim Byagowi a0b4ac4dce Turn 8 spaces to tab across the project
According to the current code style of the project
2019-08-27 02:40:41 +04:30
Ebrahim Byagowi bbad1b8298
[trak] minor, use roundf instead round to normalize the use
The change to `round` wasn't intended
2019-08-20 14:46:48 +04:30
Ebrahim Byagowi 37de38adea
Merge branch 'master' into remove-coretext-96dpi-assumption 2019-08-20 12:59:33 +04:30
Behdad Esfahbod dfc5780245 Fix more double-promotion errors
WHy do only some of the clang bots catch this I have no idea :(.
2019-05-07 23:26:09 -07:00
Ebrahim Byagowi 92588782d7
Remove space between right angle brackets now that we have C++11 (#1689) 2019-04-30 13:05:10 -07:00
Behdad Esfahbod ef00654962 Convert tag enum class consts to static constexpr
Part of https://github.com/harfbuzz/harfbuzz/issues/1553
2019-01-22 12:17:26 +01:00
Behdad Esfahbod b1152d5e66 Use NNOffsetTo<> 2019-01-17 18:17:04 -05:00
Tor Arne Vestbø f401f85a5a Remove assumption about Core Text working in 96 DPI
Core Text doesn't actually have a concept of DPI internally, as it
doesn't rasterize anything by itself, it just generates vector paths
that get passed along to Core Graphics.

In practice this means Core Text operates in the classical macOS
logical DPI of 72, with one typographic point corresponding to one
point in the Core Graphics coordinate system, which for a normal
bitmap context then corresponds to one pixel -- or two pixels for
a "retina" context with a 2x scale transform.

Scaling the font point sizes given to HarfBuzz to an assumed DPI
of 96 is problematic with this in mind, as fonts with optical
features such as 'trak' tables for tracking, or color glyphs,
will then base the metrics off of the wrong point size compared
to what the client asked for.

This in turn causes mismatches between the metrics of the shaped
text and the actual rasterization, which doesn't include the 72
to 96 DPI scaling.

If a 96 DPI is needed, such as on the Web, the scaling should be
done outside of HarfBuzz, allowing the client to keep the DPI of
the shaping in sync with the rasterization.

The recommended way to do that is by scaling the font point size,
not by applying a transform to the target Core Graphics context,
to let Core Text choose the right optical features of the target
point size, as described in WWDC 2015 session 804:

  https://developer.apple.com/videos/play/wwdc2015/804/
2019-01-15 13:26:35 +01:00
Ebrahim Byagowi e412008599 Remove redundant void from C++ sources (#1486) 2018-12-17 13:01:01 -05:00
Ebrahim Byagowi b2ebaa9afa Remove redundant 'inline' from methods (#1483) 2018-12-16 14:08:10 -05:00
Ebrahim Byagowi 7ee5c52345
minor style fix, use void in methods on no argument 2018-12-12 15:14:37 +03:30
Behdad Esfahbod 5c4fead734 Convert "static const hb_tag_t" constants to enum 2018-11-29 15:05:47 -05:00
Behdad Esfahbod 4a3b20738f [trak] Coment 2018-11-24 10:17:59 -05:00
Behdad Esfahbod aa06574823 Minor 2018-11-16 14:31:05 -08:00
Ebrahim Byagowi 1d82b4761d [colr/feat/trak] minor 2018-11-10 19:31:12 +03:30
Ebrahim Byagowi b989507fa6
[aat] Minor (#1369) 2018-11-08 20:48:54 +03:30
Behdad Esfahbod 72462eb765 Add UnsizedArrayOf::as_array() instead of hb_array() template 2018-11-02 11:46:42 -04:00
Behdad Esfahbod cf92d6579e [trak] Allow disabling tracking for ranges of text
Fixes https://github.com/harfbuzz/harfbuzz/issues/1303
2018-10-23 03:10:56 -07:00
Behdad Esfahbod 8d689f8a7b Add hb_array<>() specialization for UnsizedArrayOf
Related https://github.com/harfbuzz/harfbuzz/issues/1301
2018-10-22 21:33:18 -07:00
Behdad Esfahbod abfbba1911 Add hb_array<>()
Simplifies transient object creation.

Fixes https://github.com/harfbuzz/harfbuzz/issues/1301
2018-10-22 21:27:45 -07:00
Behdad Esfahbod d7865107ea Remove const from hb_array_t details
Will come in through <T> if desired.
2018-10-22 16:24:16 -07:00
Behdad Esfahbod 79b6356155 [trak] Fix extrapolation at end side 2018-10-19 11:00:20 -07:00
Behdad Esfahbod 9d42d70269 [trak] Fix calc
We were getting the first track record always.  Ie. this line:

       if (trackTable[i].get_track_value () == 0.f)
       {
-       trackTableEntry = &trackTable[0];
+       trackTableEntry = &trackTable[i];
        break;
       }

The rest is cleanup.

Fixes https://github.com/harfbuzz/harfbuzz/issues/1263 for the most part.
2018-10-17 17:55:47 -07:00
Behdad Esfahbod 04f72e8990 [trak] Implement extrapolation
This concludes trak, as well as AAT shaping support!
2018-10-11 11:25:07 -04:00
Behdad Esfahbod d6a12dba6d [trak] Fix, and hook up
Works beautifully!  Test coming.
2018-10-11 11:10:06 -04:00
Behdad Esfahbod 3d7dea6dfd [trak] Handle nSizes=0 and 1 2018-10-11 10:32:08 -04:00
Behdad Esfahbod 451f3de521 [trak] Fix counting 2018-10-11 10:30:32 -04:00
Behdad Esfahbod a5be380cae [trak] More 2018-10-11 10:29:02 -04:00
Behdad Esfahbod d06c4a867f [trak] Only adjust around first glyph
Assumes graphemes only have one base glyph.
2018-10-11 10:22:01 -04:00
Behdad Esfahbod 071a2cbcdd [trak] Clean up 2018-10-11 10:18:46 -04:00
Behdad Esfahbod 10642b3fbf Disallow null-enabled offsets to unsized structures...
...like UnsizedArrayOf<>.

This fixes a class of crasher bugs, mostly with color and AAT tables.  We
cannot use nullable offsets to varsized data that does not declare min_size,
because it's nost safe to use our fixed-size null pool for types that have
their size external.  So, use non_null'able offsets for these.

A further enhancement would be to make use of min_size in Null<> itself.
Will try that after.
2018-09-15 19:43:33 +02:00
Behdad Esfahbod c77ae40852 Rename hb-*private.hh to hb-*.hh
Sorry for the noise, downstream custom builders.  Please adjust.
2018-08-25 22:36:36 -07:00
Ebrahim Byagowi 32348a43c1
Fix trak table apply logic
In collaboration with Behdad
2018-07-01 15:32:43 +04:30
Ebrahim Byagowi 816b8169a9 Resolve some of clang's double-promotion warnings 2018-04-23 11:38:45 -07:00
Ebrahim Byagowi a47070cd40
Minor, annotate the added tables with likely/unlikely (#997) 2018-04-18 12:09:37 +04:30
Ebrahim Byagowi 277e328986
Make some of implicit header uses explicit (#989)
Splitted from #950 and #986 IIRC Chromium had a policy about this encouraging it,
not sure about automated way to detect and add them but for now lets have the needed
ones of them.
2018-04-17 09:13:35 +04:30
Ebrahim Byagowi a02c3ee70f Add or update tables specifications links 2018-04-12 13:44:32 +04:30
Ebrahim Byagowi 211da5efdc
[aat] Cosmetic changes (#964) 2018-04-11 17:41:24 +04:30
Ebrahim Byagowi 158f2810b2
[aat/ltag] Implement the table parsing (#911) 2018-03-26 12:04:30 +04:30
Ebrahim Byagowi 9eee38a55c
[aat/fmtx] Implement the table parsing (#910) 2018-03-25 23:56:02 +04:30
Behdad Esfahbod a0dccb6188 Add NameID 2018-03-15 07:47:02 -07:00
Behdad Esfahbod fa3a69e233 [aat/trak] Simplify sanitize() 2018-02-26 00:32:11 -08:00
Behdad Esfahbod f0bc6c0992 [aat/trak] Clean up
We always just used "unsigned int" for counter values. There's
no use for uint16_t outside of a struct.

Also, no need for explict casting where implicit does.
2018-02-26 00:18:17 -08:00
Ebrahim Byagowi bb82f01383 [aat] trak sanitization 2018-02-26 00:15:26 -08:00