/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
auto aVariations = pFace->GetVariations(*this); if (!aVariations.empty())
hb_font_set_variations(pHbFont, aVariations.data(), aVariations.size());
// If we are applying artificial italic, instruct HarfBuzz to do the same // so that mark positioning is also transformed. if (NeedsArtificialItalic())
hb_font_set_synthetic_slant(pHbFont, ARTIFICIAL_ITALIC_SKEW);
if (nYScale)
*nYScale = m_aFontSelData.mnHeight / nUPEM;
if (nXScale)
{ // On Windows, mnWidth is relative to average char width not font height, // and we need to keep it that way for GDI to correctly scale the glyphs. // Here we compensate for this so that HarfBuzz gives us the correct glyph // positions. double nWidth(m_aFontSelData.mnWidth ? m_aFontSelData.mnWidth * GetAverageWidthFactor()
: m_aFontSelData.mnHeight);
*nXScale = nWidth / nUPEM;
}
}
void LogicalFontInstance::IgnoreFallbackForUnicode(sal_UCS4 cChar, FontWeight eWeight,
std::u16string_view rFontName)
{
UnicodeFallbackList::iterator it
= maUnicodeFallbackList.find(std::pair<sal_UCS4, FontWeight>(cChar, eWeight)); if (it == maUnicodeFallbackList.end()) return; const MapEntry& rEntry = (*it).second; if (rEntry.sFontName == rFontName)
maUnicodeFallbackList.erase(it);
}
bool LogicalFontInstance::GetGlyphBoundRect(sal_GlyphId nID, basegfx::B2DRectangle& rRect, bool bVertical) const
{ // TODO: find out if it's possible for the same glyph in the same font to be used both // normally and vertically; if yes, then these two variants must be cached separately
if (mpFontCache && mpFontCache->GetCachedGlyphBoundRect(this, nID, rRect)) returntrue;
auto orientation = mnOrientation; if (bVertical)
orientation += 900_deg10; if (orientation)
{ // Apply font rotation.
rRect.transform(basegfx::utils::createRotateB2DHomMatrix(-toRadians(orientation)));
}
if (mpFontCache)
mpFontCache->CacheGlyphBoundRect(this, nID, rRect);
bool LogicalFontInstance::NeedOffsetCorrection(sal_Int32 nYOffset)
{ if (!m_xeFontFamilyEnum)
{
m_xeFontFamilyEnum = FontFamilyEnum::Unclassified;
// DFKai-SB (ukai.ttf) is a built-in font under traditional Chinese // Windows. It has wrong extent values in glyf table. The problem results // in wrong positioning of glyphs in vertical writing. // Check https://github.com/harfbuzz/harfbuzz/issues/3521 for reference. if (GetFontFace()->GetName(vcl::font::NAME_ID_FONT_FAMILY) == "DFKai-SB")
m_xeFontFamilyEnum = FontFamilyEnum::DFKaiSB;
}
bool bRet = true;
switch (*m_xeFontFamilyEnum)
{ case FontFamilyEnum::DFKaiSB: // -839: optimization for one third of ukai.ttf if (nYOffset == -839)
bRet = false; break; default:
bRet = false;
}
void close_path_func(hb_draw_funcs_t*, void* pDrawData, hb_draw_state_t*, void* pUserData)
{ auto pPolyPoly = static_cast<basegfx::B2DPolyPolygon*>(pDrawData); auto pPoly = static_cast<basegfx::B2DPolygon*>(pUserData);
pPolyPoly->append(*pPoly);
pPoly->clear();
}
}
basegfx::B2DPolyPolygon LogicalFontInstance::GetGlyphOutlineUntransformed(sal_GlyphId nGlyph) const
{ if (!m_pHbDrawFuncs)
{
m_pHbDrawFuncs = hb_draw_funcs_create(); auto pUserData = const_cast<basegfx::B2DPolygon*>(&m_aDrawPolygon);
hb_draw_funcs_set_move_to_func(m_pHbDrawFuncs, move_to_func, pUserData, nullptr);
hb_draw_funcs_set_line_to_func(m_pHbDrawFuncs, line_to_func, pUserData, nullptr);
hb_draw_funcs_set_cubic_to_func(m_pHbDrawFuncs, cubic_to_func, pUserData, nullptr); // B2DPolyPolygon does not support quadratic curves, HarfBuzz will // convert them to cubic curves for us if we don’t set a callback // function. //hb_draw_funcs_set_quadratic_to_func(m_pHbDrawFuncs, quadratic_to_func, pUserData, nullptr);
hb_draw_funcs_set_close_path_func(m_pHbDrawFuncs, close_path_func, pUserData, nullptr);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.