[Tikzdevice-bugs] metapost device: problem with calculating font space?

mat matthieu.stigler at gmail.com
Mon Apr 25 19:24:42 CEST 2011


Le 22. 04. 11 21:59, Charlie Sharpsteen a écrit :
> On Fri, Apr 22, 2011 at 3:48 AM, mat <matthieu.stigler at gmail.com 
> <mailto:matthieu.stigler at gmail.com>> wrote:
>
>     I'm however facing a very strange problem, that I do not
>     understand... It seems now that opening tikzDevice, there won't be
>     any search for the
>     compilers anymore, right? As consequence, the default options are
>     not set anymore, which will break the simplest tikz, see:
>
>     library(tikzDevice)
>     Loading required package: filehash
>     filehash: Simple key-value database (2.1-1 2010-10-04)
>     > getOption("tikzFooter")
>     NULL
>     > getOption("tikzDefaultEngine")
>     NULL
>     > library(tikzDevice)
>     > tikz("~/temp/go.tex")
>     Error in switch(engine, pdftex = { : EXPR must be a length 1 vector
>
>     (btw, is this line useful also for the metapost function?)
>
>
>     So I tried to open the session with setTikzDefaults()
>     which partly solves the problem, but I came to something more
>     critical:
>
>     Error in .External("metapDevice", file, width, height, bg, fg,
>     baseSize = pointsize,  :
>      C symbol name "metapDevice" not in DLL for package "tikzDevice"
>     Calls: metapost -> .External
>
>     which I do not understand....
>
>     Any idea? Thanks!!!
>
>     Matthieu
>
>
> Hmm, this is most strange. I cannot reproduce this behavior on my 
> machine.  I tried re-cloning the repository and reinstalling to see if 
> I was somehow using files that had not been published to GitHub.
>
> I would suggest double-checking that you are using the right version 
> of the code and that nothing else is getting mixed into the package 
> somehow:
>
>    cd path/to/RTikZDevice
>    git checkout experimental/metapost     # Checkout the metapost branch
>    # Make sure it matches what I posted on GitHub. This *will* destroy
>    # any local modifications, so stash them on another branch if you 
> want to keep them.
>    git reset --hard origin/experimental/metapost
>    git pull origin   # make sure the branch is up to date
>    make install
>
> If you are still getting problems after that, let me know which OS and 
> version of R you are using and I can try to reproduce the error.
>
> -Charlie
>
sorry, it's just a stupid error from me: I run usually R CMD INSTALL, 
and tried this instead of make install!!  Once this used (after however 
a few tricks changing chown and chmod on the R created files) it 
works!!! Indeed, plots are much better now, and space better organized, 
thanks!!!!!


I tried to adapt the metap function for my own needs (define a single 
spot colors and then its "childs") but got confused, as the script you 
wrote is quite complex!!! Idea is:
-define.metap.color should just define generic spot color, no real color 
will be associated to it. Would format just

\definecolor[PantoneBlue][c=1, m=0.58,y=0,k=0.29]

-define.metap.tint should define the real colors used, which are just 
tints (%) of the defined spot colors. Would defined just:

\definespotcolor[PantoneBlueSixtySpot][PantoneBlue][p=0.6,e=Pantone 294 C]


See: metap_tint <- function(color_name, color_ref, p=1) {
   # color_name: A name for the color. Should only contain letters.
   # color_ref: The spot color it is based on
   # p: the "tint" associated
   if ( grepl('[^a-zA-Z]', color_name) ) {
     stop("MetaPost color names cannot contain any characters other than 
ASCII letters!")
   }

   if(!color_ref%in%sapply(getOption('metapColors'), function(x) 
x$color_name)){
     stop("color_ref not defined!")
   } else {
     color_ref_detail <- 
getOption('metapColors')[sapply(getOption('metapColors'), function(x) 
x$color_name)==color_ref][[1]]
   }

   return(
     structure(
       list(color_name = color_name, color_ref=color_ref, spot_name = 
color_ref_detail$spot_name, p=p),
       class = 'metap_tint'
     )
   )

}


and its format counterpart:

format.metap_tint <- function(color, ...) {
   # Generates ConTeXt code for defining colors and spot colors.
    color_def <- c(
       "\n\\definespotcolor\n\t",
       paste("[", color$color_name, "]\n\t", sep = ''),
       paste("[", color$color_ref, "]\n\t", sep = ''),
       paste("[p=", color$p, ", e=", color$spot_name, "]\n\t", sep = 
'')#      sprintf("[p=1,e=%s]\n", color$spot_name)
     )

   return( color_def )
#  list(color_name = color_name, spot_name = color_ref_detail$spot_name, 
p=p),
#       class = 'metap_tint'
}


But then I got confused where each color should be defined and exported 
:-( Any clear idea on how I should proceed?

Thanks!!

Matthieu







More information about the Tikzdevice-bugs mailing list