b=403513 bad kerning in print output if hinting is set to medium or full r=karlt sr=vlad

This commit is contained in:
Martin Stránský 2008-12-17 13:44:32 +13:00
Родитель 643531637f
Коммит 52ccba8876
8 изменённых файлов: 48 добавлений и 14 удалений

Просмотреть файл

@ -1967,13 +1967,17 @@ nsCanvasRenderingContext2D::SetFont(const nsAString& font)
// un-zoom the font size to avoid being affected by text-only zoom
const nscoord fontSize = nsStyleFont::UnZoomText(parentContext->PresContext(), fontStyle->mFont.size);
PRBool printerFont = (presShell->GetPresContext()->Type() == nsPresContext::eContext_PrintPreview ||
presShell->GetPresContext()->Type() == nsPresContext::eContext_Print);
gfxFontStyle style(fontStyle->mFont.style,
fontStyle->mFont.weight,
NSAppUnitsToFloatPixels(fontSize, aupcp),
langGroup,
fontStyle->mFont.sizeAdjust,
fontStyle->mFont.systemFont,
fontStyle->mFont.familyNameQuirks);
fontStyle->mFont.familyNameQuirks,
printerFont);
CurrentState().fontGroup = gfxPlatform::GetPlatform()->CreateFontGroup(fontStyle->mFont.name, &style, presShell->GetPresContext()->GetUserFontSet());
NS_ASSERTION(CurrentState().fontGroup, "Could not get font group");

Просмотреть файл

@ -148,6 +148,12 @@ nsThebesDeviceContext::Shutdown()
gSystemFonts = nsnull;
}
PRBool
nsThebesDeviceContext::IsPrinterSurface()
{
return(mPrintingSurface != NULL);
}
nsresult
nsThebesDeviceContext::SetDPI()
{

Просмотреть файл

@ -118,6 +118,8 @@ public:
virtual PRBool SetPixelScale(float aScale);
PRBool IsPrinterSurface(void);
nsNativeWidget GetWidget() { return mWidget; }
#if defined(XP_WIN) || defined(XP_OS2)
HDC GetPrintHDC();

Просмотреть файл

@ -83,9 +83,11 @@ nsThebesFontMetrics::Init(const nsFont& aFont, nsIAtom* aLangGroup,
langGroup.Assign(lg);
}
PRBool printerFont = mDeviceContext->IsPrinterSurface();
mFontStyle = new gfxFontStyle(aFont.style, aFont.weight, size, langGroup,
aFont.sizeAdjust, aFont.systemFont,
aFont.familyNameQuirks);
aFont.familyNameQuirks,
printerFont);
mFontGroup =
gfxPlatform::GetPlatform()->CreateFontGroup(aFont.name, mFontStyle,

Просмотреть файл

@ -78,7 +78,8 @@ struct THEBES_API gfxFontStyle {
gfxFontStyle(PRUint8 aStyle, PRUint16 aWeight, gfxFloat aSize,
const nsACString& aLangGroup,
float aSizeAdjust, PRPackedBool aSystemFont,
PRPackedBool aFamilyNameQuirks);
PRPackedBool aFamilyNameQuirks,
PRPackedBool aPrinterFont);
gfxFontStyle(const gfxFontStyle& aStyle);
// The style of font (normal, italic, oblique)
@ -89,6 +90,9 @@ struct THEBES_API gfxFontStyle {
// sources.
PRPackedBool systemFont : 1;
// Say that this font is used for print or print preview.
PRPackedBool printerFont : 1;
// True if the character set quirks (for treatment of "Symbol",
// "Wingdings", etc.) should be applied.
PRPackedBool familyNameQuirks : 1;
@ -133,6 +137,7 @@ struct THEBES_API gfxFontStyle {
return (size == other.size) &&
(style == other.style) &&
(systemFont == other.systemFont) &&
(printerFont == other.printerFont) &&
(familyNameQuirks == other.familyNameQuirks) &&
(weight == other.weight) &&
(langGroup.Equals(other.langGroup)) &&

Просмотреть файл

@ -1227,8 +1227,8 @@ gfxFontGroup::GetGeneration()
#define DEFAULT_PIXEL_FONT_SIZE 16.0f
gfxFontStyle::gfxFontStyle() :
style(FONT_STYLE_NORMAL), systemFont(PR_TRUE), familyNameQuirks(PR_FALSE),
weight(FONT_WEIGHT_NORMAL), size(DEFAULT_PIXEL_FONT_SIZE),
style(FONT_STYLE_NORMAL), systemFont(PR_TRUE), printerFont(PR_FALSE),
familyNameQuirks(PR_FALSE), weight(FONT_WEIGHT_NORMAL), size(DEFAULT_PIXEL_FONT_SIZE),
langGroup(NS_LITERAL_CSTRING("x-western")), sizeAdjust(0.0f)
{
}
@ -1236,8 +1236,9 @@ gfxFontStyle::gfxFontStyle() :
gfxFontStyle::gfxFontStyle(PRUint8 aStyle, PRUint16 aWeight, gfxFloat aSize,
const nsACString& aLangGroup,
float aSizeAdjust, PRPackedBool aSystemFont,
PRPackedBool aFamilyNameQuirks) :
style(aStyle), systemFont(aSystemFont),
PRPackedBool aFamilyNameQuirks,
PRPackedBool aPrinterFont):
style(aStyle), systemFont(aSystemFont), printerFont(aPrinterFont),
familyNameQuirks(aFamilyNameQuirks), weight(aWeight),
size(aSize), langGroup(aLangGroup), sizeAdjust(aSizeAdjust)
{
@ -1261,7 +1262,7 @@ gfxFontStyle::gfxFontStyle(PRUint8 aStyle, PRUint16 aWeight, gfxFloat aSize,
}
gfxFontStyle::gfxFontStyle(const gfxFontStyle& aStyle) :
style(aStyle.style), systemFont(aStyle.systemFont),
style(aStyle.style), systemFont(aStyle.systemFont), printerFont(aStyle.printerFont),
familyNameQuirks(aStyle.familyNameQuirks), weight(aStyle.weight),
size(aStyle.size), langGroup(aStyle.langGroup),
sizeAdjust(aStyle.sizeAdjust)

Просмотреть файл

@ -1712,7 +1712,7 @@ static void ApplyGdkScreenFontOptions(FcPattern *aPattern);
// Apply user settings and defaults to pattern in preparation for matching.
static void
PrepareSortPattern(FcPattern *aPattern, double aFallbackSize,
double aSizeAdjustFactor)
double aSizeAdjustFactor, PRBool aIsPrinterFont)
{
FcConfigSubstitute(NULL, aPattern, FcMatchPattern);
@ -1728,8 +1728,17 @@ PrepareSortPattern(FcPattern *aPattern, double aFallbackSize,
// Using an xlib surface would also be an option to get Screen font
// options for non-GTK X11 toolkits, but less efficient than using GDK to
// pick up dynamic changes.
if(aIsPrinterFont) {
cairo_font_options_t *options = cairo_font_options_create();
cairo_font_options_set_hint_style (options, CAIRO_HINT_STYLE_NONE);
cairo_font_options_set_antialias (options, CAIRO_ANTIALIAS_GRAY);
cairo_ft_font_options_substitute(options, aPattern);
cairo_font_options_destroy(options);
}
#ifdef MOZ_WIDGET_GTK2
ApplyGdkScreenFontOptions(aPattern);
else {
ApplyGdkScreenFontOptions(aPattern);
}
#endif
// Protect against any fontconfig settings that may have incorrectly
@ -1752,7 +1761,9 @@ gfx_pango_font_map_context_substitute(PangoFcFontMap *fontmap,
// owned by the context
PangoFontDescription *desc = pango_context_get_font_description(context);
double size = pango_font_description_get_size(desc) / FLOAT_PANGO_SCALE;
PrepareSortPattern(pattern, size, 1.0);
gfxPangoFontGroup *fontGroup = GetFontGroup(context);
PRBool usePrinterFont = fontGroup && fontGroup->GetStyle()->printerFont;
PrepareSortPattern(pattern, size, 1.0, usePrinterFont);
}
static PangoFcFont *
@ -1968,7 +1979,7 @@ gfxPangoFontGroup::MakeFontSet(PangoLanguage *aLang, gfxFloat aSizeAdjustFactor,
nsAutoRef<FcPattern> pattern
(gfxFontconfigUtils::NewPattern(fcFamilyList, mStyle, lang));
PrepareSortPattern(pattern, mStyle.size, aSizeAdjustFactor);
PrepareSortPattern(pattern, mStyle.size, aSizeAdjustFactor, mStyle.printerFont);
nsRefPtr<gfxFcPangoFontSet> fontset =
new gfxFcPangoFontSet(pattern, mUserFontSet);
@ -2144,7 +2155,7 @@ gfxFcFont::GetOrMakeFont(FcPattern *aPattern)
// string through FcNameUnparse() is more trouble than it's worth.
NS_NAMED_LITERAL_CSTRING(langGroup, "x-unicode");
gfxFontStyle fontStyle(style, weight, size, langGroup, 0.0,
PR_TRUE, PR_FALSE);
PR_TRUE, PR_FALSE, PR_FALSE);
nsRefPtr<gfxFontEntry> fe;
FcChar8 *fc_file;

Просмотреть файл

@ -1263,9 +1263,12 @@ nsSVGGlyphFrame::EnsureTextRun(float *aDrawScale, float *aMetricsScale,
}
const nsFont& font = fontData->mFont;
PRBool printerFont = (presContext->Type() == nsPresContext::eContext_PrintPreview ||
presContext->Type() == nsPresContext::eContext_Print);
gfxFontStyle fontStyle(font.style, font.weight, textRunSize, langGroup,
font.sizeAdjust, font.systemFont,
font.familyNameQuirks);
font.familyNameQuirks,
printerFont);
nsRefPtr<gfxFontGroup> fontGroup =
gfxPlatform::GetPlatform()->CreateFontGroup(font.name, &fontStyle, presContext->GetUserFontSet());