MCPcopy Create free account
hub / github.com/Snapchat/Valdi / getFontForName

Method getFontForName

snap_drawing/src/snap_drawing/cpp/Text/FontManager.cpp:343–371  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

341 _fallbackFontFamilies[character] = fontFamily;
342
343 return getFontFromFamily(guard, fontFamily, fontStyle, fontSize, scale, true);
344}
345
346Valdi::Result<Ref<Font>> FontManager::getEmojiFont(Scalar fontSize, double scale) {
347 Character emoji = 0x270C;
348 return getCompatibleFont(String(), _defaultFontStyle, fontSize, scale, nullptr, 0, emoji);
349}
350
351Ref<IFontManager> FontManager::makeScoped() {
352 return Valdi::makeShared<ScopedFontManager>(*getSkValue(), _logger, Valdi::strongSmallRef(this));
353}
354
355Valdi::Result<Valdi::Ref<Font>> FontManager::getFontFromFamily(std::unique_lock<Valdi::Mutex>& lock,
356 const Ref<FontFamily>& fontFamily,
357 FontStyle fontStyle,
358 Scalar fontSize,
359 double scale,
360 bool respectDynamicType) {
361 auto typeface = _typefaceRegistry.getTypefaceFromFamily(*_fontManager, fontFamily, fontStyle);
362 if (!typeface) {
363 return typeface.moveError();
364 }
365
366 return getFontWithTypefaceAndSize(lock, typeface.value(), fontSize, scale, respectDynamicType);
367}
368
369Valdi::Result<Valdi::Ref<Font>> FontManager::getFontForName(const String& fontName, double scale) {
370 auto components = fontName.split(' ', true);
371
372 if (components.size() == 1) {
373 auto guard = lock();
374 if (components[0] == "title1") {

Callers 2

parseMethod · 0.80
preprocess_fontMethod · 0.80

Calls 5

splitMethod · 0.80
lowercasedMethod · 0.80
ValueClass · 0.50
sizeMethod · 0.45
toDoubleMethod · 0.45

Tested by

no test coverage detected