How to Adjust Font Size of a ggplot in inkscape? - r

When I export ggplots from R (with ggsave in svg) to modify them in inkscape, I run into the following problem:
I use the text tool to select some text (axis labels for example). If I want to increase font size in the drop down menu, inkscape only increases the height of the text, width stays the same. I am left with text with the wrong aspect ratio.
This must be due to some type conversion (text to object for example) that is done at some point (ggplot, ggsave or inkscape). Until now I have been unable to figure out how to solve this. So far, I have reverted to deleting the existing text and creating new text in inkscape (adjusting font size works totally normally then)
Code to create input for Inkscape:
tdf <- data.frame()
tpl <- ggplot(tdf) + xlab("testtext")
ggsave(filename="tpl.svg",plot=tpl,height=5,width=8,device="svg")

It appears svglite introduces a textLength parameter which hard-codes the width. Interstingly, Illustrator seems to not care about this when editing the file, but Inkscape does.
You could try another device, svg may not be a great choice as it appears to split words into individual letters, but gridSVG::gridsvg seems to works. Or use a pdf device, which Inkscape can also import.

Related

How do I export a ggplot as resizable image?

I'm working on a report with some coworkers in Google Docs (which will eventually be printed). We want to include some plots generated with ggplot. As we edit the document, the space for the images keeps changing slightly--often, we need to resize and/or change the aspect ratio of a plot slightly so that it fits on the page with the accompanying text.
Is there a way to export a ggplot object to an image that is resizable in the same way that plots can be resized in the Export dialog in RStudio?
Google Docs does not support SVG images--dropping an svg on the page simply opens the SVG itself (rather than adding it to the doc), so that's not an option.

Need a tool to automatically scale text size in textbox

I need to find a feature or tool that allows me to programmatically create a file in which I will have a sized textbox with text that automatically scales to fit its dimensions and still be visible.
Here is an example of what it would do:
On the left side, an already sized textbox has some text. The text is too long so it goes "out" the textbox, therefore the tool would "scale" it to a size that makes it visible only in the textbox, and not outside. It could scale by changing font size, or "zoom" in any way.
I tried looking at OpenOffice Writer & Impress, Microsoft Word & Powerpoint, with no success. It seems really difficult with CSS according to the resources I could find.
Some resources I found (like Fitty, which is in Javascript. Not what I need, but still possible) will scale it in other manners that do not correspond my needs because they keep the text on one line, and I need them multiline...
See some wrong examples:
Does anyone know any tool that would have such feature?

Pandoc and Word export: Change DPI of images

I want images in my Pandoc exported Word docx files to be scaled a little.
By default, an image can be around 640px of width at 72dpi so it is exported by Pandoc to the full width of my reference docx (which means: it isn't scaled down by Pandoc to make it fit the space).
I'd like all my images to look a little bit crispier when printing the document (or zooming on screen). I'd like all of them to be scaled down visually by 1/4th or 1/3th (staying at the same resolution).
I played around with --dpi option of Pandoc and set it to 300 (by default it's 96), which didn't have an effect on the size of the images.
I also tried to set the dpi of my images using Photoshop, which simply resulted in bigger images, but they were also displayed bigger when exported using Pandoc (regardless of the --dpi option).
The only way which had the desired effect was to set an explicit width in Markdown:
![my image](image.jpg){ width=2cm }
But this needs a lot of calculation on my side to get the desired value, because using { width=50% } makes the image have half of the width of the surrounding container. Not what I need.
I think I misunderstand something general about this topic. Maybe somebody can explain me a bit.

How do I resize a flat vector icon so that it preserves hard edges?

I recently purchased Drew Wilson's Pictos icon library. It is a library of flat, monochromatic icons for use on the web and elsewhere. The only issue is: they're vectors. I know my way around Illustrator a little bit, but ultimately I want to import these icons into Photoshop CS4 and resize to various dimensions.
When I import an icon and resize it to, say, 20x20 pixels, I notice that there is a fair bit of aliasing around the edges of the icon. I'm sure there is some magic number where the edges of these icons will remain crisp, but I can't find any option or setting that will allow me to size these icons properly.
How can I snap these icons to the closest size that removes or minimizes the aliasing?
The aliasing / pixelating is because vectors export out of illustator # whatever size they're copied #
Try opening the icons in illustrator... scaling them waaay up
And then just keep a copy of the huge ones in a separate layer
Copy that layer when you want to scale it down ..annnd that way you'll have a copy to work with..and u won't have to re
Open the file every time u need to make an edit
And a good rule of thumb for pixelation is
You can always size down.. but sizing up will create pixelating in bitmaps
Chances are, you have your logo in .eps format. If you do, open your .eps file in Photoshop. A dialog box will pop up asking the size you want to import. Be sure to select RGB color if this will display on the web. Select the Anti-aliasing checkbox. When your file opens up, zoom in, and you'll notice that Photoshop has neatly anti-aliased all of your edges for you.

Large serifs in a font cause flash to measure size incorrectly

I have a textarea where I measure the textWidth and textHeight to make sure the user cannot enter more text than can fit in the text area. I also extended the textArea with a textHeightNow and textWidthNow that measure the textField's dimensions since they update w/out requiring validation. Now this works great for 90% of the embedded fonts I'm using but any fonts that have giant serifs are not measured properly, for instance look at the 'f's in this text area:
alt text http://img.skitch.com/20091101-xhm5jguma1qgukg6fxrymrwr3u.jpg
You can see they get cut off on both sides because textWidth and textWidthNow both return an incorrect size not taking into account the massive serifs. The font size, coords and dimensions of the text area are all integers so thats not the problem, any other suggestions? I looked to see if textArea has a clipContent argument but it doesn't (that would have been nice).
Thanks
I've run into this problem before and as far as I can tell you have two options, none of them very nice:
Use the new flash.text.engine in
Flash Player 10... its very hard to use but
I think it will measure such fonts
(and ligatures) properly.
Draw the textfield into a bitmapdata
and use getColorBoundsRect to
determine its real dimensions.
I ended up using the latter as changing the whole app to the new engine would have been much much harder. You will need to tweak margins and use a larger textfield (inside some container) to be able to draw it properly, but it should work.

Resources