# Loading font from data folder in a second window

**URL:** <https://discourse.processing.org/t/loading-font-from-data-folder-in-a-second-window/32517>\
**Category:** Coding Questions\
**Created:** [September 29, 2021, 9:36pm UTC](https://discourse.processing.org/t/loading-font-from-data-folder-in-a-second-window/32517 "2021-09-29T21:36:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DonaldZhu](https://avatars.discourse-cdn.com/v4/letter/d/b487fb/32.png) [@DonaldZhu](https://discourse.processing.org/u/DonaldZhu)\
**Post date:** [September 29, 2021, 9:36pm UTC](https://discourse.processing.org/t/loading-font-from-data-folder-in-a-second-window/32517/1 "2021-09-29T21:36:18Z")

</div>

The following code create two windows when my sketch is run:

Main file:

```auto
PWindow pwindow;
PFont font;

void setup() {
  size(800, 800);
  pwindow = new PWindow();
}

```

Second file:

```auto
class PWindow extends PApplet {
  PWindow() {
    super();
    PApplet.runSketch(new String[] {this.getClass().getSimpleName()}, this);
  }

  void settings() {
    size(400,400);
  }

  void setup() {
    font = loadFont("AppleSymbols-24.vlw");
    textFont(font, 24);
    text("test", 100, 100);
  }
}

```

Everything works, however, processing can’t seem to locate the font file in the data folder when I use `loadFont` in my second file (`RuntimeException: Could not load font AppleSymbols-24.vlw. Make sure that the font has been copied to the data folder of your sketch.`). But when I put `loadFont` in my main file’s `setup`, it is able to load with no error. How can I get processing to locate the font in the data folder when I attempt to load it from a file that’s not my main file?

---

<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:** [September 30, 2021, 12:21am UTC](https://discourse.processing.org/t/loading-font-from-data-folder-in-a-second-window/32517/2 "2021-09-30T00:21:51Z")

</div>

Hello,

This worked:

```auto
PWindow pwindow;
PFont font;

String s1;

void setup() {
  size(800, 800);
  pwindow = new PWindow();
  println("W1: ", sketchPath());
  s1 = sketchPath();
  println("S1: ", s1);
}

class PWindow extends PApplet {
  PWindow() {
    super();
    PApplet.runSketch(new String[] {this.getClass().getSimpleName()}, this);
  }

  void settings() {
    size(400,400);
  }

  void setup() {
    println();
    println("W2: ", sketchPath());
    println("S1: ", s1);
    font = loadFont(s1 + "/data/Bauhaus93-48.vlw");
    textFont(font, 48);
    text(":)", 100, 100);
  }
}

```

I used `println()` statements to show the `sketchPath()` as seen by each window to better understand what was happening:

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

`:)`

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [September 30, 2021, 1:17pm UTC](https://discourse.processing.org/t/loading-font-from-data-folder-in-a-second-window/32517/3 "2021-09-30T13:17:34Z")

</div>

> [@DonaldZhu](#):
>
> , Processing can’t seem to locate the font file in the data folder when…

> [@Problems when trying to draw to a P3D PGraphics when called from a thread?](https://discourse.processing.org/t/problems-when-trying-to-draw-to-a-p3d-pgraphics-when-called-from-a-thread/6301/4):
>
> Although it’s pretty much a hack, here’s the workaround I’ve come up w/: crazy_face /\*\* \* Threaded PGraphics II (v1.0.1) \* GoToLoop (2018/Dec/07) \* \* https://Discourse.Processing.org/t/ \* problems-when-trying-to-draw-to-a-p3d-pgraphics- \* when-called-from-a-thread/6301/4 \* \* https://Forum.Processing.org/two/discussion/25799/ \* how-to-draw-a-rect-in-a-thread#Item\_2 \*/ static final int W = 250, H = 200, FPS = 10; Layer layer; void settings() { size(W, H, JAVA2D); smooth(3); } v…

> **[Processing 2.x and 3.x Forum](https://forum.processing.org/two/discussion/16457/size-method-for-intial-window-not-working-when-more-windows-are-are-added#Item_1)**
>
> Processing is an electronic sketchbook, a language and a worldwide community. This is its forum.

---

<div class="post-metadata">

**Author:** ![DonaldZhu](https://avatars.discourse-cdn.com/v4/letter/d/b487fb/32.png) [@DonaldZhu](https://discourse.processing.org/u/DonaldZhu)\
**Post date:** [October 1, 2021, 4:29am UTC](https://discourse.processing.org/t/loading-font-from-data-folder-in-a-second-window/32517/4 "2021-10-01T04:29:51Z")

</div>

Thank you! That makes sense
