| OLD | NEW |
| 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 enum BlobRotation { | 243 enum BlobRotation { |
| 244 NoRotation, | 244 NoRotation, |
| 245 CCWRotation, | 245 CCWRotation, |
| 246 }; | 246 }; |
| 247 | 247 |
| 248 class GlyphBufferBloberizer { | 248 class GlyphBufferBloberizer { |
| 249 STACK_ALLOCATED() | 249 STACK_ALLOCATED() |
| 250 public: | 250 public: |
| 251 GlyphBufferBloberizer(const GlyphBuffer& buffer, const Font* font, float dev
iceScaleFactor) | 251 GlyphBufferBloberizer(const GlyphBuffer& buffer, const Font* font, float dev
iceScaleFactor) |
| 252 : m_buffer(buffer) | 252 : m_buffer(buffer) |
| 253 , m_font(font) | |
| 254 , m_deviceScaleFactor(deviceScaleFactor) | 253 , m_deviceScaleFactor(deviceScaleFactor) |
| 255 , m_hasVerticalOffsets(buffer.hasVerticalOffsets()) | 254 , m_hasVerticalOffsets(buffer.hasVerticalOffsets()) |
| 256 , m_index(0) | 255 , m_index(0) |
| 257 , m_blobCount(0) | 256 , m_blobCount(0) |
| 258 , m_rotation(buffer.isEmpty() ? NoRotation : computeBlobRotation(buffer.
fontDataAt(0))) | 257 , m_rotation(buffer.isEmpty() ? NoRotation : computeBlobRotation(buffer.
fontDataAt(0))) |
| 259 { } | 258 { } |
| 260 | 259 |
| 261 bool done() const { return m_index >= m_buffer.size(); } | 260 bool done() const { return m_index >= m_buffer.size(); } |
| 262 unsigned blobCount() const { return m_blobCount; } | 261 unsigned blobCount() const { return m_blobCount; } |
| 263 | 262 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 294 { | 293 { |
| 295 // For vertical upright text we need to compensate the inherited 90deg C
W rotation | 294 // For vertical upright text we need to compensate the inherited 90deg C
W rotation |
| 296 // (using a 90deg CCW rotation). | 295 // (using a 90deg CCW rotation). |
| 297 return (font->platformData().isVerticalAnyUpright() && font->verticalDat
a()) ? | 296 return (font->platformData().isVerticalAnyUpright() && font->verticalDat
a()) ? |
| 298 CCWRotation : NoRotation; | 297 CCWRotation : NoRotation; |
| 299 } | 298 } |
| 300 | 299 |
| 301 void appendRun(unsigned start, unsigned count, const SimpleFontData* fontDat
a) | 300 void appendRun(unsigned start, unsigned count, const SimpleFontData* fontDat
a) |
| 302 { | 301 { |
| 303 SkPaint paint; | 302 SkPaint paint; |
| 304 fontData->platformData().setupPaint(&paint, m_deviceScaleFactor, m_font)
; | 303 fontData->style().apply(&paint, m_deviceScaleFactor); |
| 304 fontData->platformData().setupPaint(&paint); |
| 305 paint.setTextSize(SkFloatToScalar(fontData->size())); |
| 305 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); | 306 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); |
| 306 | 307 |
| 307 const SkTextBlobBuilder::RunBuffer& buffer = m_hasVerticalOffsets | 308 const SkTextBlobBuilder::RunBuffer& buffer = m_hasVerticalOffsets |
| 308 ? m_builder.allocRunPos(paint, count) | 309 ? m_builder.allocRunPos(paint, count) |
| 309 : m_builder.allocRunPosH(paint, count, 0); | 310 : m_builder.allocRunPosH(paint, count, 0); |
| 310 | 311 |
| 311 const uint16_t* glyphs = m_buffer.glyphs(start); | 312 const uint16_t* glyphs = m_buffer.glyphs(start); |
| 312 const float* offsets = m_buffer.offsets(start); | 313 const float* offsets = m_buffer.offsets(start); |
| 313 std::copy(glyphs, glyphs + count, buffer.glyphs); | 314 std::copy(glyphs, glyphs + count, buffer.glyphs); |
| 314 | 315 |
| 315 if (m_rotation == NoRotation) { | 316 if (m_rotation == NoRotation) { |
| 316 std::copy(offsets, offsets + (m_hasVerticalOffsets ? 2 * count : cou
nt), buffer.pos); | 317 std::copy(offsets, offsets + (m_hasVerticalOffsets ? 2 * count : cou
nt), buffer.pos); |
| 317 } else { | 318 } else { |
| 318 ASSERT(m_hasVerticalOffsets); | 319 ASSERT(m_hasVerticalOffsets); |
| 319 | 320 |
| 320 const float verticalBaselineXOffset = fontData->getFontMetrics().flo
atAscent() | 321 const float verticalBaselineXOffset = fontData->getFontMetrics().flo
atAscent() |
| 321 - fontData->getFontMetrics().floatAscent(IdeographicBaseline); | 322 - fontData->getFontMetrics().floatAscent(IdeographicBaseline); |
| 322 | 323 |
| 323 // TODO(fmalita): why don't we apply this adjustment when building t
he glyph buffer? | 324 // TODO(fmalita): why don't we apply this adjustment when building t
he glyph buffer? |
| 324 for (unsigned i = 0; i < 2 * count; i += 2) { | 325 for (unsigned i = 0; i < 2 * count; i += 2) { |
| 325 buffer.pos[i] = SkFloatToScalar(offsets[i] + verticalBaselineXOf
fset); | 326 buffer.pos[i] = SkFloatToScalar(offsets[i] + verticalBaselineXOf
fset); |
| 326 buffer.pos[i + 1] = SkFloatToScalar(offsets[i + 1]); | 327 buffer.pos[i + 1] = SkFloatToScalar(offsets[i + 1]); |
| 327 } | 328 } |
| 328 } | 329 } |
| 329 } | 330 } |
| 330 | 331 |
| 331 const GlyphBuffer& m_buffer; | 332 const GlyphBuffer& m_buffer; |
| 332 const Font* m_font; | |
| 333 const float m_deviceScaleFactor; | 333 const float m_deviceScaleFactor; |
| 334 const bool m_hasVerticalOffsets; | 334 const bool m_hasVerticalOffsets; |
| 335 | 335 |
| 336 SkTextBlobBuilder m_builder; | 336 SkTextBlobBuilder m_builder; |
| 337 unsigned m_index; | 337 unsigned m_index; |
| 338 unsigned m_blobCount; | 338 unsigned m_blobCount; |
| 339 BlobRotation m_rotation; | 339 BlobRotation m_rotation; |
| 340 }; | 340 }; |
| 341 | 341 |
| 342 } // anonymous namespace | 342 } // anonymous namespace |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 bool Font::computeCanShapeWordByWord() const | 460 bool Font::computeCanShapeWordByWord() const |
| 461 { | 461 { |
| 462 if (!getFontDescription().getTypesettingFeatures()) | 462 if (!getFontDescription().getTypesettingFeatures()) |
| 463 return true; | 463 return true; |
| 464 | 464 |
| 465 if (!primaryFont()) | 465 if (!primaryFont()) |
| 466 return false; | 466 return false; |
| 467 | 467 |
| 468 const FontPlatformData& platformData = primaryFont()->platformData(); | 468 const FontPlatformData& platformData = primaryFont()->platformData(); |
| 469 TypesettingFeatures features = getFontDescription().getTypesettingFeatures()
; | 469 TypesettingFeatures features = getFontDescription().getTypesettingFeatures()
; |
| 470 return !platformData.hasSpaceInLigaturesOrKerning(features); | 470 return !platformData.hasSpaceInLigaturesOrKerning(primaryFont()->size(), pri
maryFont()->style(), features); |
| 471 }; | 471 }; |
| 472 | 472 |
| 473 void Font::willUseFontData(UChar32 character) const | 473 void Font::willUseFontData(UChar32 character) const |
| 474 { | 474 { |
| 475 const FontFamily& family = getFontDescription().family(); | 475 const FontFamily& family = getFontDescription().family(); |
| 476 if (m_fontFallbackList && m_fontFallbackList->getFontSelector() && !family.f
amilyIsEmpty()) | 476 if (m_fontFallbackList && m_fontFallbackList->getFontSelector() && !family.f
amilyIsEmpty()) |
| 477 m_fontFallbackList->getFontSelector()->willUseFontData(getFontDescriptio
n(), family.family(), character); | 477 m_fontFallbackList->getFontSelector()->willUseFontData(getFontDescriptio
n(), family.family(), character); |
| 478 } | 478 } |
| 479 | 479 |
| 480 static inline GlyphData glyphDataForNonCJKCharacterWithGlyphOrientation(UChar32
character, bool isUpright, GlyphData& data, unsigned pageNumber) | 480 static inline GlyphData glyphDataForNonCJKCharacterWithGlyphOrientation(UChar32
character, bool isUpright, GlyphData& data, unsigned pageNumber) |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 { | 843 { |
| 844 return m_fontFallbackList && m_fontFallbackList->loadingCustomFonts(); | 844 return m_fontFallbackList && m_fontFallbackList->loadingCustomFonts(); |
| 845 } | 845 } |
| 846 | 846 |
| 847 bool Font::isFallbackValid() const | 847 bool Font::isFallbackValid() const |
| 848 { | 848 { |
| 849 return !m_fontFallbackList || m_fontFallbackList->isValid(); | 849 return !m_fontFallbackList || m_fontFallbackList->isValid(); |
| 850 } | 850 } |
| 851 | 851 |
| 852 } // namespace blink | 852 } // namespace blink |
| OLD | NEW |