Bug 1400411 - text-layers: fallback if SVG fonts or tofu is found. r=jrmuizel

MozReview-Commit-ID: 9vUK5r5sKWB

--HG--
extra : rebase_source : 5e4c026cf6c802554772a99064898fde3b414ea8
This commit is contained in:
Alexis Beingessner 2017-09-22 10:57:30 -04:00
Родитель 83f834aede
Коммит 6803f63105
2 изменённых файлов: 21 добавлений и 1 удалений

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

@ -40,6 +40,7 @@
#include "gfxMathTable.h"
#include "gfxSVGGlyphs.h"
#include "gfx2DGlue.h"
#include "TextDrawTarget.h"
#include "GreekCasing.h"
@ -1922,6 +1923,10 @@ gfxFont::DrawGlyphs(const gfxShapedText *aShapedText,
double advance = details->mAdvance;
if (glyphData->IsMissing()) {
if (auto* textDrawer = aRunParams.context->GetTextDrawer()) {
textDrawer->FoundUnsupportedFeature();
return false;
}
// Default-ignorable chars will have zero advance width;
// we don't have to draw the hexbox for them.
if (aRunParams.drawMode != DrawMode::GLYPH_PATH &&
@ -2061,7 +2066,14 @@ gfxFont::Draw(const gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
return;
}
auto* textDrawer = aRunParams.context->GetTextDrawer();
fontParams.haveSVGGlyphs = GetFontEntry()->TryGetSVGData(this);
if (fontParams.haveSVGGlyphs && textDrawer) {
textDrawer->FoundUnsupportedFeature();
return;
}
fontParams.haveColorGlyphs = GetFontEntry()->TryGetColorGlyphs();
fontParams.contextPaint = aRunParams.runContextPaint;
fontParams.isVerticalFont =

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

@ -92,7 +92,7 @@ public:
};
explicit TextDrawTarget()
: mCurrentlyDrawing(Phase::eSelection)
: mCurrentlyDrawing(Phase::eSelection), mHasUnsupportedFeatures(false)
{
mCurrentTarget = gfx::Factory::CreateDrawTarget(gfx::BackendType::SKIA, IntSize(1, 1), gfx::SurfaceFormat::B8G8R8A8);
SetSelectionIndex(0);
@ -104,6 +104,7 @@ public:
// Change the phase of text we're drawing.
void StartDrawing(Phase aPhase) { mCurrentlyDrawing = aPhase; }
void FoundUnsupportedFeature() { mHasUnsupportedFeatures = true; }
void SetSelectionIndex(size_t i) {
// i should only be accessed if i-1 has already been
@ -257,6 +258,10 @@ public:
bool
CanSerializeFonts()
{
if (mHasUnsupportedFeatures) {
return false;
}
for (const SelectedTextRunFragment& part : GetParts()) {
for (const TextRunFragment& frag : part.text) {
if (!frag.font->CanSerialize()) {
@ -385,6 +390,9 @@ private:
// A dummy to handle parts of the DrawTarget impl we don't care for
RefPtr<DrawTarget> mCurrentTarget;
// Whether Tofu or SVG fonts were encountered
bool mHasUnsupportedFeatures;
// The rest of this is dummy implementations of DrawTarget's API
public:
DrawTargetType GetType() const override {