Loading TrueType fonts?

Well, i was originally going to create a TrueType font loader, but after looking into the file specification there is ALOT of work which i would need to do, so i was wondering if there was a java package that can already do this for me?
Example;
Program connects to server -> server sends program a font file -> program then needs to use this file with the "Font" class, but i don't know if that class only uses installed fonts or if there is another way to do it via my program, but i don't want the fonts installed on the users system i would rather them be only available in the program of us.
Thanks for any help or info relating to my problem, any links to java api's would be a great help.

Read the API for java.awt.Font#createFont(int fontFormat, File fontFile). note that to make the newly created Font available for use with a FOnt constructor, you have to first register it with the GraphicsEnvironment. Also that the created Font has a point size of 1.
db

Similar Messages

  • Can't load truetype font

    I wrote the following program to load a truetype font, write hello in a JPanel, and then draw the alphabet on a BufferedImage and write it to a file, it works fine when I use whatever font my graphics objects default to but when I try to use the font I load I don't get the desired results.
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package topng;
    import java.awt.Color;
    import java.awt.Font;
    import java.awt.FontFormatException;
    import java.awt.FontMetrics;
    import java.awt.Graphics;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.awt.geom.Rectangle2D;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.imageio.ImageIO;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    * @author jarl
    public class Main extends JPanel {
         * @param args the command line arguments
        public static class ExitListener extends WindowAdapter {
            @Override
      public void windowClosing(WindowEvent event) {
        System.exit(0);
        private Font font;
        public Main() throws FontFormatException, IOException{
            super();
            File file = new File("Adventure Subtitles Normal.ttf");
         FileInputStream fis = new FileInputStream(file);
            font = Font.createFont(Font.TRUETYPE_FONT, fis);
            //font = font.deriveFont(20);
        @Override
        protected void paintComponent(Graphics g){
            g.setFont(font);
            g.drawString("Hello", 100, 100);
            BufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR);
            Graphics g2 = image.createGraphics();
            g2.setFont(font);
            String alphabet = "abcdefghijklmnopqrstuvwxyz";
            FontMetrics measure = new FontMetrics(g2.getFont()) {};
            Rectangle2D stringDims = measure.getStringBounds(alphabet, g);
            image = new BufferedImage((int)stringDims.getWidth(), (int)stringDims.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
            g2 = image.createGraphics();
            g2.setFont(font);
            g2.setColor(Color.black);
            g2.drawString(alphabet, 0, (int)stringDims.getHeight()*3/4);
            try {
                ImageIO.write(image, "png", new File("Adventure Subtitles Normal.png"));
            } catch (IOException ex) {
                Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        public static void main(String[] args) throws FontFormatException, IOException {
            JFrame frame = new JFrame("ToPNG");
            frame.add(new Main());
            frame.setSize(200, 200);
            frame.addWindowListener(new ExitListener());
            frame.setVisible(true);
    }Edited by: Bruhaha on Nov 27, 2009 9:42 PM

    The desired behavior is to load a truetype font, write hello in a JPanel, and then draw the alphabet on a BufferedImage and write it to a file, I thought the poorly indented WindowAdapter would be a minor enough infraction to get away with, I tried the version of createFont that takes a file, and while I've certainly never heard it encouraged I've never heard of not removing IDE comments being poor practice(although I do try to leave my name off the internet), sorry for that. Also, on reflection I guess I could have left out the part about writing a png, it kind of made it's way into the smallest model of what I'm trying to do but the problem is just loading the font.
    Anyway I think I figured it out, the font was created, but it had a size of 1 because when I called the deriveFont method I passed integer values for my size, but that ended up causing the derivedFont method that accepts an integer for a style to be called. I tried font = font.deriveFont(20f); and that solved my problem.

  • How to load a font as resource in javafx ?

    Hi,
    I am trying to load a font as a resource as supposed of installing the font on the system.
    Is there a way in javafx to load font from a file at runtime?
    Thanks.

    Yes, there is a way, and there's a tutorial for this on javafx.com: www.javafx.com/docs/techtips/custom_fonts/

  • How to convert a logo in truetype font?

    Is there a freeware or shareware program which can convert a logo in truetype font?
    I saw Fontographer, but it's very expensive...

    mnstudio
    There are many tools out there that can do the job for you. Fontographer is one of them, but there is also Fontlab Studio or Glyphs (http://glyphsapp.com) which looks very promising and is a lot cheaper than the other two.
    Fortunately there is also FontForge (FontForge.org) which is an open source font editing tool. The good thing about FontForge is that it is free, the bad thing about FontForge is that it is very complicated to get it up and running because they only provide sourve packages, no installers. But you can always search the net for a version with an installer, but these versions are mostly very outdated.
    As far as I know, FontForge is the only free tool out there, so you might try it.

  • IBooks Author TrueType font problem

    I'm working on an iBook and I'm attempting to use a truetype font for a page heading, but when I preview it on my iPad, the font shows up correctly for a brief moment, then is replaced by something generic. I have confirmed in the Font Book application that the font is a .ttf, and it DOES show up in the font selector drop down menu on the formatting bar in iBooks Author. Why would the font show up correctly for a second or two and then disappear on the iPad?

    It would appear that there's a bug in the preview mode. Maybe something to do with a cached version of the book? I fixed the problem by deleting the "proof" version on my iPad and re-sending it and now the truetype font shows up correctly.

  • Why do my TrueType fonts (from CS5 Contents/Goodies/Fonts folder) look awful?

    I recently installed the fonts that ship with CS5 Web Premium. These are located in Content dvd in the Goodies>Fonts folder. the Open Type fonts look fine but all True Type fonts are pixelated...like the font isn't really there?  Can anyone advise? 

    Actually those fonts do ship with some versions of the Creative Suite. They are absolutely not for any print-oriented production. And yes, they look like that.
    Actually, Adobe has produced a number of TrueType fonts. There are a series of "web pro" TrueType fonts produced over the years and still available. See http://store1.adobe.com/cfusion/store/html/index.cfm?store=OLS-US&event=displayFontPackage &code=1507.
              - Dov

  • ACROBAT 6 DISTILLER - TRUETYPE FONTS

    Okay so here goes....
    We use quark to save our quark files as .ps (postscript) files and drag those postscript files to the distiller to create pdf's. The problem is when i send these pdf's created from this mac to a pc and open it up and go under file--->document properties--->fonts, I am seeing TrueType Fonts, which i shouldn't be seeing. It is illegal to use TrueType fonts when your distributing pdf's online. I had a hard drive that is dying so i reloaded the os's (9&x) on a new drive. Everything seems to be setup correctly, but when i distill the .ps files from the old drive im not getting any TrueType fonts within the pdf??? It seems to be Helvetica & Times that are having a problem on the new drive, they always show up as TrueType and on both drives im using Helvita & Times in the same location. ~/system/library/fonts/ Anybody that can help me i would gladly appreciate it.

    That sounds like Adobe trying to sell you more fonts. The striped red letter A is simply Adobe's icon for any printer outline portion of a Type 1 PostScript font. But there's plenty of other vendors of PostScript fonts that of course won't have that icon. Doesn't make them any less usable.
    There's also no law or rule against using TrueType fonts if you want. Although it does depend on what you're doing with the resulting PDF. If your PDF is going to a professional printer, then you should use PostScript fonts. Most professional RIP's still don't handle TrueType fonts well. The edges of characters look like they were cut out quickly with a scissors on the final files used to create film or plates for press. But if your PDF documents are just being distributed for viewing and garden variety printing from a laser or inkjet printers, there's absolutely no reason you can't use a TrueType font.

  • Acrobat X Pro - Loading System Fonts

    I installed the software this morning and it has been "loading system fonts" for hours. I got this message when I tried to edit document text... I've tried to restart the system twice and it hasn't worked. Has anyone else run into this? How do I fix it? Does it really take this long to load my fonts?
    Thanks

    What is your operating system?
    [topic moved to Acrobat forum]

  • Embedding Truetype fonts into PDF Document

    Hi all,
    I have a question for you :
    I have a class in VB6 to make my PDF documents,
    with this class i have the possibility to enter text of
    Type 1 and text of Truetype fonts in the PDF Document,
    by the specifications of the font:
    i.e.:
    to be able to enter text in Regular Times New Roman, I must to provide these specifications :
    an array with the widths of all the characters, precisely :
    Array(250, 333, 408, 500, 500, 833, 778, 180, 333, 333, 500, 564, 250, 333, 250, 278, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 278, 278, 564, 564, 564, 444, 921, 722, 667, 667, 722, 611, 556, 722, 722, 333, 389, 722, 611, 889, 722, 722, 556, 722, 667, 556, 611, 722, 722, 944, 722, 722, 611, 333, 278, 333, 469, 500, _
                         333, 444, 500, 444, 500, 444, 333, 500, 500, 278, 278, 500, 278, 778, 500, 500, 500, 500, 333, 389, 278, 500, 500, 722, 500, 500, 444, 480, 200, 480, 541, 778, 500, 778, 333, 500, 444, 1000, 500, 500, 333, 1000, 556, 333, 889, 778, 611, 778, 778, 333, 333, 444, 444, 350, 500, 1000, 333, 980, 389, 333, 722, 778, 444, 722, _
                         250, 333, 500, 500, 500, 500, 200, 500, 333, 760, 276, 500, 564, 333, 760, 500, 400, 549, 300, 300, 333, 576, 453, 250, 333, 300, 310, 500, 750, 750, 750, 444, 722, 722, 722, 722, 722, 722, 889, 667, 611, 611, 611, 611, 333, 333, 333, 333, 722, 722, 722, 722, 722, 722, 722, 564, 722, 722, 722, 722, 722, 722, 556, 500, _
                         444, 444, 444, 444, 444, 444, 667, 444, 444, 444, 444, 444, 278, 278, 278, 278, 500, 500, 500, 500, 500, 500, 500, 549, 500, 500, 500, 500, 500, 500, 500, 500)
    And some parameters :
    /Flags 34
    /FontBBox [-250 -216 1200 1000]
    /MissingWidth 333
    /StemV 73
    /StemH 73
    /ItalicAngle 0
    /CapHeight 891
    /XHeight 446
    /Ascent 891
    /Descent -216
    /Leading 149
    /MaxWidth 1000
    /AvgWidth 401
    The question : Where I can find these specifications for other truetype fonts, like Tahoma, MS Sans Serif ecc..?
    thanks in advance for any replies!

    Thank you for replication,
    could you show me the name of API that I should use ?
    thanks in advance for any replies!

  • Can't import MapInfo TrueType fonts into MapBuilder

    Hi forum
    I am trying to import TrueType fonts from MapInfo, that we used to use in the MapInfo application, that we are migrating from. I try to use the "Import TrueType font" function in MapBuilder, but when I want to view the font afterwards, I just get a blank page. I have tested with the font MapInfo Cartographic (TTMICG__.TTF), which you can obtain as part as the free "MapInfo ProViewer" package from MapInfo, available here:
    http://extranet.mapinfo.com/products/download.cfm?ProductID=1062
    My own first idea was, that the underscores in the filename might cause trouble, but that doesn't seem so. Renaming the TTF file didnt make any difference. The file seems to import ok, but the Preview window remains empty.
    I have tried importing a "standard" font like Times New Roman, and that appears to work fine. Are there any specific type of TrueType fonts, that MapBuilder does not like, and which you therefore for some reason cannot use in a marker style for MapViewer?
    Thanks in advance

    Hi Jacob,
    look this thread: MapViewer 11g / MapBuilder / TrueType Fonts

  • [SOLVED] "Loading console font" fails at boot

    Hello everyone,
    At each boot, the line where it loads the console font fails. The font configured in rc.conf is "161", it's the one by default on installation.
    /var/log/boot
    Loading Console Font: 161 ^[[231G [BUSY] ^[[231G [FAIL]
    It's a fresh install done today.
    Any idea why it would fail that?
    Last edited by blno (2012-01-06 21:18:47)

    Navigate to /usr/share/kbd/consolefonts, pick the font, test it by issuing
    setfont font-name.gz
    -- and if everything works OK, add it to rc.conf and rebuild your initramfs.
    Edit (because I'm extremely short-minded): while adding the font to the rc.conf file, do so without any extensions, eg. Uni2-Fixed16. And 2: before you rebuild your initramfs, it's wise to add "consolefont" to HOOKS in mkinitcpio.conf. It's not obligatory, but this way the new font will become active at the earliest boot stage.
    Last edited by bohoomil (2012-01-04 22:52:51)

  • Load TTF font ???

    hi,
    i'am trying to distribute with my application an external font.it's loading correctly but nothing appear on screen :/
    JLabel label = new JLabel("Hello World");
    FileInputStream stream = new FileInputStream("c:\\LED.ttf");
    Font f = Font.createFont(Font.TRUETYPE_FONT,stream);
    label.setFont(f);
    does it's possible to set a font that is not in normal system path ?
    vincent.

    I once did it like that for a special font used via a label. It works for both file system and jar files:
    public class CSpecialFontLabel extends JLabel {
         private static final String URL_FONT = "appl/gui/font/ariblk.ttf";
         private static Font m_font;
         public CSpecialFontLabel(int style, int size) {
              loadFont();
                  setFont(m_font.deriveFont(style, size));
          * Draws the version info.
         public void paint(Graphics g) {
              Graphics2D g2d = (Graphics2D) g;
              g2d.setRenderingHint(
                   RenderingHints.KEY_ANTIALIASING,
                   RenderingHints.VALUE_ANTIALIAS_ON);
              super.paint(g);
          * Loads the font for the version info
         private void loadFont() {
              if(m_font == null) {
                try {
                        InputStream is = this.getClass().getClassLoader().getResourceAsStream(URL_FONT);
                        m_font = Font.createFont(Font.TRUETYPE_FONT, is);
                        is.close();
                   } catch (Exception e) {
                        // loading font failed -> use std. Font
                          m_font = new Font("Arial", Font.ITALIC | Font.BOLD, 60);
    }

  • Why do I have to Sign Out in Creative Cloud then Sign back in everytime I open InDesign or any other CC program for that matter to view my previously loaded TypeKit fonts?

    Why do I have to Sign Out in Creative Cloud then Sign back in everytime I open InDesign or any other CC program for that matter to view my previously loaded TypeKit fonts?

    Hi Denise, It seems that your machine is not holding up the activation. Kindly try to following steps.
    https://helpx.adobe.com/creative-cloud/kb/sign-in-out-creative-cloud-desktop-app.html
    https://helpx.adobe.com/x-productkb/policy-pricing/activation-network-issues.html
    Try to create a new admin account and check if the products are activated or not.
    We would be waiting for your response.
    Thanks,
    Atul Saini

  • Fixed layout ePub not display truetype font properly when uploaded to Amazon

    I've created a kids book with inDesign CC which works fine on iPad but when I upload the book to Amazon KDP, the font which is a truetype font and not protected doesn't display properly. It has unusual spacing between the charaters and sometimes the letters overlap each other.  Can i embed this font somehow to have it display properly? I can't find an option anywhere to do that. Or will I have to change the font entirely?  Many thanks.

    Hi Yves,
    Yes, it is an SIL license. I am not using Allatuq anymore, I switched to Quicksand which I got from fontsquirrel.com.
    Yes, there is a fixed layout epub option in inDesign CC 2014:
    It even has some default sizing options though I have gone with a custom size to account for larger devices, desktop reading etc and am hoping that it's going to work.
    The Kindle previewer (desktop version) displays perfectly.
    The online previewer has had some display issues with what looks like drop shadows on some images but i'll need to look at the actual file on multiple devices to see what the reality is.
    There are some inconsistencies between how the fonts look in the previewers. The online one is not perfect and the desktop previewer displays exactly as designed so again, I won't really know until I can get my hands on the devices. There is also a sizing issue with the online previewer that the desktop previewer doesn't seem to have. And then there will be the issue that the "purchase" file isn't consistent with the preview file you download so not sure how it will all pan out yet.
    I had lots of overlapping and other character spacing issues until I changed my font to the OTF Quicksand with the SIL License. I'm hoping the drop shadows are just an issue with the online previewer.
    And I'm hoping my conclusion is correct that the OTF with the SIL licenses work for embedding so long as you remove the encryption and replace the encrypted font with the orignal version (and include the license). And I'm hoping that is allowed.

  • Set TrueType font as Default

    We have uploaded a new font (Verdana) via se73 (Install TrueType Fonts) and made an entry in the table TBTFFONTMAP. Now in the CRM Interaction Center when creating a new email or replying to an existing email we are able to choose this new font. However we would like to set this font as a default, so that whenever you create a new email or answer an email per default it takes this Verdana font. So far we have only seen the possibility to change the Internet Settings (Internet Options -> Lettertypes/ Fonts). However if we change the settings here we are not able to choose the size of the font, so it takes the size (size 12) of the current default which is Times New Roman and this is too big for Verdana.
    Has anyone found out already how to change the default font of the email editor?
    Many thanks in advance!
    Best regards,
    Bianca

    Sorry for the late response,
    I started again with a fresh install of Windows Vista and again the same problem appears.
    So to resume:
    Open a new package
    Go to the registry menu.
    Add manually (with several right clicks New-> key) the following tree:
    HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\Adobe PDF
    Drag the "Default DevMode" binary value (REG_BINARY) from my computer into the "Adobe PDF" key of the destination computer.
    Save the project
    Click on the Summary button crashed the wizard
    In my opinion it is the REG_BINARY string length that cause the problem, I try with other long binary value from other key and it always give the same result -> Wizard crash. I also try with small binary value and these don't gives the problem (for example the "HKCU\Control Panel\Appearance\SchemeLangID" has a small value 09 04 and doesn't give the wizard crash).
    Other thing with the binary value is that you can only create empty one, they cannot be modified, so you are obliged to install acrobat pro in order to be able to drag them from my computer to destination computer registry.
    I will try with acrobat X and the related wizard next week.

Maybe you are looking for

  • Transaction cade to create Gereral text

    transaction cade to create Gereral text

  • Can't Complete Download Of New Mac OS.

    I have been trying all day so far to download the new Mac operating system (OS X Mountain Lion) to my MacBook Air via wi-fi.  It sticks at 53.25MB out of 4.34GB and won't move. I am a BT residential and domestic customer and I am appalled at the usel

  • Business Contact Manager Plugin does not install successfully in Outlook 2010 Professional Plus

    I work for a company that has provided me with a volume licensed version of Microsoft Office Professional Plus 2010. We do a lot of customer tracking so I looked into options to utilize Outlook and found out about the Business Contact Manager plugin.

  • Error in removing EM

    hi, i recently upgraded my databse form 9.2.0.5 to 10.2.0.3 , when i tried to install EM on the new databse , i had a power problem and lost connection to server, after that i am trying to remove Em with RepManager -connect devtv01 -action drop it gi

  • When is crystal reports 11 R2a support run out

    Quick note: I know this is probably the wrong fourm but I have no idea where it is meant to go. So moderators can you put this in the right place. Hi, Just a quick question when does the crystal reports 11 R2a support run out? I know the R2 ran out j