Skip to content

Commit

Permalink
Bug 1056479 p4 - fix accessibility api for font-weight. r=jfkthame
Browse files Browse the repository at this point in the history
  • Loading branch information
John Daggett committed May 12, 2015
1 parent 2f3ecb3 commit 4598171
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions accessible/base/TextAttrs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
#include "mozilla/AppUnits.h"
#include "mozilla/gfx/2D.h"

#if defined(MOZ_WIDGET_GTK)
#include "gfxPlatformGtk.h" // xxx - for UseFcFontList
#endif

using namespace mozilla;
using namespace mozilla::a11y;

Expand Down Expand Up @@ -628,21 +632,30 @@ TextAttrsMgr::FontWeightTextAttr::
if (font->IsSyntheticBold())
return 700;

#if defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_QT)
// On Linux, font->GetStyle()->weight will give the absolute weight requested
// of the font face. The Linux code uses the gfxFontEntry constructor which
// doesn't initialize the weight field.
return font->GetStyle()->weight;
#else
// On Windows, font->GetStyle()->weight will give the same weight as
// fontEntry->Weight(), the weight of the first font in the font group, which
// may not be the weight of the font face used to render the characters.
// On Mac, font->GetStyle()->weight will just give the same number as
// getComputedStyle(). fontEntry->Weight() will give the weight of the font
// face used.
gfxFontEntry *fontEntry = font->GetFontEntry();
return fontEntry->Weight();
bool useFontEntryWeight = true;

// Under Linux, when gfxPangoFontGroup code is used,
// font->GetStyle()->weight will give the absolute weight requested of the
// font face. The gfxPangoFontGroup code uses the gfxFontEntry constructor
// which doesn't initialize the weight field.
#if defined(MOZ_WIDGET_QT)
useFontEntryWeight = false;
#elif defined(MOZ_WIDGET_GTK)
useFontEntryWeight = gfxPlatformGtk::UseFcFontList();
#endif

if (useFontEntryWeight) {
// On Windows, font->GetStyle()->weight will give the same weight as
// fontEntry->Weight(), the weight of the first font in the font group,
// which may not be the weight of the font face used to render the
// characters. On Mac, font->GetStyle()->weight will just give the same
// number as getComputedStyle(). fontEntry->Weight() will give the weight
// of the font face used.
gfxFontEntry *fontEntry = font->GetFontEntry();
return fontEntry->Weight();
} else {
return font->GetStyle()->weight;
}
}

////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 4598171

Please sign in to comment.