forked from BASLQC/kc-vita-translation
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
automate most of the font generation steps and allow multi chars per …
…glyph
- Loading branch information
1 parent
207a9c2
commit d95be94
Showing
17 changed files
with
265 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Str|ate|Ret|urn|Adm|ira|l C|Cho|ose | ||
Str|ate|gy|Ret|urn|Adm|ira|l C|omm|and|Cho|ose|ls |Com|man|der | ||
Sel|ect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<html> | ||
|
||
<head> | ||
<meta http-equiv="Content-Type" content="text/html" charset="utf-8"> | ||
</head> | ||
<body> | ||
|
||
<pre> | ||
------------------------------------------------------------------------------- | ||
梅フォントのライセンス (日本語 UTF-8) (UmeFont license (In Japanese UTF-8)) | ||
------------------------------------------------------------------------------- | ||
|
||
本ライセンスは以下の梅フォントに共通のライセンスです。 | ||
|
||
* 梅ゴシック | ||
* 梅ゴシックC4 | ||
* 梅ゴシックS4 | ||
* 梅ゴシックO5 | ||
* 梅ゴシックC5 | ||
* 梅ゴシックS5 | ||
* 梅Pゴシック | ||
* 梅PゴシックC4 | ||
* 梅PゴシックS4 | ||
* 梅PゴシックO5 | ||
* 梅PゴシックC5 | ||
* 梅PゴシックS5 | ||
* 梅UIゴシック | ||
* 梅UIゴシックO5 | ||
* 梅Hyゴシック | ||
* 梅HyゴシックO5 | ||
* 梅明朝 | ||
* 梅明朝S3 | ||
* 梅P明朝 | ||
* 梅P明朝S3 | ||
|
||
|
||
これらのフォントはフリー(自由な)ソフトウエアです。 | ||
あらゆる改変の有無に関わらず、また商業的な利用であっても、自由にご利用、複製、 | ||
再配布することができますが、全て無保証とさせていただきます。 | ||
|
||
|
||
|
||
------------------------------------------------------------------------------- | ||
UmeFont license (In English) | ||
------------------------------------------------------------------------------- | ||
|
||
This is common license of the UmeFont family. UmeFont family provides the | ||
following fonts: | ||
|
||
* Ume Gothic | ||
* Ume Gothic C4 | ||
* Ume Gothic S4 | ||
* Ume Gothic O5 | ||
* Ume Gothic C5 | ||
* Ume Gothic S5 | ||
* Ume P Gothic | ||
* Ume P Gothic C4 | ||
* Ume P Gothic S4 | ||
* Ume P Gothic O5 | ||
* Ume P Gothic C5 | ||
* Ume P Gothic S5 | ||
* Ume UI Gothic | ||
* Ume UI Gothic O5 | ||
* Ume Hy Gothic | ||
* Ume Hy Gothic O5 | ||
* Ume Mincho | ||
* Ume Mincho S3 | ||
* Ume P Mincho | ||
* Ume P Mincho S3 | ||
|
||
|
||
These fonts are free software. | ||
Unlimited permission is granted to use, copy, and distribute it, | ||
with or without modification, either commercially and noncommercially. | ||
THESE FONTS ARE PROVIDED "AS IS" WITHOUT WARRANTY. | ||
|
||
</pre> | ||
</body> | ||
</html> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
dirname = $1 | ||
outfile = $2 | ||
|
||
Open(dirname) | ||
Generate(outfile) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
use 5.010; | ||
use strictures 2; | ||
use IO::All -binary; | ||
use Capture::Tiny 'tee'; | ||
|
||
run(); | ||
|
||
sub run { | ||
$|++; | ||
say "you might want to run this to enable kanji: chcp 65001"; | ||
say "your terminal's font will need to support kanji too (e.g. MS Gothic, MS Mincho)\n"; | ||
|
||
while (1) { | ||
system qq[perl translate_utf16_binary.pl]; | ||
print "do you wish to repeat the CSharp translation build? [n]"; | ||
my $in = <>; | ||
chomp $in; | ||
last if !$in or $in =~ /^n/; | ||
} | ||
print "do you wish to proceed [y]"; | ||
my $in = <>; | ||
chomp $in; | ||
return if $in and $in !~ /^y/; | ||
|
||
my $ff = "C:/Program Files (x86)/FontForgeBuilds/bin/fontforge.exe"; | ||
my $candidate_dir = "../kc_translation_mod_candidate"; | ||
my @fonts = ( | ||
{ | ||
name => "A-OTF-UDShinGoPro-Regular", | ||
target_path => "Media/Unity_Assets_Files/sharedassets3", | ||
src => "fonts/ume-pgs4.ttf" | ||
}, | ||
{ | ||
name => "A-OTF-ShinGoPro-Regular", | ||
target_path => "Media/Unity_Assets_Files/sharedassets2", | ||
src => "../kc_original_unpack/Media/Unity_Assets_Files/sharedassets3/A-OTF-UDShinGoPro-Regular.ttf" | ||
}, | ||
); | ||
io("../fonts")->mkdir if !-d "../fonts"; | ||
mod_font( $ff, $candidate_dir, $_->%* ) for @fonts; | ||
say "all done"; | ||
return; | ||
} | ||
|
||
sub mod_font { | ||
my ( $ff, $candidate_dir, %font ) = @_; | ||
say "processing font '$font{name}'"; | ||
|
||
if ( !-e "../fonts/$font{name}.sfdir" ) { | ||
say "preparing font from source with empty PUA glyphs and guaranteed space glyph"; | ||
my ( $out, $err, $res ) = tee { system(qq["$ff" -script prepare_new_font.ff "$font{src}" "../fonts/$font{name}.sfdir"]) }; | ||
$err =~ s/^Copyright.*\n(^ .*\n)+//m; | ||
$err =~ s/^The following table.*ignored.*\n(^ .*\n)+//m; | ||
$err =~ s/^Warning:.*\n(^ .*\n)+//mg; | ||
$err =~ s/^This font contains both.*\n(^ .*\n)+//m; | ||
$out =~ s/^log:.*\n//mg; | ||
die "error:\nout:\n$out\nerr:\n$err\nres: $res\n" if $out or $err or $res; | ||
} | ||
|
||
say "modding font with multi-glyphs"; | ||
my ( $out, $err, $res ) = tee { system(qq[python font_mod_run.py "$font{name}"]) }; | ||
die "error:\nout:\n$out\nerr:\n$err\nres: $res\n" if $out or $err or $res; | ||
|
||
say "generating font file from mod dir"; | ||
my $target_path = "$candidate_dir/$font{target_path}"; | ||
io($target_path)->mkpath; | ||
my $target_body = "$target_path/$font{name}"; | ||
my $temp_target = "$target_body.otf"; | ||
my $mod_dir = "../fonts/$font{name}_mod.sfdir"; | ||
my ( $out2, $err2, $res2 ) = tee { system(qq["$ff" -script generate_font_from_dir.ff "$mod_dir" "$temp_target"]) }; | ||
$err2 =~ s/^Copyright.*\n(^ .*\n)+//m; | ||
$err2 =~ s/^Lookup sub table.*is too big.*\n//m; | ||
$err2 =~ s/^Lookup .* has an\n(^ .*\n)+//m; | ||
die "error:\nout:\n$out2\nerr:\n$err2\nres: $res2\n" if $out2 or $err2 or $res2; | ||
|
||
# the extension here is for compatibility. the fonts in kc are OTF, but | ||
# have the extension ttf, so we generate the replacements to match | ||
say "fixing final extension"; | ||
io($temp_target)->rename("$target_body.ttf"); | ||
say "done\n"; | ||
return; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
infile = $1 | ||
dirname = $2 | ||
|
||
Print( "log: loading for saving to dir" ) | ||
Open(infile) # flatten if necessary, then save to a dir | ||
if ($iscid) | ||
Print( "log: flattening CID font" ) | ||
CIDFlatten() | ||
endif | ||
Print( "log: saving to dir" ) | ||
Save(dirname) | ||
Close() | ||
|
||
Print( "log: loading for resave" ) | ||
Open(dirname) # force the font through the load/save loop | ||
Print( "log: resaving" ) # as a dir in case ff decides to change some | ||
Save(dirname) # values again | ||
Close() | ||
|
||
Print( "log: loading for processing" ) | ||
Open(dirname) | ||
Print( "log: processing" ) | ||
|
||
Print( "log: preparing PUA filling" ) | ||
start = 0xE000 | ||
chars_to_add = 5000 | ||
# would prefer to add 6400 and use up the entire PUA, but UDShinGoPro-Regular | ||
# already has a char at F6BE and i guess now that we can add multiple chars per | ||
# glyph using less is fine | ||
|
||
Select("#") # copy this so we can add a shape to new chars so ff will save them | ||
Copy() | ||
|
||
oldsize = CharCnt() # add the new slots | ||
SetCharCnt(oldsize + chars_to_add) | ||
|
||
Select(oldsize, oldsize + chars_to_add - 2) # select all the newly added slots | ||
|
||
Print( "log: filling PUA" ) | ||
foreach | ||
Paste() # add the "#" shape | ||
SetUnicodeValue(start) # set the correct unicode value | ||
start++ | ||
endloop | ||
|
||
Print( "log: ensuring there's a space char" ) | ||
if (!InFont("space")) | ||
oldsize = CharCnt() | ||
SetCharCnt(oldsize + 1) | ||
Select(oldsize - 1) | ||
Print("log: adding space glyph"+GlyphInfo("Name")+" "+GlyphInfo("Unicode")+" "+GlyphInfo("Encoding")) | ||
SetUnicodeValue(0x0020) | ||
SetWidth(333) | ||
SetGlyphName("space") | ||
endif | ||
|
||
Print( "log: saving changes" ) | ||
Save(dirname) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.