本文整理汇总了C++中FontCascade类的典型用法代码示例。如果您正苦于以下问题:C++ FontCascade类的具体用法?C++ FontCascade怎么用?C++ FontCascade使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FontCascade类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shouldUnavailablePluginMessageBeButton
bool RenderEmbeddedObject::getReplacementTextGeometry(const LayoutPoint& accumulatedOffset, FloatRect& contentRect, FloatRect& indicatorRect, FloatRect& replacementTextRect, FloatRect& arrowRect, FontCascade& font, TextRun& run, float& textWidth) const
{
bool includesArrow = shouldUnavailablePluginMessageBeButton(document(), m_pluginUnavailabilityReason);
contentRect = contentBoxRect();
contentRect.moveBy(roundedIntPoint(accumulatedOffset));
FontCascadeDescription fontDescription;
RenderTheme::defaultTheme()->systemFont(CSSValueWebkitSmallControl, fontDescription);
fontDescription.setWeight(FontWeightBold);
fontDescription.setRenderingMode(frame().settings().fontRenderingMode());
fontDescription.setComputedSize(12);
font = FontCascade(fontDescription, 0, 0);
font.update(0);
run = TextRun(m_unavailablePluginReplacementText);
textWidth = font.width(run);
replacementTextRect.setSize(FloatSize(textWidth + replacementTextRoundedRectLeftTextMargin + (includesArrow ? replacementTextRoundedRectRightTextMarginWithArrow : replacementTextRoundedRectRightTextMargin), replacementTextRoundedRectHeight));
float x = (contentRect.size().width() / 2 - replacementTextRect.size().width() / 2) + contentRect.location().x();
float y = (contentRect.size().height() / 2 - replacementTextRect.size().height() / 2) + contentRect.location().y();
replacementTextRect.setLocation(FloatPoint(x, y));
indicatorRect = replacementTextRect;
// Expand the background rect to include the arrow, if it will be used.
if (includesArrow) {
arrowRect = indicatorRect;
arrowRect.setX(ceilf(arrowRect.maxX() + replacementArrowLeftMargin));
arrowRect.setWidth(arrowRect.height());
indicatorRect.unite(arrowRect);
}
return true;
}
示例2: doDrawTextAtPoint
static void doDrawTextAtPoint(GraphicsContext& context, const String& text, const IntPoint& point, const FontCascade& font, const Color& color, int underlinedIndex)
{
TextRun run(text);
context.setFillColor(color);
if (isOneLeftToRightRun(run))
font.drawText(context, run, point);
else
context.drawBidiText(font, run, point);
if (underlinedIndex >= 0) {
ASSERT_WITH_SECURITY_IMPLICATION(underlinedIndex < static_cast<int>(text.length()));
int beforeWidth;
if (underlinedIndex > 0) {
TextRun beforeRun(StringView(text).substring(0, underlinedIndex));
beforeWidth = font.width(beforeRun);
} else
beforeWidth = 0;
TextRun underlinedRun(StringView(text).substring(underlinedIndex, 1));
int underlinedWidth = font.width(underlinedRun);
IntPoint underlinePoint(point);
underlinePoint.move(beforeWidth, 1);
context.setStrokeColor(color);
context.drawLineForText(underlinePoint, underlinedWidth, false);
}
}
示例3: paintReplaced
void RenderEmbeddedObject::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
if (!showsUnavailablePluginIndicator())
return;
if (paintInfo.phase == PaintPhaseSelection)
return;
GraphicsContext& context = paintInfo.context();
if (context.paintingDisabled())
return;
FloatRect contentRect;
FloatRect indicatorRect;
FloatRect replacementTextRect;
FloatRect arrowRect;
FontCascade font;
TextRun run(emptyString());
float textWidth;
if (!getReplacementTextGeometry(paintOffset, contentRect, indicatorRect, replacementTextRect, arrowRect, font, run, textWidth))
return;
Path background;
background.addRoundedRect(indicatorRect, FloatSize(replacementTextRoundedRectRadius, replacementTextRoundedRectRadius));
GraphicsContextStateSaver stateSaver(context);
context.clip(contentRect);
context.setFillColor(m_unavailablePluginIndicatorIsPressed ? replacementTextRoundedRectPressedColor() : replacementTextRoundedRectColor());
context.fillPath(background);
Path strokePath;
FloatRect strokeRect(indicatorRect);
strokeRect.inflate(1);
strokePath.addRoundedRect(strokeRect, FloatSize(replacementTextRoundedRectRadius + 1, replacementTextRoundedRectRadius + 1));
context.setStrokeColor(unavailablePluginBorderColor());
context.setStrokeThickness(2);
context.strokePath(strokePath);
const FontMetrics& fontMetrics = font.fontMetrics();
float labelX = roundf(replacementTextRect.location().x() + replacementTextRoundedRectLeftTextMargin);
float labelY = roundf(replacementTextRect.location().y() + (replacementTextRect.size().height() - fontMetrics.height()) / 2 + fontMetrics.ascent() + replacementTextRoundedRectTopTextMargin);
context.setFillColor(replacementTextColor());
context.drawBidiText(font, run, FloatPoint(labelX, labelY));
if (shouldUnavailablePluginMessageBeButton(document(), m_pluginUnavailabilityReason)) {
arrowRect.inflate(-replacementArrowCirclePadding);
context.beginTransparencyLayer(1.0);
context.setFillColor(replacementTextColor());
context.fillEllipse(arrowRect);
context.setCompositeOperation(CompositeClear);
drawReplacementArrow(context, arrowRect);
context.endTransparencyLayer();
}
}
示例4: drawGlyphs
void GraphicsContext::drawGlyphs(const FontCascade& fontCascade, const Font& font, const GlyphBuffer& buffer, int from, int numGlyphs, const FloatPoint& point)
{
if (paintingDisabled())
return;
if (isRecording()) {
m_displayListRecorder->drawGlyphs(font, buffer, from, numGlyphs, point, fontCascade.fontDescription().fontSmoothing());
return;
}
fontCascade.drawGlyphs(*this, font, buffer, from, numGlyphs, point, fontCascade.fontDescription().fontSmoothing());
}
示例5: checkFont
bool FontLoader::checkFont(const String& fontString, const String&)
{
// FIXME: The second parameter (text) is ignored.
FontCascade font;
if (!resolveFontStyle(fontString, font))
return false;
for (unsigned i = 0; i < font.familyCount(); i++) {
CSSSegmentedFontFace* face = m_document->fontSelector().getFontFace(font.fontDescription(), font.familyAt(i));
if (!face || !face->checkFont())
return false;
}
return true;
}
示例6: width
float RenderCombineText::width(unsigned from, unsigned length, const FontCascade& font, float xPosition, HashSet<const Font*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
{
if (m_isCombined)
return font.size();
return RenderText::width(from, length, font, xPosition, fallbackFonts, glyphOverflow);
}
示例7: drawText
float GraphicsContext::drawText(const FontCascade& font, const TextRun& run, const FloatPoint& point, int from, int to)
{
if (paintingDisabled())
return 0;
return font.drawText(*this, run, point, from, to);
}
示例8: drawGlyphs
void GraphicsContext::drawGlyphs(const FontCascade& fontCascade, const Font& font, const GlyphBuffer& buffer, int from, int numGlyphs, const FloatPoint& point)
{
if (paintingDisabled())
return;
fontCascade.drawGlyphs(*this, font, buffer, from, numGlyphs, point);
}
示例9: drawEmphasisMarks
void GraphicsContext::drawEmphasisMarks(const FontCascade& font, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, int to)
{
if (paintingDisabled())
return;
font.drawEmphasisMarks(*this, run, mark, point, from, to);
}
示例10: drawBidiText
void GraphicsContext::drawBidiText(const FontCascade& font, const TextRun& run, const FloatPoint& point, FontCascade::CustomFontNotReadyAction customFontNotReadyAction)
{
if (paintingDisabled())
return;
BidiResolver<TextRunIterator, BidiCharacterRun> bidiResolver;
bidiResolver.setStatus(BidiStatus(run.direction(), run.directionalOverride()));
bidiResolver.setPositionIgnoringNestedIsolates(TextRunIterator(&run, 0));
// FIXME: This ownership should be reversed. We should pass BidiRunList
// to BidiResolver in createBidiRunsForLine.
BidiRunList<BidiCharacterRun>& bidiRuns = bidiResolver.runs();
bidiResolver.createBidiRunsForLine(TextRunIterator(&run, run.length()));
if (!bidiRuns.runCount())
return;
FloatPoint currPoint = point;
BidiCharacterRun* bidiRun = bidiRuns.firstRun();
while (bidiRun) {
TextRun subrun = run.subRun(bidiRun->start(), bidiRun->stop() - bidiRun->start());
bool isRTL = bidiRun->level() % 2;
subrun.setDirection(isRTL ? RTL : LTR);
subrun.setDirectionalOverride(bidiRun->dirOverride(false));
float width = font.drawText(*this, subrun, currPoint, 0, -1, customFontNotReadyAction);
currPoint.move(width, 0);
bidiRun = bidiRun->next();
}
bidiRuns.deleteRuns();
}
示例11: stringWidth
static float stringWidth(const FontCascade& renderer, const UChar* characters, unsigned length, bool disableRoundingHacks)
{
TextRun run(characters, length);
if (disableRoundingHacks)
run.disableRoundingHacks();
return renderer.width(run);
}
示例12: dragLabelFont
static FontCascade dragLabelFont(int size, bool bold, FontRenderingMode renderingMode)
{
FontCascade result;
NONCLIENTMETRICS metrics;
metrics.cbSize = sizeof(metrics);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, metrics.cbSize, &metrics, 0);
FontCascadeDescription description;
description.setWeight(bold ? FontWeightBold : FontWeightNormal);
description.setOneFamily(metrics.lfSmCaptionFont.lfFaceName);
description.setSpecifiedSize((float)size);
description.setComputedSize((float)size);
description.setRenderingMode(renderingMode);
result = FontCascade(description, 0, 0);
result.update(0);
return result;
}
示例13: text
void PlatformCALayerWin::drawTextAtPoint(CGContextRef context, CGFloat x, CGFloat y, CGSize scale, CGFloat fontSize, const char* message, size_t length) const
{
String text(message, length);
FontCascadeDescription desc;
NONCLIENTMETRICS metrics;
metrics.cbSize = sizeof(metrics);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, metrics.cbSize, &metrics, 0);
desc.setOneFamily(metrics.lfSmCaptionFont.lfFaceName);
desc.setComputedSize(scale.width * fontSize);
FontCascade font = FontCascade(desc, 0, 0);
font.update(nullptr);
GraphicsContext cg(context);
cg.setFillColor(Color::black, ColorSpaceDeviceRGB);
cg.drawText(font, TextRun(text), IntPoint(x, y));
}
示例14: drawSkipInkUnderline
static void drawSkipInkUnderline(GraphicsContext& context, const FontCascade& font, const TextRun& textRun, const FloatPoint& textOrigin, const FloatPoint& localOrigin,
float underlineOffset, float width, bool isPrinting, bool doubleLines, StrokeStyle strokeStyle)
{
FloatPoint adjustedLocalOrigin = localOrigin;
adjustedLocalOrigin.move(0, underlineOffset);
FloatRect underlineBoundingBox = context.computeUnderlineBoundsForText(adjustedLocalOrigin, width, isPrinting);
DashArray intersections = font.dashesForIntersectionsWithRect(textRun, textOrigin, underlineBoundingBox);
DashArray a = translateIntersectionPointsToSkipInkBoundaries(intersections, underlineBoundingBox.height(), width);
ASSERT(!(a.size() % 2));
context.drawLinesForText(adjustedLocalOrigin, a, isPrinting, doubleLines, strokeStyle);
}
示例15: createFromParams
static PassRefPtr<LoadFontCallback> createFromParams(const Dictionary& params, FontLoader& fontLoader, const FontCascade& font)
{
RefPtr<VoidCallback> onsuccess;
RefPtr<VoidCallback> onerror;
params.get("onsuccess", onsuccess);
params.get("onerror", onerror);
if (!onsuccess && !onerror)
return 0;
int numFamilies = font.familyCount();
return LoadFontCallback::create(numFamilies, fontLoader, onsuccess, onerror);
}