Skip to content

Commit

Permalink
Set the defaultOptions for BitmapFontManager
Browse files Browse the repository at this point in the history
(re: #1664)

Better to have the options in one place than scattered around the code
  • Loading branch information
bhousel committed Jan 13, 2025
1 parent a724995 commit 513589b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 35 deletions.
42 changes: 23 additions & 19 deletions modules/core/GraphicsSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,36 @@ export class GraphicsSystem extends AbstractSystem {
ticker.add(this._tick, this);
this.ticker = ticker;

Object.assign(PIXI.BitmapFontManager.defaultOptions, {
chars: PIXI.BitmapFontManager.ASCII,
resolution: 2,
padding: 6,
skipKerning: false
});

Object.assign(PIXI.HelloSystem.defaultOptions, {
hello: true // Log renderer and Pixi version to the console
});

Object.assign(PIXI.RenderableGCSystem.defaultOptions, {
renderableGCActive: false
});

Object.assign(PIXI.TextureSource.defaultOptions, {
autoGarbageCollect: false,
autoGenerateMipmaps: false,
resolution: 1
});


// Prepare a basic bitmap font that we can use for things like debug messages
PIXI.BitmapFont.install({
name: 'rapid-debug',
style: {
fill: { color: 0xffffff },
fontSize: 14,
stroke: { color: 0x333333 }
},
chars: PIXI.BitmapFontManager.ASCII,
padding: 6,
resolution: 2
}
});

}
Expand Down Expand Up @@ -655,21 +674,6 @@ export class GraphicsSystem extends AbstractSystem {
break;
}

// Setup PIXI defaults here..
Object.assign(PIXI.TextureSource.defaultOptions, {
autoGarbageCollect: false,
autoGenerateMipmaps: false,
resolution: 1
});

Object.assign(PIXI.RenderableGCSystem.defaultOptions, {
renderableGCActive: false
});

Object.assign(PIXI.HelloSystem.defaultOptions, {
hello: true // Log renderer and Pixi version to the console
});

const options = {
antialias: this.highQuality,
autoDensity: this.highQuality,
Expand Down
19 changes: 3 additions & 16 deletions modules/pixi/PixiLayerLabels.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,9 @@ export class PixiLayerLabels extends AbstractLayer {
// Tracks the difference between the top left corner of the screen and the parent "origin" container
this._labelOffset = new PIXI.Point();

// For ascii-only labels, we can use PIXI.BitmapText to avoid generating label textures
PIXI.BitmapFont.install({
name: 'label-normal',
style: TEXTSTYLE_NORMAL,
chars: PIXI.BitmapFontManager.ASCII,
padding: 6,
resolution: 2
});
// not actually used
// PIXI.BitmapFont.install({
// name: 'label-italic',
// style: TEXTSTYLE_ITALIC,
// chars: PIXI.BitmapFontManager.ASCII,
// padding: 6,
// resolution: 2
// });
// For ASCII-only labels, we can use PIXI.BitmapText to avoid generating label textures
PIXI.BitmapFont.install({ name: 'label-normal', style: TEXTSTYLE_NORMAL });
// PIXI.BitmapFont.install({ name: 'label-italic', style: TEXTSTYLE_ITALIC }); // not currently used

// For all other labels, generate it on the fly in a PIXI.Text or PIXI.Sprite
this._textStyleNormal = new PIXI.TextStyle(TEXTSTYLE_NORMAL);
Expand Down

0 comments on commit 513589b

Please sign in to comment.