Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: Source/platform/fonts/Font.cpp

Issue 656913006: Remove SVG fonts (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update tests for landing Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved. 6 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 cacheEntry->width = result; 254 cacheEntry->width = result;
255 } 255 }
256 256
257 if (glyphOverflow) 257 if (glyphOverflow)
258 updateGlyphOverflowFromBounds(glyphBounds, fontMetrics(), glyphOverflow) ; 258 updateGlyphOverflowFromBounds(glyphBounds, fontMetrics(), glyphOverflow) ;
259 return result; 259 return result;
260 } 260 }
261 261
262 float Font::width(const TextRun& run, int& charsConsumed, Glyph& glyphId) const 262 float Font::width(const TextRun& run, int& charsConsumed, Glyph& glyphId) const
263 { 263 {
264 #if ENABLE(SVG_FONTS)
265 if (TextRun::RenderingContext* renderingContext = run.renderingContext())
266 return renderingContext->floatWidthUsingSVGFont(*this, run, charsConsume d, glyphId);
267 #endif
268
269 charsConsumed = run.length(); 264 charsConsumed = run.length();
270 glyphId = 0; 265 glyphId = 0;
271 return width(run); 266 return width(run);
272 } 267 }
273 268
274 namespace { 269 namespace {
275 270
276 template <bool hasOffsets> 271 template <bool hasOffsets>
277 bool buildTextBlobInternal(const GlyphBuffer& glyphBuffer, SkScalar initialAdvan ce, 272 bool buildTextBlobInternal(const GlyphBuffer& glyphBuffer, SkScalar initialAdvan ce,
278 const SkRect* bounds, bool couldUseLCD, SkTextBlobBuilder& builder) 273 const SkRect* bounds, bool couldUseLCD, SkTextBlobBuilder& builder)
279 { 274 {
280 SkScalar x = initialAdvance; 275 SkScalar x = initialAdvance;
281 unsigned i = 0; 276 unsigned i = 0;
282 while (i < glyphBuffer.size()) { 277 while (i < glyphBuffer.size()) {
283 const SimpleFontData* fontData = glyphBuffer.fontDataAt(i); 278 const SimpleFontData* fontData = glyphBuffer.fontDataAt(i);
284 279
285 // FIXME: Handle vertical text. 280 // FIXME: Handle vertical text.
286 if (fontData->platformData().orientation() == Vertical) 281 if (fontData->platformData().orientation() == Vertical)
287 return false; 282 return false;
288 283
289 // FIXME: Handle SVG fonts.
290 if (fontData->isSVGFont())
291 return false;
292
293 // FIXME: FontPlatformData makes some decisions on the device scale 284 // FIXME: FontPlatformData makes some decisions on the device scale
294 // factor, which is found via the GraphicsContext. This should be fixed 285 // factor, which is found via the GraphicsContext. This should be fixed
295 // to avoid correctness problems here. 286 // to avoid correctness problems here.
296 SkPaint paint; 287 SkPaint paint;
297 fontData->platformData().setupPaint(&paint); 288 fontData->platformData().setupPaint(&paint);
298 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 289 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
299 290
300 // FIXME: this should go away after the big LCD cleanup. 291 // FIXME: this should go away after the big LCD cleanup.
301 paint.setLCDRenderText(paint.isLCDRenderText() && couldUseLCD); 292 paint.setLCDRenderText(paint.isLCDRenderText() && couldUseLCD);
302 293
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 return offsetForPositionForComplexText(run, x, includePartialGlyphs); 365 return offsetForPositionForComplexText(run, x, includePartialGlyphs);
375 } 366 }
376 367
377 CodePath Font::codePath(const TextRunPaintInfo& runInfo) const 368 CodePath Font::codePath(const TextRunPaintInfo& runInfo) const
378 { 369 {
379 const TextRun& run = runInfo.run; 370 const TextRun& run = runInfo.run;
380 371
381 if (fontDescription().typesettingFeatures() && (runInfo.from || runInfo.to ! = run.length())) 372 if (fontDescription().typesettingFeatures() && (runInfo.from || runInfo.to ! = run.length()))
382 return ComplexPath; 373 return ComplexPath;
383 374
384 #if ENABLE(SVG_FONTS)
385 if (run.renderingContext())
386 return SimplePath;
387 #endif
388
389 if (m_fontDescription.featureSettings() && m_fontDescription.featureSettings ()->size() > 0 && m_fontDescription.letterSpacing() == 0) 375 if (m_fontDescription.featureSettings() && m_fontDescription.featureSettings ()->size() > 0 && m_fontDescription.letterSpacing() == 0)
390 return ComplexPath; 376 return ComplexPath;
391 377
392 if (m_fontDescription.widthVariant() != RegularWidth) 378 if (m_fontDescription.widthVariant() != RegularWidth)
393 return ComplexPath; 379 return ComplexPath;
394 380
395 if (run.length() > 1 && fontDescription().typesettingFeatures()) 381 if (run.length() > 1 && fontDescription().typesettingFeatures())
396 return ComplexPath; 382 return ComplexPath;
397 383
398 // FIXME: This really shouldn't be needed but for some reason the 384 // FIXME: This really shouldn't be needed but for some reason the
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 } 523 }
538 } 524 }
539 return std::make_pair(data, page); 525 return std::make_pair(data, page);
540 } 526 }
541 527
542 std::pair<GlyphData, GlyphPage*> Font::glyphDataAndPageForCharacter(UChar32& c, bool mirror, bool normalizeSpace, FontDataVariant variant) const 528 std::pair<GlyphData, GlyphPage*> Font::glyphDataAndPageForCharacter(UChar32& c, bool mirror, bool normalizeSpace, FontDataVariant variant) const
543 { 529 {
544 ASSERT(isMainThread()); 530 ASSERT(isMainThread());
545 531
546 if (variant == AutoVariant) { 532 if (variant == AutoVariant) {
547 if (m_fontDescription.variant() == FontVariantSmallCaps && !primaryFont( )->isSVGFont()) { 533 if (m_fontDescription.variant() == FontVariantSmallCaps) {
548 UChar32 upperC = toUpper(c); 534 UChar32 upperC = toUpper(c);
549 if (upperC != c) { 535 if (upperC != c) {
550 c = upperC; 536 c = upperC;
551 variant = SmallCapsVariant; 537 variant = SmallCapsVariant;
552 } else { 538 } else {
553 variant = NormalVariant; 539 variant = NormalVariant;
554 } 540 }
555 } else { 541 } else {
556 variant = NormalVariant; 542 variant = NormalVariant;
557 } 543 }
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 float Font::drawGlyphBuffer(GraphicsContext* context, 953 float Font::drawGlyphBuffer(GraphicsContext* context,
968 const TextRunPaintInfo& runInfo, const GlyphBuffer& glyphBuffer, 954 const TextRunPaintInfo& runInfo, const GlyphBuffer& glyphBuffer,
969 const FloatPoint& point) const 955 const FloatPoint& point) const
970 { 956 {
971 // Draw each contiguous run of glyphs that use the same font data. 957 // Draw each contiguous run of glyphs that use the same font data.
972 const SimpleFontData* fontData = glyphBuffer.fontDataAt(0); 958 const SimpleFontData* fontData = glyphBuffer.fontDataAt(0);
973 FloatPoint startPoint(point); 959 FloatPoint startPoint(point);
974 float advanceSoFar = 0; 960 float advanceSoFar = 0;
975 unsigned lastFrom = 0; 961 unsigned lastFrom = 0;
976 unsigned nextGlyph = 0; 962 unsigned nextGlyph = 0;
977 #if ENABLE(SVG_FONTS)
978 TextRun::RenderingContext* renderingContext = runInfo.run.renderingContext() ;
979 #endif
980 963
981 while (nextGlyph < glyphBuffer.size()) { 964 while (nextGlyph < glyphBuffer.size()) {
982 const SimpleFontData* nextFontData = glyphBuffer.fontDataAt(nextGlyph); 965 const SimpleFontData* nextFontData = glyphBuffer.fontDataAt(nextGlyph);
983 966
984 if (nextFontData != fontData) { 967 if (nextFontData != fontData) {
985 #if ENABLE(SVG_FONTS) 968 drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - las tFrom, startPoint, runInfo.bounds);
986 if (renderingContext && fontData->isSVGFont())
987 renderingContext->drawSVGGlyphs(context, runInfo.run, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint);
988 else
989 #endif
990 drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint, runInfo.bounds);
991 969
992 lastFrom = nextGlyph; 970 lastFrom = nextGlyph;
993 fontData = nextFontData; 971 fontData = nextFontData;
994 startPoint += FloatSize(advanceSoFar, 0); 972 startPoint += FloatSize(advanceSoFar, 0);
995 advanceSoFar = 0; 973 advanceSoFar = 0;
996 } 974 }
997 advanceSoFar += glyphBuffer.advanceAt(nextGlyph); 975 advanceSoFar += glyphBuffer.advanceAt(nextGlyph);
998 nextGlyph++; 976 nextGlyph++;
999 } 977 }
1000 978
1001 #if ENABLE(SVG_FONTS) 979 drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, s tartPoint, runInfo.bounds);
1002 if (renderingContext && fontData->isSVGFont())
1003 renderingContext->drawSVGGlyphs(context, runInfo.run, fontData, glyphBuf fer, lastFrom, nextGlyph - lastFrom, startPoint);
1004 else
1005 #endif
1006 drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFro m, startPoint, runInfo.bounds);
1007
1008 startPoint += FloatSize(advanceSoFar, 0); 980 startPoint += FloatSize(advanceSoFar, 0);
1009 return startPoint.x() - point.x(); 981 return startPoint.x() - point.x();
1010 } 982 }
1011 983
1012 inline static float offsetToMiddleOfGlyph(const SimpleFontData* fontData, Glyph glyph) 984 inline static float offsetToMiddleOfGlyph(const SimpleFontData* fontData, Glyph glyph)
1013 { 985 {
1014 if (fontData->platformData().orientation() == Horizontal) { 986 if (fontData->platformData().orientation() == Horizontal) {
1015 FloatRect bounds = fontData->boundsForGlyph(glyph); 987 FloatRect bounds = fontData->boundsForGlyph(glyph);
1016 return bounds.x() + bounds.width() / 2; 988 return bounds.x() + bounds.width() / 2;
1017 } 989 }
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 if (delta <= 0) 1103 if (delta <= 0)
1132 break; 1104 break;
1133 } 1105 }
1134 } 1106 }
1135 } 1107 }
1136 1108
1137 return offset; 1109 return offset;
1138 } 1110 }
1139 1111
1140 } // namespace blink 1112 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698