caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Basic typesetting
@ 2007-10-28 14:14 Matthieu Dubuget
  2007-10-28 17:13 ` [Caml-list] " Oliver Bandel
  0 siblings, 1 reply; 7+ messages in thread
From: Matthieu Dubuget @ 2007-10-28 14:14 UTC (permalink / raw)
  To: caml-list

Hello,

I just tried CamlPDF, which is very nice for what I want to do:
just export one simple page of text into pdf.

For this kind of simple thing, I'd really like to get rid of the big, slow,
and difficult to install fop.

But in order to put text objects on page at the right place, I would
like to compute
their size. Is there any standard way to compute it?

Salutations

Matt


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Basic typesetting
  2007-10-28 14:14 Basic typesetting Matthieu Dubuget
@ 2007-10-28 17:13 ` Oliver Bandel
  2007-10-28 20:28   ` Matthieu Dubuget
  0 siblings, 1 reply; 7+ messages in thread
From: Oliver Bandel @ 2007-10-28 17:13 UTC (permalink / raw)
  To: caml-list

Zitat von Matthieu Dubuget <matthieu.dubuget@gmail.com>:

> Hello,
>
> I just tried CamlPDF, which is very nice for what I want to do:
> just export one simple page of text into pdf.
[...]

Oh, I didn't heard of CamlPDF before.
If I found the correct page, then it is a pre-release.
But there is no date on the page, so I don't know if it's up to date.


>
> For this kind of simple thing, I'd really like to get rid of the big, slow,
> and difficult to install fop.

fop?


>
> But in order to put text objects on page at the right place, I would
> like to compute
> their size. Is there any standard way to compute it?

Postscript has a pathbbox-operator, which gives you back
the bounding box of the current path; PDF seems not to have
such an operator. At least I could not find an aequivalent thing
in the last minutes, where I browsed through the PDF-Reference Manual.

So, possibly one has to calculate the size by itself?!
(So, if CamlPDF does not provide it, I see no solution to that problem
right now.)

Ciao,
   Oliver


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Basic typesetting
  2007-10-28 17:13 ` [Caml-list] " Oliver Bandel
@ 2007-10-28 20:28   ` Matthieu Dubuget
  2007-10-28 21:42     ` michael.le_barbier
  0 siblings, 1 reply; 7+ messages in thread
From: Matthieu Dubuget @ 2007-10-28 20:28 UTC (permalink / raw)
  To: Oliver Bandel; +Cc: caml-list


Oliver Bandel a écrit :
> Zitat von Matthieu Dubuget <matthieu.dubuget@gmail.com>:
>
>> Hello,
>>
>> I just tried CamlPDF, which is very nice for what I want to do:
>> just export one simple page of text into pdf.
> [...]
>
> Oh, I didn't heard of CamlPDF before.
> If I found the correct page, then it is a pre-release.
> But there is no date on the page, so I don't know if it's up to date.


Well, it was announced some time ago on the list by John Whitington,
from http://www.coherentgraphics.co.uk/. In recent announce, he also
wrote:

>> A new version of CamlPDF will be released soon, reflecting the updated
>> facilities used  by the commercial tools.


>
>
>> For this kind of simple thing, I'd really like to get rid of the big,
slow,
>> and difficult to install fop.
>
> fop?

Copied from FOP web page:
Apache FOP (Formatting Objects Processor) is a print formatter driven by
XSL formatting objects (XSL-FO) and an output independent formatter. It
is a Java application that reads a formatting object (FO) tree and
renders the resulting pages to a specified output. Output formats
currently supported include PDF, PS, PCL, AFP, XML (area tree
representation), Print, AWT and PNG, and to a lesser extent, RTF and
TXT. The primary output target is PDF.

That's the way my little software works. It generates an .fo file and
transforms it by calling fop through Sys.command. A little heavy for
one simple page...

I also could have produced one PostScript version before a pstopdf call.
But direct .pdf production is something I want to learn ;-)

>
>
>> But in order to put text objects on page at the right place, I would
>> like to compute
>> their size. Is there any standard way to compute it?
>
> Postscript has a pathbbox-operator, which gives you back
> the bounding box of the current path; PDF seems not to have
> such an operator. At least I could not find an aequivalent thing
> in the last minutes, where I browsed through the PDF-Reference Manual.
>
> So, possibly one has to calculate the size by itself?!
> (So, if CamlPDF does not provide it, I see no solution to that problem
> right now.)

Thanks Oliver.

I will certainly have to parse AFM files in order to find font metrics
and use them in order to compute the dimensions I need, then...

>
> Ciao,
>    Oliver

Guten Abend


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Basic typesetting
  2007-10-28 20:28   ` Matthieu Dubuget
@ 2007-10-28 21:42     ` michael.le_barbier
  2007-10-29  8:52       ` Oliver Bandel
  0 siblings, 1 reply; 7+ messages in thread
From: michael.le_barbier @ 2007-10-28 21:42 UTC (permalink / raw)
  To: matthieu.dubuget; +Cc: Oliver Bandel, caml-list

Matthieu Dubuget <matthieu.dubuget@gmail.com> writes:
> I will certainly have to parse AFM files in order to find font metrics
> and use them in order to compute the dimensions I need, then...

If you try to compute a ``text object size'' from font metrics the
naive way, you will get a coarse approximation of the true
result.

By computing sizes the naive way, you will not take ``kerning pairs''
neither ``ligatures'' in account.

When typesetting `WA' `TA', etc. it is customary to move the `A' on
the left. You can see this if you use your preferred typesetting tool
(I mean TeX) to process two paragraphs, the first one consisting of
`WA' the second one consisting `EA'. Depending on the font setup, you
can observe that the first `A' starts ``before'' the second. The pairs
`WA' etc. are called kerning pairs.

When typesetting ``terrific'' the `fi' pair is usually replaced by a
single symbol, this symbol is a (decorative) ligature.

So if you use a typesetting engine as a backend to typeset text, you
have three ways to know the size of an object:
  1. ask the engine;
  2. examine the engine's output;
  3. reimplement the engine's algorithms.
You do not seriously consider 3. as an option, do you?
-- 
Gute Nacht
Michaël LB


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Basic typesetting
  2007-10-28 21:42     ` michael.le_barbier
@ 2007-10-29  8:52       ` Oliver Bandel
  2007-10-30 15:43         ` Matthieu Dubuget
  0 siblings, 1 reply; 7+ messages in thread
From: Oliver Bandel @ 2007-10-29  8:52 UTC (permalink / raw)
  To: caml-list

Zitat von michael.le_barbier@laposte.net:
[...]
> So if you use a typesetting engine as a backend to typeset text, you
> have three ways to know the size of an object:
>   1. ask the engine;
>   2. examine the engine's output;
>   3. reimplement the engine's algorithms.
> You do not seriously consider 3. as an option, do you?
[...]

One can ask Ghostscript (gs) for the bounding box.

I think it was something like

$ gs -sDEVICE=bbox mypsfile.ps

and this should also work with pdf-files.

But then you get the bounding-box of the whole file.
So you have to use this way for each construct of
your page, what IMHO makes no sense.

But if you need this only occasionally, it might make sense.

I don't know the "fop" that was mentioned, but I
gs is about 5 MB big executable, and it's an interpreter.
But it's not written in Java, maybe it's faster and lighter
than the "fop" ;-)

Ciao,
   Oliver

P.S.: Or make a server as a wrapper around gs, so you do
      not have to restart it again and again ;-)
      But as far as I know, some TeX-Implementations are
      in work, that are running as a formatting-daemon.
      So, this might be also a way to make efficient typesetting.
      But if it's only for one single page, using gs by hand,
      invoked from the shell might be ok ;-)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Basic typesetting
  2007-10-29  8:52       ` Oliver Bandel
@ 2007-10-30 15:43         ` Matthieu Dubuget
  2007-10-30 17:43           ` Jon Harrop
  0 siblings, 1 reply; 7+ messages in thread
From: Matthieu Dubuget @ 2007-10-30 15:43 UTC (permalink / raw)
  To: caml-list

I found a way: the FreeType library should be enough to compute text sizes.
And even better, there is already one binding is Camlimages!

Salutations

Matt


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Basic typesetting
  2007-10-30 15:43         ` Matthieu Dubuget
@ 2007-10-30 17:43           ` Jon Harrop
  0 siblings, 0 replies; 7+ messages in thread
From: Jon Harrop @ 2007-10-30 17:43 UTC (permalink / raw)
  To: caml-list

On Tuesday 30 October 2007 15:43, Matthieu Dubuget wrote:
> I found a way: the FreeType library should be enough to compute text sizes.
> And even better, there is already one binding is Camlimages!

I haven't checked recently but it used to not support FreeType's kerning. A 
friend of mine wrote a patch to add support if you're interested...

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/products/?e


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-10-30 21:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-28 14:14 Basic typesetting Matthieu Dubuget
2007-10-28 17:13 ` [Caml-list] " Oliver Bandel
2007-10-28 20:28   ` Matthieu Dubuget
2007-10-28 21:42     ` michael.le_barbier
2007-10-29  8:52       ` Oliver Bandel
2007-10-30 15:43         ` Matthieu Dubuget
2007-10-30 17:43           ` Jon Harrop

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).