package com.knecon.fforesight.service.viewerdoc.model;

import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.font.PDFont;
import org.apache.pdfbox.pdmodel.font.PDType1Font;
import org.apache.pdfbox.pdmodel.font.Standard14Fonts;

import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;

@RequiredArgsConstructor
public class Standard14EmbeddableFont implements EmbeddableFont {

    private final PDType1Font font;


    public static Standard14EmbeddableFont helvetica() {

        return new Standard14EmbeddableFont(new PDType1Font(Standard14Fonts.FontName.HELVETICA));
    }


    @SneakyThrows
    public float getStringWidth(String text) {

        return font.getStringWidth(text);
    }


    @Override
    public PDFont embed(PDDocument document) {

        // no need to embed anything
        return font;
    }

}
