Friday, November 20, 2009

fixed and smoothed my fonts in Firefox on Windows XP

I use Windows Vista at work, and although I'm about to upgrade to Windows 7 (yay!!!) I wasn't sure how to smooth the fonts in Firefox given screenshots of a website in Firefox 3.5.5 and IE 8. The client pointed out that the fonts looked better in IE than in Firefox. What?! This never happens! So with a little searching, I discovered that Firefox displays fonts based on the user's operating system settings. There's a display setting called ClearType that you can get to from desktop Properties -> Appearance -> Effects. In Windows XP, the default is Standard, not ClearType. In Windows Vista (and I assume Windows 7) the default is ClearType.

How to make font render smoothly in firefox just like safari and IE7

How to evaluate and change Windows font smoothing or ClearType

(although I'm sure this is condemned as browser hijack)

[DllImport("user32.dll", SetLastError = true)]
static extern bool
SystemParametersInfo(uint uiAction, uint uiParam,
ref int pvParam, uint fWinIni);

/* Constants used for User32 calls. */
const uint SPI_GETFONTSMOOTHING = 74;
const uint SPI_SETFONTSMOOTHING = 75;
const unit SPI_UPDATEINI = 0x1;

private Boolean GetFontSmoothing()
{
bool iResult;
int pv = 0;
/* Call to systemparametersinfo
to get the font smoothing value. */
iResult =
SystemParametersInfo(SPI_GETFONTSMOOTHING, 0,
ref pv, 0);
if (pv > 0)
{
//pv > 0 means font smoothing is on.
return true;
}
else
{
//pv == 0 means font smoothing is off.
return false;
}
}

private void DisableFontSmoothing()
{
bool iResult;
int pv = 0;
/* Call to systemparametersinfo
to set the font smoothing value. */
iResult =
SystemParametersInfo(SPI_SETFONTSMOOTHING, 0,
ref pv, SPIF_UPDATEINIFILE);
}

private void EnableFontSmoothing()
{
bool iResult;
int pv = 0;
/* Call to systemparametersinfo
to set the font smoothing value. */
iResult =
SystemParametersInfo(SPI_SETFONTSMOOTHING, 1,
ref pv, SPIF_UPDATEINIFILE);
}


More on ClearType:
Microsoft Typography
Microsoft ClearType FAQ
Technical Overview of ClearType Filtering

Thursday, November 19, 2009

How to: Register HTTP Handlers

To register an HTTP handler for IIS 7.0 running in Integrated Mode

The following example shows how to map all HTTP requests to files with the file name extension ".SampleFileExtension" to the SampleHandler2 HTTP handler class. In this case, the handler code is in the App_Code folder, so you do not have to specify an assembly.

<configuration>
   <system.webServer>
      <handlers>
         <add name="SampleHandler" verb="*" path="SampleHandler.new" type="SampleHandler, SampleHandlerAssembly" resourceType="Unspecified" />
      </handlers>
   <system.webServer>
</configuration>

Wednesday, November 18, 2009

fixed my content disappearing in Firefox print preview

Problem

You wrote a web page which the customer will want to print out, which takes 2 or more pages of paper to print. Everything works fine in IE6, but when you go to print it in Firefox, only the first page comes out! The rest of the web page is simply missing from the printer.

Solution

Do you ever get the feeling that these Problem/Solution tricks I write about are from my own experiences as a web developer? You bet! This one took me quite some time to figure out.

The problem was in the style settings of the container of the web page content.

I was using a DIV tag to surround the entire body of the text of the web page to be printed. That DIV tag referenced a CLASS within my CSS that happened to have the element:

overflow: auto;

Removing that little bit from the DIV tag's CSS class completely solved the problem.

I actually didn't need to remove it, and instead I changed the setting to visible.

http://www.fastechws.com/tricks/web/printing-web-page-has-missing-pages-in-firefox.php