Skip to content

Commit

Permalink
[Cocoa] Slightly improve text shaping logging
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=260942
rdar://114742142

Reviewed by Cameron McCormack.

This additional logging helped me fix a bug I was investigating.

No test because there is no behavior change.

* Source/WebCore/platform/graphics/coretext/FontCoreText.cpp:
(WebCore::Font::applyTransforms const):

Canonical link: https://commits.webkit.org/267492@main
  • Loading branch information
litherum committed Aug 31, 2023
1 parent aed2f1d commit 3ebb0e8
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions Source/WebCore/platform/graphics/coretext/FontCoreText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include <pal/spi/cg/CoreGraphicsSPI.h>
#include <unicode/uchar.h>
#include <wtf/Assertions.h>
#include <wtf/HexNumber.h>
#include <wtf/RetainPtr.h>
#include <wtf/StdLibExtras.h>

Expand Down Expand Up @@ -612,12 +613,15 @@ GlyphBufferAdvance Font::applyTransforms(GlyphBuffer& glyphBuffer, unsigned begi
| (enableKerning && numberOfInputGlyphs ? kCTFontShapeWithKerning : 0)
| (textDirection == TextDirection::RTL ? kCTFontShapeRightToLeft : 0);

// FIXME: This shouldn't actually be necessary, if we pass in a pointer to the base of the string.
for (unsigned i = 0; i < glyphBuffer.size() - beginningGlyphIndex; ++i)
glyphBuffer.offsetsInString(beginningGlyphIndex)[i] -= beginningStringIndex;

LOG_WITH_STREAM(TextShaping,
stream << "Simple shaping " << numberOfInputGlyphs << " glyphs in font " << String(adoptCF(CTFontCopyPostScriptName(m_platformData.ctFont())).get()) << ".\n";
stream << "Font attributes: " << String(adoptCF(CFCopyDescription(adoptCF(CTFontDescriptorCopyAttributes(adoptCF(CTFontCopyFontDescriptor(m_platformData.ctFont())).get())).get())).get()) << "\n";
stream << "Locale: " << String(localeString.get()) << "\n";
stream << "Options: " << options << "\n";
const auto* glyphs = glyphBuffer.glyphs(beginningGlyphIndex);
stream << "Glyphs:";
for (unsigned i = 0; i < numberOfInputGlyphs; ++i)
Expand All @@ -641,7 +645,7 @@ GlyphBufferAdvance Font::applyTransforms(GlyphBuffer& glyphBuffer, unsigned begi
const UChar* codeUnits = upconvertedCharacters.get();
stream << "Code Units:";
for (unsigned i = 0; i < numberOfInputGlyphs; ++i)
stream << " " << codeUnits[i];
stream << " U+" << hex(codeUnits[i], 4);
);

auto initialAdvance = CTFontShapeGlyphs(
Expand Down Expand Up @@ -678,11 +682,6 @@ GlyphBufferAdvance Font::applyTransforms(GlyphBuffer& glyphBuffer, unsigned begi
for (unsigned i = 0; i < glyphBuffer.size() - beginningGlyphIndex; ++i)
stream << " " << offsets[i];
stream << "\n";
const UChar* codeUnits = upconvertedCharacters.get();
stream << "Code Units:";
for (unsigned i = 0; i < glyphBuffer.size() - beginningGlyphIndex; ++i)
stream << " " << codeUnits[i];
stream << "\n";
stream << "Initial advance: " << FloatSize(initialAdvance);
);

Expand All @@ -692,7 +691,6 @@ GlyphBufferAdvance Font::applyTransforms(GlyphBuffer& glyphBuffer, unsigned begi
for (unsigned i = 0; i < glyphBuffer.size() - beginningGlyphIndex; ++i)
glyphBuffer.offsetsInString(beginningGlyphIndex)[i] += beginningStringIndex;

// See the comment above in this function where the other call to reverse() is.
if (textDirection == TextDirection::RTL)
glyphBuffer.reverse(beginningGlyphIndex, glyphBuffer.size() - beginningGlyphIndex);

Expand Down

0 comments on commit 3ebb0e8

Please sign in to comment.