Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,20 @@ Add the `harfbuzz` feature when using FigDraw from another project:
requires "https://github.com/elcritch/figdraw[windy,harfbuzz]"
```

Note: Windy is the default example. Harfbuzz support works with Siwin or other WMs.
Note: Windy is the default example. Harfbuzz support works with Siwin, Surfer or other windowing libraries.

Then compile with the Harfbuzzy text backend:

### windy example
```sh
nim r -d:figdrawTextBackend=harfbuzzy examples/windy_text_shaping_demo.nim
```

### surfer example
```sh
nim r -d:figdrawTextBackend=harfbuzzy examples/surfer_text_shaping_demo.nim
```

For an example or app that should always use Harfbuzzy, put the backend switch
in a sibling `.nims` file:

Expand Down
52 changes: 44 additions & 8 deletions config.nims
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
--nimcache:".nimcache/"
--passc:"-Wno-incompatible-function-pointer-types"
--define:useMalloc
--define:release
--nimcache:
".nimcache/"
--passc:
"-Wno-incompatible-function-pointer-types"
--define:
useMalloc
--define:
release

import std/strutils
import std/[strformat, strutils]
import std/os

when defined(macosx) and defined(figdraw.moltenvkBrew):
Expand All @@ -12,6 +16,38 @@ when defined(macosx) and defined(figdraw.moltenvkBrew):
quit "figdraw.moltenvkBrew requires Homebrew molten-vk"
switch("passL", "-Wl,-rpath," & moltenVkPrefix & "/lib")

when defined(linux):
# Optional deps
when defined(figdraw.vulkan):
switch("passC", gorgeEx("pkg-config --cflags vulkan").output.strip())
switch("passL", gorgeEx("pkg-config --libs vulkan").output.strip())

when defined(figdraw.harfbuzz):
switch("passC", gorgeEx("pkg-config --cflags harfbuzz fribidi").output.strip())
switch("passL", gorgeEx("pkg-config --libs harfbuzz fribidi").output.strip())

# Deps that figdraw absolutely needs to even compile
# source: painful amounts of trial and error

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh tell me about it. Especially running in CI it's even worse.

This might help cleanup CI though.

const
XorgDependencies = "x11-xcb xcb xcursor xkbcommon xrender"
WaylandDependencies = "wayland-client wayland-egl"
AuxDependencies = "gl glesv2 egl"

switch(
"passC",
gorgeEx(
&"pkg-config --cflags {XorgDependencies} {WaylandDependencies} {AuxDependencies}"
).output
.strip(),
)
switch(
"passL",
gorgeEx(
&"pkg-config --libs {XorgDependencies} {WaylandDependencies} {AuxDependencies}"
).output
.strip(),
)

proc nimExec(subcmd, file: string, extraFlags = "", platform = "") =
let nimFlags = getEnv("NIMFLAGS").strip()
var cmd: string
Expand Down Expand Up @@ -42,7 +78,8 @@ task test, "run unit test":
getEnv("FIGDRAW_TEST_SDL2").strip().toLowerAscii() in ["1", "true", "yes", "on"]

for platformArg in platforms():
if platformArg != "": echo "Running platform args: ", platformArg
if platformArg != "":
echo "Running platform args: ", platformArg
for file in listFiles("tests"):
if file.startsWith("tests/t") and file.endsWith(".nim"):
nimExec("r", file, platform = platformArg)
Expand Down Expand Up @@ -70,8 +107,7 @@ task test_emscripten, "build emscripten examples":

task bindings, "Generate bindings":
proc compile(libName: string, flags = "") =
exec "nim c -f " & flags &
" --path:src -d:release " &
exec "nim c -f " & flags & " --path:src -d:release " &
" -d:gennyNim -d:gennyC -d:gennyPython " &
" --app:lib --gc:arc --tlsEmulation:off --out:" & libName &
" --outdir:src/figdraw/bindings/generated src/figdraw/bindings/bindings.nim"
Expand Down
Loading
Loading