Bug 530931: Maemo shouldn't use the true DPI [r=roc]

This commit is contained in:
Mark Finkle 2009-11-25 17:27:05 -05:00
Родитель a07252cff6
Коммит 14e15631fb
7 изменённых файлов: 24 добавлений и 74 удалений

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

@ -221,7 +221,7 @@ nsSystemFontsGTK2::GetSystemFontInfo(GtkWidget *aWidget, nsString *aFontName,
if (!MOZ_pango_font_description_get_size_is_absolute(desc)) {
// |size| is in pango-points, so convert to pixels.
size *= float(gfxPlatformGtk::GetPlatformDPI()) / POINTS_PER_INCH_FLOAT;
size *= float(gfxPlatform::GetDPI()) / POINTS_PER_INCH_FLOAT;
}
// |size| is now pixels

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

@ -79,7 +79,7 @@ nsSystemFontsQt::GetSystemFontInfo(const char *aClassName, nsString *aFontName,
aFontStyle->weight = qFont.weight();
// FIXME: Set aFontStyle->stretch correctly!
aFontStyle->stretch = NS_FONT_STRETCH_NORMAL;
aFontStyle->size = qFont.pointSizeF() * float(gfxQtPlatform::GetPlatformDPI()) / 72.0f;
aFontStyle->size = qFont.pointSizeF() * float(gfxPlatform::GetDPI()) / 72.0f;
return NS_OK;
}

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

@ -129,34 +129,11 @@ public:
GdkDrawable *drawable);
GdkDrawable *GetGdkDrawable(gfxASurface *target);
static PRInt32 GetPlatformDPI() {
if (sPlatformDPI < 0) {
gfxPlatformGtk::GetPlatform()->InitDisplayCaps();
}
NS_ASSERTION(sPlatformDPI > 0, "Something is wrong");
return sPlatformDPI;
}
#ifdef MOZ_PLATFORM_HILDON
static PRInt32 GetMaemoClassic() {
if (sMaemoClassic < 0) {
gfxPlatformGtk::GetPlatform()->InitDisplayCaps();
}
NS_ASSERTION(sMaemoClassic > 0, "Something is wrong");
return sMaemoClassic == 1;
}
#endif
protected:
void InitDisplayCaps();
static PRInt32 sPlatformDPI;
static gfxFontconfigUtils *sFontconfigUtils;
#ifdef MOZ_PLATFORM_HILDON
static PRInt32 sMaemoClassic;
#endif
private:
virtual qcms_profile *GetPlatformCMSOutputProfile();
};

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

@ -85,10 +85,6 @@ public:
FT_Library GetFTLibrary();
static PRInt32 GetPlatformDPI() {
return 96;
}
protected:
static gfxFontconfigUtils *sFontconfigUtils;

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

@ -709,7 +709,7 @@ gfx_pango_fc_font_describe(PangoFont *font)
gfxFcFont *gfxFont = gfxPangoFcFont::GfxFont(self);
if (gfxFont) {
double pixelsize = gfxFont->GetStyle()->size;
double dpi = gfxPlatformGtk::GetPlatformDPI();
double dpi = gfxPlatform::GetDPI();
gint size = moz_pango_units_from_double(pixelsize * dpi / 72.0);
pango_font_description_set_size(result, size);
}
@ -1706,8 +1706,8 @@ gfx_pango_font_map_get_resolution(PangoFcFontMap *fcfontmap,
PangoContext *context)
{
// This merely enables the FC_SIZE field of the pattern to be accurate.
// We use gfxPlatformGtk::GetPlatformDPI() much of the time...
return gfxPlatformGtk::GetPlatformDPI();
// We use gfxPlatform::GetDPI() much of the time...
return gfxPlatform::GetDPI();
}
#ifdef MOZ_WIDGET_GTK2

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

@ -91,12 +91,6 @@
#include FT_FREETYPE_H
#endif
#ifdef MOZ_PLATFORM_HILDON
#include "nsIPropertyBag2.h"
PRInt32 gfxPlatformGtk::sMaemoClassic = -1;
#endif
PRInt32 gfxPlatformGtk::sPlatformDPI = -1;
gfxFontconfigUtils *gfxPlatformGtk::sFontconfigUtils = nsnull;
#ifndef MOZ_PANGO
@ -529,41 +523,10 @@ gfxPlatformGtk::CreateFontGroup(const nsAString &aFamilies,
void
gfxPlatformGtk::InitDisplayCaps()
{
// Make sure init is run so we have a resolution
GdkScreen *screen = gdk_screen_get_default();
gtk_settings_get_for_screen(screen); // Make sure init is run so we have a resolution
gfxPlatformGtk::sPlatformDPI = PRInt32(round(gdk_screen_get_resolution(screen)));
if (gfxPlatformGtk::sPlatformDPI <= 0) {
// Fall back to something sane
gfxPlatformGtk::sPlatformDPI = 96;
}
#ifdef MOZ_PLATFORM_HILDON
// Check the cached value
if (gfxPlatform::sDPI == -1) {
nsresult rv;
nsCOMPtr<nsIPropertyBag2> infoService = do_GetService("@mozilla.org/system-info;1", &rv);
if (NS_FAILED(rv)) {
NS_ASSERTION(infoService, "Could not find a system info service");
return;
}
nsCString deviceType;
rv = infoService->GetPropertyAsACString(NS_LITERAL_STRING("device"), deviceType);
if (NS_SUCCEEDED(rv)) {
if (deviceType.EqualsLiteral("Nokia N900")) {
gfxPlatform::sDPI = 265; // It's an N900
gfxPlatformGtk::sMaemoClassic = 0;
}
else if (deviceType.EqualsLiteral("Nokia N8xx")) {
gfxPlatform::sDPI = 225; // It's an N810/N800
gfxPlatformGtk::sMaemoClassic = 1;
}
}
}
#else
gfxPlatform::sDPI = gfxPlatformGtk::sPlatformDPI;
#endif
gtk_settings_get_for_screen(screen);
gfxPlatform::sDPI = PRInt32(round(gdk_screen_get_resolution(screen)));
if (gfxPlatform::sDPI <= 0) {
// Fall back to something sane
gfxPlatform::sDPI = 96;

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

@ -44,7 +44,9 @@
#include "gtkdrawing.h"
#ifdef MOZ_PLATFORM_HILDON
#include "gfxPlatformGtk.h"
#include "nsIServiceManager.h"
#include "nsIPropertyBag2.h"
#include "nsLiteralString.h"
#endif
#define GDK_COLOR_TO_NS_RGB(c) \
@ -590,7 +592,19 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric)
break;
case eMetric_MaemoClassic:
#ifdef MOZ_PLATFORM_HILDON
aMetric = gfxPlatformGtk::GetMaemoClassic();
{
aMetric = 0;
nsCOMPtr<nsIPropertyBag2> infoService(do_GetService("@mozilla.org/system-info;1"));
if (infoService) {
nsCString deviceType;
nsresult rv = infoService->GetPropertyAsACString(NS_LITERAL_STRING("device"),
deviceType);
if (NS_SUCCEEDED(rv)) {
if (deviceType.EqualsLiteral("Nokia N8xx"))
aMetric = 1;
}
}
}
#else
aMetric = 0;
res = NS_ERROR_NOT_IMPLEMENTED;