### Godot version

8449592d92eaeef990f5502b419d491ee3eeb7a6

### System information

Windows 11

### Issue description

Zooming in the script editor on an empty script freezes the entire editor for a few seconds, but if the file is large then it freezes for 4-5 seconds (which is unacceptable). Looks like a recent regression.

### Steps to reproduce

Just zoom in/out on the large script file.

### Minimal reproduction project

N/A
FontTexturePosition ret;
	int mw = p_width;
	int mh = p_height;
	ShelfPackTexture *ct = p_data->textures.ptrw();
	for (int32_t i = 0; i < p_data->textures.size(); i++) {
		if (p_image_format != ct[i].format) {
			continue;
		}
		if (mw > ct[i].texture_w || mh > ct[i].texture_h) { 
			continue;
		}
		ret = ct[i].pack_rect(i, mh, mw);
		if (ret.index != -1) {
			
		}
	}
	if (ret.index == -1) {
		
		int texsize = MAX(p_data->size.x * p_data->oversampling * 8, 256);
		texsize = next_power_of_2(texsize);
		if (p_msdf) {
			texsize = MIN(texsize, 2048);
		} else {
			texsize = MIN(texsize, 1024);
		}
		if (mw > texsize) { 
			texsize = next_power_of_2(mw);