23#include <hb-graphite2.h>
32 , mpConversion(nullptr)
37 , mpFontCache(nullptr)
38 , m_aFontSelData(rFontSelData)
40 , m_nAveWidthFactor(1.0f)
41 , m_pFontFace(&const_cast<
vcl::font::PhysicalFontFace&>(rFontFace))
64 hb_face_t* pHbFace = pFace->GetHbFace();
66 auto nUPEM = pFace->UnitsPerEm();
68 hb_font_t* pHbFont = hb_font_create(pHbFace);
69 hb_font_set_scale(pHbFont, nUPEM, nUPEM);
70 hb_ot_font_set_funcs(pHbFont);
72 auto aVariations = pFace->GetVariations(*
this);
73 if (!aVariations.empty())
74 hb_font_set_variations(pHbFont, aVariations.data(), aVariations.size());
125 *nYScale = nHeight / nUPEM;
128 *nXScale = nWidth / nUPEM;
132 const OUString& rFontName,
bool bEmbolden,
142 OUString* pFontName,
bool* pEmbolden,
145 UnicodeFallbackList::const_iterator it
150 const MapEntry& rEntry = (*it).second;
158 std::u16string_view rFontName)
160 UnicodeFallbackList::iterator it
164 const MapEntry& rEntry = (*it).second;
170 bool bVertical)
const
176 hb_glyph_extents_t aExtents;
177 bool res = hb_font_get_glyph_extents(pHbFont, nID, &aExtents);
181 double nXScale = 0, nYScale = 0;
184 double fMinX = aExtents.x_bearing;
185 double fMinY = aExtents.y_bearing;
186 double fMaxX = aExtents.x_bearing + aExtents.width;
187 double fMaxY = aExtents.y_bearing + aExtents.height;
189 tools::Rectangle aRect(std::floor(fMinX * nXScale), -std::ceil(fMinY * nYScale),
190 std::ceil(fMaxX * nXScale), -std::floor(fMaxY * nYScale));
195 const double fCos = cos(fRad);
196 const double fSin = sin(fRad);
216 if (hb_font_get_glyph(pHbFont, nUnicode, nVariationSelector, &nGlyph))
226 nWidth = hb_font_get_glyph_v_advance(pHbFont, nGlyph);
228 nWidth = hb_font_get_glyph_h_advance(pHbFont, nGlyph);
235 return double(nWidth * nScale);
243 = hb_graphite2_face_get_gr_face(hb_font_get_face(
GetHbFont())) !=
nullptr;
268 if (nYOffset == -839)
290void move_to_func(hb_draw_funcs_t*,
void* , hb_draw_state_t*,
float to_x,
float to_y,
297void line_to_func(hb_draw_funcs_t*,
void* , hb_draw_state_t*,
float to_x,
float to_y,
304void cubic_to_func(hb_draw_funcs_t*,
void* , hb_draw_state_t*,
float control1_x,
305 float control1_y,
float control2_x,
float control2_y,
float to_x,
float to_y,
314void close_path_func(hb_draw_funcs_t*,
void* pDrawData, hb_draw_state_t*,
void* pUserData)
318 pPolyPoly->
append(*pPoly);
329 hb_draw_funcs_set_move_to_func(
m_pHbDrawFuncs, move_to_func, pUserData,
nullptr);
330 hb_draw_funcs_set_line_to_func(
m_pHbDrawFuncs, line_to_func, pUserData,
nullptr);
331 hb_draw_funcs_set_cubic_to_func(
m_pHbDrawFuncs, cubic_to_func, pUserData,
nullptr);
336 hb_draw_funcs_set_close_path_func(
m_pHbDrawFuncs, close_path_func, pUserData,
nullptr);
340#if HB_VERSION_ATLEAST(7, 0, 0)
constexpr float ARTIFICIAL_ITALIC_SKEW
FontItalic GetItalic() const
FontWeight GetWeight() const
bool GetCachedGlyphBoundRect(const LogicalFontInstance *, sal_GlyphId, tools::Rectangle &)
void CacheGlyphBoundRect(const LogicalFontInstance *, sal_GlyphId, tools::Rectangle &)
std::optional< bool > m_xbIsGraphiteFont
bool NeedsArtificialBold() const
basegfx::B2DPolyPolygon GetGlyphOutlineUntransformed(sal_GlyphId) const
void GetScale(double *nXScale, double *nYScale) const
const vcl::font::PhysicalFontFace * GetFontFace() const
LogicalFontInstance(const vcl::font::PhysicalFontFace &, const vcl::font::FontSelectPattern &)
void AddFallbackForUnicode(sal_UCS4 cChar, FontWeight eWeight, const OUString &rFontName, bool bEmbolden, const ItalicMatrix &rMatrix)
double GetGlyphWidth(sal_GlyphId, bool=false, bool=true) const
bool GetGlyphBoundRect(sal_GlyphId, tools::Rectangle &, bool) const
const vcl::font::FontSelectPattern m_aFontSelData
virtual void ImplInitHbFont(hb_font_t *)
bool GetFallbackForUnicode(sal_UCS4 cInChar, FontWeight eInWeight, OUString *pOutFontName, bool *pOutEmbolden, ItalicMatrix *pOutItalicMatrix) const
basegfx::B2DPolygon m_aDrawPolygon
ImplFontCache * mpFontCache
bool NeedsArtificialItalic() const
FontMetricDataRef mxFontMetric
rtl::Reference< vcl::font::PhysicalFontFace > m_pFontFace
std::optional< FontFamilyEnum > m_xeFontFamilyEnum
hb_draw_funcs_t * m_pHbDrawFuncs
hb_font_t * m_pHbFontUntransformed
bool NeedOffsetCorrection(sal_Int32 nYOffset)
void IgnoreFallbackForUnicode(sal_UCS4, FontWeight eWeight, std::u16string_view rFontName)
double GetKashidaWidth() const
UnicodeFallbackList maUnicodeFallbackList
virtual ~LogicalFontInstance() override
hb_font_t * GetHbFontUntransformed() const
sal_GlyphId GetGlyphIndex(uint32_t, uint32_t=0) const
void append(const basegfx::B2DPoint &rPoint, sal_uInt32 nCount)
void appendBezierSegment(const basegfx::B2DPoint &rNextControlPoint, const basegfx::B2DPoint &rPrevControlPoint, const basegfx::B2DPoint &rPoint)
abstract base class for physical font faces
uint32_t UnitsPerEm() const
virtual OUString GetName() const override
ItalicMatrix aItalicMatrix