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

[read-fonts] parse embedded bitmap tables #637

Merged
merged 8 commits into from
Oct 10, 2023
Merged

[read-fonts] parse embedded bitmap tables #637

merged 8 commits into from
Oct 10, 2023

Conversation

dfrg
Copy link
Member

@dfrg dfrg commented Sep 27, 2023

This can now read Noto Color Emoji bitmaps with code like the following:

    let data = std::fs::read("path/to/NotoColorEmoji.ttf").unwrap();
    let font = FontRef::from_index(&data, 0).unwrap();
    let ch = '🫶';
    let ch = '✨';
    let ch = '\u{2764}';
    let cmap = font.cmap().unwrap();
    let cblc = font.cblc().unwrap();
    let cbdt = font.cbdt().unwrap();
    let gid = cmap.map_codepoint(ch).unwrap();
    let size = &cblc.bitmap_sizes()[0];
    let location = size.location(cblc.offset_data(), gid).unwrap();
    let bitmap = cbdt.data(&location).unwrap();
    std::fs::write("emoji_image.png", bitmap.data).unwrap();

@dfrg dfrg changed the title [WIP] CBLC parsing [WIP] [read-fonts] embedded (color) bitmaps Oct 4, 2023
@dfrg dfrg changed the title [WIP] [read-fonts] embedded (color) bitmaps [read-fonts] parse embedded bitmap tables Oct 9, 2023
@dfrg dfrg marked this pull request as ready for review October 9, 2023 13:18
this covers:
* EBLC/CBLC formats 1, 2 and 3
* EBDT/CBDT formats 2, 5, and 17
* collapse test metrics asserts to single expression
* reduce CBDT test case size
* remove useless comments
* add links to issue for improving codegen to relevant places
@dfrg
Copy link
Member Author

dfrg commented Oct 10, 2023

#660 for missing format tests

@dfrg dfrg merged commit ca4fea8 into main Oct 10, 2023
6 checks passed
@dfrg dfrg deleted the bitmaps branch October 10, 2023 03:48
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.

3 participants