Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/framework/handlers/font.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { path } from '../../core/path.js';
import { string } from '../../core/string.js';
import { FILTER_LINEAR } from '../../platform/graphics/constants.js';
import { http } from '../../platform/net/http.js';
import { FONT_MSDF } from '../font/constants.js';
import { Font } from '../font/font.js';
import { ResourceHandler } from './handler.js';

Expand Down Expand Up @@ -101,6 +103,10 @@ class FontHandler extends ResourceHandler {
const textures = new Array(numTextures);
const loader = this._loader;

// MSDF atlases must not be mipmapped: mip levels average the distance-field channels,
// and median(average) != average(median), so minified text samples a corrupted median.
const isMsdf = !data.type || data.type === FONT_MSDF;

const loadTexture = function (index) {
const onLoaded = function (err, texture) {
if (error) return;
Expand All @@ -111,6 +117,11 @@ class FontHandler extends ResourceHandler {
return;
}

if (isMsdf) {
texture.minFilter = FILTER_LINEAR;
texture.mipmaps = false;
}
Comment thread
willeastcott marked this conversation as resolved.
Outdated
Comment thread
willeastcott marked this conversation as resolved.
Outdated

texture.upload();
textures[index] = texture;
numLoaded++;
Expand Down