Remove certain AFM tags

Here we remove lines from the AFM file based on a set of regular expressions.  At present we remove only "^Character" as this is the AFM tag that causes ugly warnings when used by R.  Others may be added in the future as needed.

Note that gzcopy_exclude() uses text mode to read and write the files so it can do the matching--the old gzcopy() used binary.  I have not run into a problem with this on my linux workstation but we may want to test under windows to make sure there are no gotchas.  Also in gzcopy_exclude() we use useBytes=TRUE in the grepl() call in order to avoid the warnings this generates any time a non-ascii character appears.  We might think about changing all grepl() calls to work this way at some point.
No problem.  Actually I never saw any reason for a file size limitation in
the first place.

There are a number of warnings an errors that come up as I use this
package.  I may chime back in with some other ideas for you to consider in
the future.

Grant



On Wed, Jul 23, 2014 at 4:57 PM, Winston Chang <notifications@github.com>
wrote:

> In R/utils.r:
>
> > @@ -85,3 +85,33 @@ gzcopy <- function(src, dest = NULL, delete = FALSE) {
> >
> >    if (delete)  unlink(src)
> >  }
> > +
> > +# gzip a file, excluding certain lines
> > +#
> > +# @param src Source filename.
> > +# @param dest Destination filename. Defaults to source filename with .gz
> > +# @param delete Delete the source file when done?
> > +# Currently the maximum file size is 100MB
> > +gzcopy_exclude <- function(src, dest = NULL, delete = FALSE,
> > +                           exclusions = NULL) {
> > +  # read in text mode so we can parse
> > +  srcfile <- file(src, "r")
> > +  srcdat <- readLines(srcfile, n = 1e8)
>
> I just realized that n is the number of lines to read, not bytes as it is
> with readBin. Can you remove n here and remove the comment above about
> file size?
>
> Ideally, it would be good to set the file size limit to 100MB, but I don't
> think that's easily done with readLines.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/wch/extrafont/pull/38/files#r15315360>.
>