37 Commits

Author SHA1 Message Date
Nathan Williis
23e3ab60f8 Docs: fix code-example blocks in varLib. 2024-09-03 17:53:56 +01:00
Khaled Hosny
eff90154ed [varLib.cff] Restore and deprecate convertCFFtoCFF2
It is used by ufo2ft.
2024-05-27 13:18:04 -07:00
Behdad Esfahbod
0a7433f847 [cffLib] Add CFF<->CFF2 convertors that work on otFont 2024-05-16 16:29:22 -07:00
Behdad Esfahbod
ec36fe74d5 [cffLib / varLib] Merge two impls of convertCFFToCFF2
Fixes https://github.com/fonttools/fonttools/issues/1835
2024-05-16 15:57:31 -07:00
Cosimo Lupo
c9963fd4cd
minor comment 2023-08-02 14:06:35 +01:00
Behdad Esfahbod
839e76b84d [varLib/cff] Allow sparse masters
Fixes https://github.com/fonttools/fonttools/issues/3233
2023-08-01 11:26:54 -06:00
Behdad Esfahbod
8c6e14674a Typo 2023-01-06 14:17:12 -07:00
Nikolaus Waxweiler
d584daa8fd Blacken code 2022-12-13 11:26:36 +00:00
Behdad Esfahbod
4742960f7f [varLib.cff] Don't round deltas
Fixes https://github.com/fonttools/fonttools/issues/2838
2022-10-04 14:12:01 -06:00
Behdad Esfahbod
a7cda37fbb [ttVarGlyphSet] Support CFF 2022-08-26 20:52:18 -06:00
Behdad Esfahbod
61160fe5db [cffLib.specializer] Fix generalizer blend
Fixes https://github.com/fonttools/fonttools/issues/1975
2022-08-17 11:13:42 -06:00
Simon Cozens
0f03e6529a
[docs] Fix sphinx warnings (#2453)
* Add default auto doc options

* Ensure all references are unique

* Use anonymous links to avoid duplicate references

* Remove default options, fix wrong module name

* Don’t index repeated class

* Remove repeated classes included through automodule

* Fix warnings

* We don’t use our own static directory

* Correctly format XML in docs

* Fix indentation

* Fix overline

* Bring TOC to top

* Fix definition list

* Offset definition lists and examples

* Fix erroneous markup

* Fix markup

* Already included in automodule

* Fix args markup

* Correct markup for example

* Don’t reindex repeated module

* Correct XML code block markup

* Fix markup errors, change example to doctest

* Correct list markup

* Make ttx docstring both valid RST and valid help output

* Various other boring markup fixes

* Fix example indenting

* Make docstring valid RST and valid help output

* Mock import for reportlab

* It’s ok if manual links don’t appear in toctrees

* Oops typo, I guess doctests are useful
2021-12-02 15:31:49 +00:00
Cosimo Lupo
d89b3fbea6
Merge pull request #2216 from fonttools/jh-disambiguate-varlib-merge-errors
[varlib] disambiguate cff merge errors
2021-03-11 10:51:38 +00:00
Josh Hadley
50fb04fd57 [varlib] use VarLibCFFHintTypeMergeError for hint merging 2021-03-05 08:50:43 -08:00
Behdad Esfahbod
ed6164a44f [varLib.cff] Round deltas using bankers round as well
See https://github.com/fonttools/fonttools/pull/2214#issuecomment-790742479

Good news: this reverted the one CFF test that needed its expectation to
change when I started this patchset. Bad news: it introduced a couple other
diffs to the same glyph of the same test, which is consistent with changing
the rounding from otRound to round3.
2021-03-04 13:10:01 -07:00
Behdad Esfahbod
68004b8fec [varLib] Shift most (all?) delta-rounding to VarModel
Reduces error.

The main varfont-builder now asks the model to do rounding, and asks
VariationStore to do no rounding, so we don't spend extra times rounding
multiple times (specially with the heavy otRound).

I *think* I got it all and right...

Fixes https://github.com/fonttools/fonttools/issues/2213
2021-03-04 09:20:43 -07:00
Behdad Esfahbod
3a9a2bd4b1 [misc.roundTools] Add noRound(), maybeRound(), and roundFunc()
Moving out of CFF code, to be used in VariationModel().

Part of https://github.com/fonttools/fonttools/issues/2213
2021-03-04 09:20:43 -07:00
Behdad Esfahbod
28fae1d95f [cff] Simplify rounding logic
No semantic change. Just refactoring and simplification in anticipation
of coming changes.
2021-03-03 18:27:06 -07:00
Cosimo Lupo
1f33249d36
varLib.cff: fix unbound local variable
Fixes https://github.com/fonttools/fonttools/issues/1787

Thanks Behdad.
2020-12-14 18:21:04 +00:00
Simon Cozens
eda4a2717e Use Python3 inheritance style for super.___init__
Avoids cases where super() argument is not enclosing class: https://help.semmle.com/wiki/display/PYTHON/First+argument+to+super%28%29+is+not+enclosing+class
2020-05-07 21:09:20 +01:00
Nikolaus Waxweiler
5b5c964b0f cff: Use new exceptions
Aliases for the old errors will stay because the AFDKO and maybe others
use them.
2020-02-13 15:01:52 +00:00
Khaled Hosny
366c08a9d6 [varLib, fontBuilder] Set Private.vstore as well
Otherwise T2OutlineExtractor.op_blend() would raise and exception unless
the font is saved and loaded again.
2020-01-31 23:39:47 +02:00
Khaled Hosny
38981b6dae [varLib] Allow using CFF2 table as source
Nothing clever, if the source font has a CFF2 table use it as if it were
a CFF table (i.e. non-variable, not sure what would happen in the source
CFF2 was variable already).
2020-01-31 23:39:47 +02:00
Nikolaus Waxweiler
c1bfc6ad4d cff.py: don't bother cleaning privateDict if it is None 2019-08-16 22:09:52 +01:00
Nikolaus Waxweiler
68a5ceac6d varLib: Remove py23 imports 2019-08-10 15:39:02 +01:00
Miguel Sousa
e1f0d1ae09 varLib CFF fixes (#1653)
* varLib.cff: Apply conv_to_int() to all the values

* varLib: Don't hardcode file extension to 'ttf'

Also remove unused imports

* varLib.cff: Fix merging of sparse PrivateDict items

Fixes #1651
2019-06-24 17:10:36 -07:00
Cosimo Lupo
eda353c4c1
Merge pull request #1642 from fonttools/CFF2-fixes
Fixes merge bug when VF source have no blends or no marking glyphs in any charstrings.
2019-06-17 16:57:16 +01:00
Cosimo Lupo
fc6ea56568
must add comma to make parentheses into a tuple 2019-06-14 16:20:48 +01:00
Cosimo Lupo
c6cf9bbb35
minor typo fix 2019-06-14 16:19:54 +01:00
Cosimo Lupo
3ab7dd143d
minor whitespace 2019-06-14 16:19:29 +01:00
ReadRoberts
cc3c928053 [varLib.cff] Fix important bug in merging FF2 PrivateDicts.
There was a bug that caused the PrivateDict of the first region to be used for all others.
2019-06-12 17:11:01 -07:00
ReadRoberts
ec54541e30 [varLib.cff] Fix merging bug when there are no blends or marking glyphs.
If the CFF2 VF has no blends, or no marking glyphs, the default variation table does not get built; this can be needed later for the PrivateDict.
2019-06-12 16:31:29 -07:00
Read Roberts
5b3db36670
Sparse cff2vf support (#1591)
* Added getter (in the form of a property decorator) for T2Charstring.vsindex. Fixes endless compile loop in some circumstances.

Fixed bug in mutator: need to remove vsindex from snapshotted charstrings, plus formatting clean up

* Fix for subsetting HVAR tables that have an AdvanceWidthMap when the --retain-gid option is used. Needed to make subset_test.py::test_retain_gids_cff2 tests pass.

* in varLib/cffLib.py, add support for sparse sources, and sources with more than one model, and hence more than one VarData element in the VarStore.

CFF2 source fonts with multiple FontDicts in the FDArray need some extra work. With sparse fonts, some of the source fonts may have a fewer FontDicts than the default font. The getfd_map function() builds a map from the FontDict indices in the default font to those in each region font. This is needed when building up the blend value lists in the master font FontDict PrivateDicts, in order to fetch PrivateDict values from the correct FontDict in each region font.

In specializer.py, add support for CFF2 CharStrings with blend operators. 1) In generalizeCommands, convert a blend op to a list of args that are blend lists for the following regular operator. A blend list as a default font value, followed by the delta tuple. 2) In specializeCommands(), convert these back to blend ops, combining as many successive blend lists as allowed by the stack limit.

Add test case for sparse CFF2 sources.
The test font has 55 glyphs. 2 glyphs use only 2 sources (weight = 0 and 100). The rest use 4 source fonts: the two end points of the weight axis, and two intermediate masters. The intermediate masters are only 1 design space unit apart, and are used to change glyph design at the point in design space. For the rest, at most 2 glyphs use the same set of source fonts. There are 12 source fonts.

Add test case for specializer programToCommands() and commandsToProgram by converting each CharString.program in the font to a command list, and back again, and comparing original and final versions.
2019-04-26 09:33:52 -07:00
ReadRoberts
1fe0348bad Remove old debug pdb.set_trace(). This has already been fixed on another branch that has not yet been merged, but I need to fix it here for the VVAR test to pass. 2019-03-21 10:48:56 -07:00
Cosimo Lupo
39f49b785b
[varLib.cff]: shouldn't iterate through a dict while deleting keys
cherry-picked from https://github.com/fonttools/fonttools/pull/1415
2019-01-02 17:31:47 +00:00
ReadRoberts
0586c06199 [varLib subset CFF2] Set PrivateDict nominal and default WidthX to None
@bedhad
Address issues raised in #1403

I do think setting the dummy CFF2 PrivateDict nominalWidthX and defaultWidthX to None, which leads to the charstring.width also being None,  is a good idea. I originally set them to 0, which produces a charstring width of 0, in order to avoid problems with logic that assumes that the field is good for math. However, I now think that it is better to find errors around charstring type assumptions earlier than later.

 "drop_hints()" is actually not wrong - I did look at this when making the changes. For CFF2 charstrings, self.width is always equal to self.private.defaultWidthX, so the width is never inserted. This is because in psCharstrings.py::T2WidthExtractor.popallWidth(), the test "evenOdd ^ (len(args) % 2)" is alway False.  Left to myself, I would not change this code. If the CFF2 charstring is correct, there is not a problem. if the CFF2 charstring is not correct, then both in drop_hints() and in T2WidthExtractor.popallWidth(), the logic will stack dump. I did add asserts, but am not totally sure it is worth the extra calls.
2018-12-06 11:55:48 -08:00
Behdad Esfahbod
93633a85ef [CFF] Move variations-specific CFF code to varLib.cff module 2018-12-04 19:22:02 -08:00