Skip Menu |

This queue is for tickets about the Pango CPAN distribution.

Report information
The Basics
Id: 130241
Status: resolved
Priority: 0/
Queue: Pango

People
Owner: XAOC [...] cpan.org
Requestors: PMPERRY [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Will Pango work best for me?
I need the ability to handle a wide variety of script systems for my Perl PDF builder library (PDF::Builder on CPAN), and am wondering if Pango is the right solution for this. What I start with is a selected OTF or TTF font, possibly a font size at this point, and a UTF-8 string (or a list of raw CIDs... I can already do that). What I need back are a list of substituted CIDs in the correct order AND any size or positioning correction information, so that complex scripts can be properly placed on the page. The output width in points (or some unit that I can convert to points) would be great. I DON'T need Pango or anything else to do the actual rendering -- I already have the means to put CIDs (glyph IDs) into the PDF output at certain positions on the page. The description of HarfBuzz sounds like what I need, but there doesn't seem to be a Perl wrapper around it, or a way to install it from the 'cpan' utility. Pango sounds like the next-best thing (it uses HarfBuzz internally?), but I am leery of code bloat from all the rendering stuff it carries along. Is there any way just to install the parts I need? I tried installing it, but it failed on not finding 'cairo' (Cairo 1.106 is available to install, so maybe this is RT 44649?)... can the full thing (including HarfBuzz) be installed through 'cpan', or will someone be required to manually install other parts? As long as I can document what manual steps will be needed for all major OS's and Perl installations, that's presumably usable, and better than nothing. My development system is Strawberry Perl 5.26 on Windows 10. So, is Pango my best choice here for what I want to do, or can someone recommend a Perl product (on CPAN) that better suits my needs?
On Thu Aug 01 12:23:37 2019, PMPERRY wrote: Show quoted text
> I need the ability to handle a wide variety of script systems for my > Perl PDF builder library (PDF::Builder on CPAN), and am wondering if > Pango is the right solution for this. What I start with is a selected > OTF or TTF font, possibly a font size at this point, and a UTF-8 > string (or a list of raw CIDs... I can already do that). What I need > back are a list of substituted CIDs in the correct order AND any size > or positioning correction information, so that complex scripts can be > properly placed on the page. The output width in points (or some unit > that I can convert to points) would be great. I DON'T need Pango or > anything else to do the actual rendering -- I already have the means > to put CIDs (glyph IDs) into the PDF output at certain positions on > the page.
I can't really tell you if Pango will suit your purpose; what I can tell you that the Perl GTK+ modules are just wrappers around the C libraries, so if you know it's possible to do what you want using a given GTK+ C library, then it should also be possible to do what you want using the corresponding Perl module(s). Show quoted text
> The description of HarfBuzz sounds like what I need, but there doesn't > seem to be a Perl wrapper around it, or a way to install it from the > 'cpan' utility. Pango sounds like the next-best thing (it uses > HarfBuzz internally?), but I am leery of code bloat from all the > rendering stuff it carries along. Is there any way just to install the > parts I need?
I'm going to say "probably not"; more below... Show quoted text
> I tried installing it, but it failed on not finding > 'cairo' (Cairo 1.106 is available to install, so maybe this is RT > 44649?)... can the full thing (including HarfBuzz) be installed > through 'cpan', or will someone be required to manually install other > parts? As long as I can document what manual steps will be needed for > all major OS's and Perl installations, that's presumably usable, and > better than nothing. My development system is Strawberry Perl 5.26 on > Windows 10.
I didn't see you mention if you have the GTK+ C libraries installed, so I'm assuming you don't; you would know if you installed them, as they are not bundled with Strawberry. You need to get the GTK+ C libraries for Windows installed (somehow) before you would be able to go any further with installing Gtk-Perl modules (like Pango or Cairo) under Strawberry. Another special caveat for Windows platforms, is that you have to make sure that the GTK+ C library DLLs are in your %PATH% in Strawberry before you try to compile the Gtk-Perl modules that wrap those GTK+ C libraries. A suggestion at this point would be to do a proof-of-concept using the Pango Perl module (+harfbuzz) in a Linux VM prior to investing the time to get a full Gtk-Perl stack going on Windows. Installing a GTK3+ Gtk-Perl stack on Windows can be done, there are tutorials floating around out there, but there's not currently a maintained/curated installer that does the work for you.
Hi Brian, thanks for getting back to me on this. Unfortunately, what you seem to be telling me is that the use of HarfBuzz and/or Pango is going to be a lot more complicated than simply requiring it (optional prerequisite) in my package (PDF::Builder), and 'cpan' happily installs it for anyone as a prereq. While I could probably figure out a way to do it, requiring manual GTK+ installation first is probably going to be a deal-breaker for most users. Unless I'm misreading your statements and it's actually a lot simpler than I fear, it's going to be too much for most potential users, and they'll just go elsewhere to get their PDF generation with complex scripts. As I said before, I don't need all the rendering stuff that comes with Pango; only the glyph selection/ordering/positioning provided by HarfBuzz. Is the Cairo code all rendering? Is that what's using GTK+ (Gtk3 on CPAN)? It would be a shame to put PDF::Builder users through all sorts of extra effort to get GTK+ and possibly other prereqs manually installed, and then ignore all that new stuff. I think I have at least three options: 1. Bite the bullet and work out clean installation instructions that will apply to all OS's and Perl distributions, and hope that users will be willing to put up with the extra work. I have only a Win10 box and only Strawberry Perl, so it would be difficult to test other installations. 2. Talk to the HarfBuzz developers and see if a thin Perl wrapper could be put around the library, so I can call it (analagous to Graphics::TIFF wrapper around libtiff.a). Something would have to be done about building HarfBuzz itself, that would work across all platforms). Does Pango installation build HarfBuzz from C/C++ sources? If you already build it as a standalone .a or .dll library, would YOU be interested in providing a Perl wrapper around it, possibly as a separate CPAN module? Not having looked at the code, I have no idea if this is a large task. I'm quite willing to help out with the C coding, if there are some guidelines on how to do it. I see that my MiKTeX installation seems to have a HarfBuzz .dll file, so it can be done (but I can't require a MiKTeX installation as a prereq). 3. Rewrite HarfBuzz as a pure Perl solution. That sounds like a lot of work, and I'm not anxious to invest the time. Plus, it's likely to be noticeably slower than a C solution, and I would be responsible for keeping such a module updated as HarfBuzz evolves. Thoughts or suggestions?
On Fri Aug 02 11:28:59 2019, PMPERRY wrote: Show quoted text
> Hi Brian, thanks for getting back to me on this. > > Unfortunately, what you seem to be telling me is that the use of > HarfBuzz and/or Pango is going to be a lot more complicated than > simply requiring it (optional prerequisite) in my package > (PDF::Builder), and 'cpan' happily installs it for anyone as a prereq.
All Gtk-Perl modules (Pango/Cairo/GTK2+/GTK3+/Glib) need the corresponding C libraries (libpango, libcairo, libgtk2/3+/libglib), and their dependencies (libharfbuzz in the case of libpango) installed on the system before the Perl modules will compile. Show quoted text
> While I could probably figure out a way to do it, requiring manual > GTK+ installation first is probably going to be a deal-breaker for > most users. Unless I'm misreading your statements and it's actually a > lot simpler than I fear, it's going to be too much for most potential > users, and they'll just go elsewhere to get their PDF generation with > complex scripts.
It will be a lot of work to document and/or compile the GTK+ C libraries (+ dependencies) on Windows. You may be able to find compiled versions of the GTK+ C libraries for Windows on the GTK website, but no guarantees. Show quoted text
> As I said before, I don't need all the rendering stuff that comes with > Pango; only the glyph selection/ordering/positioning provided by > HarfBuzz. Is the Cairo code all rendering? Is that what's using GTK+ > (Gtk3 on CPAN)? It would be a shame to put PDF::Builder users through > all sorts of extra effort to get GTK+ and possibly other prereqs > manually installed, and then ignore all that new stuff. > > I think I have at least three options: > > 1. Bite the bullet and work out clean installation instructions that > will apply to all OS's and Perl distributions, and hope that users > will be willing to put up with the extra work. I have only a Win10 box > and only Strawberry Perl, so it would be difficult to test other > installations.
For what it's worth, VirtualBox is free and runs on Windows 10, most Linux distros are free, so you *could* test on other platforms besides Windows. But to answer the question you asked, it would be a lot of time for someone to set up Gtk-Perl on Windows in order to get access to Harfbuzz C library functions. The Gtk-Perl project does not currently have a Windows installer for the C libraries that are required in order to run Gtk-Perl on Windows. Like I said in my previous reply, other people have done it and documented it, but running Gtk-Perl on Windows is not as easy as installing Linux then installing the Perl modules and C libraries via a package manager. Show quoted text
> 2. Talk to the HarfBuzz developers and see if a thin Perl wrapper > could be put around the library, so I can call it (analagous to > Graphics::TIFF wrapper around libtiff.a). Something would have to be > done about building HarfBuzz itself, that would work across all > platforms).
That's not a trivial amount of time that you're asking of someone else for your project. Yes a thin Perl wrapper can be put around the Harfbuzz C library, but I can't guarantee someone else will do it for you. Show quoted text
> Does Pango installation build HarfBuzz from C/C++ sources?
"Pango" is the Perl module, "libpango" is the C library. If you get these confused, you will cause yourself and anyone you ask questions of endless amounts of grief. "Pango" the Perl module knows nothing about Harfbuzz; the libpango C library *does* know about the Harfbuzz C library, and makes calls into the libharfbuzz C library as needed to perform text rendering functions. So this means that in order for the libpango C library to work, it also needs a copy of the libharfbuzz C library installed and linked on the same system. The Pango Perl module just makes calls to the libpango C library. This is true regardless of what operating system you are trying run your Perl or C libraries on. Show quoted text
> If you already build it as a standalone .a or .dll library, would YOU > be interested in providing a Perl wrapper around it, possibly as a > separate CPAN module? Not having looked at the code, I have no idea if > this is a large task. I'm quite willing to help out with the C coding, > if there are some guidelines on how to do it. I see that my MiKTeX > installation seems to have a HarfBuzz .dll file, so it can be done > (but I can't require a MiKTeX installation as a prereq).
Please see the above for an explanation about libpango/libharfbuzz dependencies, and how the Pango Perl module doesn't know about Harfbuzz. You could steal/borrow a Harfbuzz C library Windows .dll file from another project, but you would still need to wrap it somehow in order to talk to it from Perl. Personally, I'm not interested in writing a Harfbuzz Perl module, I don't have the desire and time for it. As far as coding guidelines, there are many "wrapper" Perl modules on CPAN that you can use as examples for writing a Harfbuzz Perl module. You may want to create a project for a Harfbuzz Perl module, then ask on the Gtk-Perl or harfbuzz mailing lists for volunteers to collaborate with you on this. Show quoted text
> 3. Rewrite HarfBuzz as a pure Perl solution. That sounds like a lot of > work, and I'm not anxious to invest the time. Plus, it's likely to be > noticeably slower than a C solution, and I would be responsible for > keeping such a module updated as HarfBuzz evolves.
You could also write a HarfBuzz Perl module yourself that wraps the C libraries via XS, as I've mentioned a few times above. So to answer the question you originally posed in this ticket, the Pango Perl module will more than likely not do what you want, you are probably better off writing a wrapper to the Harfbuzz C library, or implementing Harfbuzz in Pure Perl. I personally am not interested in doing this work for you, but feel free to ask on mailing lists to see if you can get some help. Do you need anything else for this ticket?
OK, it's beginning to look as if Pango is probably the wrong path to go down, to do what I want to do. There's too much rendering overhead that I don't need, and it's not something that I can simply give as a package prereq and let 'cpan' take care of its full installation. I will take a closer look at HarfBuzz itself to see if it's feasible to either get someone to write a thin Perl wrapper around it (a la libtiff.a and Graphics::TIFF), or whether it's something I can even do myself (including the building of the library itself from C source, not assuming that someone else has already installed it). First I will need to study HarfBuzz very carefully to confirm that it can do the things I need, and talk to the people there. Thank you for taking the time to answer my question, and good luck with further work on Pango. If I can't close this ticket myself, please feel free to do so yourself.
Closing.