Skip to content

Commit

Permalink
Replace pangocairo with freetype
Browse files Browse the repository at this point in the history
  • Loading branch information
klsruan committed Apr 23, 2024
1 parent d4a8f0b commit 892f6d6
Show file tree
Hide file tree
Showing 5 changed files with 700 additions and 242 deletions.
2 changes: 1 addition & 1 deletion modules/ILL/ILL.moon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module_version = "1.4.6"
module_version = "1.4.7"

haveDepCtrl, DependencyControl = pcall require, "l0.DependencyControl"

Expand Down
12 changes: 10 additions & 2 deletions modules/ILL/ILL/Ass/Line.moon
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ class Line
.internal_leading = textMetrics.internal_leading
.external_leading = textMetrics.external_leading

font\free! if IS_UNIX

-- text alignment
{:an} = .data

Expand Down Expand Up @@ -486,7 +488,9 @@ class Line
-- sets new values
lineBlock.data.scale_x = 100
lineBlock.data.scale_y = 100
textExtents = Font(lineBlock.data)\getTextExtents lineBlock.text_stripped
font = Font lineBlock.data
textExtents = font\getTextExtents lineBlock.text_stripped
font\free! if IS_UNIX
lineBlock.width = textExtents.width
lineBlock.height = textExtents.height
-- converts the text to shape and then converts the shape to Path
Expand Down Expand Up @@ -718,7 +722,11 @@ class Line
return x * w, y * w

-- converts the text to shape
toShape: (l) -> Font(l.data)\getTextToShape l.text_stripped
toShape: (l) ->
font = Font l.data
shape = font\getTextToShape l.text_stripped
font\free! if IS_UNIX
return shape

-- converts the text to Path
toPath: (l) -> Path Line.toShape l
Expand Down
7 changes: 4 additions & 3 deletions modules/ILL/ILL/Font/Font.moon
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@
-- Font scale values for increased size & later downscaling to produce floating point coordinates
export FONT_UPSCALE = 64
export FONT_DOWNSCALE = 1 / FONT_UPSCALE
export IS_UNIX = jit.os != "Windows"

if jit.os == "Windows"
unless IS_UNIX
-- if the operating system is windows
import WindowsGDI from require "ILL.ILL.Font.Win"
return {Font: WindowsGDI}

-- if the operating system is unix
import PangoCairo from require "ILL.ILL.Font.Unx"
return {Font: PangoCairo}
import FreeType from require "ILL.ILL.Font.Unx"
return {Font: FreeType}
Loading

0 comments on commit 892f6d6

Please sign in to comment.