/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- * 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/. */
#ifdefined(MOZ_WIDGET_GTK) # include "gfxPlatformGtk.h" # define gfxToolkitPlatform gfxPlatformGtk #elifdefined(XP_WIN) # include "gfxWindowsPlatform.h" # define gfxToolkitPlatform gfxWindowsPlatform #elifdefined(ANDROID) # include "gfxAndroidPlatform.h" # define gfxToolkitPlatform gfxAndroidPlatform #endif
const uint32_t appUnitsPerDevUnit = aShapedText->GetAppUnitsPerDevUnit(); // we'll pass this in/figure it out dynamically, but at this point there can // be only one face.
gfxFT2LockedFace faceLock(this);
FT_Face face = faceLock.get();
if (gid == 0) {
advance = -1; // trigger the missing glyphs case below
} else { // find next character and its glyph -- in case they exist // and exist in the current font face -- to compute kerning
char16_t chNext = 0;
FT_UInt gidNext = 0;
FT_Pos lsbDeltaNext = 0;
if (FT_HAS_KERNING(face) && i + 1 < aLength) {
chNext = aText[i + 1]; if (chNext != 0) {
cgdNext = GetGlyphDataForChar(face, chNext);
gidNext = cgdNext->glyphIndex; if (gidNext && gidNext != spaceGlyph)
lsbDeltaNext = cgdNext->lsbDelta;
}
}
advance = cgd->xAdvance;
// now add kerning to the current glyph's advance if (chNext && gidNext) {
FT_Vector kerning;
kerning.x = 0;
FT_Get_Kerning(face, gid, gidNext, FT_KERNING_DEFAULT, &kerning);
advance += kerning.x; if (cgd->rsbDelta - lsbDeltaNext >= 32) {
advance -= 64;
} elseif (cgd->rsbDelta - lsbDeltaNext < -32) {
advance += 64;
}
}
// convert 26.6 fixed point to app units // round rather than truncate to nearest pixel // because these advances are often scaled
advance = ((advance * appUnitsPerDevUnit + 32) >> 6);
}
if (advance >= 0 && CompressedGlyph::IsSimpleAdvance(advance) &&
CompressedGlyph::IsSimpleGlyphID(gid)) {
charGlyphs[aOffset].SetSimpleGlyph(advance, gid);
} elseif (gid == 0) { // gid = 0 only happens when the glyph is missing from the font
aShapedText->SetMissingGlyph(aOffset, ch, this);
} else {
gfxTextRun::DetailedGlyph details;
details.mGlyphID = gid;
NS_ASSERTION(details.mGlyphID == gid, "Seriously weird glyph ID detected!");
details.mAdvance = advance;
aShapedText->SetDetailedGlyphs(aOffset, 1, &details);
}
}
}
gfxFT2Font::gfxFT2Font(const RefPtr<UnscaledFontFreeType>& aUnscaledFont,
RefPtr<mozilla::gfx::SharedFTFace>&& aFTFace,
FT2FontEntry* aFontEntry, const gfxFontStyle* aFontStyle, int aLoadFlags)
: gfxFT2FontBase(aUnscaledFont, std::move(aFTFace), aFontEntry, aFontStyle,
aLoadFlags, aFontStyle->NeedsSyntheticBold(aFontEntry)),
mCharGlyphCache(32) {
NS_ASSERTION(mFontEntry, "Unable to find font entry for font. Something is whack.");
InitMetrics();
}
void gfxFT2Font::FillGlyphDataForChar(FT_Face face, uint32_t ch,
CachedGlyphData* gd) { if (!face->charmap || (face->charmap->encoding != FT_ENCODING_UNICODE &&
face->charmap->encoding != FT_ENCODING_MS_SYMBOL)) { if (FT_Err_Ok != FT_Select_Charmap(face, FT_ENCODING_UNICODE) &&
FT_Err_Ok != FT_Select_Charmap(face, FT_ENCODING_MS_SYMBOL)) {
NS_WARNING("failed to select Unicode or symbol charmap!");
}
}
FT_UInt gid = FT_Get_Char_Index(face, ch);
if (gid == 0) { // this font doesn't support this char!
NS_ASSERTION(gid != 0, "We don't have a glyph, but font indicated that it supported " "this char in tables?");
gd->glyphIndex = 0; return;
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.15Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.