Skip to content

[read-fonts] parse embedded bitmap tables - #637

Merged
dfrg merged 8 commits into
mainfrom
bitmaps
Oct 10, 2023
Merged

dfrg merged 8 commits into
mainfrom
bitmaps

Conversation

@dfrg

@dfrg dfrg commented Sep 27, 2023 •

Copy link
Copy Markdown
Contributor

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
Comment thread font-codegen/src/fields.rs Resolved
Comment thread font-codegen/src/fields.rs Resolved
Comment thread font-codegen/src/record.rs Resolved
Comment thread read-fonts/src/tables/cbdt.rs Resolved
Comment thread read-fonts/src/tables/cbdt.rs Resolved
* 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

dfrg commented Oct 10, 2023

Copy link
Copy Markdown
Contributor Author

#660 for missing format tests

@dfrg
dfrg merged commit ca4fea8 into main Oct 10, 2023
@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