mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2024-11-23 07:02:25 +00:00
!17197 增加能使用主题字的fontCollection接口
Merge pull request !17197 from liumingxiang/fontmgr_add_family_name_limit
This commit is contained in:
commit
3caafae586
@ -103,6 +103,16 @@ void OH_Drawing_DisableFontCollectionSystemFont(OH_Drawing_FontCollection*);
|
||||
* @version 1.0
|
||||
*/
|
||||
void OH_Drawing_ClearFontCaches(OH_Drawing_FontCollection*);
|
||||
|
||||
/**
|
||||
* @brief Get the <b>OH_Drawing_FontCollection</b> global instance.
|
||||
*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
|
||||
* @return Return the pointer to the <b>OH_Drawing_FontCollection</b> global instance.
|
||||
* @since 14
|
||||
* @version 1.0
|
||||
*/
|
||||
OH_Drawing_FontCollection* OH_Drawing_GetFontCollectionGlobalInstance(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -127,3 +127,13 @@ void OH_Drawing_ClearFontCaches(OH_Drawing_FontCollection* fontCollection)
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
OH_Drawing_FontCollection* OH_Drawing_GetFontCollectionGlobalInstance(void)
|
||||
{
|
||||
std::shared_ptr<OHOS::Rosen::FontCollection> fc = OHOS::Rosen::FontCollection::Create();
|
||||
OH_Drawing_FontCollection* pointer = reinterpret_cast<OH_Drawing_FontCollection*>(fc.get());
|
||||
if (!FontCollectionMgr::GetInstance().Find(pointer)) {
|
||||
FontCollectionMgr::GetInstance().Insert(pointer, fc);
|
||||
}
|
||||
return pointer;
|
||||
}
|
@ -615,6 +615,24 @@ void OHDrawingCreateSharedFontCollectionTest(const uint8_t* data, size_t size)
|
||||
OH_Drawing_ClearFontCaches(nullptr);
|
||||
OH_Drawing_DestroyFontCollection(fontCollection);
|
||||
}
|
||||
|
||||
void OHDrawingCreateFontCollectionGlobalInstanceTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (data == nullptr) {
|
||||
return;
|
||||
}
|
||||
// initialize
|
||||
g_data = data;
|
||||
g_size = size;
|
||||
g_pos = 0;
|
||||
|
||||
// initialize
|
||||
OH_Drawing_FontCollection* fontCollection = OH_Drawing_GetFontCollectionGlobalInstance();
|
||||
OH_Drawing_DisableFontCollectionFallback(fontCollection);
|
||||
OH_Drawing_DisableFontCollectionSystemFont(fontCollection);
|
||||
OH_Drawing_ClearFontCaches(fontCollection);
|
||||
OH_Drawing_ClearFontCaches(nullptr);
|
||||
}
|
||||
} // namespace OHOS::Rosen::Drawing
|
||||
|
||||
/* Fuzzer entry point */
|
||||
|
@ -34,8 +34,10 @@ HWTEST_F(OH_Drawing_FontCollectionTest, OH_Drawing_FontCollectionTest001, TestSi
|
||||
{
|
||||
OH_Drawing_FontCollection* fontCollection = OH_Drawing_CreateFontCollection();
|
||||
OH_Drawing_FontCollection* fontCollection2 = OH_Drawing_CreateSharedFontCollection();
|
||||
OH_Drawing_FontCollection* fontCollection3 = OH_Drawing_GetFontCollectionGlobalInstance();
|
||||
EXPECT_NE(fontCollection, nullptr);
|
||||
EXPECT_NE(fontCollection2, nullptr);
|
||||
EXPECT_NE(fontCollection3, nullptr);
|
||||
OH_Drawing_DisableFontCollectionFallback(fontCollection);
|
||||
OH_Drawing_DisableFontCollectionFallback(nullptr);
|
||||
OH_Drawing_DisableFontCollectionSystemFont(fontCollection);
|
||||
|
Loading…
Reference in New Issue
Block a user