# "Create font" not find new font

**URL:** <https://discourse.processing.org/t/create-font-not-find-new-font/18006>\
**Category:** Beginners\
**Created:** [February 22, 2020, 10:42am UTC](https://discourse.processing.org/t/create-font-not-find-new-font/18006 "2020-02-22T10:42:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Naik\_Trofimov](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/naik_trofimov/32/8143_2.png) [@Naik\_Trofimov](https://discourse.processing.org/u/Naik_Trofimov)\
**Post date:** [February 22, 2020, 10:42am UTC](https://discourse.processing.org/t/create-font-not-find-new-font/18006/1 "2020-02-22T10:42:26Z")

</div>

Downloaded new and install new ttf font, but processing dont see he!  
Haw I do using .ttf font in processing?  
and:  
[image|690x475](https://discourse.processing.org/uploads/short-url/cQorLueCALHcr5cONVjNBKleIvz.png)  
and:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/5/5905d4d55c7b8e3c63302076fcaedd7a0ebffcc8.png)

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [February 22, 2020, 12:13pm UTC](https://discourse.processing.org/t/create-font-not-find-new-font/18006/2 "2020-02-22T12:13:39Z")

</div>

Hello,

Welcome to the Processing community.

I tried adding a TTF font (to W10 and data folder) also and came up with the same message.

A bit of exploration prompted me to write this:

```auto
// Show Font Avaiability
// v1.0.0
// GLV 2020-02-22

PFont font;
String[] fontList;

void setup() 
	{
  size(200, 200);
  fontList = PFont.list();
  //printArray(fontList);
  
  for (int i= 0; i< fontList.length; i++)
    {
    font = createFont(fontList[i], 16);
    println(i, fontList[i]);
    }
  }

void draw() 
	{
  background(0);
	}

```

It seems that some of the installed fonts are “not available, so another font will be used.”

References:  
[https://processing.org/tutorials/typography/](https://processing.org/tutorials/typography/)  
[https://processing.org/reference/createFont\_.html](https://processing.org/reference/createFont_.html)

`:) `

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/1/1706a3f0d2d45d6449a1c0b3e47923a0be159b17.png)

---

<div class="post-metadata">

**Author:** ![anon94203042](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@anon94203042](https://discourse.processing.org/u/anon94203042)\
**Post date:** [February 26, 2020, 12:23am UTC](https://discourse.processing.org/t/create-font-not-find-new-font/18006/3 "2020-02-26T00:23:52Z")

</div>

I think all fonts must end in `.ttf` (true type font). So for example: `font.ttf`. This is similar to how images must end in `.img`.

Try:

```auto
PFont font = createFont("fontName.ttf", 14);

```

And if that doesn’t work, then but that line outside of the `setup()` function.

---

<div class="post-metadata">

**Author:** ![Naik\_Trofimov](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/naik_trofimov/32/8143_2.png) [@Naik\_Trofimov](https://discourse.processing.org/u/Naik_Trofimov)\
**Post date:** [February 27, 2020, 2:14pm UTC](https://discourse.processing.org/t/create-font-not-find-new-font/18006/5 "2020-02-27T14:14:14Z")

</div>

Do I understand correctly that there are currently no available means of using third-party fonts? It cannot be that I alone come across this problem. It’s generally strange that developers use font conversion tools to convert to .vlw format and not all, but only specific system fonts.

---

<div class="post-metadata">

**Author:** ![monkstone](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monkstone/32/64_2.png) [@monkstone](https://discourse.processing.org/u/monkstone)\
**Post date:** [February 27, 2020, 2:52pm UTC](https://discourse.processing.org/t/create-font-not-find-new-font/18006/6 "2020-02-27T14:52:25Z")

</div>

If you want to share sketches with other users the `YourFont.ttf` needs to be in the data folder, and called:-

```java
createFont("YourFont.ttf", 24);

```

If you want to use some funky font installed on your system (I know this for linux but expect it’s true elsewhere) then it needs to be called by either the system font name, or full path to `ttf` or `otf` file eg:-

```java
createFont("/usr/share/fonts/adobe-source-code-pro/SourceCodePro-Medium.otf", 24);

```

---

<div class="post-metadata">

**Author:** ![JoseMY](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josemy/32/2016_2.png) [@JoseMY](https://discourse.processing.org/u/JoseMY)\
**Post date:** [May 10, 2020, 10:54am UTC](https://discourse.processing.org/t/create-font-not-find-new-font/18006/8 "2020-05-10T10:54:11Z")

</div>

Hi.  
Today I hit the same obstacle.  
I was planning to make bit jpgs out of an installed handwritten font to make a handwriting practice game.  
After trying to use an installed font (“Mestra3(pauta doble)”) using its font name, I ended up writing a routine to choose fonts with similar name:

```auto
PFont myFont;
PImage myImage;
int letraIndex=0;
String letras="abcdefghijklmnopqrstuvwxyzABCDEFEGHIJKLMNOPQRSTUVWXYZáéíóúüÁÉÍÓÚñÑ";

void setup()
{
  size(800,800);
  String[] fontArray={"Mestra","Masallera","Memima"};
  chooseFont(myFont,100, fontArray);
}

/* 
 * chooseFont 
 * Tries to choose a font with similar name to a list
 * mFont: PFont input/output objetct 
 * Size: font Size
 * fontArray: Font names to choose from 
*/  
void chooseFont(PFont theFont, int Size, String[] fontArray)
{
  int i,j;
  int fontchosen, fontNameLength;
  String[] lista=theFont.list();
 printArray(fontArray);
 printArray(lista);
  
/* fontChosen: *
 * A big value, bigger than fontArray, so we can use it *
 * to make a hierarchy of fonts. *
 */
  int fontChosen=fontArray.length+999;
/* fontChosenSystemName= stores the system font in fontArray for the chosen font*/
  int fontChosenSystemName=0; 

  for (i=0;i<lista.length;i++){
    for (j=0;j<fontArray.length;j++)
   {
      /* Manage precedence of font names */
      if (j>fontChosen) {
       // println("Test font "+str(j)+"has lower priority than "+str(fontChosen));
        break;
      }
     
      fontNameLength=fontArray[j].length();
      if (fontNameLength<=lista[i].length()){
        if (fontArray[j].equals(lista[i].substring(0,fontNameLength))){
          println("chosen: >"+fontArray[j]+"<");
          fontChosen=j;
          fontChosenSystemName=i;
        } else {
          //println("Test font name >"+lista[i].substring(0,fontNameLength)+"< is not >"+fontArray[j]+"<");
        }
    } else {
        println("Test font >"+lista[i]+"< is shorter than >"+fontArray[j]+"<");
      }
    }  
  }
     theFont=createFont(lista[fontChosenSystemName],Size);
     textSize(200);
    textAlign(CENTER);

 }

void draw(){
  text(letras.substring(letraIndex,1), height/2,width/2);
}

```

The output of the program was:

`…`  
`[347] "Mestra3(PautaDoble)"`  
`…`  
`Test font >AR CENA< is shorter than >Masallera<`  
`…`  
`Test font >Marlett< is shorter than >Masallera<`  
`chosen: >Mestra<`  
`Test font >Onyx< is shorter than >Mestra<`  
`…`  
`"Mestra3(PautaDoble)" is not available, so another font will be used. Use PFont.list() to show available fonts.`

Yours,

José

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [May 10, 2020, 8:48pm UTC](https://discourse.processing.org/t/create-font-not-find-new-font/18006/9 "2020-05-10T20:48:22Z")

</div>

Fun! Thank you for sharing this.

You might also use the Levenshtein distance – or the distance on each token and weighing them – first token is heavy, 3rd or 4th token is light.

Times  
Times New Roman  
RomanD
