Ajouts d'une version BETA du menu principal qui respecte le modèle MVC et la responsabilité unique + Modifications du README.md
This commit is contained in:
33
TestV2/src/fr/monkhanny/dorfromantik/utils/FontLoader.java
Normal file
33
TestV2/src/fr/monkhanny/dorfromantik/utils/FontLoader.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package fr.monkhanny.dorfromantik.utils;
|
||||
|
||||
import fr.monkhanny.dorfromantik.enums.Fonts;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Classe utilitaire pour charger des polices à partir de fichiers.
|
||||
* @version 1.0
|
||||
* @author Moncef STITI
|
||||
* @see Fonts
|
||||
* @see Font
|
||||
*/
|
||||
public class FontLoader {
|
||||
|
||||
/**
|
||||
* Charge une police à partir du fichier spécifié.
|
||||
* @param fontEnumName Enumération de la police à charger.
|
||||
* @return La police chargée.
|
||||
* @throws IOException Si une erreur se produit lors de la lecture du fichier.
|
||||
* @throws FontFormatException Si une erreur se produit lors de la création de la police.
|
||||
*/
|
||||
public static Font loadFont(Fonts fontEnumName) throws IOException, FontFormatException {
|
||||
String fontFilePath = fontEnumName.getFontPath();
|
||||
File fontFile = new File(fontFilePath);
|
||||
Font customFont = Font.createFont(Font.TRUETYPE_FONT, fontFile);
|
||||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
ge.registerFont(customFont);
|
||||
return customFont;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user