fschutt / printpdf

A fully-featured PDF library for Rust, WASM-ready
https://fschutt.github.io/printpdf/
MIT License
829 stars 98 forks source link

`write_text` function cannot use different font than used `use_text` #150

Open qarmin opened 1 year ago

qarmin commented 1 year ago
        layer.use_text(
            format!("{} ", header),
            FONT_SIZE,
            Mm(position.x),
            Mm(PAGE_HEIGHT - position.y - idx as f32 * 5.0),
            &fonts[&Fonts::RobotoRegular],
        );
        layer.write_text(*data, &fonts[&Fonts::RobotoBold]);

        layer.use_text(
            format!("{} ", header),
            FONT_SIZE,
            Mm(position.x),
            Mm(PAGE_HEIGHT - position.y - idx as f32 * 5.0 - 20.0),
            &fonts[&Fonts::RobotoBold],
        );
        layer.write_text(*data, &fonts[&Fonts::RobotoRegular]);

First part should be writeten with one font and second(after :) with another, but this not works

Screenshot from 2023-09-25 12-26-52

In fpdf2 with similar construction I got such output

Screenshot from 2023-09-25 12-34-18