Skip to content

Commit

Permalink
feat: properly position some punctuation between more Hangul
Browse files Browse the repository at this point in the history
  • Loading branch information
Dalgona committed May 23, 2021
1 parent 3d530dd commit adb6e40
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
13 changes: 13 additions & 0 deletions lib/neodgm/bitmap_font.ex
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,17 @@ defmodule NeoDGM.BitmapFont do
def all_cho_glyphs, do: @all_cho_glyphs
def all_jung_glyphs, do: @all_jung_glyphs
def all_jong_glyphs, do: @all_jong_glyphs

a_and_wa_components =
0..3
|> Enum.map(&["jung_#{&1}_00", "jung_#{&1}_09"])
|> List.flatten()

a_and_wa_syllables =
[0, 252]
|> Enum.map(fn x -> Enum.map(0..18, & &1 * 588 + 0xAC00 + x) end)
|> List.flatten()

def a_and_wa_components, do: unquote(a_and_wa_components)
def a_and_wa_syllables, do: unquote(a_and_wa_syllables)
end
6 changes: 3 additions & 3 deletions lib/neodgm/lookups/gpos/hangul_punctuation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use PixelFont.OTFLayout

lookups NeoDGM.Lookups.GPOS.HangulPunctuation, for: "GPOS" do
module do
import NeoDGM.BitmapFont, only: [all_cho_glyphs: 0]
import NeoDGM.BitmapFont

defp scripts do
%{"DFLT" => [:default], "hang" => [:default], "jamo" => [:default]}
Expand All @@ -14,15 +14,15 @@ lookups NeoDGM.Lookups.GPOS.HangulPunctuation, for: "GPOS" do

# LVT form
context do
backtrack Enum.map(0..3, &"jung_#{&1}_00")
backtrack a_and_wa_components()
backtrack all_cho_glyphs()
input '-~', apply: "Move 1px forward"
lookahead [all_cho_glyphs(), ?가..?힣]
end

# Hangul syllable form
context do
backtrack '가까나다따라마바빠사싸아자짜차카타파하'
backtrack a_and_wa_syllables()
input '-~', apply: "Move 1px forward"
lookahead [all_cho_glyphs(), ?가..?힣]
end
Expand Down
10 changes: 5 additions & 5 deletions lib/neodgm/lookups/gsub/hangul_punctuation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use PixelFont.OTFLayout

lookups NeoDGM.Lookups.GSUB.HangulPunctuation, for: "GSUB" do
module do
import NeoDGM.BitmapFont, only: [all_cho_glyphs: 0]
import NeoDGM.BitmapFont

defp scripts do
%{"DFLT" => [:default], "hang" => [:default], "jamo" => [:default]}
Expand All @@ -29,29 +29,29 @@ lookups NeoDGM.Lookups.GSUB.HangulPunctuation, for: "GSUB" do

# Ignore: This context is covered by a GPOS lookup.
context do
backtrack Enum.map(0..3, &"jung_#{&1}_00")
backtrack a_and_wa_components()
backtrack all_cho_glyphs()
input '-~'
lookahead [all_cho_glyphs(), ?가..?힣]
end

# Ignore: This context is covered by a GPOS lookup.
context do
backtrack '가까나다따라마바빠사싸아자짜차카타파하'
backtrack a_and_wa_syllables()
input '-~'
lookahead [all_cho_glyphs(), ?가..?힣]
end

# LVT form
context do
backtrack Enum.map(0..3, &"jung_#{&1}_00")
backtrack a_and_wa_components()
backtrack all_cho_glyphs()
input '-~', apply: "Shorter punctuation for Hangul"
end

# Hangul syllable form
context do
backtrack '가까나다따라마바빠사싸아자짜차카타파하'
backtrack a_and_wa_syllables()
input '-~', apply: "Shorter punctuation for Hangul"
end
end
Expand Down

0 comments on commit adb6e40

Please sign in to comment.