[R] Truetype and Opentype font in pdf device

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Jan 18 19:53:12 CET 2011


On Wed, 19 Jan 2011, Kohske Takahashi wrote:

> Thanks for the reply.
>
> I got that there is no general way to generate PDF with ttf or otf
> fonts. Thanks, it's enough.
>
> Also, cario_pdf is useful (I'm using OSX).
> But I found it cannot correctly(?) work with CJK.

The Mac OS X (why do Mac users not know the name of their OS?) 
implementation of cairographics is rather limited, because of font 
issues.

CJK works fine (I am told by Chinese and Japanese users) with 
cairographics on other OSes.

> I will play with them some more.
>
> Thanks again.
>
> --
> Kohske Takahashi <takahashi.kohske at gmail.com>
>
> Research Center for Advanced Science and Technology,
> The University of  Tokyo, Japan.
> http://www.fennel.rcast.u-tokyo.ac.jp/profilee_ktakahashi.html
>
>
>
> On Mon, Jan 17, 2011 at 6:32 PM, Prof Brian Ripley
> <ripley at stats.ox.ac.uk> wrote:
>> On Sat, 15 Jan 2011, Kohske Takahashi wrote:
>>
>>> Deal all,
>>>
>>> I want to know if truetype or opentype fonts are available in pdf
>>> device (i.e., pdf() or dev.copy2pdf()), and if so, how to do it?
>>
>> They are not in general available in PDF, the language.  The cairo-based
>> device embed individual glyph information from such fonts (perhaps as
>> vectors and perhaps as bitmaps).
>>
>>> Now I can do as followings:
>>>
>>> 1. convert ttf to afm using ttf2afm, e.g.: $ ttf2afm Impact.ttf >
>>> Impact.afm
>>> 2. put the afm file in $R_HOME/library/grDevices/afm
>>> 3. register a new type1 font: pdfFonts(Impact=Type1Font("Impact",
>>> rep("Impact.afm", 4), encoding = "TeXtext.enc"))
>>> 4. specify the fontfamily in gpar: grid.text('hello grid world',
>>> gp=gpar(fontfamily="Impact"))
>>>
>>> but obviously, it is better if truetype or opentype fonts are directly
>>> available without conversion to type1 font.
>>
>> But you would still need to make the font available to your PDF
>> viewer/printer, and in general that does need coversion (to a font type
>> supported in PDF or to bitmaps/vectors).
>>
>>> Also, I found that Cairo package can handle truetype or opnetype font.
>>> However, the package seems not to support fontfamily, hence I cannot
>>> use it through gpar.
>>
>> Have you not considered the built-in and fully featured cairo_pdf device?
>>  (Not Windows, but you didn't tell us your OS.)
>>
>>> Does anyone know about this topic?
>>>
>>> Thank you in advance.
>>>
>>> --
>>> Kohske Takahashi <takahashi.kohske at gmail.com>
>>>
>>> Research Center for Advanced Science and Technology,
>>> The University of  Tokyo, Japan.
>>> http://www.fennel.rcast.u-tokyo.ac.jp/profilee_ktakahashi.html
>>>
>>> ______________________________________________
>>> R-help at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>> --
>> Brian D. Ripley,                  ripley at stats.ox.ac.uk
>> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
>> University of Oxford,             Tel:  +44 1865 272861 (self)
>> 1 South Parks Road,                     +44 1865 272866 (PA)
>> Oxford OX1 3TG, UK                Fax:  +44 1865 272595
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


More information about the R-help mailing list