FontCairoHarfbuzzNG.cpp [plain text]
#include "config.h"
#include "Font.h"
#include "GraphicsContext.h"
#include "HarfBuzzShaper.h"
#include "LayoutRect.h"
#include "Logging.h"
#include "NotImplemented.h"
#include "PlatformContextCairo.h"
#include "SimpleFontData.h"
#include <cairo.h>
namespace WebCore {
float Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int, int) const
{
GlyphBuffer glyphBuffer;
HarfBuzzShaper shaper(this, run);
if (shaper.shape(&glyphBuffer)) {
FloatPoint startPoint = point;
float startX = startPoint.x();
drawGlyphBuffer(context, run, glyphBuffer, startPoint);
return startPoint.x() - startX;
}
LOG_ERROR("Shaper couldn't shape glyphBuffer.");
return 0;
}
void Font::drawEmphasisMarksForComplexText(GraphicsContext* , const TextRun& , const AtomicString& , const FloatPoint& , int , int ) const
{
notImplemented();
}
bool Font::canReturnFallbackFontsForComplexText()
{
return false;
}
bool Font::canExpandAroundIdeographsInComplexText()
{
return false;
}
float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>*, GlyphOverflow*) const
{
HarfBuzzShaper shaper(this, run);
if (shaper.shape())
return shaper.totalWidth();
LOG_ERROR("Shaper couldn't shape text run.");
return 0;
}
int Font::offsetForPositionForComplexText(const TextRun& run, float x, bool) const
{
HarfBuzzShaper shaper(this, run);
if (shaper.shape())
return shaper.offsetForPosition(x);
LOG_ERROR("Shaper couldn't shape text run.");
return 0;
}
void Font::adjustSelectionRectForComplexText(const TextRun& run, LayoutRect& selectionRect, int from, int to) const
{
HarfBuzzShaper shaper(this, run);
if (shaper.shape()) {
FloatRect rect = shaper.selectionRect(FloatPoint(selectionRect.location()), selectionRect.height().toInt(), from, to);
selectionRect = LayoutRect(rect);
return;
}
LOG_ERROR("Shaper couldn't shape text run.");
}
}