зеркало из https://github.com/mozilla/pjs.git
[OS/2] Bug 432575: add options for font hinting and antialiasing to get approximately equal display than on branch.
This commit is contained in:
Родитель
3be56e1e23
Коммит
f99a0d0b6e
|
@ -79,6 +79,8 @@ private:
|
||||||
Metrics *mMetrics;
|
Metrics *mMetrics;
|
||||||
gfxFloat mAdjustedSize;
|
gfxFloat mAdjustedSize;
|
||||||
PRUint32 mSpaceGlyph;
|
PRUint32 mSpaceGlyph;
|
||||||
|
int mHinting;
|
||||||
|
PRBool mAntialias;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,8 @@
|
||||||
|
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsIPlatformCharset.h"
|
#include "nsIPlatformCharset.h"
|
||||||
|
#include "nsIPrefBranch.h"
|
||||||
|
#include "nsIPrefService.h"
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* class gfxOS2Font
|
* class gfxOS2Font
|
||||||
|
@ -55,11 +57,29 @@
|
||||||
gfxOS2Font::gfxOS2Font(const nsAString &aName, const gfxFontStyle *aFontStyle)
|
gfxOS2Font::gfxOS2Font(const nsAString &aName, const gfxFontStyle *aFontStyle)
|
||||||
: gfxFont(aName, aFontStyle),
|
: gfxFont(aName, aFontStyle),
|
||||||
mFontFace(nsnull), mScaledFont(nsnull),
|
mFontFace(nsnull), mScaledFont(nsnull),
|
||||||
mMetrics(nsnull), mAdjustedSize(0)
|
mMetrics(nsnull), mAdjustedSize(0),
|
||||||
|
mHinting(FC_HINT_MEDIUM), mAntialias(FcTrue)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_thebes_2
|
#if 1 //def DEBUG_thebes_2
|
||||||
printf("gfxOS2Font[%#x]::gfxOS2Font(\"%s\", aFontStyle)\n",
|
printf("gfxOS2Font[%#x]::gfxOS2Font(\"%s\", aFontStyle)\n",
|
||||||
(unsigned)this, NS_LossyConvertUTF16toASCII(aName).get());
|
(unsigned)this, NS_LossyConvertUTF16toASCII(aName).get());
|
||||||
|
#endif
|
||||||
|
// try to get the preferences for hinting, antialias, and embolden options
|
||||||
|
nsCOMPtr<nsIPrefBranch> prefbranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||||
|
if (prefbranch) {
|
||||||
|
int value;
|
||||||
|
nsresult rv = prefbranch->GetIntPref("gfx.os2.font.hinting", &value);
|
||||||
|
if (NS_SUCCEEDED(rv) && value >= FC_HINT_NONE && value <= FC_HINT_FULL)
|
||||||
|
mHinting = value;
|
||||||
|
|
||||||
|
PRBool enabled;
|
||||||
|
rv = prefbranch->GetBoolPref("gfx.os2.font.antialiasing", &enabled);
|
||||||
|
if (NS_SUCCEEDED(rv))
|
||||||
|
mAntialias = enabled;
|
||||||
|
}
|
||||||
|
#if 1 //def DEBUG_thebes_2
|
||||||
|
printf(" font display options: hinting=%d, antialiasing=%s\n",
|
||||||
|
mHinting, mAntialias ? "on" : "off");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,13 +338,20 @@ cairo_font_face_t *gfxOS2Font::CairoFontFace()
|
||||||
(char *)str2, w2, i2, s2);
|
(char *)str2, w2, i2, s2);
|
||||||
#endif
|
#endif
|
||||||
FcPatternDestroy(fcPattern);
|
FcPatternDestroy(fcPattern);
|
||||||
|
|
||||||
if (mName == NS_LITERAL_STRING("Workplace Sans") && fcW >= FC_WEIGHT_DEMIBOLD) {
|
if (mName == NS_LITERAL_STRING("Workplace Sans") && fcW >= FC_WEIGHT_DEMIBOLD) {
|
||||||
// if we are dealing with Workplace Sans and want a bold font, we
|
// if we are dealing with Workplace Sans and want a bold font, we
|
||||||
// need to artificially embolden it (no bold counterpart yet)
|
// need to artificially embolden it (no bold counterpart yet)
|
||||||
FcPatternAddBool(fcMatch, FC_EMBOLDEN, FcTrue);
|
FcPatternAddBool(fcMatch, FC_EMBOLDEN, FcTrue);
|
||||||
|
} else {
|
||||||
|
// if we don't embolden, we can possibly switch off antialiasing
|
||||||
|
FcPatternAddBool(fcMatch, FC_ANTIALIAS, mAntialias);
|
||||||
}
|
}
|
||||||
|
FcPatternAddInteger(fcMatch, FC_HINT_STYLE, mHinting);
|
||||||
|
|
||||||
// and ask cairo to return a font face for this
|
// and ask cairo to return a font face for this
|
||||||
mFontFace = cairo_ft_font_face_create_for_pattern(fcMatch);
|
mFontFace = cairo_ft_font_face_create_for_pattern(fcMatch);
|
||||||
|
|
||||||
FcPatternDestroy(fcMatch);
|
FcPatternDestroy(fcMatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче