MCPcopy Create free account
hub / github.com/defold/defold / FontCollectionAddFont

Function FontCollectionAddFont

engine/font/src/fontcollection.cpp:56–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56FontResult FontCollectionAddFont(HFontCollection coll, HFont hfont)
57{
58 if (coll->m_Fonts.Full())
59 coll->m_Fonts.OffsetCapacity(1);
60 coll->m_Fonts.Push(hfont);
61
62 TextLayoutType layout_type = FontGetLayoutType(hfont);
63 if (layout_type != TEXT_LAYOUT_TYPE_FULL)
64 coll->m_LayoutType = TEXT_LAYOUT_TYPE_LEGACY;
65
66 // We mustn't use the full layout code path if the font doesn't support it
67 if (coll->m_LayoutType == TEXT_LAYOUT_TYPE_LEGACY)
68 {
69 return FONT_RESULT_OK;
70 }
71
72#if defined(FONT_USE_SKRIBIDI)
73 hb_font_t* hb_font = FontGetHarfbuzzFontFromTTF(hfont);
74 skb_font_handle_t skbfont = skb_font_collection_add_hb_font(coll->m_Collection,
75 hb_font,
76 FontGetPath(hfont),
77 SKB_FONT_FAMILY_DEFAULT);
78
79 if (skbfont)
80 {
81 HFont* pfont = coll->m_FontLookup.Get(skbfont);
82 if (!pfont && coll->m_FontLookup.Full())
83 {
84 coll->m_FontLookup.OffsetCapacity(1);
85 }
86 coll->m_FontLookup.Put(skbfont, hfont);
87 }
88 return skbfont ? FONT_RESULT_OK : FONT_RESULT_ERROR;
89#else
90 return FONT_RESULT_OK;
91#endif
92}
93
94FontResult FontCollectionRemoveFont(HFontCollection coll, HFont hfont)
95{

Callers 8

SetUpMethod · 0.85
SetUpMethod · 0.85
TEST_FFunction · 0.85
SetUpMethod · 0.85
SetUpMethod · 0.85
TEST_FFunction · 0.85
CreateFontFunction · 0.85
AddFontInternalFunction · 0.85

Calls 9

FontGetLayoutTypeFunction · 0.85
FontGetPathFunction · 0.85
FullMethod · 0.45
OffsetCapacityMethod · 0.45
PushMethod · 0.45
GetMethod · 0.45
PutMethod · 0.45

Tested by 6

SetUpMethod · 0.68
SetUpMethod · 0.68
TEST_FFunction · 0.68
SetUpMethod · 0.68
SetUpMethod · 0.68
TEST_FFunction · 0.68