| 54 | } |
| 55 | |
| 56 | FontResult 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 | |
| 94 | FontResult FontCollectionRemoveFont(HFontCollection coll, HFont hfont) |
| 95 | { |