bug-lilypond
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Garbage copied from PDF when using certain fonts


From: Masamichi Hosoda
Subject: Re: Garbage copied from PDF when using certain fonts
Date: Sat, 21 Aug 2021 10:41:12 +0900 (JST)

>>>> The problem does not appear if the cairo backend is used, see
>>>> https://gitlab.com/lilypond/lilypond/-/merge_requests/853.
>>> 
>>> This is good news!
>> 
>> When copying and pasting from a PDF generated using cairo backend,
>> some characters turned into similar but different characters.  The
>> characters are garbled in both AJ1 and AI0 fonts.  If you use ps
>> backend, characters by the AJ1 font are not garbled.  [...]
> 
> I've looked up the cairo bug tracker but couldn't find something
> related to copy-and-paste of CID-keyed fonts.  Masamichi-san, could
> you submit an issue there so that this gets fixed eventually?  I guess
> this would be beneficial for other projects, too.

In my experiment, Cairo without LilyPond does not generate garbled characters.
It seems to be a LilyPond issue instead of a Cairo issue.
Here's a python-cairo sample that works fine.

```
#!/bin/env python3

import cairo

def main():
    with cairo.PDFSurface("test.pdf", 300, 100) as surface:
        context = cairo.Context(surface)

        context.select_font_face("Noto Serif CJK JP")
        context.set_font_size(12)
        context.move_to(12, 24)
        context.show_text("初見はハ長調で高音の白玉があった")

        context.select_font_face("HaranoAjiMincho")
        context.set_font_size(12)
        context.move_to(12, 48)
        context.show_text("初見はハ長調で高音の白玉があった")

        surface.show_page()

if __name__ == '__main__':
    main ()
```



reply via email to

[Prev in Thread] Current Thread [Next in Thread]