Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

[klippa] subset CBLC/CBDT tables #1351

wants to merge 2 commits into from

Conversation

qxliu76
Copy link
Contributor

@qxliu76 qxliu76 commented Feb 11, 2025

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

Copy link
Member

@cmyr cmyr left a 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();
Copy link
Member

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,
Copy link
Member

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?

Comment on lines +2 to +6
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::{
Copy link
Member

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..

Comment on lines +92 to +95
let cblc = args.0;
let cbdt = args.1;
let src_bytes = args.2;
let cbdt_out = args.3;
Copy link
Member

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);
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants