Skip to content

Comments

优化字体加载实现方式以便支持小游戏环境#1806

Closed
Geequlim wants to merge 1 commit intolayabox:Master3.0from
QYGames:improve-font-load
Closed

优化字体加载实现方式以便支持小游戏环境#1806
Geequlim wants to merge 1 commit intolayabox:Master3.0from
QYGames:improve-font-load

Conversation

@Geequlim
Copy link
Contributor

将字体加载的实现从 TTFFontLoader 挪到 Donwloader 中,与图片/音频这类平台相关的功能对应。
小游戏平台实现使用平台的接口重写 Download.font 函数即可实现支持。

例如微信小游戏适配

Laya.Downloader.prototype.font = function (owner: any, url: string, originalUrl: string, onProgress: (progress: number) => void, onComplete: (data: any, error?: string) => void) {
	let path = url; // 如有需要在此实现下载、缓存、逻辑,这里假设字体在小游戏包内
	const family = wx.loadFont(path);
	if (family) {
		onComplete({ family })
	} else {
		onComplete(null, 'load font failed');
	}
};

@xiaoguzhu
Copy link
Member

小游戏适配库已经着手重构,在重构时会考虑像你这样优化。

@Geequlim Geequlim force-pushed the improve-font-load branch from faf679b to ee4832e Compare March 23, 2025 12:44
@Geequlim Geequlim force-pushed the improve-font-load branch from ee4832e to dcea23e Compare March 29, 2025 15:14
@xiaoguzhu
Copy link
Member

已在3.3优化

@xiaoguzhu xiaoguzhu closed this Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants