/** * Loads a Java font from {@code path}. Currently only TrueType ({@code .ttf}) fonts are * supported. * * @param path the path to the font resource (relative to the asset manager's path prefix). * @throws Exception if an error occurs loading or decoding the font. */ public Font getFont(String path) throws Exception { return requireResource(path).createFont(); }
@Override public byte[] getBytesSync(String path) throws Exception { return requireResource(path).readBytes(); }
@Override public String getTextSync(String path) throws Exception { return requireResource(path).readString(); }
@Override public ByteBuffer getBytesSync(String path) throws Exception { return requireResource(path).readBytes(); }
@Override public String getTextSync(String path) throws Exception { return requireResource(path).readString(); }
@Override public ByteBuffer getBytesSync(String path) throws Exception { return requireResource(path).readBytes(); }
/** * Loads a Java font from {@code path}. Currently only TrueType ({@code .ttf}) fonts are * supported. * * @param path the path to the font resource (relative to the asset manager's path prefix). * @throws Exception if an error occurs loading or decoding the font. */ public Font getFont(String path) throws Exception { return requireResource(path).createFont(); }
@Override public String getTextSync(String path) throws Exception { return requireResource(path).readString(); }
@Override public byte[] getBytesSync(String path) throws Exception { return requireResource(path).readBytes(); }
@Override public String getTextSync(String path) throws Exception { return requireResource(path).readString(); }
/** * Registers a font with the graphics system. * * @param name the name under which to register the font. * @param path the path to the font resource (relative to the asset manager's path prefix). * Currently only TrueType ({@code .ttf}) fonts are supported. */ public void registerFont(String name, String path) { try { _fonts.put(name, ((JavaAssets) assets()).requireResource(path).createFont()); } catch (Exception e) { platform.reportError("Failed to load font [name=" + name + ", path=" + path + "]", e); } }
/** * Registers a font with the graphics system. * * @param name the name under which to register the font. * @param path the path to the font resource (relative to the asset manager's path prefix). * Currently only TrueType ({@code .ttf}) fonts are supported. */ public void registerFont(String name, String path) { try { _fonts.put(name, ((JavaAssets) assets()).requireResource(path).createFont()); } catch (Exception e) { platform.reportError("Failed to load font [name=" + name + ", path=" + path + "]", e); } }
protected Sound getSound(String path, boolean music) { Exception err = null; for (String suff : SUFFIXES) { final String soundPath = path + suff; try { return platform.audio().createSound(requireResource(soundPath), music); } catch (Exception e) { err = e; // note the error, and loop through and try the next format } } platform.log().warn("Sound load error " + path + ": " + err); return new Sound.Error(err); }
protected Sound getSound(String path, boolean music) { Exception err = null; for (String suff : SUFFIXES) { final String soundPath = path + suff; try { return platform.audio().createSound(requireResource(soundPath), music); } catch (Exception e) { err = e; // note the error, and loop through and try the next format } } platform.log().warn("Sound load error " + path + ": " + err); return new Sound.Error(err); }
protected Sound getSound(String path, boolean music) { Exception err = null; for (String suff : SUFFIXES) { final String soundPath = path + suff; try { return plat.audio().createSound(requireResource(soundPath), music); } catch (Exception e) { err = e; // note the error, and loop through and try the next format } } plat.log().warn("Sound load error " + path + ": " + err); return new Sound.Error(err); }
protected Sound getSound(String path, boolean music) { Exception err = null; for (String suff : SUFFIXES) { final String soundPath = path + suff; try { return plat.audio().createSound(requireResource(soundPath), music); } catch (Exception e) { err = e; // note the error, and loop through and try the next format } } plat.log().warn("Sound load error " + path + ": " + err); return new Sound.Error(err); }
@Override protected ImageImpl.Data load (String path) throws Exception { Exception error = null; for (Scale.ScaledResource rsrc : assetScale().getScaledResources(path)) { try { BufferedImage image = requireResource(rsrc.path).readImage(); // if image is at a higher scale factor than the view, scale to the view display factor Scale viewScale = plat.graphics().scale(), imageScale = rsrc.scale; float viewImageRatio = viewScale.factor / imageScale.factor; if (viewImageRatio < 1) { image = scaleImage(image, viewImageRatio); imageScale = viewScale; } if (plat.config.convertImagesOnLoad) { BufferedImage convertedImage = JavaGraphics.convertImage(image); if (convertedImage != image) { plat.log().debug("Converted image: " + path + " [type=" + image.getType() + "]"); image = convertedImage; } } return new ImageImpl.Data(imageScale, image, image.getWidth(), image.getHeight()); } catch (FileNotFoundException fnfe) { error = fnfe; // keep going, checking for lower resolution images } } plat.log().warn("Could not load image: " + path + " [error=" + error + "]"); throw error != null ? error : new FileNotFoundException(path); }
@Override protected ImageImpl.Data load (String path) throws Exception { Exception error = null; for (Scale.ScaledResource rsrc : assetScale().getScaledResources(path)) { try { BufferedImage image = requireResource(rsrc.path).readImage(); // if image is at a higher scale factor than the view, scale to the view display factor Scale viewScale = plat.graphics().scale(), imageScale = rsrc.scale; float viewImageRatio = viewScale.factor / imageScale.factor; if (viewImageRatio < 1) { image = scaleImage(image, viewImageRatio); imageScale = viewScale; } if (plat.config.convertImagesOnLoad) { BufferedImage convertedImage = JavaGraphics.convertImage(image); if (convertedImage != image) { plat.log().debug("Converted image: " + path + " [type=" + image.getType() + "]"); image = convertedImage; } } return new ImageImpl.Data(imageScale, image, image.getWidth(), image.getHeight()); } catch (FileNotFoundException fnfe) { error = fnfe; // keep going, checking for lower resolution images } } plat.log().warn("Could not load image: " + path + " [error=" + error + "]"); throw error != null ? error : new FileNotFoundException(path); }
for (Scale.ScaledResource rsrc : assetScale().getScaledResources(fullPath)) { try { BufferedImage image = requireResource(rsrc.path).readImage();
for (Scale.ScaledResource rsrc : assetScale().getScaledResources(fullPath)) { try { BufferedImage image = requireResource(rsrc.path).readImage();