Showing posts with label fonts. Show all posts
Showing posts with label fonts. Show all posts

gs (GhostScript) cheat sheet

Aug 28, 2012
Cheat-sheet for versatile interpreter GhostScript. It can be used to tweak, convert, produce high quality Postscript and PDF files.

Convert postscript (ps) to pdf:

gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=fileout.pdf filein.ps

Merge ps and/or pdf:

gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=fileout.pdf filein1.ps filein2.pdf filein3.pdf

Extract page(s) from a ps or a pdf document:

gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -dFirstPage=3 -dLastPage=3 -sOutputFile=fileout.pdf filein.ps

Embed fonts in a pdf:

gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=fileout.pdf -dPDFSETTINGS=/prepress -dEmbedAllFonts=true -dSubsetFonts=true -dCompatibilityLevel=1.6 filein.pdf

Convert images to pdf:

Check this post. Or else use ImageMagic's convert.

PDF optimization options

-dPDFSETTINGS=/screen (screen-view-only quality, 72 dpi images) -dPDFSETTINGS=/ebook (low quality, 150 dpi images) -dPDFSETTINGS=/printer (high quality, 300 dpi images) -dPDFSETTINGS=/prepress (high quality, color preserving, 300 dpi imgs) -dPDFSETTINGS=/default (almost identical to /screen)

Paper size options

-sPAPERSIZE=letter -sPAPERSIZE=a4 -dDEVICEWIDTHPOINTS=w -dDEVICEHEIGHTPOINTS=h (point=1/72 of an inch) -dFIXEDMEDIA (force paper size over the PostScript defined size) -gWIDTHxHEIGHT (page size in pixels)

Output devices:

-sDEVICE=pdfwrite -sDEVICE=ps2write -sDEVICE=png16m (24-bit RGB color) -sDEVICE=pnggray (grayscale) -sDEVICE=pngmono (black-and-white) -sDEVICE=pngalpha (32-bit RGBA color) -sDEVICE=jpeg (color JPEG) -sDEVICE=jpeggray (grayscale JPEG) -sDEVICE=epswrite (encapsulated postscript) -sDEVICE=txtwrite (text output, UTF-8) Check -sOutputFile below, for separate images for each page of a multi-page document. Tiff, PNM and many more formats are supported. Check details in Ghostscript output devices.

Help & list of available devices:

gs -h

Other options

-dNOPAUSE (no pause after page) -dBATCH (exit after last file) -sOutputFile=ABC-%03d.pgm (produces 'ABC-001.pgm'..'ABC-010.pgm'..) -dEmbedAllFonts=true -dSubsetFonts=true (Embeds only the characters used in document) -dCompatibilityLevel=1.4 (Adobe's PDF specifications, >=1.4 for font embedding, =1.6 for OpenType font embedding) -dCompressPages=true (compress page content) -dFirstPage=pagenumber -dLastPage=pagenumber -dAutoRotatePages=/PageByPage (or /All or /None) -rXRESxYRES (XRES & YRES in pixels/inch) -rRES (same XRES & YRES, affects images and fonts converted to bitmaps) -sPDFPassword=password More details & defaults on ps2pdf documentation.
Adobe® PDF Creation Settings - Used by GhostScript.
GhostScript Documentation.

Read more ...

Font & old emacs

Jul 11, 2011
Tested on: CentOS release 5.6 (Final)

The newer version of emacs (23.x) has a nice option in menu to change the default font. But the older emacs (21.4.1) does not have these options. The older (& stable) versions of emacs are generally shipped with centos. Here are steps for changing the default fonts in emacs 21.4.1

Option 1 (for current sessions only)
  1. Open emacs.
  2. Left-click on mouse while holding 'Shift' key on keyboard. A Font-menu will pop-up.
  3. Play around with the menu & set required font.

Option 2 (for all future sessions)
We have to find the available system fonts and apply them to ~/.emacs file.
  1. Open terminal & execute following command: xfontsel
  2. Left-click on 'fmly' & others to select a value. You will be able to see how the font looks like in the same window. When you are satisfied with the font selected press 'Select' button. It will copy the font name with details to clipboard. Following are some of the examples of the fonts: -*-courier-medium-r-*-*-17-*-*-*-*-*-iso8859-* -*-lucidatypewriter-medium-*-*-*-14-*-*-*-*-90-iso8859-* -*-luxi mono-medium-r-*-*-17-*-*-*-*-*-ascii-*
  3. Open ~/.emacs file in any text editor and add following at the end of the file: (set-default-font "-*-*-*-*-*-*-*-*-*-*-*-*-*-*") Replace -*-*-*-*-*-*-*-*-*-*-*-*-*-* by your selected font name (like one of the examples shown above) Save ~/.emacs & re-launch emacs. You should be able to see the difference.
  4. There might be some delay before text is displayed in emacs. Add following to top of the ~/.emacs file for a workaround: (modify-frame-parameters nil '((wait-for-wm . nil)))
Read more ...

Matlab Font(s) - Windows

Jan 14, 2011
I do not find Matlab default font to be soothing to eyes, specially the fonts in figure windows. See more about fonts here. So, here are the instructions to change the fonts in matlab. Make sure that you have installed the font of your choice.
  • For editor, main window, GUI
    Navigate to File->Preference. Select "Fonts" in the left panel. Then follow the instructions over there. You can also check the 'Custom' tab for advanced settings.
  • For figure window
    Add following lines to your startup.m. See next section for details. set(0,'DefaultAxesFontName','DejaVu Sans'); set(0,'DefaultAxesFontSize',10); set(0,'DefaultAxesFontWeight','Bold'); set(0,'DefaultTextFontName','DejaVu Sans'); set(0,'DefaultTextFontSize',10); set(0,'DefaultTextFontWeight','Bold'); Change the font-name & size according your choice. You can find a list of installed fonts by typing following command at matlab prompt. listfonts
startup.m
Each time matlab is started, it searches all the matlab path for this file. The most common place to keep this file is: C:\Users\<user-name>\Documents\MATLAB\ This is good place to put/over-ride settings. Create this file, if it is not present.

I am having hard-time  to configure the same thing in Ubuntu. I will be posting the same, if I get some success.
Update: I was not able to get anti-aliased fonts in linux. But, I found a font called 'Andale Mono', which gives good result with aliased fonts. This link might help in some cases.
Read more ...

Programmer's fonts comparison

Jan 1, 2011
In my opinion every programmer should be very selective about fonts, as bad fonts can not only decrease efficiency but also bless you with eye problems and headaches. Here is my own comparison of fonts. You can also find other font comparisons on many websites or just google 'programmer fonts'. I have listed the fonts in order of my preference. All the fonts shown below are anti-aliased. If you are forced to use aliased fonts, you can try Andale Mono, I find it good even at bigger font size and bold font weight. This blog uses Droid Sans Mono from Google web fonts for all the code sections.

1. DejaVu Sans Mono, 11 pt



2. Inconsolata-dz, 12 pt



3. Consolas, 11 pt



4. Anonymous, 11 pt



5. Courier-New, 11 pt



6. Lucida Console, 11 pt



7. Verdana, 11 pt;



8. Segoe UI, 11 pt

Read more ...