Closed camertron closed 6 years ago
Dict
until it's actually used. PRs are as big as they need to be. You can use commits within a PR to show logical progression and further split changes into smaller pieces.Sci
is indeed a bit vague. Maybe SkiForm
? It's not much better but at least resemble a noun and maybe a bit more telling to people who are familiar with a proper term.Table
would be useful for all table-like structures and more specialized subclasses would implement specifics of top-level tables. Maybe we should consider this as an intermediary refactoring step either before or after this PR. WDYT?SciForm
? The math world has to have invented a word for this, but I don't know what it is. I'll keep thinking about it.Table
class to correspond to the True-Type concept of a table, which is a structure that has an entry in the font's directory. The structures within the CFF table aren't truly tables, or at least not according to the spec. So perhaps the right move here is to rename SubTable
to something like CFFStructure
.otf_encoder
, handles encoding OTF fonts and takes the missing glyf table into consideration.Just a reminder that we're merging everything into the otf
branch not master
, so there's no danger of messing things up by merging incomplete features. I appreciate what you said about PRs being as large as they need to be, but I really don't see the need for the otf
branch to be fully working after every one of my smaller PRs. It will be fully working when they have all been merged. I split things up to make the whole feature conceptually easier to understand. Just as I have submitted PRs for individual tables like VORG and DSIG, these upcoming CFF PRs introduce a few sub-tables (i.e. CFF structures) at a time. If you're ok with the entire CFF feature landing at once, I can create a single giant PR for the remaining work. A valid CFF table contains 5 top-level structures.
This PR is rather heavy on complex logic but specs are sparse. Maybe you could add a bit more coverage?
Hey @pointlessone, I think I've addressed all your concerns specifically I have:
Dict
and Index
(caught several bugs too hehe).Index
to parse everything immediately, which simplified the logic considerably.Dict
operands (specifically sci form operands since it's not really possible to validate integers).
This pull request is part of a larger effort to bring OTF support to TTFunk. See https://github.com/prawnpdf/ttfunk/issues/53 for details.
Highlights of this PR:
Index
andDict
. An index is essentially an array that can be accessed by index, and a dict is a dictionary of operator/operand (i.e. key/value) pairs. Operators have special meaning depending on the context. For example the CFF top and private dicts both use the dict structure but define different operators for the data they contain.Dict
class technically isn't used anywhere yet. Including it when it is actually used would make the corresponding PR too large in my opinion, so it is introduced here instead.Sci
class (couldn't come up with a better name, suggestions welcome) is supposed to represent a number in scientific notation (i.e. 5.2 x 104). TheDict
class uses it for a special type of operand that starts with a byte30
. I could have stored it as a float, but it would then have been a lot more work to re-encode later.TTFunk::SubTable
class has been introduced to handle the case when table-like parsing behavior is desired but the table is not a top-level, directory-based font table.