Thread: [Paps-discuss] printing librarian data with paps 0.6.8
Brought to you by:
dov-g
From: Matthias A. <gu...@un...> - 2011-09-15 13:32:46
|
Hello, The background of my interest in paps (or pango) is that I'm working for a provider of IT solutions for libraries (catalogue, circulation and so, all IT stuff a library of a university needs, to not go into further marketing :-)). We moved with our recent version from ISO 8859-1 data to UTF-8 and all data of the library about users, books, ... is now stored in the database in UTF-8, including CJK data. The system is UNIX based and has of course printouts for orders, letters, etc., and in all the languages in which are data is stored in the database. This as background only. My questions: 1. It seems that paps is not developed further, the last modifications in the sources are from 2006; is this true? 2. We need to combine the rendering of UTF-8 to Postscript (as possible with paps) together with printing some chars in OCR-B font; at the moment we are doing this without paps, by embedding FreeFonts and OCR-B font and writing the Postscript with some Perl engine. The problem with this is that FreeFoont have no CJK support. Is there some way to handle OCR-B font with paps as well? 3. And last question: should we skip paps and use pango directly? Thanks for your time reading all this Regards matthias -- Matthias Apitz t +49-89-61308 351 - f +49-89-61308 399 - m +49-170-4527211 e <gu...@un...> - w http://www.unixarea.de/ |
From: Dov G. <dov...@gm...> - 2011-09-16 07:14:00
|
Hi Matthias, Paps was indeed written some time ago, and since it was written the graphics library cairo has integrated with pango and had it been written today it would have been written that way. A rewrite of paps using cairo is really overdue. For your solution I certainly suggest using cairo + pango in whatever language these have bindings for. A solution similar to your problem can be seen in the following example on the vala tutorial page: http://live.gnome.org/Vala/PangoCairoSample That example outputs png files, but you can easily change it to outputting postscript. You did not state what graphics you want to output, but with cairo you can easily layout whatever graphics objects you want on the page, including text by pango and if for some reason (encoding?) pango doesn't support the OCR-B font, then you can use the simple cairo text interface to output the necessary glyphs. So in summary: 1. Yes 2. Since paps only supports a single font (in contrast to pags which uses pango markup) you would have to do weird things like defining virtual fontconfig files to include your OCR font. Absolutely not worth it, imo. 3. Yes, together with cairo and pangocairo. Regards, Dov On Thu, Sep 15, 2011 at 15:23, Matthias Apitz <gu...@un...> wrote: > > Hello, > > The background of my interest in paps (or pango) is that I'm working for > a provider of IT solutions for libraries (catalogue, circulation and so, > all IT stuff a library of a university needs, to not go into further > marketing :-)). We moved with our recent version from ISO 8859-1 data to > UTF-8 and all data of the library about users, books, ... is now stored > in the database in UTF-8, including CJK data. > The system is UNIX based and has of course printouts for > orders, letters, etc., and in all the languages in which are data is > stored in the database. This as background only. > > My questions: > > 1. It seems that paps is not developed further, the last modifications > in the sources are from 2006; is this true? > > 2. We need to combine the rendering of UTF-8 to Postscript (as possible > with paps) together with printing some chars in OCR-B font; at the moment > we are doing this without paps, by embedding FreeFonts and OCR-B font and > writing the Postscript with some Perl engine. The problem with this is > that FreeFoont have no CJK support. Is there some way to > handle OCR-B font with paps as well? > > 3. And last question: should we skip paps and use pango directly? > > Thanks for your time reading all this > > Regards > > matthias > -- > Matthias Apitz > t +49-89-61308 351 - f +49-89-61308 399 - m +49-170-4527211 > e <gu...@un...> - w http://www.unixarea.de/ > > > ------------------------------------------------------------------------------ > Doing More with Less: The Next Generation Virtual Desktop > What are the key obstacles that have prevented many mid-market businesses > from deploying virtual desktops? How do next-generation virtual desktops > provide companies an easier-to-deploy, easier-to-manage and more affordable > virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/ > _______________________________________________ > Paps-discuss mailing list > Pap...@li... > https://lists.sourceforge.net/lists/listinfo/paps-discuss > |
From: Matthias A. <gu...@un...> - 2011-09-18 14:47:43
|
El día Friday, September 16, 2011 a las 10:13:52AM +0300, Dov Grobgeld escribió: > Hi Matthias, > > Paps was indeed written some time ago, and since it was written the graphics > library cairo has integrated with pango and had it been written today it > would have been written that way. A rewrite of paps using cairo is really > overdue. > > For your solution I certainly suggest using cairo + pango in whatever > language these have bindings for. A solution similar to your problem can be > seen in the following example on the vala tutorial page: > > http://live.gnome.org/Vala/PangoCairoSample > > That example outputs png files, but you can easily change it to outputting > postscript. > .... Hi Dov, First of all, thanks for your reply. Do you have some pointer to a tutorial "Pango for C" for me? I found the cairo documentation, its FAQ and samples which are quite enough to start with. But for pango I only see the Pango Reference Manual. Using the FAQ of cairo I am already able to write your text of the file small-hello.utf8 to a png file, but this is certainly not enough, and the Pange Reference does not give much explanations :-( Thanks in advance matthias -- Matthias Apitz t +49-89-61308 351 - f +49-89-61308 399 - m +49-170-4527211 e <gu...@un...> - w http://www.unixarea.de/ |
From: Dov G. <dov...@gm...> - 2011-09-19 07:57:02
|
I'm afraid that I know of no such tutorial, but for what you want to achieve I think that the link that I sent you should be sufficient. Basically you want to create a pango layout in whatever font and size, and then paste it in your cairo surface. Why isn't your small-hello.utf8 example enough for you? What are you missing? Postscript output? Create a cairo postscript surface instead of an image surface. OCR-B font? Depending on your encoding you may find it sufficient and easier to use the cairo text interface instead: http://cairographics.org/manual/cairo-text.html Feel free to ask if you have more questions. Regards, Dov On Sun, Sep 18, 2011 at 17:47, Matthias Apitz <gu...@un...> wrote: > El día Friday, September 16, 2011 a las 10:13:52AM +0300, Dov Grobgeld > escribió: > > > Hi Matthias, > > > > Paps was indeed written some time ago, and since it was written the > graphics > > library cairo has integrated with pango and had it been written today it > > would have been written that way. A rewrite of paps using cairo is really > > overdue. > > > > For your solution I certainly suggest using cairo + pango in whatever > > language these have bindings for. A solution similar to your problem can > be > > seen in the following example on the vala tutorial page: > > > > http://live.gnome.org/Vala/PangoCairoSample > > > > That example outputs png files, but you can easily change it to > outputting > > postscript. > > .... > > Hi Dov, > > First of all, thanks for your reply. > > Do you have some pointer to a tutorial "Pango for C" for me? > I found the cairo documentation, its FAQ and samples which are quite > enough to start with. But for pango I only see the Pango Reference > Manual. > > Using the FAQ of cairo I am already able to write your text of the file > small-hello.utf8 to a png file, but this is certainly not enough, and > the Pange Reference does not give much explanations :-( > > Thanks in advance > > matthias > -- > Matthias Apitz > t +49-89-61308 351 - f +49-89-61308 399 - m +49-170-4527211 > e <gu...@un...> - w http://www.unixarea.de/ > |
From: Dov G. <dov...@gm...> - 2011-09-19 11:50:41
|
Hi Matthias, You are making two mistakes: 1. You don't call cairo_move_to() before drawing the text. This causes cairo to move its point to the first position after the bounding box of the strign. 2. You use cairo_translate() without using surrounding cairo_save() and cairo_restore() to preserve the global translation matrix. To fix this you can change your code to: void rendertext(cairo_t *cr, char *text, float line) { PangoLayout *layout; PangoFontDescription *desc; layout = pango_cairo_create_layout(cr); pango_layout_set_markup(layout, text, -1); desc = pango_font_description_from_string("Monospace 16"); pango_layout_set_font_description(layout, desc); pango_font_description_free(desc); cairo_set_source_rgb(cr, 0.0, 0.0, 1.0); pango_cairo_update_layout(cr, layout); cairo_move_to(cr, 0,line); pango_cairo_show_layout(cr, layout); } Regards, Dov On Mon, Sep 19, 2011 at 14:31, Matthias Apitz <gu...@un...> wrote: > > Hello Dov, > > Thanks for your helping hand; > > El día Monday, September 19, 2011 a las 10:56:55AM +0300, Dov Grobgeld > escribió: > > > I'm afraid that I know of no such tutorial, but for what you want to > achieve > > I think that the link that I sent you should be sufficient. Basically you > > want to create a pango layout in whatever font and size, and then paste > it > > in your cairo surface. Why isn't your small-hello.utf8 example enough for > > you? > > I have put together all I have learned from places I found w/ Google and > I am now able to render some text, even with markup; but the positioning > with cairo_translate() does not work as I expect (see the attachment of > example1.c and its output out.png); I'm trying to print lines of UTF-8 > text (because this is mostly what I need for this printing). The text > and bold/italic comes out fine, but with some stairs-effect. Not only > stairs, but as well the distance between the lines is growing. Any idea > what I do wrong? > > > What are you missing? Postscript output? Create a cairo postscript > > surface instead of an image surface. > > Yes, I saw this in some tutorial and will use this later, once I can > solve the above problem. > > > OCR-B font? Depending on your encoding > > you may find it sufficient and easier to use the cairo text interface > > instead: > > > > http://cairographics.org/manual/cairo-text.html > > Thanks for the pointer concerning OCR-B. > > > Feel free to ask if you have more questions. > > Thanks > > matthias > > -- > Matthias Apitz > t +49-89-61308 351 - f +49-89-61308 399 - m +49-170-4527211 > e <gu...@un...> - w http://www.unixarea.de/ > |
From: Matthias A. <gu...@un...> - 2011-09-19 12:23:35
|
El día Monday, September 19, 2011 a las 02:50:29PM +0300, Dov Grobgeld escribió: > Hi Matthias, > > You are making two mistakes: > > > 1. You don't call cairo_move_to() before drawing the text. This causes > cairo to move its point to the first position after the bounding box of the > strign. > 2. You use cairo_translate() without using surrounding cairo_save() and > cairo_restore() to preserve the global translation matrix. Hi Dov, I did the mistake because I started from a tutorial sample code in http://x11.gp2x.de/personal/google/ the example1.c there used cairo_translate() only and without cairo_save() and cairo_restore(); thanks for the tip; with your code it works now as I expect; one question: your code does not have anymore g_object_unref(layout); at the end of rendertext(), why? I will move over to next step: Postscript; Thanks matthias -- Matthias Apitz t +49-89-61308 351 - f +49-89-61308 399 - m +49-170-4527211 e <gu...@un...> - w http://www.unixarea.de/ |
From: Dov G. <dov...@gm...> - 2011-09-19 12:31:57
|
Regarding g_object_unref(), my mistake. I guess my fingers were too trigger happy. Great that it works. Good luck! Dov On Mon, Sep 19, 2011 at 15:23, Matthias Apitz <gu...@un...> wrote: > El día Monday, September 19, 2011 a las 02:50:29PM +0300, Dov Grobgeld > escribió: > > > Hi Matthias, > > > > You are making two mistakes: > > > > > > 1. You don't call cairo_move_to() before drawing the text. This causes > > cairo to move its point to the first position after the bounding box > of the > > strign. > > 2. You use cairo_translate() without using surrounding cairo_save() > and > > cairo_restore() to preserve the global translation matrix. > > Hi Dov, > > I did the mistake because I started from a tutorial sample code in > http://x11.gp2x.de/personal/google/ > the example1.c there used cairo_translate() only and without > cairo_save() and cairo_restore(); > > thanks for the tip; with your code it works now as I expect; one > question: your code does not have anymore > > g_object_unref(layout); > > at the end of rendertext(), why? > > I will move over to next step: Postscript; > Thanks > > matthias > -- > Matthias Apitz > t +49-89-61308 351 - f +49-89-61308 399 - m +49-170-4527211 > e <gu...@un...> - w http://www.unixarea.de/ > |
From: Matthias A. <gu...@un...> - 2011-09-19 13:07:02
Attachments:
postscript.c
|
El día Monday, September 19, 2011 a las 03:31:47PM +0300, Dov Grobgeld escribió: > Regarding g_object_unref(), my mistake. I guess my fingers were too trigger > happy. Great that it works. > > Good luck! > Dov > I need another small hint now, concerning Postscript; my code works a bit, but only print Prolog etc., no real page. Perhaps I do again something stupid wrong with what I have found in the manuals. Thanks in advance matthias -- Matthias Apitz t +49-89-61308 351 - f +49-89-61308 399 - m +49-170-4527211 e <gu...@un...> - w http://www.unixarea.de/ |
From: Dov G. <dov...@gm...> - 2011-09-21 13:36:06
|
I realized that I must have misunderstood you. I misread OCR font as a Barcode font (yes, my mistake) and thought that it must have some strange encoding. But since it appears that it is a standard font and you have copied it to the standard plaace, you may much easier use it through: <span font="OCR-B 12">ABC 123</span> Use fc-list to get the font-config name of the font, which is used by cairo as well. Regarding the baseline position of text through pango, you should look at the following example: http://live.gnome.org/PangoLayoutLineBbox But again, by using ORC-B from within Pango, I don't think that you need it. Regards, Dov On Wed, Sep 21, 2011 at 16:24, Matthias Apitz <gu...@un...> wrote: > El día Monday, September 19, 2011 a las 01:31:24PM +0200, Matthias Apitz > escribió: > > > > OCR-B font? Depending on your encoding > > > you may find it sufficient and easier to use the cairo text interface > > > instead: > > > > > > http://cairographics.org/manual/cairo-text.html > > > > Thanks for the pointer concerning OCR-B. > > Hello Dov, > > I have expanded my small test pgm postscript.c to use the font OCRB.pfb > (which is in ~/.fonts/ dir) from Cairo; see the function renderocrb(); > and the PostScript output is attached as well; > > one (maybe last) question: it would be good if I could put the two > different > fonts, i.e. the "normal" font for the CJK/UTF-8 text and the OCR-B > string, on the same line; but as far as I understand how > pango_layout_set_markup() works, this is not possible; > > any idea how to solve this? > > Thanks > > matthias > -- > Matthias Apitz > t +49-89-61308 351 - f +49-89-61308 399 - m +49-170-4527211 > e <gu...@un...> - w http://www.unixarea.de/ > |
From: Matthias A. <gu...@un...> - 2011-09-29 08:44:19
|
El día Wednesday, September 21, 2011 a las 04:36:00PM +0300, Dov Grobgeld escribió: > I realized that I must have misunderstood you. I misread OCR font as a > Barcode font (yes, my mistake) and thought that it must have some strange > encoding. But since it appears that it is a standard font and you have > copied it to the standard plaace, you may much easier use it through: > > <span font="OCR-B 12">ABC 123</span> Thanks, this works as it should. Now, because you say "Barcode font", and since I see how pango+cairo can paint something to Postscript, another project waiting for a good solution comes into my mind... Are there any Barcode fonts that I should integrate (by placing them into the ~/.fonts dir) and I could use from cairo? Thanks for a pointer matthias -- Matthias Apitz t +49-89-61308 351 - f +49-89-61308 399 - m +49-170-4527211 e <gu...@un...> - w http://www.unixarea.de/ |