зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1436048 part 1 - Use a user defined type for font weight everywhere. r=jfkthame,emilio
--HG-- extra : rebase_source : 2e267ff99de6f52484e34ac15c39e5ca8b473394
This commit is contained in:
Родитель
cd28f53640
Коммит
1e7f76576a
|
@ -592,7 +592,7 @@ TextAttrsMgr::FontStyleTextAttr::
|
|||
|
||||
TextAttrsMgr::FontWeightTextAttr::
|
||||
FontWeightTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame) :
|
||||
TTextAttr<int32_t>(!aFrame)
|
||||
TTextAttr<FontWeight>(!aFrame)
|
||||
{
|
||||
mRootNativeValue = GetFontWeight(aRootFrame);
|
||||
mIsRootDefined = true;
|
||||
|
@ -605,7 +605,7 @@ TextAttrsMgr::FontWeightTextAttr::
|
|||
|
||||
bool
|
||||
TextAttrsMgr::FontWeightTextAttr::
|
||||
GetValueFor(Accessible* aAccessible, int32_t* aValue)
|
||||
GetValueFor(Accessible* aAccessible, FontWeight* aValue)
|
||||
{
|
||||
nsIContent* elm = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
|
||||
if (elm) {
|
||||
|
@ -620,15 +620,16 @@ TextAttrsMgr::FontWeightTextAttr::
|
|||
|
||||
void
|
||||
TextAttrsMgr::FontWeightTextAttr::
|
||||
ExposeValue(nsIPersistentProperties* aAttributes, const int32_t& aValue)
|
||||
ExposeValue(nsIPersistentProperties* aAttributes,
|
||||
const FontWeight& aValue)
|
||||
{
|
||||
nsAutoString formattedValue;
|
||||
formattedValue.AppendInt(aValue);
|
||||
formattedValue.AppendFloat(aValue.ToFloat());
|
||||
|
||||
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::fontWeight, formattedValue);
|
||||
}
|
||||
|
||||
int32_t
|
||||
FontWeight
|
||||
TextAttrsMgr::FontWeightTextAttr::
|
||||
GetFontWeight(nsIFrame* aFrame)
|
||||
{
|
||||
|
@ -645,8 +646,9 @@ TextAttrsMgr::FontWeightTextAttr::
|
|||
// bold font, i.e. synthetic bolding is used. IsSyntheticBold method is only
|
||||
// needed on Mac, but it is "safe" to use on all platforms. (For non-Mac
|
||||
// platforms it always return false.)
|
||||
if (font->IsSyntheticBold())
|
||||
return 700;
|
||||
if (font->IsSyntheticBold()) {
|
||||
return FontWeight::Bold();
|
||||
}
|
||||
|
||||
// On Windows, font->GetStyle()->weight will give the same weight as
|
||||
// fontEntry->Weight(), the weight of the first font in the font group,
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#ifndef nsTextAttrs_h_
|
||||
#define nsTextAttrs_h_
|
||||
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsString.h"
|
||||
|
@ -354,7 +355,7 @@ protected:
|
|||
/**
|
||||
* Class is used for the work with "font-weight" text attribute.
|
||||
*/
|
||||
class FontWeightTextAttr : public TTextAttr<int32_t>
|
||||
class FontWeightTextAttr : public TTextAttr<mozilla::FontWeight>
|
||||
{
|
||||
public:
|
||||
FontWeightTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame);
|
||||
|
@ -363,13 +364,14 @@ protected:
|
|||
protected:
|
||||
|
||||
// TTextAttr
|
||||
virtual bool GetValueFor(Accessible* aAccessible, int32_t* aValue)
|
||||
virtual bool GetValueFor(Accessible* aAccessible,
|
||||
mozilla::FontWeight* aValue)
|
||||
override;
|
||||
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
|
||||
const int32_t& aValue) override;
|
||||
const mozilla::FontWeight& aValue) override;
|
||||
|
||||
private:
|
||||
int32_t GetFontWeight(nsIFrame* aFrame);
|
||||
mozilla::FontWeight GetFontWeight(nsIFrame* aFrame);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -117,7 +117,7 @@ struct FontListEntry {
|
|||
nsString familyName;
|
||||
nsString faceName;
|
||||
nsCString filepath;
|
||||
uint16_t weight;
|
||||
float weight;
|
||||
int16_t stretch;
|
||||
uint8_t italic;
|
||||
uint8_t index;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "nsMathMLElement.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsITableCellLayout.h" // for MAX_COLSPAN / MAX_ROWSPAN
|
||||
#include "nsCRT.h"
|
||||
|
@ -726,10 +727,10 @@ nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
|
|||
str.CompressWhitespace();
|
||||
if (str.EqualsASCII("normal")) {
|
||||
aData->SetKeywordValue(eCSSProperty_font_weight,
|
||||
NS_FONT_WEIGHT_NORMAL);
|
||||
FontWeight::Normal().ToFloat());
|
||||
} else if (str.EqualsASCII("bold")) {
|
||||
aData->SetKeywordValue(eCSSProperty_font_weight,
|
||||
NS_FONT_WEIGHT_BOLD);
|
||||
FontWeight::Bold().ToFloat());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ ScaledFontDWrite::ScaledFontDWrite(IDWriteFontFace *aFontFace,
|
|||
, mContrast(aContrast)
|
||||
{
|
||||
if (aStyle) {
|
||||
mStyle = SkFontStyle(aStyle->weight,
|
||||
mStyle = SkFontStyle(aStyle->weight.ToIntRounded(),
|
||||
DWriteFontStretchFromStretch(aStyle->stretch),
|
||||
aStyle->style == NS_FONT_STYLE_NORMAL ?
|
||||
SkFontStyle::kUpright_Slant : SkFontStyle::kItalic_Slant);
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/* font specific types shared by both thebes and layout */
|
||||
|
||||
#ifndef GFX_FONT_PROPERTY_TYPES_H
|
||||
#define GFX_FONT_PROPERTY_TYPES_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
/*
|
||||
* This file is separate from gfxFont.h so that layout can include it
|
||||
* without bringing in gfxFont.h and everything it includes.
|
||||
*/
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
/**
|
||||
* A type that will in future encode a value as fixed point.
|
||||
*/
|
||||
class FontFixedPointValue
|
||||
{
|
||||
public:
|
||||
// Ugh. We need a default constructor to allow this type to be used in the
|
||||
// union in nsCSSValue. Furthermore we need the default and copy
|
||||
// constructors to be "trivial" (i.e. the compiler implemented defaults that
|
||||
// do no initialization).
|
||||
// Annoyingly it seems we can't make the default implementations constexpr
|
||||
// (at least in clang). We'd like to do that to allow Thin() et. al. below
|
||||
// to also be constexpr. :/
|
||||
FontFixedPointValue() = default;
|
||||
FontFixedPointValue(const FontFixedPointValue& aOther) = default;
|
||||
|
||||
// Not currently encoded, but it will be in future
|
||||
explicit FontFixedPointValue(int16_t aValue)
|
||||
: mEncoded(aValue)
|
||||
{}
|
||||
|
||||
explicit FontFixedPointValue(int32_t aValue)
|
||||
: mEncoded(aValue)
|
||||
{}
|
||||
|
||||
explicit FontFixedPointValue(float aValue)
|
||||
: mEncoded(int16_t(aValue))
|
||||
{}
|
||||
|
||||
float ToFloat() const {
|
||||
return float(mEncoded);
|
||||
}
|
||||
|
||||
int16_t ToIntRounded() const {
|
||||
return mEncoded;
|
||||
}
|
||||
|
||||
bool operator==(const FontFixedPointValue& aOther) const {
|
||||
return mEncoded == aOther.mEncoded;
|
||||
}
|
||||
|
||||
bool operator!=(const FontFixedPointValue& aOther) const {
|
||||
return mEncoded != aOther.mEncoded;
|
||||
}
|
||||
|
||||
bool operator<(const FontFixedPointValue& aOther) const {
|
||||
return mEncoded < aOther.mEncoded;
|
||||
}
|
||||
|
||||
bool operator<=(const FontFixedPointValue& aOther) const {
|
||||
return mEncoded <= aOther.mEncoded;
|
||||
}
|
||||
|
||||
bool operator>=(const FontFixedPointValue& aOther) const {
|
||||
return mEncoded >= aOther.mEncoded;
|
||||
}
|
||||
|
||||
bool operator>(const FontFixedPointValue& aOther) const {
|
||||
return mEncoded > aOther.mEncoded;
|
||||
}
|
||||
|
||||
int16_t ForHash() const {
|
||||
return mEncoded;
|
||||
}
|
||||
|
||||
protected:
|
||||
int16_t mEncoded;
|
||||
};
|
||||
|
||||
class FontWeight : public FontFixedPointValue
|
||||
{
|
||||
public:
|
||||
// Ugh, to get union in nsCSSValue compiling
|
||||
FontWeight() = default;
|
||||
FontWeight(const FontWeight& aOther) = default;
|
||||
|
||||
// Not currently encoded, but it will be in future
|
||||
explicit FontWeight(int16_t aValue)
|
||||
: FontFixedPointValue(aValue)
|
||||
{}
|
||||
|
||||
explicit FontWeight(int32_t aValue)
|
||||
: FontFixedPointValue(aValue)
|
||||
{}
|
||||
|
||||
explicit FontWeight(float aValue)
|
||||
: FontFixedPointValue(int16_t(aValue))
|
||||
{}
|
||||
|
||||
bool operator==(const FontWeight& aOther) const
|
||||
{
|
||||
return mEncoded == aOther.mEncoded;
|
||||
}
|
||||
|
||||
/// The "distance" between two font weights
|
||||
float operator-(const FontWeight& aOther) const {
|
||||
return this->ToFloat() - aOther.ToFloat();
|
||||
}
|
||||
|
||||
static FontWeight Thin() {
|
||||
return FontWeight{100};
|
||||
}
|
||||
static FontWeight Normal() {
|
||||
return FontWeight{400};
|
||||
}
|
||||
static FontWeight Bold() {
|
||||
return FontWeight{700};
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // GFX_FONT_PROPERTY_TYPES_H
|
||||
|
|
@ -45,6 +45,7 @@ EXPORTS += [
|
|||
EXPORTS.mozilla += [
|
||||
'AppUnits.h',
|
||||
'ArrayView.h',
|
||||
'FontPropertyTypes.h',
|
||||
]
|
||||
|
||||
EXPORTS.mozilla.gfx += [
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "gfxFontConstants.h" // for NS_FONT_KERNING_AUTO, etc
|
||||
#include "gfxFontFeatures.h"
|
||||
#include "gfxFontVariations.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/RefPtr.h" // for RefPtr
|
||||
#include "nsColor.h" // for nsColor and NS_RGBA
|
||||
#include "nsCoord.h" // for nscoord
|
||||
|
@ -44,6 +45,7 @@ const uint8_t kGenericFont_fantasy = 0x20;
|
|||
|
||||
// Font structure.
|
||||
struct nsFont {
|
||||
typedef mozilla::FontWeight FontWeight;
|
||||
|
||||
// list of font families, either named or generic
|
||||
mozilla::FontFamilyList fontlist;
|
||||
|
@ -79,7 +81,7 @@ struct nsFont {
|
|||
nscolor fontSmoothingBackgroundColor = NS_RGBA(0,0,0,0);
|
||||
|
||||
// The weight of the font; see gfxFontConstants.h.
|
||||
uint16_t weight = NS_FONT_WEIGHT_NORMAL;
|
||||
FontWeight weight = FontWeight::Normal();
|
||||
|
||||
// The stretch of the font (the sum of various NS_FONT_STRETCH_*
|
||||
// constants; see gfxFontConstants.h).
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/intl/OSPreferences.h"
|
||||
|
||||
|
@ -219,12 +220,12 @@ gfxDWriteFontFamily::FindStyleVariations(FontInfoData *aFontInfoData)
|
|||
|
||||
if (LOG_FONTLIST_ENABLED()) {
|
||||
LOG_FONTLIST(("(fontlist) added (%s) to family (%s)"
|
||||
" with style: %s weight: %d stretch: %d psname: %s fullname: %s",
|
||||
" with style: %s weight: %g stretch: %d psname: %s fullname: %s",
|
||||
NS_ConvertUTF16toUTF8(fe->Name()).get(),
|
||||
NS_ConvertUTF16toUTF8(Name()).get(),
|
||||
(fe->IsItalic()) ?
|
||||
"italic" : (fe->IsOblique() ? "oblique" : "normal"),
|
||||
fe->Weight(), fe->Stretch(),
|
||||
fe->Weight().ToFloat(), fe->Stretch(),
|
||||
NS_ConvertUTF16toUTF8(psname).get(),
|
||||
NS_ConvertUTF16toUTF8(fullname).get()));
|
||||
}
|
||||
|
@ -956,7 +957,7 @@ gfxDWriteFontList::GetDefaultFontForPlatform(const gfxFontStyle *aStyle)
|
|||
|
||||
gfxFontEntry *
|
||||
gfxDWriteFontList::LookupLocalFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle)
|
||||
{
|
||||
|
@ -980,7 +981,7 @@ gfxDWriteFontList::LookupLocalFont(const nsAString& aFontName,
|
|||
|
||||
gfxFontEntry *
|
||||
gfxDWriteFontList::MakePlatformFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const uint8_t* aFontData,
|
||||
|
@ -1151,12 +1152,12 @@ gfxDWriteFontList::InitFontListForPlatform()
|
|||
if (LOG_FONTLIST_ENABLED()) {
|
||||
gfxFontEntry *fe = faces[i];
|
||||
LOG_FONTLIST(("(fontlist) moved (%s) to family (%s)"
|
||||
" with style: %s weight: %d stretch: %d",
|
||||
" with style: %s weight: %g stretch: %d",
|
||||
NS_ConvertUTF16toUTF8(fe->Name()).get(),
|
||||
NS_ConvertUTF16toUTF8(gillSansMTFamily->Name()).get(),
|
||||
(fe->IsItalic()) ?
|
||||
"italic" : (fe->IsOblique() ? "oblique" : "normal"),
|
||||
fe->Weight(), fe->Stretch()));
|
||||
fe->Weight().ToFloat(), fe->Stretch()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#ifndef GFX_DWRITEFONTLIST_H
|
||||
#define GFX_DWRITEFONTLIST_H
|
||||
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "gfxDWriteCommon.h"
|
||||
#include "dwrite_3.h"
|
||||
|
@ -46,6 +47,8 @@ class gfxDWriteFontEntry;
|
|||
class gfxDWriteFontFamily : public gfxFontFamily
|
||||
{
|
||||
public:
|
||||
typedef mozilla::FontWeight FontWeight;
|
||||
|
||||
/**
|
||||
* Constructs a new DWriteFont Family.
|
||||
*
|
||||
|
@ -119,7 +122,7 @@ public:
|
|||
|
||||
weight = std::max<uint16_t>(100, weight);
|
||||
weight = std::min<uint16_t>(900, weight);
|
||||
mWeight = weight;
|
||||
mWeight = FontWeight(weight);
|
||||
|
||||
mIsCJK = UNINITIALIZED_VALUE;
|
||||
}
|
||||
|
@ -137,7 +140,7 @@ public:
|
|||
*/
|
||||
gfxDWriteFontEntry(const nsAString& aFaceName,
|
||||
IDWriteFont *aFont,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle)
|
||||
: gfxFontEntry(aFaceName), mFont(aFont), mFontFile(nullptr),
|
||||
|
@ -164,7 +167,7 @@ public:
|
|||
gfxDWriteFontEntry(const nsAString& aFaceName,
|
||||
IDWriteFontFile *aFontFile,
|
||||
IDWriteFontFileStream *aFontFileStream,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle)
|
||||
: gfxFontEntry(aFaceName), mFont(nullptr),
|
||||
|
@ -401,12 +404,12 @@ public:
|
|||
gfxFontFamily* CreateFontFamily(const nsAString& aName) const override;
|
||||
|
||||
virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle);
|
||||
|
||||
virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const uint8_t* aFontData,
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "gfxTextRun.h"
|
||||
|
||||
#include "harfbuzz/hb.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::gfx;
|
||||
|
@ -135,7 +136,7 @@ bool
|
|||
gfxDWriteFont::GetFakeMetricsForArialBlack(DWRITE_FONT_METRICS *aFontMetrics)
|
||||
{
|
||||
gfxFontStyle style(mStyle);
|
||||
style.weight = 700;
|
||||
style.weight = FontWeight(700);
|
||||
bool needsBold;
|
||||
|
||||
gfxFontEntry* fe =
|
||||
|
@ -156,7 +157,7 @@ void
|
|||
gfxDWriteFont::ComputeMetrics(AntialiasOption anAAOption)
|
||||
{
|
||||
DWRITE_FONT_METRICS fontMetrics;
|
||||
if (!(mFontEntry->Weight() == 900 &&
|
||||
if (!(mFontEntry->Weight() == FontWeight(900) &&
|
||||
!mFontEntry->IsUserFont() &&
|
||||
mFontEntry->Name().EqualsLiteral("Arial Black") &&
|
||||
GetFakeMetricsForArialBlack(&fontMetrics)))
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/Base64.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
|
@ -256,7 +257,7 @@ FT2FontEntry::CreateFontInstance(const gfxFontStyle *aFontStyle, bool aNeedsBold
|
|||
/* static */
|
||||
FT2FontEntry*
|
||||
FT2FontEntry::CreateFontEntry(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const uint8_t* aFontData,
|
||||
|
@ -327,7 +328,9 @@ FT2FontEntry::CreateFontEntry(const FontListEntry& aFLE)
|
|||
FT2FontEntry *fe = new FT2FontEntry(aFLE.faceName());
|
||||
fe->mFilename = aFLE.filepath();
|
||||
fe->mFTFontIndex = aFLE.index();
|
||||
fe->mWeight = aFLE.weight();
|
||||
// The weight transported across IPC is a float, so we need to explicitly
|
||||
// convert it back to a FontWeight.
|
||||
fe->mWeight = FontWeight(aFLE.weight());
|
||||
fe->mStretch = aFLE.stretch();
|
||||
fe->mStyle = (aFLE.italic() ? NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL);
|
||||
return fe;
|
||||
|
@ -340,7 +343,7 @@ FTFaceIsItalic(FT_Face aFace)
|
|||
return !!(aFace->style_flags & FT_STYLE_FLAG_ITALIC);
|
||||
}
|
||||
|
||||
static uint16_t
|
||||
static FontWeight
|
||||
FTFaceGetWeight(FT_Face aFace)
|
||||
{
|
||||
TT_OS2 *os2 = static_cast<TT_OS2*>(FT_Get_Sfnt_Table(aFace, ft_sfnt_os2));
|
||||
|
@ -368,7 +371,7 @@ FTFaceGetWeight(FT_Face aFace)
|
|||
|
||||
NS_ASSERTION(result >= 100 && result <= 900, "Invalid weight in font!");
|
||||
|
||||
return result;
|
||||
return FontWeight(result);
|
||||
}
|
||||
|
||||
// Used to create the font entry for installed faces on the device,
|
||||
|
@ -660,10 +663,13 @@ FT2FontFamily::AddFacesToFontList(InfallibleTArray<FontListEntry>* aFontList)
|
|||
if (!fe) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// We convert the weight to a float purely for transport across IPC.
|
||||
// Ideally we'd avoid doing that.
|
||||
aFontList->AppendElement(FontListEntry(Name(), fe->Name(),
|
||||
fe->mFilename,
|
||||
fe->Weight(), fe->Stretch(),
|
||||
fe->Weight().ToFloat(),
|
||||
fe->Stretch(),
|
||||
fe->mStyle,
|
||||
fe->mFTFontIndex));
|
||||
}
|
||||
|
@ -985,7 +991,7 @@ AppendToFaceList(nsCString& aFaceList,
|
|||
aFaceList.Append(',');
|
||||
aFaceList.Append(aFontEntry->IsItalic() ? '1' : '0');
|
||||
aFaceList.Append(',');
|
||||
aFaceList.AppendInt(aFontEntry->Weight());
|
||||
aFaceList.AppendFloat(aFontEntry->Weight().ToFloat());
|
||||
aFaceList.Append(',');
|
||||
aFaceList.AppendInt(aFontEntry->Stretch());
|
||||
aFaceList.Append(',');
|
||||
|
@ -1144,11 +1150,11 @@ gfxFT2FontList::AddFaceToList(const nsCString& aEntryName, uint32_t aIndex,
|
|||
AppendToFaceList(aFaceList, name, fe);
|
||||
if (LOG_ENABLED()) {
|
||||
LOG(("(fontinit) added (%s) to family (%s)"
|
||||
" with style: %s weight: %d stretch: %d",
|
||||
" with style: %s weight: %g stretch: %d",
|
||||
NS_ConvertUTF16toUTF8(fe->Name()).get(),
|
||||
NS_ConvertUTF16toUTF8(family->Name()).get(),
|
||||
fe->IsItalic() ? "italic" : "normal",
|
||||
fe->Weight(), fe->Stretch()));
|
||||
fe->Weight().ToFloat(), fe->Stretch()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1458,7 +1464,7 @@ gfxFT2FontList::InitFontListForPlatform()
|
|||
|
||||
gfxFontEntry*
|
||||
gfxFT2FontList::LookupLocalFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle)
|
||||
{
|
||||
|
@ -1540,7 +1546,7 @@ gfxFT2FontList::GetDefaultFontForPlatform(const gfxFontStyle* aStyle)
|
|||
|
||||
gfxFontEntry*
|
||||
gfxFT2FontList::MakePlatformFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const uint8_t* aFontData,
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
// create a font entry for a downloaded font
|
||||
static FT2FontEntry*
|
||||
CreateFontEntry(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const uint8_t* aFontData,
|
||||
|
@ -122,12 +122,12 @@ public:
|
|||
virtual ~gfxFT2FontList();
|
||||
|
||||
virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle) override;
|
||||
|
||||
virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const uint8_t* aFontData,
|
||||
|
|
|
@ -160,40 +160,40 @@ GetFaceNames(FcPattern* aFont, const nsAString& aFamilyName,
|
|||
}
|
||||
}
|
||||
|
||||
static uint16_t
|
||||
static FontWeight
|
||||
MapFcWeight(int aFcWeight)
|
||||
{
|
||||
if (aFcWeight <= (FC_WEIGHT_THIN + FC_WEIGHT_EXTRALIGHT) / 2) {
|
||||
return 100;
|
||||
return FontWeight(100);
|
||||
}
|
||||
if (aFcWeight <= (FC_WEIGHT_EXTRALIGHT + FC_WEIGHT_LIGHT) / 2) {
|
||||
return 200;
|
||||
return FontWeight(200);
|
||||
}
|
||||
if (aFcWeight <= (FC_WEIGHT_LIGHT + FC_WEIGHT_BOOK) / 2) {
|
||||
return 300;
|
||||
return FontWeight(300);
|
||||
}
|
||||
if (aFcWeight <= (FC_WEIGHT_REGULAR + FC_WEIGHT_MEDIUM) / 2) {
|
||||
// This includes FC_WEIGHT_BOOK
|
||||
return 400;
|
||||
return FontWeight(400);
|
||||
}
|
||||
if (aFcWeight <= (FC_WEIGHT_MEDIUM + FC_WEIGHT_DEMIBOLD) / 2) {
|
||||
return 500;
|
||||
return FontWeight(500);
|
||||
}
|
||||
if (aFcWeight <= (FC_WEIGHT_DEMIBOLD + FC_WEIGHT_BOLD) / 2) {
|
||||
return 600;
|
||||
return FontWeight(600);
|
||||
}
|
||||
if (aFcWeight <= (FC_WEIGHT_BOLD + FC_WEIGHT_EXTRABOLD) / 2) {
|
||||
return 700;
|
||||
return FontWeight(700);
|
||||
}
|
||||
if (aFcWeight <= (FC_WEIGHT_EXTRABOLD + FC_WEIGHT_BLACK) / 2) {
|
||||
return 800;
|
||||
return FontWeight(800);
|
||||
}
|
||||
if (aFcWeight <= FC_WEIGHT_BLACK) {
|
||||
return 900;
|
||||
return FontWeight(900);
|
||||
}
|
||||
|
||||
// including FC_WEIGHT_EXTRABLACK
|
||||
return 901;
|
||||
return FontWeight(901);
|
||||
}
|
||||
|
||||
static int16_t
|
||||
|
@ -311,7 +311,7 @@ CreateFaceForPattern(FcPattern* aPattern)
|
|||
}
|
||||
|
||||
gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsAString& aFaceName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const uint8_t *aData,
|
||||
|
@ -334,7 +334,7 @@ gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsAString& aFaceName,
|
|||
|
||||
gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsAString& aFaceName,
|
||||
FcPattern* aFontPattern,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle)
|
||||
: gfxFontEntry(aFaceName), mFontPattern(aFontPattern),
|
||||
|
@ -1202,13 +1202,13 @@ gfxFontconfigFontFamily::FindStyleVariations(FontInfoData *aFontInfoData)
|
|||
|
||||
if (LOG_FONTLIST_ENABLED()) {
|
||||
LOG_FONTLIST(("(fontlist) added (%s) to family (%s)"
|
||||
" with style: %s weight: %d stretch: %d"
|
||||
" with style: %s weight: %g stretch: %d"
|
||||
" psname: %s fullname: %s",
|
||||
NS_ConvertUTF16toUTF8(fontEntry->Name()).get(),
|
||||
NS_ConvertUTF16toUTF8(Name()).get(),
|
||||
(fontEntry->IsItalic()) ?
|
||||
"italic" : (fontEntry->IsOblique() ? "oblique" : "normal"),
|
||||
fontEntry->Weight(), fontEntry->Stretch(),
|
||||
fontEntry->Weight().ToFloat(), fontEntry->Stretch(),
|
||||
NS_ConvertUTF16toUTF8(psname).get(),
|
||||
NS_ConvertUTF16toUTF8(fullname).get()));
|
||||
}
|
||||
|
@ -1857,7 +1857,7 @@ gfxFcPlatformFontList::GetDefaultFontForPlatform(const gfxFontStyle* aStyle)
|
|||
|
||||
gfxFontEntry*
|
||||
gfxFcPlatformFontList::LookupLocalFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle)
|
||||
{
|
||||
|
@ -1876,7 +1876,7 @@ gfxFcPlatformFontList::LookupLocalFont(const nsAString& aFontName,
|
|||
|
||||
gfxFontEntry*
|
||||
gfxFcPlatformFontList::MakePlatformFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const uint8_t* aFontData,
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "gfxFontEntry.h"
|
||||
#include "gfxFT2FontBase.h"
|
||||
#include "gfxPlatformFontList.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/mozalloc.h"
|
||||
#include "nsAutoRef.h"
|
||||
#include "nsClassHashtable.h"
|
||||
|
@ -93,7 +94,7 @@ public:
|
|||
// used for data fonts where the fontentry takes ownership
|
||||
// of the font data and the FT_Face
|
||||
explicit gfxFontconfigFontEntry(const nsAString& aFaceName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const uint8_t *aData,
|
||||
|
@ -103,7 +104,7 @@ public:
|
|||
// used for @font-face local system fonts with explicit patterns
|
||||
explicit gfxFontconfigFontEntry(const nsAString& aFaceName,
|
||||
FcPattern* aFontPattern,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle);
|
||||
|
||||
|
@ -287,11 +288,13 @@ public:
|
|||
InfallibleTArray<mozilla::dom::SystemFontListEntry>* retValue);
|
||||
|
||||
gfxFontEntry*
|
||||
LookupLocalFont(const nsAString& aFontName, uint16_t aWeight,
|
||||
LookupLocalFont(const nsAString& aFontName,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch, uint8_t aStyle) override;
|
||||
|
||||
gfxFontEntry*
|
||||
MakePlatformFont(const nsAString& aFontName, uint16_t aWeight,
|
||||
MakePlatformFont(const nsAString& aFontName,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const uint8_t* aFontData,
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "mozilla/BinarySearch.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/MathAlgorithms.h"
|
||||
#include "mozilla/SVGContextPaint.h"
|
||||
|
@ -3521,7 +3522,7 @@ gfxFont::GetSmallCapsFont()
|
|||
style.size *= SMALL_CAPS_SCALE_FACTOR;
|
||||
style.variantCaps = NS_FONT_VARIANT_CAPS_NORMAL;
|
||||
gfxFontEntry* fe = GetFontEntry();
|
||||
bool needsBold = style.weight >= 600 && !fe->IsBold();
|
||||
bool needsBold = style.weight >= FontWeight(600) && !fe->IsBold();
|
||||
return fe->FindOrMakeFont(&style, needsBold, mUnicodeRangeMap);
|
||||
}
|
||||
|
||||
|
@ -3531,7 +3532,7 @@ gfxFont::GetSubSuperscriptFont(int32_t aAppUnitsPerDevPixel)
|
|||
gfxFontStyle style(*GetStyle());
|
||||
style.AdjustForSubSuperscript(aAppUnitsPerDevPixel);
|
||||
gfxFontEntry* fe = GetFontEntry();
|
||||
bool needsBold = style.weight >= 600 && !fe->IsBold();
|
||||
bool needsBold = style.weight >= FontWeight(600) && !fe->IsBold();
|
||||
return fe->FindOrMakeFont(&style, needsBold, mUnicodeRangeMap);
|
||||
}
|
||||
|
||||
|
@ -4110,7 +4111,8 @@ gfxFontStyle::gfxFontStyle() :
|
|||
size(DEFAULT_PIXEL_FONT_SIZE), sizeAdjust(-1.0f), baselineOffset(0.0f),
|
||||
languageOverride(NO_FONT_LANGUAGE_OVERRIDE),
|
||||
fontSmoothingBackgroundColor(NS_RGBA(0, 0, 0, 0)),
|
||||
weight(NS_FONT_WEIGHT_NORMAL), stretch(NS_FONT_STRETCH_NORMAL),
|
||||
weight(FontWeight::Normal()),
|
||||
stretch(NS_FONT_STRETCH_NORMAL),
|
||||
style(NS_FONT_STYLE_NORMAL),
|
||||
variantCaps(NS_FONT_VARIANT_CAPS_NORMAL),
|
||||
variantSubSuper(NS_FONT_VARIANT_POSITION_NORMAL),
|
||||
|
@ -4121,7 +4123,9 @@ gfxFontStyle::gfxFontStyle() :
|
|||
{
|
||||
}
|
||||
|
||||
gfxFontStyle::gfxFontStyle(uint8_t aStyle, uint16_t aWeight, int16_t aStretch,
|
||||
gfxFontStyle::gfxFontStyle(uint8_t aStyle,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
gfxFloat aSize,
|
||||
nsAtom *aLanguage, bool aExplicitLanguage,
|
||||
float aSizeAdjust, bool aSystemFont,
|
||||
|
@ -4133,7 +4137,8 @@ gfxFontStyle::gfxFontStyle(uint8_t aStyle, uint16_t aWeight, int16_t aStretch,
|
|||
size(aSize), sizeAdjust(aSizeAdjust), baselineOffset(0.0f),
|
||||
languageOverride(aLanguageOverride),
|
||||
fontSmoothingBackgroundColor(NS_RGBA(0, 0, 0, 0)),
|
||||
weight(aWeight), stretch(aStretch),
|
||||
weight(aWeight),
|
||||
stretch(aStretch),
|
||||
style(aStyle),
|
||||
variantCaps(NS_FONT_VARIANT_CAPS_NORMAL),
|
||||
variantSubSuper(NS_FONT_VARIANT_POSITION_NORMAL),
|
||||
|
@ -4147,10 +4152,12 @@ gfxFontStyle::gfxFontStyle(uint8_t aStyle, uint16_t aWeight, int16_t aStretch,
|
|||
MOZ_ASSERT(!mozilla::IsNaN(size));
|
||||
MOZ_ASSERT(!mozilla::IsNaN(sizeAdjust));
|
||||
|
||||
if (weight > 900)
|
||||
weight = 900;
|
||||
if (weight < 100)
|
||||
weight = 100;
|
||||
if (weight > FontWeight(900)) {
|
||||
weight = FontWeight(900);
|
||||
}
|
||||
if (weight < FontWeight(100)) {
|
||||
weight = FontWeight(100);
|
||||
}
|
||||
|
||||
if (size >= FONT_MAX_SIZE) {
|
||||
size = FONT_MAX_SIZE;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "nsIObserver.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/TypedEnumBits.h"
|
||||
#include "MainThreadUtils.h"
|
||||
#include <algorithm>
|
||||
|
@ -75,8 +76,10 @@ class SVGContextPaint;
|
|||
} // namespace mozilla
|
||||
|
||||
struct gfxFontStyle {
|
||||
typedef mozilla::FontWeight FontWeight;
|
||||
|
||||
gfxFontStyle();
|
||||
gfxFontStyle(uint8_t aStyle, uint16_t aWeight, int16_t aStretch,
|
||||
gfxFontStyle(uint8_t aStyle, FontWeight aWeight, int16_t aStretch,
|
||||
gfxFloat aSize, nsAtom *aLanguage, bool aExplicitLanguage,
|
||||
float aSizeAdjust, bool aSystemFont,
|
||||
bool aPrinterFont,
|
||||
|
@ -137,7 +140,7 @@ struct gfxFontStyle {
|
|||
nscolor fontSmoothingBackgroundColor;
|
||||
|
||||
// The weight of the font: 100, 200, ... 900.
|
||||
uint16_t weight;
|
||||
FontWeight weight;
|
||||
|
||||
// The stretch of the font (the sum of various NS_FONT_STRETCH_*
|
||||
// constants; see gfxFontConstants.h).
|
||||
|
@ -184,8 +187,8 @@ struct gfxFontStyle {
|
|||
}
|
||||
|
||||
PLDHashNumber Hash() const {
|
||||
return ((style + (systemFont << 7) +
|
||||
(weight << 8)) + uint32_t(size*1000) + int32_t(sizeAdjust*1000)) ^
|
||||
return (style + (systemFont << 7) + (weight.ForHash() << 8) +
|
||||
uint32_t(size*1000) + int32_t(sizeAdjust*1000)) ^
|
||||
nsRefPtrHashKey<nsAtom>::HashKey(language);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,12 +3,14 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "gfxFontEntry.h"
|
||||
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/MathAlgorithms.h"
|
||||
|
||||
#include "mozilla/Logging.h"
|
||||
|
||||
#include "gfxFontEntry.h"
|
||||
#include "gfxTextRun.h"
|
||||
#include "gfxPlatform.h"
|
||||
#include "nsGkAtoms.h"
|
||||
|
@ -1234,24 +1236,25 @@ StretchDistance(int16_t aFontStretch, int16_t aTargetStretch)
|
|||
|
||||
// weight distance ==> [0,1598]
|
||||
static inline uint32_t
|
||||
WeightDistance(uint32_t aFontWeight, uint32_t aTargetWeight)
|
||||
WeightDistance(FontWeight aFontWeight, FontWeight aTargetWeight)
|
||||
{
|
||||
// Compute a measure of the "distance" between the requested
|
||||
// weight and the given fontEntry
|
||||
|
||||
int32_t distance = 0, addedDistance = 0;
|
||||
float distance = 0.0f, addedDistance = 0.0f;
|
||||
if (aTargetWeight != aFontWeight) {
|
||||
if (aTargetWeight > 500) {
|
||||
if (aTargetWeight > FontWeight(500)) {
|
||||
distance = aFontWeight - aTargetWeight;
|
||||
} else if (aTargetWeight < 400) {
|
||||
} else if (aTargetWeight < FontWeight(400)) {
|
||||
distance = aTargetWeight - aFontWeight;
|
||||
} else {
|
||||
// special case - target is between 400 and 500
|
||||
|
||||
// font weights between 400 and 500 are close
|
||||
if (aFontWeight >= 400 && aFontWeight <= 500) {
|
||||
if (aFontWeight >= FontWeight(400) &&
|
||||
aFontWeight <= FontWeight(500)) {
|
||||
if (aFontWeight < aTargetWeight) {
|
||||
distance = 500 - aFontWeight;
|
||||
distance = FontWeight(500) - aFontWeight;
|
||||
} else {
|
||||
distance = aFontWeight - aTargetWeight;
|
||||
}
|
||||
|
@ -1263,7 +1266,7 @@ WeightDistance(uint32_t aFontWeight, uint32_t aTargetWeight)
|
|||
addedDistance = 100;
|
||||
}
|
||||
}
|
||||
if (distance < 0) {
|
||||
if (distance < 0.0f) {
|
||||
distance = -distance + REVERSE_WEIGHT_DISTANCE;
|
||||
}
|
||||
distance += addedDistance;
|
||||
|
@ -1307,7 +1310,7 @@ gfxFontFamily::FindAllFontsForStyle(const gfxFontStyle& aFontStyle,
|
|||
|
||||
aNeedsSyntheticBold = false;
|
||||
|
||||
bool wantBold = aFontStyle.weight >= 600;
|
||||
bool wantBold = aFontStyle.weight >= FontWeight(600);
|
||||
gfxFontEntry *fe = nullptr;
|
||||
|
||||
// If the family has only one face, we simply return it; no further
|
||||
|
@ -1406,7 +1409,7 @@ gfxFontFamily::FindAllFontsForStyle(const gfxFontStyle& aFontStyle,
|
|||
|
||||
if (matched) {
|
||||
aFontEntryList.AppendElement(matched);
|
||||
if (!matched->IsBold() && aFontStyle.weight >= 600 &&
|
||||
if (!matched->IsBold() && aFontStyle.weight >= FontWeight(600) &&
|
||||
aFontStyle.allowSyntheticWeight) {
|
||||
aNeedsSyntheticBold = true;
|
||||
}
|
||||
|
@ -1442,7 +1445,7 @@ gfxFontFamily::CheckForSimpleFamily()
|
|||
return;
|
||||
}
|
||||
uint8_t faceIndex = (fe->IsItalic() ? kItalicMask : 0) |
|
||||
(fe->Weight() >= 600 ? kBoldMask : 0);
|
||||
(fe->Weight() >= FontWeight(600) ? kBoldMask : 0);
|
||||
if (faces[faceIndex]) {
|
||||
return; // two faces resolve to the same slot; family isn't "simple"
|
||||
}
|
||||
|
@ -1501,7 +1504,7 @@ CalcStyleMatch(gfxFontEntry *aFontEntry, const gfxFontStyle *aStyle)
|
|||
}
|
||||
|
||||
// measure of closeness of weight to the desired value
|
||||
rank += 9 - Abs((aFontEntry->Weight() - aStyle->weight) / 100);
|
||||
rank += 9 - Abs((aFontEntry->Weight() - aStyle->weight) / 100.0f);
|
||||
} else {
|
||||
// if no font to match, prefer non-bold, non-italic fonts
|
||||
if (aFontEntry->IsUpright()) {
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "nsUnicodeScriptCodes.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "harfbuzz/hb.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/WeakPtr.h"
|
||||
|
@ -109,6 +110,7 @@ struct gfxFontFeatureInfo {
|
|||
|
||||
class gfxFontEntry {
|
||||
public:
|
||||
typedef mozilla::FontWeight FontWeight;
|
||||
typedef mozilla::gfx::DrawTarget DrawTarget;
|
||||
typedef mozilla::unicode::Script Script;
|
||||
|
||||
|
@ -139,7 +141,7 @@ public:
|
|||
// returns Name() if nothing better is available.
|
||||
virtual nsString RealFaceName();
|
||||
|
||||
uint16_t Weight() const { return mWeight; }
|
||||
FontWeight Weight() const { return mWeight; }
|
||||
int16_t Stretch() const { return mStretch; }
|
||||
|
||||
bool IsUserFont() const { return mIsDataUserFont || mIsLocalUserFont; }
|
||||
|
@ -148,7 +150,7 @@ public:
|
|||
bool IsItalic() const { return mStyle == NS_FONT_STYLE_ITALIC; }
|
||||
bool IsOblique() const { return mStyle == NS_FONT_STYLE_OBLIQUE; }
|
||||
bool IsUpright() const { return mStyle == NS_FONT_STYLE_NORMAL; }
|
||||
bool IsBold() const { return mWeight >= 600; } // bold == weights 600 and above
|
||||
bool IsBold() const { return mWeight >= FontWeight(600); } // bold == weights 600 and above
|
||||
bool IgnoreGDEF() const { return mIgnoreGDEF; }
|
||||
bool IgnoreGSUB() const { return mIgnoreGSUB; }
|
||||
|
||||
|
@ -161,7 +163,7 @@ public:
|
|||
bool IsNormalStyle() const
|
||||
{
|
||||
return IsUpright() &&
|
||||
Weight() == NS_FONT_WEIGHT_NORMAL &&
|
||||
Weight() == FontWeight::Normal() &&
|
||||
Stretch() == NS_FONT_STRETCH_NORMAL;
|
||||
}
|
||||
|
||||
|
@ -402,7 +404,7 @@ public:
|
|||
uint32_t mDefaultSubSpaceFeatures[(int(Script::NUM_SCRIPT_CODES) + 31) / 32];
|
||||
uint32_t mNonDefaultSubSpaceFeatures[(int(Script::NUM_SCRIPT_CODES) + 31) / 32];
|
||||
|
||||
uint16_t mWeight;
|
||||
FontWeight mWeight;
|
||||
int16_t mStretch;
|
||||
|
||||
RefPtr<gfxCharacterMap> mCharacterMap;
|
||||
|
|
|
@ -445,20 +445,20 @@ gfxGDIFont::FillLogFont(LOGFONTW& aLogFont, gfxFloat aSize)
|
|||
{
|
||||
GDIFontEntry *fe = static_cast<GDIFontEntry*>(GetFontEntry());
|
||||
|
||||
uint16_t weight;
|
||||
FontWeight weight;
|
||||
if (fe->IsUserFont()) {
|
||||
if (fe->IsLocalUserFont()) {
|
||||
// for local user fonts, don't change the original weight
|
||||
// in the entry's logfont, because that could alter the
|
||||
// choice of actual face used (bug 724231)
|
||||
weight = 0;
|
||||
weight = FontWeight(0);
|
||||
} else {
|
||||
// avoid GDI synthetic bold which occurs when weight
|
||||
// specified is >= font data weight + 200
|
||||
weight = mNeedsBold ? 700 : 200;
|
||||
weight = mNeedsBold ? FontWeight(700) : FontWeight(200);
|
||||
}
|
||||
} else {
|
||||
weight = mNeedsBold ? 700 : fe->Weight();
|
||||
weight = mNeedsBold ? FontWeight(700) : fe->Weight();
|
||||
}
|
||||
|
||||
fe->FillLogFont(&aLogFont, weight, aSize);
|
||||
|
|
|
@ -115,7 +115,8 @@ FontTypeToOutPrecision(uint8_t fontType)
|
|||
|
||||
GDIFontEntry::GDIFontEntry(const nsAString& aFaceName,
|
||||
gfxWindowsFontType aFontType,
|
||||
uint8_t aStyle, uint16_t aWeight,
|
||||
uint8_t aStyle,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
gfxUserFontData *aUserFontData)
|
||||
: gfxFontEntry(aFaceName),
|
||||
|
@ -255,7 +256,8 @@ GDIFontEntry::LookupUnscaledFont(HFONT aFont)
|
|||
|
||||
void
|
||||
GDIFontEntry::FillLogFont(LOGFONTW *aLogFont,
|
||||
uint16_t aWeight, gfxFloat aSize)
|
||||
FontWeight aWeight,
|
||||
gfxFloat aSize)
|
||||
{
|
||||
memcpy(aLogFont, &mLogFont, sizeof(LOGFONTW));
|
||||
|
||||
|
@ -270,8 +272,8 @@ GDIFontEntry::FillLogFont(LOGFONTW *aLogFont,
|
|||
// for installed families with no bold face, and for downloaded fonts
|
||||
// (but NOT for local user fonts, because it could cause a different,
|
||||
// glyph-incompatible face to be used)
|
||||
if (aWeight) {
|
||||
aLogFont->lfWeight = aWeight;
|
||||
if (aWeight.ToFloat() != 0.0f) {
|
||||
aLogFont->lfWeight = LONG(aWeight.ToFloat());
|
||||
}
|
||||
|
||||
// for non-local() user fonts, we never want to apply italics here;
|
||||
|
@ -382,7 +384,7 @@ GDIFontEntry::InitLogFont(const nsAString& aName,
|
|||
// it may give us a regular one based on weight. Windows should
|
||||
// do fake italic for us in that case.
|
||||
mLogFont.lfItalic = !IsUpright();
|
||||
mLogFont.lfWeight = mWeight;
|
||||
mLogFont.lfWeight = int(mWeight.ToFloat());
|
||||
|
||||
int len = std::min<int>(aName.Length(), LF_FACESIZE - 1);
|
||||
memcpy(&mLogFont.lfFaceName, aName.BeginReading(), len * sizeof(char16_t));
|
||||
|
@ -393,7 +395,8 @@ GDIFontEntry*
|
|||
GDIFontEntry::CreateFontEntry(const nsAString& aName,
|
||||
gfxWindowsFontType aFontType,
|
||||
uint8_t aStyle,
|
||||
uint16_t aWeight, int16_t aStretch,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
gfxUserFontData* aUserFontData)
|
||||
{
|
||||
// jtdfix - need to set charset, unicode ranges, pitch/family
|
||||
|
@ -464,7 +467,7 @@ GDIFontFamily::FamilyAddStylesProc(const ENUMLOGFONTEXW *lpelfe,
|
|||
for (uint32_t i = 0; i < ff->mAvailableFonts.Length(); ++i) {
|
||||
fe = static_cast<GDIFontEntry*>(ff->mAvailableFonts[i].get());
|
||||
// check if we already know about this face
|
||||
if (fe->mWeight == logFont.lfWeight &&
|
||||
if (fe->mWeight == FontWeight(int32_t(logFont.lfWeight)) &&
|
||||
fe->IsItalic() == (logFont.lfItalic == 0xFF)) {
|
||||
// update the charset bit here since this could be different
|
||||
// XXX Can we still do this now that we store mCharset
|
||||
|
@ -481,7 +484,7 @@ GDIFontFamily::FamilyAddStylesProc(const ENUMLOGFONTEXW *lpelfe,
|
|||
NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL);
|
||||
fe = GDIFontEntry::CreateFontEntry(nsDependentString(lpelfe->elfFullName),
|
||||
feType, italicStyle,
|
||||
(uint16_t) (logFont.lfWeight), 0,
|
||||
FontWeight(int32_t(logFont.lfWeight)), 0,
|
||||
nullptr);
|
||||
if (!fe)
|
||||
return 1;
|
||||
|
@ -707,7 +710,7 @@ gfxGDIFontList::EnumFontFamExProc(ENUMLOGFONTEXW *lpelfe,
|
|||
|
||||
gfxFontEntry*
|
||||
gfxGDIFontList::LookupLocalFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle)
|
||||
{
|
||||
|
@ -734,7 +737,7 @@ gfxGDIFontList::LookupLocalFont(const nsAString& aFontName,
|
|||
fe->mIsLocalUserFont = true;
|
||||
|
||||
// make the new font entry match the userfont entry style characteristics
|
||||
fe->mWeight = (aWeight == 0 ? 400 : aWeight);
|
||||
fe->mWeight = (aWeight == FontWeight(0) ? FontWeight(400) : aWeight);
|
||||
fe->mStyle = aStyle;
|
||||
|
||||
return fe;
|
||||
|
@ -799,7 +802,7 @@ FixupSymbolEncodedFont(uint8_t* aFontData, uint32_t aLength)
|
|||
|
||||
gfxFontEntry*
|
||||
gfxGDIFontList::MakePlatformFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const uint8_t* aFontData,
|
||||
|
@ -864,7 +867,7 @@ gfxGDIFontList::MakePlatformFont(const nsAString& aFontName,
|
|||
|
||||
// make a new font entry using the unique name
|
||||
WinUserFontData *winUserFontData = new WinUserFontData(fontRef);
|
||||
uint16_t w = (aWeight == 0 ? 400 : aWeight);
|
||||
FontWeight w = (aWeight == FontWeight(0) ? FontWeight(400) : aWeight);
|
||||
|
||||
GDIFontEntry *fe = GDIFontEntry::CreateFontEntry(uniqueName,
|
||||
gfxWindowsFontType(isCFF ? GFX_FONT_TYPE_PS_OPENTYPE : GFX_FONT_TYPE_TRUETYPE) /*type*/,
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#ifndef GFX_GDIFONTLIST_H
|
||||
#define GFX_GDIFONTLIST_H
|
||||
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "gfxWindowsPlatform.h"
|
||||
#include "gfxPlatformFontList.h"
|
||||
|
@ -107,11 +108,15 @@ enum gfxWindowsFontType {
|
|||
class GDIFontEntry : public gfxFontEntry
|
||||
{
|
||||
public:
|
||||
typedef mozilla::FontWeight FontWeight;
|
||||
|
||||
LPLOGFONTW GetLogFont() { return &mLogFont; }
|
||||
|
||||
nsresult ReadCMAP(FontInfoData *aFontInfoData = nullptr) override;
|
||||
|
||||
void FillLogFont(LOGFONTW *aLogFont, uint16_t aWeight, gfxFloat aSize);
|
||||
void FillLogFont(LOGFONTW *aLogFont,
|
||||
FontWeight aWeight,
|
||||
gfxFloat aSize);
|
||||
|
||||
static gfxWindowsFontType DetermineFontType(const NEWTEXTMETRICW& metrics,
|
||||
DWORD fontType)
|
||||
|
@ -164,12 +169,13 @@ public:
|
|||
static GDIFontEntry* CreateFontEntry(const nsAString& aName,
|
||||
gfxWindowsFontType aFontType,
|
||||
uint8_t aStyle,
|
||||
uint16_t aWeight, int16_t aStretch,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
gfxUserFontData* aUserFontData);
|
||||
|
||||
// create a font entry for a font referenced by its fullname
|
||||
static GDIFontEntry* LoadLocalFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle);
|
||||
|
||||
|
@ -182,7 +188,7 @@ protected:
|
|||
friend class gfxGDIFont;
|
||||
|
||||
GDIFontEntry(const nsAString& aFaceName, gfxWindowsFontType aFontType,
|
||||
uint8_t aStyle, uint16_t aWeight, int16_t aStretch,
|
||||
uint8_t aStyle, FontWeight aWeight, int16_t aStretch,
|
||||
gfxUserFontData *aUserFontData);
|
||||
|
||||
void InitLogFont(const nsAString& aName, gfxWindowsFontType aFontType);
|
||||
|
@ -314,6 +320,8 @@ private:
|
|||
|
||||
class gfxGDIFontList : public gfxPlatformFontList {
|
||||
public:
|
||||
typedef mozilla::FontWeight FontWeight;
|
||||
|
||||
static gfxGDIFontList* PlatformFontList() {
|
||||
return static_cast<gfxGDIFontList*>(sPlatformFontList);
|
||||
}
|
||||
|
@ -330,12 +338,12 @@ public:
|
|||
gfxFloat aDevToCssSize = 1.0) override;
|
||||
|
||||
virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle);
|
||||
|
||||
virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const uint8_t* aFontData,
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "nsRefPtrHashtable.h"
|
||||
|
@ -30,13 +31,13 @@ class MacOSFontEntry : public gfxFontEntry
|
|||
public:
|
||||
friend class gfxMacPlatformFontList;
|
||||
|
||||
MacOSFontEntry(const nsAString& aPostscriptName, int32_t aWeight,
|
||||
MacOSFontEntry(const nsAString& aPostscriptName, FontWeight aWeight,
|
||||
bool aIsStandardFace = false,
|
||||
double aSizeHint = 0.0);
|
||||
|
||||
// for use with data fonts
|
||||
MacOSFontEntry(const nsAString& aPostscriptName, CGFontRef aFontRef,
|
||||
uint16_t aWeight, uint16_t aStretch, uint8_t aStyle,
|
||||
FontWeight aWeight, uint16_t aStretch, uint8_t aStyle,
|
||||
bool aIsDataUserFont, bool aIsLocal);
|
||||
|
||||
virtual ~MacOSFontEntry() {
|
||||
|
@ -130,12 +131,12 @@ public:
|
|||
bool GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName) override;
|
||||
|
||||
gfxFontEntry* LookupLocalFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle) override;
|
||||
|
||||
gfxFontEntry* MakePlatformFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const uint8_t* aFontData,
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Sprintf.h"
|
||||
|
@ -363,7 +364,7 @@ MacOSFontEntry::IsCFF()
|
|||
}
|
||||
|
||||
MacOSFontEntry::MacOSFontEntry(const nsAString& aPostscriptName,
|
||||
int32_t aWeight,
|
||||
FontWeight aWeight,
|
||||
bool aIsStandardFace,
|
||||
double aSizeHint)
|
||||
: gfxFontEntry(aPostscriptName, aIsStandardFace),
|
||||
|
@ -387,7 +388,8 @@ MacOSFontEntry::MacOSFontEntry(const nsAString& aPostscriptName,
|
|||
|
||||
MacOSFontEntry::MacOSFontEntry(const nsAString& aPostscriptName,
|
||||
CGFontRef aFontRef,
|
||||
uint16_t aWeight, uint16_t aStretch,
|
||||
FontWeight aWeight,
|
||||
uint16_t aStretch,
|
||||
uint8_t aStyle,
|
||||
bool aIsDataUserFont,
|
||||
bool aIsLocalUserFont)
|
||||
|
@ -902,7 +904,8 @@ gfxMacFontFamily::FindStyleVariations(FontInfoData *aFontInfoData)
|
|||
|
||||
// create a font entry
|
||||
MacOSFontEntry *fontEntry =
|
||||
new MacOSFontEntry(postscriptFontName, cssWeight, isStandardFace, mSizeHint);
|
||||
new MacOSFontEntry(postscriptFontName, FontWeight(cssWeight),
|
||||
isStandardFace, mSizeHint);
|
||||
if (!fontEntry) {
|
||||
break;
|
||||
}
|
||||
|
@ -1530,7 +1533,7 @@ gfxMacPlatformFontList::AppleWeightToCSSWeight(int32_t aAppleWeight)
|
|||
|
||||
gfxFontEntry*
|
||||
gfxMacPlatformFontList::LookupLocalFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle)
|
||||
{
|
||||
|
@ -1545,8 +1548,8 @@ gfxMacPlatformFontList::LookupLocalFont(const nsAString& aFontName,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
NS_ASSERTION(aWeight >= 100 && aWeight <= 900,
|
||||
"bogus font weight value!");
|
||||
MOZ_ASSERT(aWeight >= FontWeight(100) && aWeight <= FontWeight(900),
|
||||
"bogus font weight value!");
|
||||
|
||||
newFontEntry =
|
||||
new MacOSFontEntry(aFontName, fontRef, aWeight, aStretch, aStyle,
|
||||
|
@ -1563,7 +1566,7 @@ static void ReleaseData(void *info, const void *data, size_t size)
|
|||
|
||||
gfxFontEntry*
|
||||
gfxMacPlatformFontList::MakePlatformFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const uint8_t* aFontData,
|
||||
|
@ -1571,7 +1574,8 @@ gfxMacPlatformFontList::MakePlatformFont(const nsAString& aFontName,
|
|||
{
|
||||
NS_ASSERTION(aFontData, "MakePlatformFont called with null data");
|
||||
|
||||
NS_ASSERTION(aWeight >= 100 && aWeight <= 900, "bogus font weight value!");
|
||||
MOZ_ASSERT(aWeight >= FontWeight(100) && aWeight <= FontWeight(900),
|
||||
"bogus font weight value!");
|
||||
|
||||
// create the font entry
|
||||
nsAutoString uniqueName;
|
||||
|
@ -1701,7 +1705,7 @@ gfxMacPlatformFontList::LookupSystemFont(LookAndFeel::FontID aSystemFontID,
|
|||
aFontStyle.style =
|
||||
(traits & NSFontItalicTrait) ? NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL;
|
||||
aFontStyle.weight =
|
||||
(traits & NSFontBoldTrait) ? NS_FONT_WEIGHT_BOLD : NS_FONT_WEIGHT_NORMAL;
|
||||
(traits & NSFontBoldTrait) ? FontWeight::Bold() : FontWeight::Normal();
|
||||
aFontStyle.stretch =
|
||||
(traits & NSFontExpandedTrait) ?
|
||||
NS_FONT_STRETCH_EXPANDED : (traits & NSFontCondensedTrait) ?
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/layers/CompositorManagerChild.h"
|
||||
#include "mozilla/layers/CompositorThread.h"
|
||||
#include "mozilla/layers/ImageBridgeChild.h"
|
||||
|
@ -1757,7 +1758,7 @@ gfxPlatform::IsFontFormatSupported(uint32_t aFormatFlags)
|
|||
|
||||
gfxFontEntry*
|
||||
gfxPlatform::LookupLocalFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle)
|
||||
{
|
||||
|
@ -1769,7 +1770,7 @@ gfxPlatform::LookupLocalFont(const nsAString& aFontName,
|
|||
|
||||
gfxFontEntry*
|
||||
gfxPlatform::MakePlatformFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const uint8_t* aFontData,
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#ifndef GFX_PLATFORM_H
|
||||
#define GFX_PLATFORM_H
|
||||
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/gfx/Types.h"
|
||||
#include "nsTArray.h"
|
||||
|
@ -158,6 +159,7 @@ class gfxPlatform {
|
|||
friend class SRGBOverrideObserver;
|
||||
|
||||
public:
|
||||
typedef mozilla::FontWeight FontWeight;
|
||||
typedef mozilla::gfx::Color Color;
|
||||
typedef mozilla::gfx::DataSourceSurface DataSourceSurface;
|
||||
typedef mozilla::gfx::DrawTarget DrawTarget;
|
||||
|
@ -391,7 +393,7 @@ public:
|
|||
* who must either AddRef() or delete.
|
||||
*/
|
||||
virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle);
|
||||
|
||||
|
@ -404,7 +406,7 @@ public:
|
|||
* who must either AddRef() or delete.
|
||||
*/
|
||||
virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const uint8_t* aFontData,
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "nsIMemoryReporter.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "mozilla/RangedArray.h"
|
||||
|
@ -97,6 +98,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader
|
|||
friend class InitOtherFamilyNamesRunnable;
|
||||
|
||||
public:
|
||||
typedef mozilla::FontWeight FontWeight;
|
||||
typedef mozilla::unicode::Script Script;
|
||||
|
||||
static gfxPlatformFontList* PlatformFontList() {
|
||||
|
@ -186,14 +188,14 @@ public:
|
|||
|
||||
// look up a font by name on the host platform
|
||||
virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle) = 0;
|
||||
|
||||
// create a new platform font from downloaded data (@font-face)
|
||||
// this method is responsible to ensure aFontData is free()'d
|
||||
virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const uint8_t* aFontData,
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "base/task.h"
|
||||
#include "base/thread.h"
|
||||
#include "base/message_loop.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/gfx/Logging.h"
|
||||
|
||||
#include "mozilla/gfx/2D.h"
|
||||
|
@ -274,7 +275,7 @@ gfxPlatformGtk::CreateFontGroup(const FontFamilyList& aFontFamilyList,
|
|||
|
||||
gfxFontEntry*
|
||||
gfxPlatformGtk::LookupLocalFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle)
|
||||
{
|
||||
|
@ -285,7 +286,7 @@ gfxPlatformGtk::LookupLocalFont(const nsAString& aFontName,
|
|||
|
||||
gfxFontEntry*
|
||||
gfxPlatformGtk::MakePlatformFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const uint8_t* aFontData,
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
* support @font-face src local() )
|
||||
*/
|
||||
virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle) override;
|
||||
|
||||
|
@ -75,7 +75,7 @@ public:
|
|||
*
|
||||
*/
|
||||
virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int16_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const uint8_t* aFontData,
|
||||
|
|
|
@ -1768,9 +1768,9 @@ gfxTextRun::Dump(FILE* aOutput) {
|
|||
NS_ConvertUTF16toUTF8 fontName(font->GetName());
|
||||
nsAutoCString lang;
|
||||
style->language->ToUTF8String(lang);
|
||||
fprintf(aOutput, "%d: %s %f/%d/%d/%s", glyphRuns[i].mCharacterOffset,
|
||||
fprintf(aOutput, "%d: %s %f/%g/%d/%s", glyphRuns[i].mCharacterOffset,
|
||||
fontName.get(), style->size,
|
||||
style->weight, style->style, lang.get());
|
||||
style->weight.ToFloat(), style->style, lang.get());
|
||||
}
|
||||
fputc(']', aOutput);
|
||||
}
|
||||
|
@ -2416,7 +2416,7 @@ gfxFontGroup::InitTextRun(DrawTarget* aDrawTarget,
|
|||
nsAutoCString str((const char*)aString, aLength);
|
||||
MOZ_LOG(log, LogLevel::Warning,\
|
||||
("(%s) fontgroup: [%s] default: %s lang: %s script: %d "
|
||||
"len %d weight: %d width: %d style: %s size: %6.2f %zu-byte "
|
||||
"len %d weight: %g width: %d style: %s size: %6.2f %zu-byte "
|
||||
"TEXTRUN [%s] ENDTEXTRUN\n",
|
||||
(mStyle.systemFont ? "textrunui" : "textrun"),
|
||||
NS_ConvertUTF16toUTF8(families).get(),
|
||||
|
@ -2425,7 +2425,7 @@ gfxFontGroup::InitTextRun(DrawTarget* aDrawTarget,
|
|||
(mFamilyList.GetDefaultFontType() == eFamily_sans_serif ?
|
||||
"sans-serif" : "none")),
|
||||
lang.get(), static_cast<int>(Script::LATIN), aLength,
|
||||
uint32_t(mStyle.weight), uint32_t(mStyle.stretch),
|
||||
mStyle.weight.ToFloat(), uint32_t(mStyle.stretch),
|
||||
(mStyle.style & NS_FONT_STYLE_ITALIC ? "italic" :
|
||||
(mStyle.style & NS_FONT_STYLE_OBLIQUE ? "oblique" :
|
||||
"normal")),
|
||||
|
@ -2464,7 +2464,7 @@ gfxFontGroup::InitTextRun(DrawTarget* aDrawTarget,
|
|||
uint32_t runLen = runLimit - runStart;
|
||||
MOZ_LOG(log, LogLevel::Warning,\
|
||||
("(%s) fontgroup: [%s] default: %s lang: %s script: %d "
|
||||
"len %d weight: %d width: %d style: %s size: %6.2f "
|
||||
"len %d weight: %g width: %d style: %s size: %6.2f "
|
||||
"%zu-byte TEXTRUN [%s] ENDTEXTRUN\n",
|
||||
(mStyle.systemFont ? "textrunui" : "textrun"),
|
||||
NS_ConvertUTF16toUTF8(families).get(),
|
||||
|
@ -2473,7 +2473,7 @@ gfxFontGroup::InitTextRun(DrawTarget* aDrawTarget,
|
|||
(mFamilyList.GetDefaultFontType() == eFamily_sans_serif ?
|
||||
"sans-serif" : "none")),
|
||||
lang.get(), static_cast<int>(runScript), runLen,
|
||||
uint32_t(mStyle.weight), uint32_t(mStyle.stretch),
|
||||
mStyle.weight.ToFloat(), uint32_t(mStyle.stretch),
|
||||
(mStyle.style & NS_FONT_STYLE_ITALIC ? "italic" :
|
||||
(mStyle.style & NS_FONT_STYLE_OBLIQUE ? "oblique" :
|
||||
"normal")),
|
||||
|
@ -2818,7 +2818,7 @@ gfxFontGroup::FindFallbackFaceForChar(gfxFontFamily* aFamily, uint32_t aCh)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool needsBold = mStyle.weight >= 600 && !fe->IsBold() &&
|
||||
bool needsBold = mStyle.weight >= FontWeight(600) && !fe->IsBold() &&
|
||||
mStyle.allowSyntheticWeight;
|
||||
return fe->FindOrMakeFont(&mStyle, needsBold);
|
||||
}
|
||||
|
@ -3444,7 +3444,7 @@ gfxFontGroup::WhichSystemFontSupportsChar(uint32_t aCh, uint32_t aNextCh,
|
|||
gfxPlatformFontList::PlatformFontList()->
|
||||
SystemFindFontForChar(aCh, aNextCh, aRunScript, &mStyle);
|
||||
if (fe) {
|
||||
bool wantBold = mStyle.weight >= 600;
|
||||
bool wantBold = mStyle.weight >= FontWeight(600);
|
||||
return fe->FindOrMakeFont(&mStyle, wantBold && !fe->IsBold());
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "gfxPrefs.h"
|
||||
#include "nsIProtocolHandler.h"
|
||||
#include "gfxFontConstants.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
|
@ -104,7 +105,7 @@ private:
|
|||
|
||||
gfxUserFontEntry::gfxUserFontEntry(gfxUserFontSet* aFontSet,
|
||||
const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
|
||||
uint32_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int32_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const nsTArray<gfxFontFeature>& aFeatureSettings,
|
||||
|
@ -120,8 +121,8 @@ gfxUserFontEntry::gfxUserFontEntry(gfxUserFontSet* aFontSet,
|
|||
mLoader(nullptr),
|
||||
mFontSet(aFontSet)
|
||||
{
|
||||
MOZ_ASSERT(aWeight != 0,
|
||||
"aWeight must not be 0; use NS_FONT_WEIGHT_NORMAL instead");
|
||||
MOZ_ASSERT(aWeight != FontWeight(0),
|
||||
"aWeight must not be 0; use FontWeight::Normal() instead");
|
||||
mIsUserFontContainer = true;
|
||||
mSrcList = aFontFaceSrcList;
|
||||
mSrcIndex = 0;
|
||||
|
@ -144,7 +145,7 @@ gfxUserFontEntry::~gfxUserFontEntry()
|
|||
|
||||
bool
|
||||
gfxUserFontEntry::Matches(const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
|
||||
uint32_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int32_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const nsTArray<gfxFontFeature>& aFeatureSettings,
|
||||
|
@ -935,7 +936,7 @@ already_AddRefed<gfxUserFontEntry>
|
|||
gfxUserFontSet::FindOrCreateUserFontEntry(
|
||||
const nsAString& aFamilyName,
|
||||
const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
|
||||
uint32_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int32_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const nsTArray<gfxFontFeature>& aFeatureSettings,
|
||||
|
@ -975,7 +976,7 @@ gfxUserFontSet::FindOrCreateUserFontEntry(
|
|||
already_AddRefed<gfxUserFontEntry>
|
||||
gfxUserFontSet::CreateUserFontEntry(
|
||||
const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
|
||||
uint32_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int32_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const nsTArray<gfxFontFeature>& aFeatureSettings,
|
||||
|
@ -996,7 +997,7 @@ gfxUserFontEntry*
|
|||
gfxUserFontSet::FindExistingUserFontEntry(
|
||||
gfxUserFontFamily* aFamily,
|
||||
const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
|
||||
uint32_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int32_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const nsTArray<gfxFontFeature>& aFeatureSettings,
|
||||
|
@ -1005,8 +1006,8 @@ gfxUserFontSet::FindExistingUserFontEntry(
|
|||
gfxCharacterMap* aUnicodeRanges,
|
||||
uint8_t aFontDisplay)
|
||||
{
|
||||
MOZ_ASSERT(aWeight != 0,
|
||||
"aWeight must not be 0; use NS_FONT_WEIGHT_NORMAL instead");
|
||||
MOZ_ASSERT(aWeight != FontWeight(0),
|
||||
"aWeight must not be 0; use FontWeight::Normal() instead");
|
||||
|
||||
nsTArray<RefPtr<gfxFontEntry>>& fontList = aFamily->GetFontList();
|
||||
|
||||
|
@ -1039,12 +1040,12 @@ gfxUserFontSet::AddUserFontEntry(const nsAString& aFamilyName,
|
|||
family->AddFontEntry(aUserFontEntry);
|
||||
|
||||
if (LOG_ENABLED()) {
|
||||
LOG(("userfonts (%p) added to \"%s\" (%p) style: %s weight: %d "
|
||||
LOG(("userfonts (%p) added to \"%s\" (%p) style: %s weight: %g "
|
||||
"stretch: %d display: %d",
|
||||
this, NS_ConvertUTF16toUTF8(aFamilyName).get(), aUserFontEntry,
|
||||
(aUserFontEntry->IsItalic() ? "italic" :
|
||||
(aUserFontEntry->IsOblique() ? "oblique" : "normal")),
|
||||
aUserFontEntry->Weight(), aUserFontEntry->Stretch(),
|
||||
aUserFontEntry->Weight().ToFloat(), aUserFontEntry->Stretch(),
|
||||
aUserFontEntry->GetFontDisplay()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "nsIPrincipal.h"
|
||||
#include "nsIScriptError.h"
|
||||
#include "nsURIHashKey.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/net/ReferrerPolicy.h"
|
||||
#include "gfxFontConstants.h"
|
||||
|
||||
|
@ -184,6 +185,7 @@ class gfxUserFontSet {
|
|||
friend class gfxOTSContext;
|
||||
|
||||
public:
|
||||
typedef mozilla::FontWeight FontWeight;
|
||||
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(gfxUserFontSet)
|
||||
|
||||
|
@ -229,7 +231,7 @@ public:
|
|||
// TODO: support for unicode ranges not yet implemented
|
||||
virtual already_AddRefed<gfxUserFontEntry> CreateUserFontEntry(
|
||||
const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
|
||||
uint32_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int32_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const nsTArray<gfxFontFeature>& aFeatureSettings,
|
||||
|
@ -243,7 +245,7 @@ public:
|
|||
already_AddRefed<gfxUserFontEntry> FindOrCreateUserFontEntry(
|
||||
const nsAString& aFamilyName,
|
||||
const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
|
||||
uint32_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int32_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const nsTArray<gfxFontFeature>& aFeatureSettings,
|
||||
|
@ -404,8 +406,8 @@ public:
|
|||
HashFeatures(aKey->mFontEntry->mFeatureSettings),
|
||||
HashVariations(aKey->mFontEntry->mVariationSettings),
|
||||
mozilla::HashString(aKey->mFontEntry->mFamilyName),
|
||||
aKey->mFontEntry->mWeight.ForHash(),
|
||||
(aKey->mFontEntry->mStyle |
|
||||
(aKey->mFontEntry->mWeight << 2) |
|
||||
(aKey->mFontEntry->mStretch << 11) ) ^
|
||||
aKey->mFontEntry->mLanguageOverride);
|
||||
}
|
||||
|
@ -497,7 +499,7 @@ protected:
|
|||
gfxUserFontEntry* FindExistingUserFontEntry(
|
||||
gfxUserFontFamily* aFamily,
|
||||
const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
|
||||
uint32_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int32_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const nsTArray<gfxFontFeature>& aFeatureSettings,
|
||||
|
@ -537,6 +539,8 @@ class gfxUserFontEntry : public gfxFontEntry {
|
|||
friend class gfxOTSContext;
|
||||
|
||||
public:
|
||||
typedef mozilla::FontWeight FontWeight;
|
||||
|
||||
enum UserFontLoadState {
|
||||
STATUS_NOT_LOADED = 0,
|
||||
STATUS_LOAD_PENDING,
|
||||
|
@ -547,7 +551,7 @@ public:
|
|||
|
||||
gfxUserFontEntry(gfxUserFontSet* aFontSet,
|
||||
const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
|
||||
uint32_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int32_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const nsTArray<gfxFontFeature>& aFeatureSettings,
|
||||
|
@ -560,7 +564,7 @@ public:
|
|||
|
||||
// Return whether the entry matches the given list of attributes
|
||||
bool Matches(const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
|
||||
uint32_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int32_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const nsTArray<gfxFontFeature>& aFeatureSettings,
|
||||
|
|
|
@ -636,7 +636,7 @@ MathMLTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
|||
// This overrides the initial values specified in fontStyle, to avoid
|
||||
// inconsistencies in which attributes allow CSS changes and which do not.
|
||||
if (mFlags & MATH_FONT_WEIGHT_BOLD) {
|
||||
font.weight = NS_FONT_WEIGHT_BOLD;
|
||||
font.weight = FontWeight::Bold();
|
||||
if (mFlags & MATH_FONT_STYLING_NORMAL) {
|
||||
font.style = NS_FONT_STYLE_NORMAL;
|
||||
} else {
|
||||
|
@ -644,7 +644,7 @@ MathMLTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
|||
}
|
||||
} else if (mFlags & MATH_FONT_STYLING_NORMAL) {
|
||||
font.style = NS_FONT_STYLE_NORMAL;
|
||||
font.weight = NS_FONT_WEIGHT_NORMAL;
|
||||
font.weight = FontWeight::Normal();
|
||||
} else {
|
||||
mathVar = NS_MATHML_MATHVARIANT_ITALIC;
|
||||
}
|
||||
|
@ -723,20 +723,20 @@ MathMLTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
|||
|
||||
if (mathVar == NS_MATHML_MATHVARIANT_BOLD && doMathvariantStyling) {
|
||||
font.style = NS_FONT_STYLE_NORMAL;
|
||||
font.weight = NS_FONT_WEIGHT_BOLD;
|
||||
font.weight = FontWeight::Bold();
|
||||
} else if (mathVar == NS_MATHML_MATHVARIANT_ITALIC && doMathvariantStyling) {
|
||||
font.style = NS_FONT_STYLE_ITALIC;
|
||||
font.weight = NS_FONT_WEIGHT_NORMAL;
|
||||
font.weight = FontWeight::Normal();
|
||||
} else if (mathVar == NS_MATHML_MATHVARIANT_BOLD_ITALIC &&
|
||||
doMathvariantStyling) {
|
||||
font.style = NS_FONT_STYLE_ITALIC;
|
||||
font.weight = NS_FONT_WEIGHT_BOLD;
|
||||
font.weight = FontWeight::Bold();
|
||||
} else if (mathVar != NS_MATHML_MATHVARIANT_NONE) {
|
||||
// Mathvariant overrides fontstyle and fontweight
|
||||
// Need to check to see if mathvariant is actually applied as this function
|
||||
// is used for other purposes.
|
||||
font.style = NS_FONT_STYLE_NORMAL;
|
||||
font.weight = NS_FONT_WEIGHT_NORMAL;
|
||||
font.weight = FontWeight::Normal();
|
||||
}
|
||||
gfxFontGroup* newFontGroup = nullptr;
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#define mozilla_dom_FontFace_h
|
||||
|
||||
#include "mozilla/dom/FontFaceBinding.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "gfxUserFontSet.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCSSPropertyID.h"
|
||||
|
@ -47,7 +48,7 @@ public:
|
|||
public:
|
||||
Entry(gfxUserFontSet* aFontSet,
|
||||
const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
|
||||
uint32_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int32_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const nsTArray<gfxFontFeature>& aFeatureSettings,
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "mozilla/dom/FontFaceSetLoadEvent.h"
|
||||
#include "mozilla/dom/FontFaceSetLoadEventBinding.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/net/ReferrerPolicy.h"
|
||||
#include "mozilla/AsyncEventDispatcher.h"
|
||||
#include "mozilla/Logging.h"
|
||||
|
@ -205,7 +206,7 @@ void
|
|||
FontFaceSet::ParseFontShorthandForMatching(
|
||||
const nsAString& aFont,
|
||||
RefPtr<SharedFontList>& aFamilyList,
|
||||
uint32_t& aWeight,
|
||||
FontWeight& aWeight,
|
||||
int32_t& aStretch,
|
||||
uint8_t& aStyle,
|
||||
ErrorResult& aRv)
|
||||
|
@ -219,7 +220,12 @@ FontFaceSet::ParseFontShorthandForMatching(
|
|||
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
|
||||
return;
|
||||
}
|
||||
aWeight = weight.GetIntValue();
|
||||
if (weight.GetUnit() == eCSSUnit_FontWeight) {
|
||||
aWeight = weight.GetFontWeight();
|
||||
} else {
|
||||
MOZ_ASSERT(weight.GetUnit() == eCSSUnit_Enumerated);
|
||||
aWeight = FontWeight(weight.GetIntValue());
|
||||
}
|
||||
aStretch = stretch.GetIntValue();
|
||||
aStyle = style.GetIntValue();
|
||||
}
|
||||
|
@ -247,7 +253,7 @@ FontFaceSet::FindMatchingFontFaces(const nsAString& aFont,
|
|||
ErrorResult& aRv)
|
||||
{
|
||||
RefPtr<SharedFontList> familyList;
|
||||
uint32_t weight;
|
||||
FontWeight weight;
|
||||
int32_t stretch;
|
||||
uint8_t italicStyle;
|
||||
ParseFontShorthandForMatching(aFont, familyList, weight, stretch, italicStyle,
|
||||
|
@ -972,7 +978,7 @@ FontFaceSet::FindOrCreateUserFontEntryFromFontFace(const nsAString& aFamilyName,
|
|||
nsCSSValue val;
|
||||
nsCSSUnit unit;
|
||||
|
||||
uint32_t weight = NS_FONT_WEIGHT_NORMAL;
|
||||
FontWeight weight = FontWeight::Normal();
|
||||
int32_t stretch = NS_STYLE_FONT_STRETCH_NORMAL;
|
||||
uint8_t italicStyle = NS_STYLE_FONT_STYLE_NORMAL;
|
||||
uint32_t languageOverride = NO_FONT_LANGUAGE_OVERRIDE;
|
||||
|
@ -981,18 +987,19 @@ FontFaceSet::FindOrCreateUserFontEntryFromFontFace(const nsAString& aFamilyName,
|
|||
// set up weight
|
||||
aFontFace->GetDesc(eCSSFontDesc_Weight, val);
|
||||
unit = val.GetUnit();
|
||||
if (unit == eCSSUnit_Integer || unit == eCSSUnit_Enumerated) {
|
||||
weight = val.GetIntValue();
|
||||
if (weight == 0) {
|
||||
weight = NS_FONT_WEIGHT_NORMAL;
|
||||
}
|
||||
if (unit == eCSSUnit_FontWeight) {
|
||||
weight = val.GetFontWeight();
|
||||
} else if (unit == eCSSUnit_Enumerated) {
|
||||
weight = FontWeight(val.GetIntValue());
|
||||
} else if (unit == eCSSUnit_Normal) {
|
||||
weight = NS_FONT_WEIGHT_NORMAL;
|
||||
weight = FontWeight::Normal();
|
||||
} else {
|
||||
NS_ASSERTION(unit == eCSSUnit_Null,
|
||||
"@font-face weight has unexpected unit");
|
||||
MOZ_ASSERT(unit == eCSSUnit_Null, "@font-face weight has unexpected unit");
|
||||
}
|
||||
|
||||
if (weight == FontWeight(0)) {
|
||||
weight = FontWeight::Normal();
|
||||
}
|
||||
// set up stretch
|
||||
aFontFace->GetDesc(eCSSFontDesc_Stretch, val);
|
||||
unit = val.GetUnit();
|
||||
|
@ -1243,25 +1250,13 @@ FontFaceSet::LogMessage(gfxUserFontEntry* aUserFontEntry,
|
|||
nsAutoCString fontURI;
|
||||
aUserFontEntry->GetFamilyNameAndURIForLogging(familyName, fontURI);
|
||||
|
||||
char weightKeywordBuf[8]; // plenty to sprintf() a uint16_t
|
||||
const char* weightKeyword;
|
||||
const nsCString& weightKeywordString =
|
||||
nsCSSProps::ValueToKeyword(aUserFontEntry->Weight(),
|
||||
nsCSSProps::kFontWeightKTable);
|
||||
if (weightKeywordString.Length() > 0) {
|
||||
weightKeyword = weightKeywordString.get();
|
||||
} else {
|
||||
SprintfLiteral(weightKeywordBuf, "%u", aUserFontEntry->Weight());
|
||||
weightKeyword = weightKeywordBuf;
|
||||
}
|
||||
|
||||
nsPrintfCString message
|
||||
("downloadable font: %s "
|
||||
"(font-family: \"%s\" style:%s weight:%s stretch:%s src index:%d)",
|
||||
"(font-family: \"%s\" style:%s weight:%g stretch:%s src index:%d)",
|
||||
aMessage,
|
||||
familyName.get(),
|
||||
aUserFontEntry->IsItalic() ? "italic" : "normal",
|
||||
weightKeyword,
|
||||
aUserFontEntry->Weight().ToFloat(),
|
||||
nsCSSProps::ValueToKeyword(aUserFontEntry->Stretch(),
|
||||
nsCSSProps::kFontStretchKTable).get(),
|
||||
aUserFontEntry->GetSrcIndex());
|
||||
|
@ -1934,7 +1929,7 @@ FontFaceSet::UserFontSet::DoRebuildUserFontSet()
|
|||
/* virtual */ already_AddRefed<gfxUserFontEntry>
|
||||
FontFaceSet::UserFontSet::CreateUserFontEntry(
|
||||
const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
|
||||
uint32_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int32_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const nsTArray<gfxFontFeature>& aFeatureSettings,
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "mozilla/dom/FontFace.h"
|
||||
#include "mozilla/dom/FontFaceSetBinding.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "gfxUserFontSet.h"
|
||||
#include "nsICSSLoaderObserver.h"
|
||||
|
||||
|
@ -95,9 +96,9 @@ public:
|
|||
uint32_t aFlags = nsIScriptError::errorFlag,
|
||||
nsresult aStatus = NS_OK) override;
|
||||
virtual void DoRebuildUserFontSet() override;
|
||||
virtual already_AddRefed<gfxUserFontEntry> CreateUserFontEntry(
|
||||
already_AddRefed<gfxUserFontEntry> CreateUserFontEntry(
|
||||
const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
|
||||
uint32_t aWeight,
|
||||
FontWeight aWeight,
|
||||
int32_t aStretch,
|
||||
uint8_t aStyle,
|
||||
const nsTArray<gfxFontFeature>& aFeatureSettings,
|
||||
|
@ -312,7 +313,7 @@ private:
|
|||
void ParseFontShorthandForMatching(
|
||||
const nsAString& aFont,
|
||||
RefPtr<SharedFontList>& aFamilyList,
|
||||
uint32_t& aWeight,
|
||||
FontWeight& aWeight,
|
||||
int32_t& aStretch,
|
||||
uint8_t& aStyle,
|
||||
ErrorResult& aRv);
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include "mozilla/EffectCompositor.h"
|
||||
#include "mozilla/EffectSet.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/Keyframe.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
@ -1327,6 +1328,19 @@ Gecko_nsFont_SetFontFeatureValuesLookup(nsFont* aFont,
|
|||
aFont->featureValueLookup = aPresContext->GetFontFeatureValuesLookup();
|
||||
}
|
||||
|
||||
float
|
||||
Gecko_FontWeight_ToFloat(mozilla::FontWeight aWeight)
|
||||
{
|
||||
return aWeight.ToFloat();
|
||||
}
|
||||
|
||||
void
|
||||
Gecko_FontWeight_SetFloat(mozilla::FontWeight* aWeight,
|
||||
float aFloat)
|
||||
{
|
||||
*aWeight = mozilla::FontWeight(aFloat);
|
||||
}
|
||||
|
||||
void
|
||||
Gecko_nsFont_ResetFontFeatureValuesLookup(nsFont* aFont)
|
||||
{
|
||||
|
@ -2306,6 +2320,13 @@ Gecko_CSSValue_Drop(nsCSSValueBorrowedMut aCSSValue)
|
|||
aCSSValue->~nsCSSValue();
|
||||
}
|
||||
|
||||
void
|
||||
Gecko_CSSValue_SetFontWeight(nsCSSValueBorrowedMut aCSSValue,
|
||||
float weight)
|
||||
{
|
||||
aCSSValue->SetFontWeight(mozilla::FontWeight(weight));
|
||||
}
|
||||
|
||||
void
|
||||
Gecko_nsStyleFont_SetLang(nsStyleFont* aFont, nsAtom* aAtom)
|
||||
{
|
||||
|
|
|
@ -565,6 +565,7 @@ void Gecko_CSSValue_SetKeyword(nsCSSValueBorrowedMut css_value, nsCSSKeyword key
|
|||
void Gecko_CSSValue_SetPercentage(nsCSSValueBorrowedMut css_value, float percent);
|
||||
void Gecko_CSSValue_SetPixelLength(nsCSSValueBorrowedMut aCSSValue, float aLen);
|
||||
void Gecko_CSSValue_SetCalc(nsCSSValueBorrowedMut css_value, nsStyleCoord::CalcValue calc);
|
||||
void Gecko_CSSValue_SetFontWeight(nsCSSValueBorrowedMut css_value, float weight);
|
||||
void Gecko_CSSValue_SetFunction(nsCSSValueBorrowedMut css_value, int32_t len);
|
||||
void Gecko_CSSValue_SetString(nsCSSValueBorrowedMut css_value,
|
||||
const uint8_t* string, uint32_t len, nsCSSUnit unit);
|
||||
|
@ -584,6 +585,10 @@ void Gecko_CSSValue_InitSharedList(nsCSSValueBorrowedMut css_value, uint32_t len
|
|||
void Gecko_CSSValue_Drop(nsCSSValueBorrowedMut css_value);
|
||||
NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsCSSValueSharedList, CSSValueSharedList);
|
||||
|
||||
float Gecko_FontWeight_ToFloat(mozilla::FontWeight aWeight);
|
||||
void Gecko_FontWeight_SetFloat(mozilla::FontWeight* aWeight,
|
||||
float aFloatValue);
|
||||
|
||||
void Gecko_nsStyleFont_SetLang(nsStyleFont* font, nsAtom* atom);
|
||||
void Gecko_nsStyleFont_CopyLangFrom(nsStyleFont* aFont, const nsStyleFont* aSource);
|
||||
void Gecko_nsStyleFont_FixupNoneGeneric(nsStyleFont* font,
|
||||
|
|
|
@ -463,6 +463,7 @@ structs-types = [
|
|||
"mozilla::dom::CallerType",
|
||||
"mozilla::AnonymousCounterStyle",
|
||||
"mozilla::AtomArray",
|
||||
"mozilla::FontWeight",
|
||||
"mozilla::MallocSizeOf",
|
||||
"mozilla::OriginFlags",
|
||||
"mozilla::UniquePtr",
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "nsCSSValue.h"
|
||||
|
||||
#include "mozilla/CORSMode.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/ServoBindings.h"
|
||||
#include "mozilla/ServoStyleSet.h"
|
||||
#include "mozilla/ServoTypes.h"
|
||||
|
@ -121,6 +122,12 @@ nsCSSValue::nsCSSValue(SharedFontList* aValue)
|
|||
mValue.mFontFamilyList->AddRef();
|
||||
}
|
||||
|
||||
nsCSSValue::nsCSSValue(FontWeight aWeight)
|
||||
: mUnit(eCSSUnit_FontWeight)
|
||||
{
|
||||
mValue.mFontWeight = aWeight;
|
||||
}
|
||||
|
||||
nsCSSValue::nsCSSValue(const nsCSSValue& aCopy)
|
||||
: mUnit(aCopy.mUnit)
|
||||
{
|
||||
|
@ -180,6 +187,9 @@ nsCSSValue::nsCSSValue(const nsCSSValue& aCopy)
|
|||
mValue.mFontFamilyList = aCopy.mValue.mFontFamilyList;
|
||||
mValue.mFontFamilyList->AddRef();
|
||||
}
|
||||
else if (eCSSUnit_FontWeight == mUnit) {
|
||||
mValue.mFontWeight = aCopy.mValue.mFontWeight;
|
||||
}
|
||||
else if (eCSSUnit_AtomIdent == mUnit) {
|
||||
mValue.mAtom = aCopy.mValue.mAtom;
|
||||
mValue.mAtom->AddRef();
|
||||
|
@ -259,6 +269,9 @@ bool nsCSSValue::operator==(const nsCSSValue& aOther) const
|
|||
return mValue.mFontFamilyList->mNames ==
|
||||
aOther.mValue.mFontFamilyList->mNames;
|
||||
}
|
||||
else if (eCSSUnit_FontWeight == mUnit) {
|
||||
return mValue.mFontWeight == aOther.mValue.mFontWeight;
|
||||
}
|
||||
else if (eCSSUnit_AtomIdent == mUnit) {
|
||||
return mValue.mAtom == aOther.mValue.mAtom;
|
||||
}
|
||||
|
@ -477,6 +490,13 @@ void nsCSSValue::SetFontFamilyListValue(already_AddRefed<SharedFontList> aValue)
|
|||
mValue.mFontFamilyList = aValue.take();
|
||||
}
|
||||
|
||||
void nsCSSValue::SetFontWeight(FontWeight aWeight)
|
||||
{
|
||||
Reset();
|
||||
mUnit = eCSSUnit_FontWeight;
|
||||
mValue.mFontWeight = aWeight;
|
||||
}
|
||||
|
||||
void nsCSSValue::SetPairValue(const nsCSSValuePair* aValue)
|
||||
{
|
||||
// pairs should not be used for null/inherit/initial values
|
||||
|
@ -895,6 +915,7 @@ nsCSSValue::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
|
|||
// Int: nothing extra to measure.
|
||||
case eCSSUnit_Integer:
|
||||
case eCSSUnit_Enumerated:
|
||||
case eCSSUnit_FontWeight:
|
||||
break;
|
||||
|
||||
// Float: nothing extra to measure.
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/CORSMode.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/ServoTypes.h"
|
||||
#include "mozilla/SheetType.h"
|
||||
|
@ -441,7 +442,10 @@ enum nsCSSUnit {
|
|||
eCSSUnit_Milliseconds = 3001, // (float) 1/1000 second
|
||||
|
||||
// Flexible fraction (CSS Grid)
|
||||
eCSSUnit_FlexFraction = 4000 // (float) Fraction of free space
|
||||
eCSSUnit_FlexFraction = 4000, // (float) Fraction of free space
|
||||
|
||||
// Font property types
|
||||
eCSSUnit_FontWeight = 5000, // An encoded font-weight
|
||||
};
|
||||
|
||||
struct nsCSSValuePair;
|
||||
|
@ -476,6 +480,7 @@ public:
|
|||
explicit nsCSSValue(mozilla::css::ImageValue* aValue);
|
||||
explicit nsCSSValue(mozilla::css::GridTemplateAreasValue* aValue);
|
||||
explicit nsCSSValue(mozilla::SharedFontList* aValue);
|
||||
explicit nsCSSValue(mozilla::FontWeight aWeight);
|
||||
nsCSSValue(const nsCSSValue& aCopy);
|
||||
nsCSSValue(nsCSSValue&& aOther)
|
||||
: mUnit(aOther.mUnit)
|
||||
|
@ -631,6 +636,12 @@ public:
|
|||
return mozilla::WrapNotNull(mValue.mFontFamilyList);
|
||||
}
|
||||
|
||||
mozilla::FontWeight GetFontWeight() const
|
||||
{
|
||||
MOZ_ASSERT(mUnit == eCSSUnit_FontWeight, "not a font weight value");
|
||||
return mValue.mFontWeight;
|
||||
}
|
||||
|
||||
// bodies of these are below
|
||||
inline nsCSSValuePair& GetPairValue();
|
||||
inline const nsCSSValuePair& GetPairValue() const;
|
||||
|
@ -708,6 +719,7 @@ public:
|
|||
void SetImageValue(mozilla::css::ImageValue* aImage);
|
||||
void SetGridTemplateAreas(mozilla::css::GridTemplateAreasValue* aValue);
|
||||
void SetFontFamilyListValue(already_AddRefed<mozilla::SharedFontList> aFontListValue);
|
||||
void SetFontWeight(mozilla::FontWeight aWeight);
|
||||
void SetPairValue(const nsCSSValuePair* aPair);
|
||||
void SetPairValue(const nsCSSValue& xValue, const nsCSSValue& yValue);
|
||||
void SetSharedListValue(nsCSSValueSharedList* aList);
|
||||
|
@ -784,6 +796,7 @@ protected:
|
|||
nsCSSValuePairList_heap* MOZ_OWNING_REF mPairList;
|
||||
nsCSSValuePairList* mPairListDependent;
|
||||
mozilla::SharedFontList* MOZ_OWNING_REF mFontFamilyList;
|
||||
mozilla::FontWeight mFontWeight;
|
||||
} mValue;
|
||||
};
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "nsComputedDOMStyle.h"
|
||||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
#include "nsError.h"
|
||||
|
@ -1973,8 +1974,9 @@ nsComputedDOMStyle::DoGetFontWeight()
|
|||
|
||||
const nsStyleFont* font = StyleFont();
|
||||
|
||||
uint16_t weight = font->mFont.weight;
|
||||
NS_ASSERTION(weight % 100 == 0, "unexpected value of font-weight");
|
||||
float weight = font->mFont.weight.ToFloat();
|
||||
MOZ_ASSERT(1.0f <= weight && weight <= 1000.0f,
|
||||
"unexpected font-weight value");
|
||||
val->SetNumber(weight);
|
||||
|
||||
return val.forget();
|
||||
|
|
|
@ -25,7 +25,7 @@ impl<'a> ToNsCssValue for &'a FamilyName {
|
|||
|
||||
impl ToNsCssValue for font_weight::T {
|
||||
fn convert(self, nscssvalue: &mut nsCSSValue) {
|
||||
nscssvalue.set_integer(self.0 as i32)
|
||||
nscssvalue.set_font_weight(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ impl<'a> ToNsCssValue for &'a FontWeight {
|
|||
match *self {
|
||||
FontWeight::Normal => nscssvalue.set_enum(structs::NS_FONT_WEIGHT_NORMAL as i32),
|
||||
FontWeight::Bold => nscssvalue.set_enum(structs::NS_FONT_WEIGHT_BOLD as i32),
|
||||
FontWeight::Weight(weight) => nscssvalue.set_integer(weight.0 as i32),
|
||||
FontWeight::Weight(weight) => nscssvalue.set_font_weight(weight.0),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -177,6 +177,11 @@ impl nsCSSValue {
|
|||
self.set_string_from_atom_internal(s, nsCSSUnit::eCSSUnit_Local_Font);
|
||||
}
|
||||
|
||||
/// Set to a font weight
|
||||
pub fn set_font_weight(&mut self, w: u16) {
|
||||
unsafe { bindings::Gecko_CSSValue_SetFontWeight(self, w as f32) }
|
||||
}
|
||||
|
||||
fn set_int_internal(&mut self, value: i32, unit: nsCSSUnit) {
|
||||
unsafe { bindings::Gecko_CSSValue_SetInt(self, value, unit) }
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ use gecko_bindings::bindings::Gecko_CopyFontFamilyFrom;
|
|||
use gecko_bindings::bindings::Gecko_CopyImageValueFrom;
|
||||
use gecko_bindings::bindings::Gecko_CopyListStyleImageFrom;
|
||||
use gecko_bindings::bindings::Gecko_EnsureImageLayersLength;
|
||||
use gecko_bindings::bindings::Gecko_FontWeight_SetFloat;
|
||||
use gecko_bindings::bindings::Gecko_FontWeight_ToFloat;
|
||||
use gecko_bindings::bindings::Gecko_SetCursorArrayLength;
|
||||
use gecko_bindings::bindings::Gecko_SetCursorImageValue;
|
||||
use gecko_bindings::bindings::Gecko_StyleTransition_SetUnsupportedProperty;
|
||||
|
@ -2599,13 +2601,15 @@ fn static_assert() {
|
|||
}
|
||||
|
||||
pub fn set_font_weight(&mut self, v: longhands::font_weight::computed_value::T) {
|
||||
self.gecko.mFont.weight = v.0;
|
||||
unsafe { Gecko_FontWeight_SetFloat(&mut self.gecko.mFont.weight, v.0 as f32) };
|
||||
}
|
||||
${impl_simple_copy('font_weight', 'mFont.weight')}
|
||||
|
||||
pub fn clone_font_weight(&self) -> longhands::font_weight::computed_value::T {
|
||||
debug_assert!(self.gecko.mFont.weight <= ::std::u16::MAX);
|
||||
longhands::font_weight::computed_value::T(self.gecko.mFont.weight)
|
||||
let weight: f32 = unsafe { Gecko_FontWeight_ToFloat(self.gecko.mFont.weight) };
|
||||
debug_assert!(weight >= 0.0 &&
|
||||
weight <= ::std::u16::MAX as f32);
|
||||
longhands::font_weight::computed_value::T(weight as u16)
|
||||
}
|
||||
|
||||
${impl_simple_type_with_conversion("font_synthesis", "mFont.synthesis")}
|
||||
|
|
|
@ -75,10 +75,12 @@ impl FontWeight {
|
|||
}
|
||||
|
||||
/// Convert from an Gecko weight
|
||||
pub fn from_gecko_weight(weight: u16) -> Self {
|
||||
#[cfg(feature = "gecko")]
|
||||
pub fn from_gecko_weight(weight: structs::FontWeight) -> Self {
|
||||
// we allow a wider range of weights than is parseable
|
||||
// because system fonts may provide custom values
|
||||
FontWeight(weight)
|
||||
let weight = unsafe { bindings::Gecko_FontWeight_ToFloat(weight) };
|
||||
FontWeight(weight as u16)
|
||||
}
|
||||
|
||||
/// Weither this weight is bold
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "nsLookAndFeel.h"
|
||||
#include "gfxFont.h"
|
||||
#include "gfxFontConstants.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
@ -466,7 +467,7 @@ nsLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName,
|
|||
{
|
||||
aFontName.AssignLiteral("\"Roboto\"");
|
||||
aFontStyle.style = NS_FONT_STYLE_NORMAL;
|
||||
aFontStyle.weight = NS_FONT_WEIGHT_NORMAL;
|
||||
aFontStyle.weight = FontWeight::Normal();
|
||||
aFontStyle.stretch = NS_FONT_STRETCH_NORMAL;
|
||||
aFontStyle.size = 9.0 * 96.0f / 72.0f * aDevPixPerCSSPixel;
|
||||
aFontStyle.systemFont = true;
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "gfxFont.h"
|
||||
#include "gfxFontConstants.h"
|
||||
#include "gfxPlatformMac.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/widget/WidgetMessageUtils.h"
|
||||
|
||||
|
@ -565,7 +566,7 @@ nsLookAndFeel::GetFontImpl(FontID aID, nsString &aFontName,
|
|||
// hack for now
|
||||
if (aID == eFont_Window || aID == eFont_Document) {
|
||||
aFontStyle.style = NS_FONT_STYLE_NORMAL;
|
||||
aFontStyle.weight = NS_FONT_WEIGHT_NORMAL;
|
||||
aFontStyle.weight = mozilla::FontWeight::Normal();
|
||||
aFontStyle.stretch = NS_FONT_STRETCH_NORMAL;
|
||||
aFontStyle.size = 14 * aDevPixPerCSSPixel;
|
||||
aFontStyle.systemFont = true;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include <fontconfig/fontconfig.h>
|
||||
#include "gfxPlatformGtk.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "ScreenHelperGTK.h"
|
||||
|
||||
#include "gtkdrawing.h"
|
||||
|
@ -722,7 +723,8 @@ GetSystemFontInfo(GtkStyleContext *aStyle,
|
|||
NS_ConvertUTF8toUTF16 family(pango_font_description_get_family(desc));
|
||||
*aFontName = quote + family + quote;
|
||||
|
||||
aFontStyle->weight = pango_font_description_get_weight(desc);
|
||||
aFontStyle->weight =
|
||||
mozilla::FontWeight(pango_font_description_get_weight(desc));
|
||||
|
||||
// FIXME: Set aFontStyle->stretch correctly!
|
||||
aFontStyle->stretch = NS_FONT_STRETCH_NORMAL;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "HeadlessLookAndFeel.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "nsIContent.h"
|
||||
|
||||
using mozilla::LookAndFeel;
|
||||
|
@ -337,7 +338,7 @@ HeadlessLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName,
|
|||
{
|
||||
// Default to san-serif for everything.
|
||||
aFontStyle.style = NS_FONT_STYLE_NORMAL;
|
||||
aFontStyle.weight = NS_FONT_WEIGHT_NORMAL;
|
||||
aFontStyle.weight = FontWeight::Normal();
|
||||
aFontStyle.stretch = NS_FONT_STRETCH_NORMAL;
|
||||
aFontStyle.size = 14 * aDevPixPerCSSPixel;
|
||||
aFontStyle.systemFont = true;
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#import <UIKit/UIInterface.h>
|
||||
|
||||
#include "nsLookAndFeel.h"
|
||||
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "gfxFont.h"
|
||||
#include "gfxFontConstants.h"
|
||||
|
@ -400,7 +402,7 @@ nsLookAndFeel::GetFontImpl(FontID aID, nsString &aFontName,
|
|||
// hack for now
|
||||
if (aID == eFont_Window || aID == eFont_Document) {
|
||||
aFontStyle.style = NS_FONT_STYLE_NORMAL;
|
||||
aFontStyle.weight = NS_FONT_WEIGHT_NORMAL;
|
||||
aFontStyle.weight = FontWeight::Normal();
|
||||
aFontStyle.stretch = NS_FONT_STRETCH_NORMAL;
|
||||
aFontStyle.size = 14 * aDevPixPerCSSPixel;
|
||||
aFontStyle.systemFont = true;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "nsUXThemeData.h"
|
||||
#include "nsUXThemeConstants.h"
|
||||
#include "WinUtils.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/WindowsVersion.h"
|
||||
#include "gfxFontConstants.h"
|
||||
|
@ -707,7 +708,7 @@ GetSysFontInfo(HDC aHDC, LookAndFeel::FontID anID,
|
|||
// FIXME: Other weights?
|
||||
aFontStyle.weight =
|
||||
(ptrLogFont->lfWeight == FW_BOLD ?
|
||||
NS_FONT_WEIGHT_BOLD : NS_FONT_WEIGHT_NORMAL);
|
||||
FontWeight::Bold() : FontWeight::Normal());
|
||||
|
||||
// FIXME: Set aFontStyle->stretch correctly!
|
||||
aFontStyle.stretch = NS_FONT_STRETCH_NORMAL;
|
||||
|
|
Загрузка…
Ссылка в новой задаче