-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[klippa] subset CBLC/CBDT tables #1351
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few notes inline but nothing major is jumping out at me...
@@ -343,6 +346,13 @@ impl Plan { | |||
this.populate_gids_to_retain(font); | |||
this.create_old_gid_to_new_gid_map(); | |||
|
|||
//update the unicode to new gid list | |||
let num = this.unicode_to_new_gid_list.len(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this related to the cblc/cbdt changes?
@@ -807,13 +818,14 @@ pub trait Subset { | |||
// A helper trait providing a 'subset' method for various subtables that have no associated tag | |||
pub(crate) trait SubsetTable<'a> { | |||
type ArgsForSubset: 'a; | |||
type SubsetOutput: 'a; | |||
/// Subset this table and write a subset version of this table into serializer | |||
fn subset( | |||
&self, | |||
plan: &Plan, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd just call this Output
, we know it's part of the SubsetTable
trait. (Looking back I would have also suggested Args
instead of ArgsForSubset
but maybe that name was about avoiding clashing with FontRead
?
use crate::serialize::{OffsetWhence, SerializeErrorFlags, Serializer}; | ||
use crate::{Plan, Subset, SubsetError, SubsetTable}; | ||
use skrifa::raw::collections::IntSet; | ||
use write_fonts::types::FixedSize; | ||
use write_fonts::{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
total nit but this can be cleaned up a bit..
let cblc = args.0; | ||
let cbdt = args.1; | ||
let src_bytes = args.2; | ||
let cbdt_out = args.3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or,
let (cblc, cbdt, src_bytes, cbdt_out) = args;
impl<'a> SubsetTable<'a> for IndexSubtableList<'a> { | ||
type ArgsForSubset = (&'a Cbdt<'a>, &'a mut Vec<u8>); | ||
// min_gid(new), max_gid(new), indexSubtableListSize, numberOfIndexSubtables | ||
type SubsetOutput = (GlyphId, GlyphId, usize, usize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could consider defining a simple struct for passing in these args, so that you have named fields? in this case in particular it seems easy to get the argument order wrong.
Also updated SubsetTable trait.
Harfbuzz implementation is suboptimal, rust code is using a different approach, following fonttools' method:
https://github.com/fonttools/fonttools/blob/7854669acd63be43e1ad41d0486297d8d6da325d/Lib/fontTools/subset/__init__.py#L1799