Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #3044

Re: How to get glyph metric info of CID-keyed font?

From ken <ken@spamcop.net>
Newsgroups comp.lang.postscript
Subject Re: How to get glyph metric info of CID-keyed font?
Date 2017-04-10 08:13 +0100
Message-ID <MPG.33554113eb971902989917@usenet.plus.net> (permalink)
References <occp90$tl6$1@dont-email.me>

Show all headers | View raw


In article <occp90$tl6$1@dont-email.me>, jszhao@yeah.net says...
> 
> Hi there,
> 
> I am using R (www.r-project.org) to plot statistical figure. I prefer to 
> use postscript device. Instead of Type1 fonts, I hope to use Truetype or 
> Opentype fonts in my figure,

You cannot directly use TrueType fonts or OpenType fonts with a 
PostScript interpreter, because PostScript deos not support either 
TrueType or OpenType.

Language Level 3 PostScript interpreters can use both type 42 (which are 
TrueType fonts 'bundled up' in a way which PostScript interpreters can 
understand) and CFF font outlines. Earlier language levels did not 
support CFF and may not support type, support for CFF was added with 
level 3, and support for type 42 was introduced as a supplement to the 
original level 2 sepcification. CIDFonts were also added (in version 
2015 as I recall) during the lifetime of language level 2.

Note (1) that for OpenType fonts, you would need to check the outline 
type of the font and then supply either a Type 42 (TrueType) font or a 
CFF font, in each case extracting the relevant data from the font.

Note (2) Ghostscript *can* make use directly of both TrueType and 
OpenType fonts as substitutes for missing fonts. However this involves 
the interpreter 'guessing' at certain information which would normally 
be presented unambiguously in the tytpe 42 font. So sometimes it will 
get it wrong.


> that means I have to use CIDFont function. 

Nope. Type 42 fonts are not CIDFonts. A CIDFont may have a number of 
different kinds of outlines, including type 42 outlines, but its 
entirely possible to have a type 42 font which is not a CIDFont.

The same is also true for CFF outlines (OpenType fonts may have CFF 
outline data, instead of TrueType.


> I read the help page of CIDFont function which state that the CID-keyed 
> font are intended only for use for the glyphs of East Asian languages 
> that are all treated as filling the same bounding box.

No, sorry, that's not really true either. It is the case that the 
original impetus for development of CIDFonts was the complexity of the 
written forms of Asian languages, but nowadays CIDFonts are used 
extensively for all languages.


> In the source 
> code of ``devPS.c'', the ascent, descent and width of glyph is assumed, 
> and not calculated based on actual font. In fact, I think, R can't get 
> the exact metric info for the glyph in CID-keyed font, and can't typeset 
> correctly or beautifully. It seems that R can't find or access to the 
> actual font. After output to a postscript file, Ghostscript with 
> correctly configuration can render the figure correctly.
> 
> My question is how to get glyph metric info of CID-keyed font in C code 
> directly or by call Ghostscript?

You can interpret the font. There is no equivalent of the '.pfm' files 
that were once supplied with Type 1 fonts and contained the metrics of 
the glyphs.

Ghostscript, like any font rendering engine, *must* interpret the font 
in order to render it. The font (whether TrueType or CFF outlines) will 
contain its own set of metrics which cover all the glyphs in the font, 
each glyph will additionally contain information such as the BoundingBox 
(or hsbw, Horizontal Side Bearing and Width) information in the glyph 
description.

Ghostscript (mostly) uses FreeType for its font rendering, I would think 
that the simplest approach for you would be to do the same.

I'm afraid I can't offer you any help with R, I know nothing about it.

				Ken

Back to comp.lang.postscript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

How to get glyph metric info of CID-keyed font? Jinsong Zhao <jszhao@yeah.net> - 2017-04-09 15:56 +0800
  Re: How to get glyph metric info of CID-keyed font? ken <ken@spamcop.net> - 2017-04-10 08:13 +0100
    Re: How to get glyph metric info of CID-keyed font? Jinsong Zhao <jszhao@yeah.net> - 2017-04-18 11:32 +0800

csiph-web