зеркало из https://github.com/mozilla/pjs.git
backing out 362682 due to linux tinderboxen not being upgraded... (396805, 389426)
This commit is contained in:
Родитель
baefe4b050
Коммит
672cdf445b
|
@ -213,7 +213,6 @@ Gdiplus.h
|
||||||
gdk/gdkevents.h
|
gdk/gdkevents.h
|
||||||
gdk/gdk.h
|
gdk/gdk.h
|
||||||
gdk/gdkkeysyms.h
|
gdk/gdkkeysyms.h
|
||||||
gdk/gdkpango.h
|
|
||||||
gdk/gdkprivate.h
|
gdk/gdkprivate.h
|
||||||
gdk/gdkregion.h
|
gdk/gdkregion.h
|
||||||
gdk/gdkwindow.h
|
gdk/gdkwindow.h
|
||||||
|
@ -506,7 +505,6 @@ PALM_CMN.H
|
||||||
pango-engine.h
|
pango-engine.h
|
||||||
pango-glyph.h
|
pango-glyph.h
|
||||||
pango-modules.h
|
pango-modules.h
|
||||||
pango/pangocairo.h
|
|
||||||
pango/pangofc-decoder.h
|
pango/pangofc-decoder.h
|
||||||
pango/pangofc-font.h
|
pango/pangofc-font.h
|
||||||
pango/pangofc-fontmap.h
|
pango/pangofc-fontmap.h
|
||||||
|
@ -515,7 +513,6 @@ pango/pango-fontmap.h
|
||||||
pango/pango.h
|
pango/pango.h
|
||||||
pango/pangoxft.h
|
pango/pangoxft.h
|
||||||
pango/pangox.h
|
pango/pangox.h
|
||||||
pango/pango-utils.h
|
|
||||||
pango-types.h
|
pango-types.h
|
||||||
pascal.h
|
pascal.h
|
||||||
Patches.h
|
Patches.h
|
||||||
|
|
22
configure.in
22
configure.in
|
@ -116,8 +116,7 @@ PERL_VERSION=5.006
|
||||||
LIBART_VERSION=2.3.4
|
LIBART_VERSION=2.3.4
|
||||||
CAIRO_VERSION=1.4.2
|
CAIRO_VERSION=1.4.2
|
||||||
GLITZ_VERSION=0.4.0
|
GLITZ_VERSION=0.4.0
|
||||||
PANGO_VERSION=1.10.0
|
GTK2_VERSION=1.3.7
|
||||||
GTK2_VERSION=1.8.0
|
|
||||||
MAKE_VERSION=3.78
|
MAKE_VERSION=3.78
|
||||||
WINDRES_VERSION=2.14.90
|
WINDRES_VERSION=2.14.90
|
||||||
W32API_VERSION=3.8
|
W32API_VERSION=3.8
|
||||||
|
@ -4568,7 +4567,7 @@ fi
|
||||||
if test "$COMPILE_ENVIRONMENT"; then
|
if test "$COMPILE_ENVIRONMENT"; then
|
||||||
if test "$MOZ_ENABLE_GTK2"
|
if test "$MOZ_ENABLE_GTK2"
|
||||||
then
|
then
|
||||||
PKG_CHECK_MODULES(MOZ_GTK2, gtk+-2.0 >= $GTK2_VERSION gdk-x11-2.0 glib-2.0 gobject-2.0)
|
PKG_CHECK_MODULES(MOZ_GTK2, gtk+-2.0 >= 1.3.7 gdk-x11-2.0 glib-2.0 gobject-2.0)
|
||||||
fi
|
fi
|
||||||
fi # COMPILE_ENVIRONMENT
|
fi # COMPILE_ENVIRONMENT
|
||||||
|
|
||||||
|
@ -4807,7 +4806,7 @@ if test "$MOZ_ENABLE_XFT"
|
||||||
then
|
then
|
||||||
AC_DEFINE(MOZ_ENABLE_XFT)
|
AC_DEFINE(MOZ_ENABLE_XFT)
|
||||||
PKG_CHECK_MODULES(MOZ_XFT, xft)
|
PKG_CHECK_MODULES(MOZ_XFT, xft)
|
||||||
PKG_CHECK_MODULES(_PANGOCHK, pango >= $PANGO_VERSION)
|
PKG_CHECK_MODULES(_PANGOCHK, pango >= 1.1.0)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_SUBST(MOZ_ENABLE_XFT)
|
AC_SUBST(MOZ_ENABLE_XFT)
|
||||||
|
@ -4824,7 +4823,12 @@ MOZ_ARG_ENABLE_BOOL(pango,
|
||||||
|
|
||||||
if test "$MOZ_ENABLE_PANGO" && test -z "$MOZ_ENABLE_CAIRO_GFX"
|
if test "$MOZ_ENABLE_PANGO" && test -z "$MOZ_ENABLE_CAIRO_GFX"
|
||||||
then
|
then
|
||||||
AC_MSG_ERROR([Cairo gfx is required for Pango font rendering])
|
AC_DEFINE(MOZ_ENABLE_PANGO)
|
||||||
|
PKG_CHECK_MODULES(MOZ_PANGO, pangoxft >= 1.6.0)
|
||||||
|
|
||||||
|
AC_SUBST(MOZ_ENABLE_PANGO)
|
||||||
|
AC_SUBST(MOZ_PANGO_CFLAGS)
|
||||||
|
AC_SUBST(MOZ_PANGO_LIBS)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "$MOZ_ENABLE_GTK2" && test "$MOZ_ENABLE_CAIRO_GFX"
|
if test "$MOZ_ENABLE_GTK2" && test "$MOZ_ENABLE_CAIRO_GFX"
|
||||||
|
@ -4840,7 +4844,13 @@ fi
|
||||||
if test "$MOZ_ENABLE_PANGO" && test "$MOZ_ENABLE_CAIRO_GFX"
|
if test "$MOZ_ENABLE_PANGO" && test "$MOZ_ENABLE_CAIRO_GFX"
|
||||||
then
|
then
|
||||||
AC_DEFINE(MOZ_ENABLE_PANGO)
|
AC_DEFINE(MOZ_ENABLE_PANGO)
|
||||||
PKG_CHECK_MODULES(MOZ_PANGO, pango >= $PANGO_VERSION pangocairo >= $PANGO_VERSION pangoft2 >= $PANGO_VERSION)
|
dnl PKG_CHECK_MODULES(MOZ_PANGO, pango >= 1.10.0 pangocairo >= 1.10.0)
|
||||||
|
if test "$MOZ_X11"; then
|
||||||
|
PKG_CHECK_MODULES(MOZ_PANGO, pango >= 1.6.0 pangoft2 >= 1.6.0 pangoxft >= 1.6.0)
|
||||||
|
else
|
||||||
|
PKG_CHECK_MODULES(MOZ_PANGO, pango >= 1.6.0 pangoft2 >= 1.6.0)
|
||||||
|
fi
|
||||||
|
|
||||||
AC_SUBST(MOZ_ENABLE_PANGO)
|
AC_SUBST(MOZ_ENABLE_PANGO)
|
||||||
AC_SUBST(MOZ_PANGO_CFLAGS)
|
AC_SUBST(MOZ_PANGO_CFLAGS)
|
||||||
AC_SUBST(MOZ_PANGO_LIBS)
|
AC_SUBST(MOZ_PANGO_LIBS)
|
||||||
|
|
|
@ -1097,9 +1097,7 @@ _render_glyph_bitmap (FT_Face face,
|
||||||
* we avoid the FT_LOAD_NO_RECURSE flag.
|
* we avoid the FT_LOAD_NO_RECURSE flag.
|
||||||
*/
|
*/
|
||||||
error = FT_Render_Glyph (glyphslot, FT_RENDER_MODE_NORMAL);
|
error = FT_Render_Glyph (glyphslot, FT_RENDER_MODE_NORMAL);
|
||||||
/* XXX ignoring all other errors for now. They are not fatal, typically
|
if (error) {
|
||||||
* just a glyph-not-found. */
|
|
||||||
if (error == FT_Err_Out_Of_Memory) {
|
|
||||||
_cairo_error (CAIRO_STATUS_NO_MEMORY);
|
_cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||||
return CAIRO_STATUS_NO_MEMORY;
|
return CAIRO_STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -1893,9 +1891,8 @@ _cairo_ft_scaled_glyph_init (void *abstract_font,
|
||||||
error = FT_Load_Glyph (scaled_font->unscaled->face,
|
error = FT_Load_Glyph (scaled_font->unscaled->face,
|
||||||
_cairo_scaled_glyph_index(scaled_glyph),
|
_cairo_scaled_glyph_index(scaled_glyph),
|
||||||
load_flags);
|
load_flags);
|
||||||
/* XXX ignoring all other errors for now. They are not fatal, typically
|
|
||||||
* just a glyph-not-found. */
|
if (error) {
|
||||||
if (error == FT_Err_Out_Of_Memory) {
|
|
||||||
status = CAIRO_STATUS_NO_MEMORY;
|
status = CAIRO_STATUS_NO_MEMORY;
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
}
|
}
|
||||||
|
@ -2045,9 +2042,8 @@ _cairo_ft_scaled_glyph_init (void *abstract_font,
|
||||||
error = FT_Load_Glyph (face,
|
error = FT_Load_Glyph (face,
|
||||||
_cairo_scaled_glyph_index(scaled_glyph),
|
_cairo_scaled_glyph_index(scaled_glyph),
|
||||||
load_flags | FT_LOAD_NO_BITMAP);
|
load_flags | FT_LOAD_NO_BITMAP);
|
||||||
/* XXX ignoring all other errors for now. They are not fatal, typically
|
|
||||||
* just a glyph-not-found. */
|
if (error) {
|
||||||
if (error == FT_Err_Out_Of_Memory) {
|
|
||||||
_cairo_ft_unscaled_font_unlock_face (unscaled);
|
_cairo_ft_unscaled_font_unlock_face (unscaled);
|
||||||
_cairo_error (CAIRO_STATUS_NO_MEMORY);
|
_cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||||
return CAIRO_STATUS_NO_MEMORY;
|
return CAIRO_STATUS_NO_MEMORY;
|
||||||
|
|
|
@ -44,15 +44,14 @@
|
||||||
#include "gfxFont.h"
|
#include "gfxFont.h"
|
||||||
|
|
||||||
#include <pango/pango.h>
|
#include <pango/pango.h>
|
||||||
|
#include <X11/Xft/Xft.h>
|
||||||
|
|
||||||
// Control when we bypass Pango
|
// Control when we use Xft directly, bypassing Pango
|
||||||
// Enable this to use FreeType to glyph-convert 8bit-only textruns, but use Pango
|
// Enable this to use Xft to glyph-convert 8bit-only textruns, but use Pango
|
||||||
// to shape any textruns with non-8bit characters
|
// to shape any textruns with non-8bit characters
|
||||||
// XXX
|
#define ENABLE_XFT_FAST_PATH_8BIT
|
||||||
#define ENABLE_FAST_PATH_8BIT
|
// Enable this to use Xft to glyph-convert all textruns
|
||||||
// Enable this to bypass Pango shaping for all textruns. Don't expect
|
// #define ENABLE_XFT_FAST_PATH_ALWAYS
|
||||||
// anything other than simple Latin work though!
|
|
||||||
//#define ENABLE_FAST_PATH_ALWAYS
|
|
||||||
|
|
||||||
#include "nsDataHashtable.h"
|
#include "nsDataHashtable.h"
|
||||||
#include "nsClassHashtable.h"
|
#include "nsClassHashtable.h"
|
||||||
|
@ -71,15 +70,17 @@ public:
|
||||||
|
|
||||||
virtual const gfxFont::Metrics& GetMetrics();
|
virtual const gfxFont::Metrics& GetMetrics();
|
||||||
|
|
||||||
PangoFontDescription *GetPangoFontDescription() { if (!mPangoFontDesc) RealizeFont(); return mPangoFontDesc; }
|
PangoFontDescription *GetPangoFontDescription() { RealizeFont(); return mPangoFontDesc; }
|
||||||
PangoContext *GetPangoContext() { if (!mPangoFontDesc) RealizeFont(); return mPangoCtx; }
|
PangoContext *GetPangoContext() { RealizeFont(); return mPangoCtx; }
|
||||||
|
|
||||||
void GetMozLang(nsACString &aMozLang);
|
void GetMozLang(nsACString &aMozLang);
|
||||||
void GetActualFontFamily(nsACString &aFamily);
|
void GetActualFontFamily(nsACString &aFamily);
|
||||||
|
|
||||||
PangoFont *GetPangoFont() { if (!mPangoFont) RealizePangoFont(); return mPangoFont; }
|
XftFont *GetXftFont () { RealizeXftFont (); return mXftFont; }
|
||||||
gfxFloat GetAdjustedSize() { if (!mPangoFontDesc) RealizeFont(); return mAdjustedSize; }
|
PangoFont *GetPangoFont() { RealizePangoFont(); return mPangoFont; }
|
||||||
|
gfxFloat GetAdjustedSize() { RealizeFont(); return mAdjustedSize; }
|
||||||
|
|
||||||
|
PRBool HasGlyph(const PRUint32 aChar);
|
||||||
PRUint32 GetGlyph(const PRUint32 aChar);
|
PRUint32 GetGlyph(const PRUint32 aChar);
|
||||||
|
|
||||||
virtual nsString GetUniqueName();
|
virtual nsString GetUniqueName();
|
||||||
|
@ -94,7 +95,9 @@ protected:
|
||||||
PangoFontDescription *mPangoFontDesc;
|
PangoFontDescription *mPangoFontDesc;
|
||||||
PangoContext *mPangoCtx;
|
PangoContext *mPangoCtx;
|
||||||
|
|
||||||
|
XftFont *mXftFont;
|
||||||
PangoFont *mPangoFont;
|
PangoFont *mPangoFont;
|
||||||
|
PangoFont *mGlyphTestingFont;
|
||||||
cairo_scaled_font_t *mCairoFont;
|
cairo_scaled_font_t *mCairoFont;
|
||||||
|
|
||||||
PRBool mHasMetrics;
|
PRBool mHasMetrics;
|
||||||
|
@ -103,6 +106,7 @@ protected:
|
||||||
gfxFloat mAdjustedSize;
|
gfxFloat mAdjustedSize;
|
||||||
|
|
||||||
void RealizeFont(PRBool force = PR_FALSE);
|
void RealizeFont(PRBool force = PR_FALSE);
|
||||||
|
void RealizeXftFont(PRBool force = PR_FALSE);
|
||||||
void RealizePangoFont(PRBool aForce = PR_FALSE);
|
void RealizePangoFont(PRBool aForce = PR_FALSE);
|
||||||
void GetCharSize(const char aChar, gfxSize& aInkSize, gfxSize& aLogSize,
|
void GetCharSize(const char aChar, gfxSize& aInkSize, gfxSize& aLogSize,
|
||||||
PRUint32 *aGlyphID = nsnull);
|
PRUint32 *aGlyphID = nsnull);
|
||||||
|
@ -120,7 +124,7 @@ public:
|
||||||
|
|
||||||
virtual gfxFontGroup *Copy(const gfxFontStyle *aStyle);
|
virtual gfxFontGroup *Copy(const gfxFontStyle *aStyle);
|
||||||
|
|
||||||
// Create and initialize a textrun using Pango
|
// Create and initialize a textrun using Pango (or Xft)
|
||||||
virtual gfxTextRun *MakeTextRun(const PRUnichar *aString, PRUint32 aLength,
|
virtual gfxTextRun *MakeTextRun(const PRUnichar *aString, PRUint32 aLength,
|
||||||
const Parameters *aParams, PRUint32 aFlags);
|
const Parameters *aParams, PRUint32 aFlags);
|
||||||
virtual gfxTextRun *MakeTextRun(const PRUint8 *aString, PRUint32 aLength,
|
virtual gfxTextRun *MakeTextRun(const PRUint8 *aString, PRUint32 aLength,
|
||||||
|
@ -142,8 +146,8 @@ protected:
|
||||||
* but stored in UTF16 format)
|
* but stored in UTF16 format)
|
||||||
*/
|
*/
|
||||||
void InitTextRun(gfxTextRun *aTextRun, const gchar *aUTF8Text,
|
void InitTextRun(gfxTextRun *aTextRun, const gchar *aUTF8Text,
|
||||||
PRUint32 aUTF8Length, PRBool aTake8BitPath);
|
PRUint32 aUTF8Length, PRUint32 aUTF8HeaderLength,
|
||||||
|
PRBool aTake8BitPath);
|
||||||
// Returns NS_ERROR_FAILURE if there's a missing glyph
|
// Returns NS_ERROR_FAILURE if there's a missing glyph
|
||||||
nsresult SetGlyphs(gfxTextRun *aTextRun, gfxPangoFont *aFont,
|
nsresult SetGlyphs(gfxTextRun *aTextRun, gfxPangoFont *aFont,
|
||||||
const gchar *aUTF8, PRUint32 aUTF8Length,
|
const gchar *aUTF8, PRUint32 aUTF8Length,
|
||||||
|
@ -154,11 +158,11 @@ protected:
|
||||||
const gchar *aUTF8, PRUint32 aUTF8Length,
|
const gchar *aUTF8, PRUint32 aUTF8Length,
|
||||||
PRUint32 *aUTF16Offset);
|
PRUint32 *aUTF16Offset);
|
||||||
void CreateGlyphRunsItemizing(gfxTextRun *aTextRun,
|
void CreateGlyphRunsItemizing(gfxTextRun *aTextRun,
|
||||||
const gchar *aUTF8, PRUint32 aUTF8Length);
|
const gchar *aUTF8, PRUint32 aUTF8Length,
|
||||||
#if defined(ENABLE_FAST_PATH_8BIT) || defined(ENABLE_FAST_PATH_ALWAYS)
|
PRUint32 aUTF8HeaderLength);
|
||||||
PRBool CanTakeFastPath(PRUint32 aFlags);
|
#if defined(ENABLE_XFT_FAST_PATH_8BIT) || defined(ENABLE_XFT_FAST_PATH_ALWAYS)
|
||||||
void CreateGlyphRunsFast(gfxTextRun *aTextRun,
|
void CreateGlyphRunsXft(gfxTextRun *aTextRun,
|
||||||
const gchar *aUTF8, PRUint32 aUTF8Length);
|
const gchar *aUTF8, PRUint32 aUTF8Length);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static PRBool FontCallback (const nsAString& fontName,
|
static PRBool FontCallback (const nsAString& fontName,
|
||||||
|
@ -208,4 +212,30 @@ private:
|
||||||
nsClassHashtable<nsUint32HashKey, gfxPangoFontWrapper> mPangoFonts;
|
nsClassHashtable<nsUint32HashKey, gfxPangoFontWrapper> mPangoFonts;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// XXX we should remove this class, because this class is used only in |HasGlyph| of gfxPangoFont.
|
||||||
|
// But it can use fontconfig directly after bug 366664.
|
||||||
|
class gfxPangoFontNameMap
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
gfxPangoFontNameMap();
|
||||||
|
~gfxPangoFontNameMap();
|
||||||
|
|
||||||
|
static gfxPangoFontNameMap* GetPangoFontNameMap() {
|
||||||
|
if (!sPangoFontNameMap)
|
||||||
|
sPangoFontNameMap = new gfxPangoFontNameMap();
|
||||||
|
return sPangoFontNameMap;
|
||||||
|
}
|
||||||
|
static void Shutdown() {
|
||||||
|
if (sPangoFontNameMap)
|
||||||
|
delete sPangoFontNameMap;
|
||||||
|
sPangoFontNameMap = nsnull;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Put(const nsACString &aName, PangoFont *aPangoFont);
|
||||||
|
PangoFont* Get(const nsACString &aName);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static gfxPangoFontNameMap *sPangoFontNameMap;
|
||||||
|
nsClassHashtable<nsCStringHashKey, gfxPangoFontWrapper> mPangoFonts;
|
||||||
|
};
|
||||||
#endif /* GFX_PANGOFONTS_H */
|
#endif /* GFX_PANGOFONTS_H */
|
||||||
|
|
|
@ -79,7 +79,7 @@ public:
|
||||||
if (sDPI == -1) {
|
if (sDPI == -1) {
|
||||||
InitDPI();
|
InitDPI();
|
||||||
}
|
}
|
||||||
NS_ASSERTION(sDPI > 0, "Something is wrong");
|
NS_ASSERTION(sDPI != 0, "Something is wrong");
|
||||||
return sDPI;
|
return sDPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,6 @@
|
||||||
#include "cairo-xlib.h"
|
#include "cairo-xlib.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#if HAVE_STDINT_H
|
#if HAVE_STDINT_H
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#elif HAVE_INTTYPES_H
|
#elif HAVE_INTTYPES_H
|
||||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -60,6 +60,12 @@
|
||||||
|
|
||||||
#include <fontconfig/fontconfig.h>
|
#include <fontconfig/fontconfig.h>
|
||||||
|
|
||||||
|
#ifndef THEBES_USE_PANGO_CAIRO
|
||||||
|
#include <pango/pangoxft.h>
|
||||||
|
#endif // THEBES_USE_PANGO_CAIRO
|
||||||
|
|
||||||
|
#include <pango/pango-font.h>
|
||||||
|
|
||||||
#include "nsMathUtils.h"
|
#include "nsMathUtils.h"
|
||||||
|
|
||||||
#include "lcms.h"
|
#include "lcms.h"
|
||||||
|
@ -83,8 +89,6 @@ gfxPlatformGtk::gfxPlatformGtk()
|
||||||
#endif
|
#endif
|
||||||
if (!sFontconfigUtils)
|
if (!sFontconfigUtils)
|
||||||
sFontconfigUtils = gfxFontconfigUtils::GetFontconfigUtils();
|
sFontconfigUtils = gfxFontconfigUtils::GetFontconfigUtils();
|
||||||
|
|
||||||
InitDPI();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gfxPlatformGtk::~gfxPlatformGtk()
|
gfxPlatformGtk::~gfxPlatformGtk()
|
||||||
|
@ -94,6 +98,10 @@ gfxPlatformGtk::~gfxPlatformGtk()
|
||||||
|
|
||||||
gfxPangoFont::Shutdown();
|
gfxPangoFont::Shutdown();
|
||||||
|
|
||||||
|
#ifndef THEBES_USE_PANGO_CAIRO
|
||||||
|
pango_xft_shutdown_display(GDK_DISPLAY(), 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// It would be nice to do this (although it might need to be after
|
// It would be nice to do this (although it might need to be after
|
||||||
// the cairo shutdown that happens in ~gfxPlatform). It even looks
|
// the cairo shutdown that happens in ~gfxPlatform). It even looks
|
||||||
|
@ -270,17 +278,93 @@ gfxPlatformGtk::CreateFontGroup(const nsAString &aFamilies,
|
||||||
return new gfxPangoFontGroup(aFamilies, aStyle);
|
return new gfxPangoFontGroup(aFamilies, aStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PRInt32
|
||||||
|
GetXftDPI()
|
||||||
|
{
|
||||||
|
char *val = XGetDefault(GDK_DISPLAY(), "Xft", "dpi");
|
||||||
|
if (val) {
|
||||||
|
char *e;
|
||||||
|
double d = strtod(val, &e);
|
||||||
|
|
||||||
|
if (e != val)
|
||||||
|
return NS_lround(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static PRInt32
|
||||||
|
GetDPIFromPangoFont()
|
||||||
|
{
|
||||||
|
#ifndef THEBES_USE_PANGO_CAIRO
|
||||||
|
PangoContext* ctx = pango_xft_get_context(GDK_DISPLAY(), 0);
|
||||||
|
gdk_pango_context_set_colormap(ctx, gdk_rgb_get_cmap());
|
||||||
|
#else
|
||||||
|
PangoContext* ctx =
|
||||||
|
pango_cairo_font_map_create_context(
|
||||||
|
PANGO_CAIRO_FONT_MAP(pango_cairo_font_map_get_default()));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!ctx) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
double dblDPI = 0.0f;
|
||||||
|
GList *items = nsnull;
|
||||||
|
PangoItem *item = nsnull;
|
||||||
|
PangoFcFont *fcfont = nsnull;
|
||||||
|
|
||||||
|
PangoAttrList *al = pango_attr_list_new();
|
||||||
|
|
||||||
|
if (!al) {
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Just using the string "a" because we need _some_ text.
|
||||||
|
items = pango_itemize(ctx, "a", 0, 1, al, NULL);
|
||||||
|
|
||||||
|
if (!items) {
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
item = (PangoItem*)items->data;
|
||||||
|
|
||||||
|
if (!item) {
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
fcfont = PANGO_FC_FONT(item->analysis.font);
|
||||||
|
|
||||||
|
if (!fcfont) {
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
FcPatternGetDouble(fcfont->font_pattern, FC_DPI, 0, &dblDPI);
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
if (al)
|
||||||
|
pango_attr_list_unref(al);
|
||||||
|
if (item)
|
||||||
|
pango_item_free(item);
|
||||||
|
if (items)
|
||||||
|
g_list_free(items);
|
||||||
|
if (ctx)
|
||||||
|
g_object_unref(ctx);
|
||||||
|
|
||||||
|
return NS_lround(dblDPI);
|
||||||
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
void
|
void
|
||||||
gfxPlatformGtk::InitDPI()
|
gfxPlatformGtk::InitDPI()
|
||||||
{
|
{
|
||||||
PangoContext *context = gdk_pango_context_get ();
|
sDPI = GetXftDPI();
|
||||||
sDPI = pango_cairo_context_get_resolution (context);
|
|
||||||
g_object_unref (context);
|
|
||||||
|
|
||||||
if (sDPI <= 0) {
|
if (sDPI <= 0) {
|
||||||
// Fall back to something sane
|
sDPI = GetDPIFromPangoFont();
|
||||||
sDPI = 96;
|
if (sDPI <= 0) {
|
||||||
|
// Fall back to something sane
|
||||||
|
sDPI = 96;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче