Upgrade to Pro — share decks privately, control downloads, hide ads and more …

kanji banner

MSR
December 25, 2016

kanji banner

漢字バナー芸 - 仮名だけじゃなく漢字もください

※bannerコマンドにおける「GNU系」という表記は誤りで、正しくは「System V由来」です。

MSR

December 25, 2016
Tweet

More Decks by MSR

Other Decks in Technology

Transcript

  1. ׽ࣈόφʔܳ
    @ୈ26ճγΣϧܳษڧձ େࡕαςϥΠτ (2016.12.25)
    MSR (@msr386)

    View full-size slide

  2. ໨࣍
    ➤ ࣗݾ঺հ
    ➤ όφʔܳͱ͸
    ➤ banner, figlet, toilet
    ➤ toiletίϚϯυͷ֦ு (׽ࣈΛ͍ͩ͘͞)
    ➤ ·ͱΊ

    View full-size slide

  3. ࣗݾ঺հ
    ➤ ϋϯυϧωʔϜ: MSR (@msr386)
    ➤ C++ϓϩάϥϛϯάɺαʔόʔӡ༻͕ಘҙ
    ➤ Chromium Contributor
    ➤ Webϒϥ΢β࡞͍ͬͯ·͢

    http://app.tungsten-start.net/

    View full-size slide

  4. όφʔܳͱ͸
    ➤ ఆ͕ٛ͋Δͷ͔͸ఆ͔Ͱ͸ͳ͍͕…
    ➤ ҰݴͰݴ͑͹ʮจࣈΛ໨ཱͨͤΔγΣϧܳʯ
    ➤ ར༻͞ΕΔ୅දతͳίϚϯυʹbanner, figlet, toilet͕͋Δ
    ➤ όφʔܳͷྫ
    ➤ ಥવͷࢮΛϫϯϥΠφʔͰදࣔ
    ➤ ໨ཱͨͤͨ΋ͷΛwallίϚϯυͰ୺຤ʹҰ੪ૹ৴

    View full-size slide

  5. όφʔܳͷ୅දతͳίϚϯυ (1) - BANNER
    ➤ ੲ͔Β͋Δ఻౷తɺ͔ͭݪ࢝తͳίϚϯυ
    ➤ GNUܥͱBSDܥͰ͸ରԠҾ਺΍ද͕ࣔશ͘ҟͳΔ
    ➤ GNUܥ͸ͨͩ#Ͱେ͖͚ͨͩ͘͠ͰɺҾ਺͸Ұ੾ରԠ͠ͳ͍
    ➤ BSDܥ͸͔ͬ͜Α͘දࣔ͞ΕΔ͕ͳ͔ͥॎʹදࣔͯ͘͠Δ

    ˠԣʹදࣔ͢ΔγΣϧ͕ܳొ৔ (※͜Ε͕όφʔܳͷ͸͡·Γ)

    View full-size slide

  6. ➤ https://twitter.com/grethlen/status/778952287339163649
    BANNERίϚϯυ࣮ߦྫ

    View full-size slide

  7. BANNERίϚϯυ࣮ߦྫ
    $ banner -w 50 a

    ### 

    ########

    ########## ##### 

    #### #### ######

    ## ## ## 

    ## ## # 

    ## ## ## 

    ##################

    ###################

    ##################

    ## 

    #

    $

    View full-size slide

  8. όφʔܳͷ୅දతͳίϚϯυ (2) - FIGLET
    ➤ bannerίϚϯυ͔Βදݱྗ͕ਐԽ
    ➤ ༷ʑͳදࣔํࣜ
    ➤ ඪ४౥ࡌͷϑΥϯτ͕๛෋(ΧλΧφͷΈ΍RTLͳ΋ͷ΋)

    showfigfonts ͰҰཡදࣔՄೳ
    ➤ ϑΥϯτ͸ࣗ࡞Մೳ
    ➤ ݱࡏɺ։ൃఀࢭத? (࠷৽൛͸2.2.5ɺ2012೥5݄Ҏ߱ߋ৽͞Ε͍ͯͳ͍)

    View full-size slide

  9. FIGLETίϚϯυ࣮ߦྫ
    $ figlet FIGlet

    _____ ___ ____ _ _ 

    | ___|_ _/ ___| | ___| |_ 

    | |_ | | | _| |/ _ \ __|

    | _| | | |_| | | __/ |_ 

    |_| |___\____|_|\___|\__|


    $ figlet -f roman FIGlet

    oooooooooooo ooooo .oooooo. oooo . 

    `888' `8 `888' d8P' `Y8b `888 .o8 

    888 888 888 888 .ooooo. .o888oo 

    888oooo8 888 888 888 d88' `88b 888 

    888 " 888 888 ooooo 888 888ooo888 888 

    888 888 `88. .88' 888 888 .o 888 . 

    o888o o888o `Y8bood8P' o888o `Y8bod8P' "888" 




    $

    View full-size slide

  10. όφʔܳͷ୅දతͳίϚϯυ (3) - TOILET
    ➤ figletͷஔ͖׵͑Λ໨తͨ͠ίϚϯυ
    ➤ Ծ໊ϑΥϯτඪ४౥ࡌ
    ➤ ΧϥʔදࣔɺHTMLग़ྗରԠ
    ➤ figletͱಉ༷ɺϑΥϯτࣗ࡞Մೳ(figletͱ͸ܗ͕ࣜҟͳΔ)
    ➤ ϥΠηϯε͸௝͍͠WTFPL (ύϒϦοΫϥΠηϯε͔ͩΒ޷͖ʹ͠΍͕Ε)
    ➤ ϗʔϜϖʔδ( http://caca.zoy.org/wiki/toilet )͸Ͳ͏ݟͯ΋͏˓͜

    View full-size slide

  11. TOILETίϚϯυ࣮ߦྫ
    $ toilet ͻΒ͕ͳΧλΧφOK׽ࣈ×

    m m m m m 

    m # m "" "m m" " mmm#m"mm # 

    ""#" # # "mm#""m "m # m"" "mmm#"""# 

    m" #"m #m""""m # # m# # # m" # 

    # # " # # # " m"""#m m" # 

    "mmm" mmm"" # "m" "mmm" " m" "m" 



    m m m 

    #mmmm # # mmmm m m 

    # m" "mmm#"""# "mmmm#"""" m" "m # m" m m 

    m" "mm" m" # # # # #m# "m" 

    m" m" # # # # # #m m" "m 

    mm"" m" "m" m" #mm# # "m 


    $

    View full-size slide

  12. ΍ͬͺΓ׽ࣈ͕΄͍͠

    View full-size slide

  13. TOILETͷϑΥϯτσʔλ
    ➤ ৔ॴ: /usr/local/share/figlet ͳͲ
    ➤ ֦ுࢠ: .tlf (※figletܗࣜ(.flf)΋࢖༻Մೳ)
    ➤ ϑΥϯτσʔλ͸zipѹॖͯ͠΋Α͍
    ➤ จࣈίʔυ͸Unicode

    →׽ࣈ΋ֆจࣈ΋(͠Α͏ͱࢥ͑͹)දࣔͰ͖Δ!

    View full-size slide

  14. ϑΥϯτσʔλͷܗࣜʢ֓ཁʣ
    ➤ 1ߦ໨͸tlf2a$ͱ͍͏ϔομ
    ɺ1จࣈ͋ͨΓͷߦ਺ͳͲΛఆٛ
    ➤ จࣈ͸UnicodeॱͰ֨ೲ͞Ε͍ͯΔ
    ➤ จࣈఆٛ
    ➤ 1ߦ໨͸Unicode஋ͱจࣈΛهड़
    ➤ 2ߦ໨Ҏ߱ʹରԠ͢ΔจࣈΛඳ͘
    ➤ ֤ߦͷऴ୺͸@ͰऴΘΔ
    ➤ จࣈ1ݸͷ࠷ऴߦ͸@@ͰऴΘΔ
    0x3042 ͋

    m @ 

    mmm#m"" @ 

    #mm#m @ 

    m# m" "m @ 

    # "m" # @ 

    "m" mm" @ 

    @ 

    @@

    View full-size slide

  15. ϑΥϯτσʔλฤूྫ
    ➤ ascii9.tlfΛల։ͯ͠add.tlfʹมߋͯ͠ɺ࣍ͷจࣈΛ௥Ճ
    0x4ECA ࠓ

    # @

    m” “m @

    mm" --- "mm @

    mmmmm @

    m @

    m" @

    @

    @@
    0x65E5 ೔

    mmmmmmmmmm @

    # # @

    #mmmmmmmm# @

    # # @

    # # @

    mmmmmmmmmm @

    @

    @@
    0x1F359 

    m @

    # # @

    # # @

    # mmm # @

    # #m# # @

    mmmmmmmmm @

    @

    @@

    View full-size slide

  16. ࣮ߦྫ
    $ toilet -f add ࠓ೔͸

    # mmmmmmmmmm m m 

    m" "m # # "m m #mm # # 

    mm" --- "mm #mmmmmmmm# m" """# # # 

    mmmmm # # # # # mmm # 

    m # # # mm"""#m # #m# # 

    m" mmmmmmmmmm "# "mmm" " mmmmmmmmm 



    $

    View full-size slide

  17. ࢖͏จࣈΛ͍͍ͪͪ

    ௥Ճ͢Δͷ͸ΊΜͲ͍

    View full-size slide

  18. ࣗಈੜ੒͍ͨ͠
    ➤ toiletͷιʔείʔυʹ͸ caca2tlf ͱ͍͏πʔϧ͕ଘࡏ
    ➤ caca2tlf ͸ libcaca಺෦Ͱ࢖༻͢ΔϑΥϯτΛtlfʹม׵͢Δπʔϧ

    (※libcaca͸ΞεΩʔΞʔτΛੜ੒͢ΔάϥϑΟοΫϥΠϒϥϦɺtoiletͰ࢖༻)
    ➤ libcaca಺෦Ͱ࢖༻͢ΔϑΥϯτ͸libcacaͷmakefontπʔϧͰੜ੒͢Δ
    ͔͠͠ɾɾɾ
    ➤ libcaca಺෦Ͱ࢖༻͢ΔϑΥϯτ͸׽ࣈ͕ੜ੒ର৅֎

    ͦͷ··ͩͱcaca2tlfͰ͸׽ࣈ͕ग़ͯ͜ͳ͍
    ➤ makefontͱlibcacaͷιʔείʔυΛมߋ͠ɺίϯύΠϧ͢Δඞཁ͕͋Δ

    View full-size slide

  19. ׽ࣈΛࣗಈੜ੒͢Δʹ͸
    1. toilet, libcacaͷιʔείʔυΛೖख


    2. toiletΛίϯύΠϧ



    3. libcacaΛbootstrapͱconfigure·Ͱ࣮ߦ
    $ git clone https://github.com/cacalabs/toilet.git

    $ git clone https://github.com/cacalabs/libcaca.git
    $ cd toilet

    $ ./bootstrap

    $ ./configure

    $ make
    $ cd libcaca

    $ ./bootstrap

    $ ./configure

    View full-size slide

  20. ׽ࣈΛࣗಈੜ੒͢Δʹ͸
    4. libcaca/tools/makefont.cͷάϩʔόϧఆ਺഑ྻ blocklist ʹCJK౷߹׽ࣈΤϦΞ
    (0x3d00ʙ0x9fd5)Λ௥Ճ

    5. makefontΛίϯύΠϧ
    diff --git a/tools/makefont.c b/tools/makefont.c

    index 226c883..7c58c79 100644

    --- a/tools/makefont.c

    +++ b/tools/makefont.c

    @@ -61,6 +61,7 @@ static unsigned int const blocklist[] =

    0x3000, 0x3040, /* CJK Symbols and Punctuation: 。「」 */

    0x3040, 0x30a0, /* Hiragana: で す */

    0x30a0, 0x3100, /* Katakana: ロ ル */

    + 0x3d00, 0x9fd5, /* CJK unified Ideographs */

    0xff00, 0xfff0, /* Halfwidth and Fullwidth Forms: A, B, C, a, b, c */

    0x10400, 0x10450, /* Deseret: */

    0, 0

    View full-size slide

  21. ׽ࣈΛࣗಈੜ੒͢Δʹ͸
    6. ಺ଂϑΥϯτΛੜ੒͠ɺcaca/mono*.dataΛ্ॻ͖



    ˞ͦΕͧΕ9ϙΠϯτ༻ͱ12ϙΠϯτ༻Λੜ੒ɻmono9ͱmonobold12͸ݻఆ

    ˞ୈ2Ҿ਺ʹϑΥϯτ໊ͱϙΠϯτ਺Λهड़ɻ͜ΕͰਖ਼͍͔͠͸ະ֬ೝ

    ˞ୈ3Ҿ਺͸DPI஋(௨ৗ96)ɺୈ4Ҿ਺͸bpp(1ϐΫηϧ͋ͨΓͷϏοτ਺)
    7. libcacaΛίϯύΠϧɺΠϯετʔϧ

    8. toiletͷtools/caca2tlfΛ࣮ߦ

    [libcaca/tools] $ ./makefont mono9 "IPA Gothic 9" 96 1 > ../caca/mono9.data

    [libcaca/tools] $./makefont monobold12 "IPA Gothic 12" 96 1 > ../caca/monobold12.data
    [libcaca] $ make

    [libcaca] $ sudo make install
    [toilet/tools] $ ./caca2tlf "Monospace 9" > /usr/local/share/figlet/ipa9

    [toilet/tools] $ ./caca2tlf "Monospace Bold 12" > /usr/local/share/figlet/ipa12

    View full-size slide

  22. ࣮ߦྫ
    $ toilet -f ipa12 ׽ࣈOK




    ## # ## 

    # ########## ############ ## # # 

    # ## # ## ## # # ## ## 

    ######### ## ## # # ## ## 

    # ## ## ## ## ######## ## # # ## # 

    # ## ## ## ## # # #### 

    # ######## ## # # ### 

    ## # # # ### 

    ########## ############## # # #### 

    # ## ############## # # ## # 

    # ########## # # # ## ## 

    # #### # ## ## ## ## 

    # ## ## # #### ## # 

    # ## ## #####

    View full-size slide

  23. ׽ࣈੜ੒͸Մೳ͕ͩɾɾɾ
    ➤ CJK౷߹׽ࣈ(໿28,000ࣈ)ͷ͓͔͛Ͱ࣮ߦʹ͕͔͔࣌ؒΔ

    ϑΝΠϧαΠζ : ໿5MBʙ10MB

    ascii9.tlf(ඇѹॖ) : ໿290KB
    ➤ ͋·Γ៉ྷ͡Όͳ͍

    ϏοτϚοϓϑΥϯτͳΒ៉ྷʹͳΔ?
    ➤ αΠζ͕9ϙΠϯτͩͱ׽ࣈ͕ͭͿΕΔ

    View full-size slide

  24. ·ͱΊ
    ➤ όφʔܳͰ࢖༻͢Δ୅දίϚϯυ: banner, figlet, toilet
    ➤ toiletͷϑΥϯτ͸֦ுՄೳ
    ➤ ͦͷؾʹͳΕ͹׽ࣈදࣔ΋ֆจࣈ΋දࣔͰ͖Δ
    ➤ ׽ࣈͷࣗಈੜ੒͕͚ͨ͠Ε͹
    1. libcacaͷπʔϧmakefontΛվ଄ͯ͠libcacaΛίϯύΠϧɺΠϯετʔϧ
    2. caca2tlfͰੜ੒
    ➤ ࣗಈੜ੒͞ΕͨϑΥϯτϑΝΠϧ͸αΠζ͕େ͖͗ͯ͢ද͕ࣔ஗͍

    View full-size slide