%%
%% This is file `unitipa.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% unitipa.dtx  (with options: `package')
%% 
%% ---------------------------------------------------------------------------
%% Package:      unitipa
%% Author:       Niranjan
%% Description:  TIPA typefaces with Unicode characters.
%% Repository:   https://gitlab.com/niranjanvikastambe/unitipa
%% Bug tracker:  https://gitlab.com/niranjanvikastambe/unitipa/-/issues
%% License:      The LaTeX Project Public License v1.3c or later.
%% ---------------------------------------------------------------------------
%% This work may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License, either version 1.3c of this license or (at
%% your option) any later version.
%% 
%% The latest version of this license is in
%% 
%%     http://www.latex-project.org/lppl.txt.
%% 
%% This work has the LPPL maintenance status `maintained'.
%% 
%% The Current Maintainer of this work is Niranjan.
%% 
%% This work consists of the files unitipa.dtx
%%                                 unitipa.ins
%% and the derived file            unitipa.sty.
%% ---------------------------------------------------------------------------
%% 
\def\unitipaname{unitipa}
\def\unitipaversion{0.2}
\def\unitipadate{2021/03/13}
\def\unitipadescription{TIPA typefaces with Unicode characters.}
\ProvidesPackage{unitipa}[2021/03/13 v0.2
TIPA typefaces with unicode characters]
\RequirePackage{tipa}
\RequirePackage{graphicx}
\RequirePackage{newunicodechar}
\RequirePackage{fontspec}
\RequirePackage{pgfkeys}
\pgfkeys{%
  unitipa/.is family, unitipa/.cd,%
  ipafont/.code={\setfontfamily{\ipa}{#1}},%
  ipafont=DoulosSIL%
}%
\DeclareTextFontCommand{\ipatext}{\ipa}
\def\unitipa@ipafont#1{\pgfkeys{unitipa/.cd,#1}}
\DeclareOption*{\expandafter\unitipa@ipafont\expandafter{\CurrentOption}}
\newif\ifnodiacritics
\nodiacriticsfalse
\DeclareOption{nodiacritics}{\nodiacriticstrue}
\ProcessOptions\relax
\ifnodiacritics
\relax
\else
\RequirePackage{iftex}
\RequirePackage{luacode}
\RequireLuaTeX
%% Dependent diacritic marks
\begin{luacode}
    function voiceless ( s )
    s = unicode.utf8.gsub ( s , '(%a)̥', '\\textsubring{%1}' )
    return s
    end
\end{luacode}
\directlua{luatexbase.add_to_callback("process_input_buffer",
    voiceless, "voiceless")}
\begin{luacode}
    function voiced ( s )
    s = unicode.utf8.gsub ( s , '(%a)̬', '\\textsubwedge{%1}' )
    return s
    end
\end{luacode}
\directlua{luatexbase.add_to_callback("process_input_buffer",
    voiced, "voiced")}
\begin{luacode}
    function morerounded ( s )
    s = unicode.utf8.gsub ( s , '(%a)̹', '\\textsubrhalfring{%1}' )
    return s
    end
  \end{luacode}
  \directlua{luatexbase.add_to_callback("process_input_buffer",
    morerounded, "morerounded")}
  \begin{luacode}
    function lessrounded ( s )
    s = unicode.utf8.gsub ( s , '(%a)̜', '\\textsublhalfring{%1}' )
    return s
    end
  \end{luacode}
  \directlua{luatexbase.add_to_callback("process_input_buffer",
    lessrounded, "lessrounded")}
  \begin{luacode}
    function advanced ( s )
    s = unicode.utf8.gsub ( s , '(%a)̟', '\\textsubplus{%1}' )
    return s
    end
  \end{luacode}
  \directlua{luatexbase.add_to_callback("process_input_buffer",
    advanced, "advanced")}
  \begin{luacode}
    function retracted ( s )
    s = unicode.utf8.gsub ( s , '(%a)̠', '\\textsubbar{%1}' )
    return s
    end
  \end{luacode}
  \directlua{luatexbase.add_to_callback("process_input_buffer",
    retracted, "retracted")}
  \begin{luacode}
    function midcentralized ( s )
    s = unicode.utf8.gsub ( s , '(%a)̽', '\\textovercross{%1}' )
    return s
    end
  \end{luacode}
  \directlua{luatexbase.add_to_callback("process_input_buffer",
    midcentralized, "midcentralized")}
  \begin{luacode}
    function syllabic ( s )
    s = unicode.utf8.gsub ( s , '(%a)̩', '\\textsyllabic{%1}' )
    return s
    end
  \end{luacode}
  \directlua{luatexbase.add_to_callback("process_input_buffer",
    syllabic, "syllabic")}
  \begin{luacode}
    function nonsyllabic ( s )
    s = unicode.utf8.gsub ( s , '(%a)̯', '\\textsubarch{%1}' )
    return s
    end
  \end{luacode}
  \directlua{luatexbase.add_to_callback("process_input_buffer",
    nonsyllabic, "nonsyllabic")}
  \begin{luacode}
    function breathyvoiced ( s )
    s = unicode.utf8.gsub ( s , '(%a)̤', '\\textsubumlaut{%1}' )
    return s
    end
  \end{luacode}
  \directlua{luatexbase.add_to_callback("process_input_buffer",
    breathyvoiced, "breathyvoiced")}
  \begin{luacode}
    function linguolabial ( s )
    s = unicode.utf8.gsub ( s , '(%a)̼', '\\textseagull{%1}' )
    return s
    end
  \end{luacode}
  \directlua{luatexbase.add_to_callback("process_input_buffer",
    linguolabial, "linguolabial")}
  \begin{luacode}
    function velarized ( s )
    s = unicode.utf8.gsub ( s , '(%a)̴', '\\textsuperimposetilde{%1}' )
    return s
    end
  \end{luacode}
  \directlua{luatexbase.add_to_callback("process_input_buffer",
    velarized, "velarized")}
  \begin{luacode}
    function raised ( s )
    s = unicode.utf8.gsub ( s , '(%a)̝', '\\textraising{%1}' )
    return s
    end
  \end{luacode}
  \directlua{luatexbase.add_to_callback("process_input_buffer",
    raised, "raised")}
  \begin{luacode}
    function lowered ( s )
    s = unicode.utf8.gsub ( s , '(%a)̞', '\\textlowering{%1}' )
    return s
    end
  \end{luacode}
  \directlua{luatexbase.add_to_callback("process_input_buffer",
    lowered, "lowered")}
  \begin{luacode}
    function advancedtr ( s )
    s = unicode.utf8.gsub ( s , '(%a)̘', '\\textadvancing{%1}' )
    return s
    end
  \end{luacode}
  \directlua{luatexbase.add_to_callback("process_input_buffer",
    advancedtr, "advancedtr")}
  \begin{luacode}
    function retractedtr ( s )
    s = unicode.utf8.gsub ( s , '(%a)̙', '\\textretracting{%1}' )
    return s
    end
  \end{luacode}
  \directlua{luatexbase.add_to_callback("process_input_buffer",
    retractedtr, "retractedtr")}
  \begin{luacode}
    function dental ( s )
    s = unicode.utf8.gsub ( s , '(%a)̪', '\\textsubbridge{%1}' )
    return s
    end
  \end{luacode}
  \directlua{luatexbase.add_to_callback("process_input_buffer",
    dental, "dental")}
  \begin{luacode}
    function apical ( s )
    s = unicode.utf8.gsub ( s , '(%a)̺', '\\textinvsubbridge{%1}' )
    return s
    end
  \end{luacode}
  \directlua{luatexbase.add_to_callback("process_input_buffer",
    apical, "apical")}
  \begin{luacode}
    function laminal ( s )
    s = unicode.utf8.gsub ( s , '(%a)̻', '\\textsubsquare{%1}' )
    return s
    end
  \end{luacode}
  \directlua{luatexbase.add_to_callback("process_input_buffer",
    laminal, "laminal")}
  \begin{luacode}
    function unaudible ( s )
    s = unicode.utf8.gsub ( s , '(%a)̚', '%1\\textcorner' )
    return s
    end
  \end{luacode}
  \directlua{luatexbase.add_to_callback("process_input_buffer",
    unaudible, "unaudible")}
%% Tie bars
\begin{luacode}
  function tiebarup ( s )
  s = unicode.utf8.gsub ( s , '(%a)͡(%a)', '\\texttoptiebar{%1%2}' )
  return s
  end
\end{luacode}
\directlua{luatexbase.add_to_callback("process_input_buffer",
  tiebarup, "tiebarup")}
\begin{luacode}
  function tiebardown ( s )
  s = unicode.utf8.gsub ( s , '(%a)͜(%a)', '\\textbottomtiebar{%1%2}' )
  return s
  end
\end{luacode}
\directlua{luatexbase.add_to_callback("process_input_buffer",
  tiebardown, "tiebardown")}
\begin{luacode}
  function risefall ( s )
  s = unicode.utf8.gsub ( s , '(%a)᷈', '\\textrisefall{%1}' )
  return s
  end
\end{luacode}
\directlua{luatexbase.add_to_callback("process_input_buffer",
  risefall, "risefall")}
\begin{luacode}
  function rising ( s )
  s = unicode.utf8.gsub ( s , '(%a)᷄', '\\texthighrise{%1}' )
  return s
  end
\end{luacode}
\directlua{luatexbase.add_to_callback("process_input_buffer",
  rising, "rising")}
\begin{luacode}
  function falling ( s )
  s = unicode.utf8.gsub ( s , '(%a)᷅', '\\textlowrise{%1}' )
  return s
  end
\end{luacode}
\directlua{luatexbase.add_to_callback("process_input_buffer",
  falling, "falling")}
\fi
%% Pulmonic Consonants
%% Plosives
\newunicodechar{ʈ}{\textrtailt}
\newunicodechar{ɖ}{\textrtaild}
\newunicodechar{ɟ}{\textbardotlessj}
\newunicodechar{ɢ}{\textscg}
\newunicodechar{ʔ}{\textglotstop}
%% Nasals
\newunicodechar{ɱ}{\textltailm}
\newunicodechar{ɳ}{\textrtailn}
\newunicodechar{ɲ}{\textltailn} %% Added in v0.2
\newunicodechar{ɴ}{\textscn}
%% Trills
\newunicodechar{ʙ}{\textscb}
\newunicodechar{ʀ}{\textscr}
%% Taps or flaps
\newunicodechar{ⱱ}{\ipatext{ⱱ}} %% Sorry for the bad typography!
\newunicodechar{ɾ}{\textfishhookr}
\newunicodechar{ɽ}{\textrtailr}
%% Fricatives
\newunicodechar{ɸ}{\textphi}
\newunicodechar{β}{\textbeta}
\newunicodechar{θ}{\texttheta}
\newunicodechar{ʃ}{\textesh}
\newunicodechar{ʒ}{\textyogh}
\newunicodechar{ʂ}{\textrtails}
\newunicodechar{ʐ}{\textrtailz}
\newunicodechar{ʝ}{\textctj}
\newunicodechar{ɣ}{\textgamma}
\newunicodechar{χ}{\textchi}
\newunicodechar{ʁ}{\textinvscr}
\newunicodechar{ʕ}{\textrevglotstop}
\newunicodechar{ɦ}{\texthth}
%% Lateral fricatives
\newunicodechar{ɬ}{\textbeltl}
\newunicodechar{ɮ}{\textlyoghlig}
%% Approximants
\newunicodechar{ʋ}{\textscriptv}
\newunicodechar{ɹ}{\textturnr}
\newunicodechar{ɻ}{\textturnrrtail}
\newunicodechar{ɰ}{\textturnmrleg}
%% Lateral approximants
\newunicodechar{ɭ}{\textrtaill}
\newunicodechar{ʎ}{\textturny}
\newunicodechar{ʟ}{\textscl}
%% Affricates
\newunicodechar{ʧ}{\textteshlig}
\newunicodechar{ʤ}{\textdyoghlig}
\newunicodechar{ʦ}{\texttslig}
\newunicodechar{ʣ}{\textdzlig}
%% Vowels
%% Close
\newunicodechar{ɨ}{\textbari}
\newunicodechar{ʉ}{\textbaru}
\newunicodechar{ɯ}{\textturnm}
%% Near-close
\newunicodechar{ɪ}{\textsci}
\newunicodechar{ʏ}{\textscy}
\newunicodechar{ʊ}{\textupsilon}
%% Close-mid
\newunicodechar{ɵ}{\textbaro}
\newunicodechar{ɤ}{\textramshorns}
%% Open-mid
\newunicodechar{ɛ}{\textepsilon}
\newunicodechar{ɜ}{\textrevepsilon}
\newunicodechar{ɞ}{\reflectbox{\textcloseepsilon}} %% Latest changes
\newunicodechar{ʌ}{\textturnv}
\newunicodechar{ɔ}{\textopeno}
%% Near-open
\newunicodechar{ɐ}{\textturna}
\newunicodechar{ɶ}{\textscoelig}
\newunicodechar{ɒ}{\textturnscripta}
%% Open
%% Reported and added by Heller, Thomas on 2021/03/13
%% Bug report - https://gitlab.com/niranjanvikastambe/unitipa/-/issues/1
%% MR - https://gitlab.com/niranjanvikastambe/unitipa/-/merge_requests/1
\newunicodechar{ɑ}{\textscripta}
%% Non-Pulmonic
\newunicodechar{ʘ}{\textbullseye}
\newunicodechar{ǀ}{\textpipe}
\newunicodechar{ǃ}{\textipa{!}}
\newunicodechar{ǂ}{\textdoublebarpipe}
\newunicodechar{ǁ}{\textdoublepipe}
%% Voiced Implosives
\newunicodechar{ɓ}{\texthtb}
\newunicodechar{ɗ}{\texthtd}
\newunicodechar{ʄ}{\texthtbardotlessj}
\newunicodechar{ɠ}{\texthtg}
\newunicodechar{ʛ}{\texthtscg}
\newunicodechar{ʼ}{'}
%% Suprasegmentals
\newunicodechar{ˈ}{\textprimstress}
\newunicodechar{ˌ}{\textsecstress}
\newunicodechar{ː}{\textlengthmark}
\newunicodechar{ˑ}{\texthalflength}
\newunicodechar{ʍ}{\textturnw}
\newunicodechar{ɥ}{\textturnh}
\newunicodechar{ʜ}{\textsch}
\newunicodechar{ʢ}{\textbarrevglotstop}
\newunicodechar{ʡ}{\textbarglotstop}
\newunicodechar{ɕ}{\textctc}
\newunicodechar{ʑ}{\textctz}
\newunicodechar{ɺ}{\textturnlonglegr}
\newunicodechar{ɧ}{\texththeng}
%% Diacritics
\newunicodechar{ʰ}{\textsuperscript{h}}
\newunicodechar{ʱ}{\textsuperscript{ɦ}}
\newunicodechar{ʷ}{\textsuperscript{w}}
\newunicodechar{ʲ}{\textsuperscript{j}}
\newunicodechar{ˠ}{\textsuperscript{ɣ}}
\newunicodechar{ˤ}{\textsuperscript{ʕ}}
%% Tones independent diacritics
\newunicodechar{ꜜ}{\textdownstep}
\newunicodechar{ꜛ}{\textupstep}
%% \newunicodechar{︎↗}{\textglobrise} %% Not working :'(
%% \newunicodechar{↘}{\textglobfall} %% Need help here
\endinput
%%
%% End of file `unitipa.sty'.
