Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
原因是js用了FaceFont然后传字体数据,此时会在BinaryDataFontFaceSource::createFontData里创建自定义字体。而此字体在
SkScalerContext_GDI::SkScalerContext_GDI里通过CreateFontIndirect创建的fTM.tmMaxCharWidth是0,从而在
Font::drawText->SkCanvas::drawPosTextH->SkRecorder::onDrawPosTextH里传给了
SkRecordDraw.cpp:AdjustTextForFontMetrics,
导致了断言错误。
chromium没出现这断言的原因是Font::drawGlyphBuffer走drawTextBlob通路了,没调用到
SkRecorder::onDrawPosTextH
所以这次我独立做了个修复,如果创建自定义字体的tmMaxCharWidth是0,就赋值为tmAveCharWidth
  • Loading branch information
weolar committed May 20, 2018
1 parent 9f7a531 commit bc3dcc4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion third_party/skia/src/ports/SkFontHost_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,14 +662,17 @@ SkScalerContext_GDI::SkScalerContext_GDI(SkTypeface* rawTypeface,
}

fSavefont = (HFONT)SelectObject(fDDC, fFont);

if (0 == GetTextMetrics(fDDC, &fTM)) {
call_ensure_accessible(lf);
if (0 == GetTextMetrics(fDDC, &fTM)) {
fTM.tmPitchAndFamily = TMPF_TRUETYPE;
}
}

if (0 == fTM.tmMaxCharWidth)
fTM.tmMaxCharWidth = fTM.tmAveCharWidth;

XFORM xform;
if (fTM.tmPitchAndFamily & TMPF_VECTOR) {
// Used a logfont on a memory context, should never get a device font.
Expand Down

0 comments on commit bc3dcc4

Please sign in to comment.