Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Bitmapfont add cachebuster & compress #116

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

h1ve2
Copy link
Contributor

@h1ve2 h1ve2 commented Feb 3, 2025

BitmapFont (sdf/msdf)

Note: To be compatible with compress, the output file name has been changed to xxx.[png|webp|...].fnt.
There should be no impact for projects using a manifest.
If you need to use xxx.fnt by default, please let me know, and I will take the time to modify it so that xxx.fnt is used without compress.

cachebuster

image

compress

image

mipmap

image

split

replace the file of all pages in fnt
image

BMFont file

support .xml | .fnt
mipmap is not supported
image

custom config

The font.charset in the JSON will be merged with the global font.charset, while other fields will be replaced by the JSON.

.json :
image

pipes :
image

output (fnt):
image

output (image):
image

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 8 out of 11 changed files in this pull request and generated 1 comment.

Files not reviewed (3)
  • packages/assetpack/package.json: Language not supported
  • packages/assetpack/test/resources/font/custom.json: Language not supported
  • packages/docs/docs/guide/pipes/webfont.mdx: Language not supported
Comments suppressed due to low confidence (4)

packages/assetpack/test/webfont/SDFCustomConfig.test.ts:87

  • [nitpick] The test could be more comprehensive by adding more edge cases to ensure robustness.
checkChars(json.font.chars.char, 'abcABC');

packages/assetpack/src/webfont/sdf.ts:215

  • [nitpick] The function name 'createName' is ambiguous. It should be renamed to 'generateScaledName' for better clarity.
export function createName(

packages/assetpack/src/webfont/sdf.ts:203

  • The 'resolve' call is nested inside the 'generateBMFont' callback. If 'generateBMFont' throws an error synchronously, it will not be caught by the 'reject' call. Consider adding a try-catch block around 'generateBMFont' to handle synchronous errors.
resolve({ textures, font });

packages/assetpack/src/webfont/sdf.ts:215

  • The new behavior introduced by 'createName' and 'mergeCharset' functions should be covered by tests to ensure they work as expected.
export function createName(


const json: jsonType = JSON.parse(fntJsonStr);
const extname = path.extname(asset.filename);

Copy link
Preview

Copilot AI Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function transform uses formats.map to create new assets but does not handle the case where formats might be empty. Add a check to ensure formats is not empty before proceeding.

Suggested change
if (formats.length === 0) {
return [];
}

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
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.

1 participant