inline bool HarfBuzzShaper::shapeRange(hb_buffer_t* harfBuzzBuffer, unsigned startIndex, unsigned numCharacters, const SimpleFontData* currentFont, PassRefPtr<UnicodeRangeSet> currentFontRangeSet, UScriptCode currentRunScript, hb_language_t language) { const FontPlatformData* platformData = &(currentFont->platformData()); HarfBuzzFace* face = platformData->harfBuzzFace(); if (!face) { DLOG(ERROR) << "Could not create HarfBuzzFace from FontPlatformData."; return false; } hb_buffer_set_language(harfBuzzBuffer, language); hb_buffer_set_script(harfBuzzBuffer, ICUScriptToHBScript(currentRunScript)); hb_buffer_set_direction(harfBuzzBuffer, TextDirectionToHBDirection(m_textRun.direction(), m_font->getFontDescription().orientation(), currentFont)); hb_font_t* hbFont = face->getScaledFont(currentFontRangeSet); hb_shape(hbFont, harfBuzzBuffer, m_features.isEmpty() ? 0 : m_features.data(), m_features.size()); return true; }
bool FontPlatformData::hasSpaceInLigaturesOrKerning( TypesettingFeatures features) const { HarfBuzzFace* hbFace = harfBuzzFace(); if (!hbFace) return false; hb_font_t* font = hbFace->getScaledFont(); ASSERT(font); hb_face_t* face = hb_font_get_face(font); ASSERT(face); hb_codepoint_t space; // If the space glyph isn't present in the font then each space character // will be rendering using a fallback font, which grantees that it cannot // affect the shape of the preceding word. if (!hb_font_get_glyph(font, spaceCharacter, 0, &space)) return false; if (!hb_ot_layout_has_substitution(face) && !hb_ot_layout_has_positioning(face)) { return false; } bool foundSpaceInTable = false; hb_set_t* glyphs = hb_set_create(); if (features & Kerning) foundSpaceInTable = tableHasSpace(face, glyphs, HB_OT_TAG_GPOS, space); if (!foundSpaceInTable && (features & Ligatures)) foundSpaceInTable = tableHasSpace(face, glyphs, HB_OT_TAG_GSUB, space); hb_set_destroy(glyphs); return foundSpaceInTable; }