Add support for some basic non-unicoded IPA macros

We now support everything on the IPA chart via the toolbar
This commit is contained in:
Juergen Spitzmueller 2012-08-23 17:42:53 +02:00
parent 8fe8966a97
commit ee1fc9130a
30 changed files with 1535 additions and 15 deletions

View File

@ -11,6 +11,35 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx.
----------------------- -----------------------
2012-08-23 Jürgen Spitzmüller <spitz@lyx.org>
* Format incremented to 438
Support for some IPA macros that are not unicoded.
(1) tone symbols from tipa's "tone" subpackage:
-- \tone{51} => \IPAChar \tone{51}
-- \tone{15} => \IPAChar \tone{15}
-- \tone{45} => \IPAChar \tone{45}
-- \tone{12} => \IPAChar \tone{12}
-- \tone{454} => \IPAChar \tone{454}
(2) TIPA tie bars:
-- \toptiebar{<content>} =>
\begin_inset IPADeco toptiebar
status open
\begin_layout Plain Layout
<content>
\end_layout
\end_inset
-- \bottomtiebar{<content>} =>
\begin_inset IPADeco bottomtiebar
status open
\begin_layout Plain Layout
<content>
\end_layout
\end_inset
2012-08-19 Jürgen Spitzmüller <spitz@lyx.org> 2012-08-19 Jürgen Spitzmüller <spitz@lyx.org>
* Format incremented to 437 * Format incremented to 437
Support for the TeX Gyre LaTeX fonts. Support for the TeX Gyre LaTeX fonts.

Binary file not shown.

After

Width:  |  Height:  |  Size: 529 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 527 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 353 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 319 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 B

View File

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.0"
width="260.31"
height="281"
id="svg1905"
inkscape:version="0.48.2 r9819"
sodipodi:docname="ipamacro-insert_deco_bottomtiebar.svg"
inkscape:export-filename="/home/jspitzm/lyx/lyx-devel/lib/images/ipa/ipamacro-insert_deco_bottomtiebar.png"
inkscape:export-xdpi="6.405694"
inkscape:export-ydpi="6.405694">
<metadata
id="metadata8">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="960"
inkscape:window-height="788"
id="namedview6"
showgrid="false"
inkscape:zoom="0.82198639"
inkscape:cx="26.80969"
inkscape:cy="57.865206"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0"
inkscape:current-layer="svg1905"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0" />
<defs
id="defs1907" />
<text
xml:space="preserve"
style="font-size:288px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="14.533237"
y="196.0462"
id="text3082"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3084"
x="14.533237"
y="196.0462">‿</tspan></text>
<rect
style="fill:none;stroke:#000000;stroke-width:16.96167183;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:16.9616723, 16.9616723;stroke-dashoffset:0"
id="rect2986"
width="224.5611"
height="153.57632"
x="19.974745"
y="31.459579" />
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.0"
width="260.31"
height="281"
id="svg1905"
inkscape:version="0.48.2 r9819"
sodipodi:docname="ipamacro-insert_deco_toptiebar.svg"
inkscape:export-filename="/home/jspitzm/lyx/lyx-devel/lib/images/ipa/ipamacro-insert_deco_toptiebar.png"
inkscape:export-xdpi="6.405694"
inkscape:export-ydpi="6.405694">
<metadata
id="metadata8">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="960"
inkscape:window-height="788"
id="namedview6"
showgrid="false"
inkscape:zoom="0.82198639"
inkscape:cx="26.80969"
inkscape:cy="57.865206"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0"
inkscape:current-layer="svg1905"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0" />
<defs
id="defs1907" />
<rect
style="fill:none;stroke:#000000;stroke-width:16.96167183;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:16.9616723, 16.9616723;stroke-dashoffset:0"
id="rect2986"
width="224.5611"
height="153.57632"
x="19.974745"
y="95.459579" />
<text
xml:space="preserve"
style="font-size:288px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="14.625625"
y="280.85333"
id="text3009"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3011"
x="14.625625"
y="280.85333">⁀</tspan></text>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.0"
width="111.98"
height="199.38"
id="svg1905"
inkscape:version="0.48.2 r9819"
sodipodi:docname="ipamacro-insert_tone-falling.svg"
inkscape:export-filename="/home/jspitzm/lyx/lyx-devel/lib/images/ipa/ipamacro-insert_tone-falling.png"
inkscape:export-xdpi="9.0279865"
inkscape:export-ydpi="9.0279865">
<metadata
id="metadata8">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="960"
inkscape:window-height="788"
id="namedview6"
showgrid="false"
inkscape:zoom="0.82198639"
inkscape:cx="-8.9154187"
inkscape:cy="-39.048491"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0"
inkscape:current-layer="svg1905"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
borderlayer="true" />
<defs
id="defs1907" />
<text
xml:space="preserve"
style="font-size:288px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="-6.4440536"
y="196.94687"
id="text3082"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3084"
x="-6.4440536"
y="196.94687">˥˩</tspan></text>
</svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.0"
width="144.98"
height="199.38"
id="svg1905"
inkscape:version="0.48.2 r9819"
sodipodi:docname="ipamacro-insert_tone-high-rising-falling.svg"
inkscape:export-filename="/home/jspitzm/lyx/lyx-devel/lib/images/ipa/ipamacro-insert_tone-high-rising-falling.png"
inkscape:export-xdpi="9.0279865"
inkscape:export-ydpi="9.0279865">
<metadata
id="metadata8">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="960"
inkscape:window-height="788"
id="namedview6"
showgrid="false"
inkscape:zoom="0.82198639"
inkscape:cx="-8.9154187"
inkscape:cy="-39.048491"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0"
inkscape:current-layer="svg1905"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
borderlayer="true" />
<defs
id="defs1907" />
<text
xml:space="preserve"
style="font-size:316.35415649px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="72.342529"
y="176.94406"
id="text2983"
sodipodi:linespacing="125%"
transform="scale(1.177221,0.84945818)"><tspan
sodipodi:role="line"
id="tspan2985"
x="72.342529"
y="176.94406"
style="font-size:219.69036865px">|</tspan></text>
<text
xml:space="preserve"
style="font-size:248.34390259px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="-19.880419"
y="186.38248"
id="text2987"
sodipodi:linespacing="125%"
transform="scale(0.8623052,1.1596822)"><tspan
sodipodi:role="line"
id="tspan2989"
x="-19.880419"
y="186.38248">^</tspan></text>
</svg>

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.0"
width="111.98"
height="199.38"
id="svg1905"
inkscape:version="0.48.2 r9819"
sodipodi:docname="ipamacro-insert_tone-rising.svg"
inkscape:export-filename="/home/jspitzm/lyx/lyx-devel/lib/images/ipa/ipamacro-insert_tone-rising.png"
inkscape:export-xdpi="9.0279865"
inkscape:export-ydpi="9.0279865">
<metadata
id="metadata8">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="960"
inkscape:window-height="788"
id="namedview6"
showgrid="false"
inkscape:zoom="0.82198639"
inkscape:cx="-8.9154187"
inkscape:cy="-39.048491"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0"
inkscape:current-layer="svg1905"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
borderlayer="true" />
<defs
id="defs1907" />
<text
xml:space="preserve"
style="font-size:288px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="-6.4440536"
y="196.94687"
id="text3082"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3084"
x="-6.4440536"
y="196.94687">˧˥</tspan></text>
</svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.0"
width="111.98"
height="199.38"
id="svg1905"
inkscape:version="0.48.2 r9819"
sodipodi:docname="ipamacro-insert_tone-low-rising.svg"
inkscape:export-filename="/home/jspitzm/lyx/lyx-devel/lib/images/ipa/ipamacro-insert_tone-low-rising.png"
inkscape:export-xdpi="9.0279865"
inkscape:export-ydpi="9.0279865">
<metadata
id="metadata8">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="960"
inkscape:window-height="788"
id="namedview6"
showgrid="false"
inkscape:zoom="0.82198639"
inkscape:cx="-8.9154187"
inkscape:cy="-39.048491"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0"
inkscape:current-layer="svg1905"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
borderlayer="true" />
<defs
id="defs1907" />
<text
xml:space="preserve"
style="font-size:288px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="-6.4440536"
y="196.94687"
id="text3082"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3084"
x="-6.4440536"
y="196.94687">˩˧</tspan></text>
</svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.0"
width="111.98"
height="199.38"
id="svg1905"
inkscape:version="0.48.2 r9819"
sodipodi:docname="ipamacro-insert_tone-falling.svg"
inkscape:export-filename="/home/jspitzm/lyx/lyx-devel/lib/images/ipa/ipamacro-insert_tone-falling.png"
inkscape:export-xdpi="9.0279865"
inkscape:export-ydpi="9.0279865">
<metadata
id="metadata8">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="960"
inkscape:window-height="788"
id="namedview6"
showgrid="false"
inkscape:zoom="0.82198639"
inkscape:cx="-8.9154187"
inkscape:cy="-39.048491"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0"
inkscape:current-layer="svg1905"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
borderlayer="true" />
<defs
id="defs1907" />
<text
xml:space="preserve"
style="font-size:288px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="-6.4440536"
y="196.94687"
id="text3082"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3084"
x="-6.4440536"
y="196.94687">˩˥</tspan></text>
</svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -170,6 +170,16 @@ InsetLayout Phantom
ForcePlain true ForcePlain true
End End
InsetLayout IPADeco
Decoration minimalistic
Font
Color foreground
EndFont
MultiPar false
CustomPars false
ForcePlain true
End
InsetLayout TOC:Listings InsetLayout TOC:Listings
# We need the [[List of Listings]] context, since "Listings" is also # We need the [[List of Listings]] context, since "Listings" is also
# the name of the inset and translated differently. # the name of the inset and translated differently.

View File

@ -913,6 +913,76 @@ def revert_texgyre(document):
preamble = "\\usepackage{%s}" % val preamble = "\\usepackage{%s}" % val
add_to_preamble(document, [preamble]) add_to_preamble(document, [preamble])
document.header[i] = "\\font_typewriter default" document.header[i] = "\\font_typewriter default"
def revert_ipadeco(document):
" Revert IPA decorations to ERT "
i = 0
while True:
i = find_token(document.body, "\\begin_inset IPADeco", i)
if i == -1:
return
end = find_end_of_inset(document.body, i)
if end == -1:
document.warning("Can't find end of inset at line " + str(i))
i += 1
continue
line = document.body[i]
rx = re.compile(r'\\begin_inset IPADeco (.*)$')
m = rx.match(line)
decotype = m.group(1)
if decotype != "toptiebar" and decotype != "bottomtiebar":
document.warning("Invalid IPADeco type: " + decotype)
i = end
continue
blay = find_token(document.body, "\\begin_layout Plain Layout", i, end)
if blay == -1:
document.warning("Can't find layout for inset at line " + str(i))
i = end
continue
bend = find_end_of_layout(document.body, blay)
if bend == -1:
document.warning("Malformed LyX document: Could not find end of IPADeco inset's layout.")
i = end
continue
substi = ["\\begin_inset ERT", "status collapsed", "",
"\\begin_layout Plain Layout", "", "", "\\backslash",
decotype + "{", "\\end_layout", "", "\\end_inset"]
substj = ["\\size default", "", "\\begin_inset ERT", "status collapsed", "",
"\\begin_layout Plain Layout", "", "}", "\\end_layout", "", "\\end_inset"]
# do the later one first so as not to mess up the numbering
document.body[bend:end + 1] = substj
document.body[i:blay + 1] = substi
i = end + len(substi) + len(substj) - (end - bend) - (blay - i) - 2
add_to_preamble(document, "\\usepackage{tipa}")
def revert_ipachar(document):
' Revert \\IPAChar to ERT '
i = 0
found = False
while i < len(document.body):
m = re.match(r'(.*)\\IPAChar \\(\w+\{\w+\})(.*)', document.body[i])
if m:
found = True
before = m.group(1)
ipachar = m.group(2)
after = m.group(3)
subst = [before,
'\\begin_inset ERT',
'status collapsed', '',
'\\begin_layout Standard',
'', '', '\\backslash',
ipachar,
'\\end_layout', '',
'\\end_inset', '',
after]
document.body[i: i+1] = subst
i = i + len(subst)
else:
i = i + 1
if found:
add_to_preamble(document, "\\usepackage{tone}")
## ##
@ -944,12 +1014,14 @@ convert = [
[434, []], [434, []],
[435, []], [435, []],
[436, []], [436, []],
[437, []] [437, []],
[438, []]
] ]
revert = [ revert = [
[434, [revert_texgyre]], [437, [revert_ipadeco, revert_ipachar]],
[434, [revert_mathdesign]], [436, [revert_texgyre]],
[435, [revert_mathdesign]],
[434, [revert_txtt]], [434, [revert_txtt]],
[433, [revert_libertine]], [433, [revert_libertine]],
[432, [revert_armenian]], [432, [revert_armenian]],

View File

@ -1021,6 +1021,8 @@ ToolbarSet
Item "Voiced alveolo-palatal fricative" "unicode-insert 0x0291" Item "Voiced alveolo-palatal fricative" "unicode-insert 0x0291"
Item "Voiced alveolar lateral flap" "unicode-insert 0x027a" Item "Voiced alveolar lateral flap" "unicode-insert 0x027a"
Item "Simultaneous voiceless postalveolar and velar fricative" "unicode-insert 0x0267" Item "Simultaneous voiceless postalveolar and velar fricative" "unicode-insert 0x0267"
Item "Top tie bar" "ipamacro-insert deco toptiebar"
Item "Bottom tie bar" "ipamacro-insert deco bottomtiebar"
End End
Toolbar "ipa_suprasegmentals" "IPA Suprasegmentals" Toolbar "ipa_suprasegmentals" "IPA Suprasegmentals"
@ -1084,15 +1086,15 @@ ToolbarSet
Item "Downstep" "unicode-insert 0xa71c" Item "Downstep" "unicode-insert 0xa71c"
Item "Upstep" "unicode-insert 0xa71b" Item "Upstep" "unicode-insert 0xa71b"
Item "Rising (accent)" "unicode-insert 0x030c" Item "Rising (accent)" "unicode-insert 0x030c"
# Item "Rising (tone letter)" "" // Not covered by Unicode (def. as a sequence 0x02e9 0x02e5) Item "Rising (tone letter)" "ipamacro-insert tone-rising"
Item "Falling (accent)" "unicode-insert 0x0302" Item "Falling (accent)" "unicode-insert 0x0302"
# Item "Falling (tone letter)" "" // Not covered by Unicode (def. as a sequence 0x02e5 0x02e9) Item "Falling (tone letter)" "ipamacro-insert tone-falling"
Item "High rising (accent)" "unicode-insert 0x1dc4" Item "High rising (accent)" "unicode-insert 0x1dc4"
# Item "High rising (tone letter)" "" // Not covered by Unicode (def. as a sequence 0x02e7 0x02e5) Item "High rising (tone letter)" "ipamacro-insert tone-high-rising"
Item "Low rising (accent)" "unicode-insert 0x1dc5" Item "Low rising (accent)" "unicode-insert 0x1dc5"
# Item "Low rising (tone letter)" "" // Not covered by Unicode (def. as a sequence 0x02e9 0x02e7) Item "Low rising (tone letter)" "ipamacro-insert tone-low-rising"
Item "Rising-falling (accent)" "unicode-insert 0x1dc8" Item "Rising-falling (accent)" "unicode-insert 0x1dc8"
# Item "Rising-falling (tone letter)" "" // Not covered by Unicode (def. as a sequence 0x02e8 0x02e5 0x02e8) Item "Rising-falling (tone letter)" "ipamacro-insert tone-high-rising-falling"
Item "Global rise" "unicode-insert 0x2197" Item "Global rise" "unicode-insert 0x2197"
Item "Global fall" "unicode-insert 0x2198" Item "Global fall" "unicode-insert 0x2198"
End End

View File

@ -454,6 +454,8 @@ enum FuncCode
LFUN_IPA_INSERT, // spitz, 20120305 LFUN_IPA_INSERT, // spitz, 20120305
LFUN_BUFFER_FORALL, // scottkostyshak, 20120720 LFUN_BUFFER_FORALL, // scottkostyshak, 20120720
LFUN_IN_IPA, // spitz, 20120520 LFUN_IN_IPA, // spitz, 20120520
LFUN_IPAMACRO_INSERT, // spitz, 20120822
// 355
LFUN_LASTACTION // end of the table LFUN_LASTACTION // end of the table
}; };

View File

@ -561,7 +561,16 @@ void LyXAction::init()
* \endvar * \endvar
*/ */
{ LFUN_IN_IPA, "in-ipa", Noop, Edit }, { LFUN_IN_IPA, "in-ipa", Noop, Edit },
/*!
* \var lyx::FuncCode lyx::LFUN_IPAMACRO_INSERT
* \li Action: Inserts special IPA characters into the document.
* \li Syntax: ipamacro-insert <CHAR>
* \li Params: <CHAR>: tone-falling, tone-rising, tone-high-rising, tone-low-rising,
* tone-high-rising-falling.
* \li Origin: JSpitzm, 22 Aug 2012
* \endvar
*/
{ LFUN_IPAMACRO_INSERT, "ipamacro-insert", Noop, Edit },
/*! /*!
* \var lyx::FuncCode lyx::LFUN_NOMENCL_INSERT * \var lyx::FuncCode lyx::LFUN_NOMENCL_INSERT
* \li Action: Inserts Nomenclature entry. * \li Action: Inserts Nomenclature entry.

View File

@ -562,6 +562,7 @@ SOURCEFILESINSETS = \
insets/InsetIndex.cpp \ insets/InsetIndex.cpp \
insets/InsetInfo.cpp \ insets/InsetInfo.cpp \
insets/InsetIPA.cpp \ insets/InsetIPA.cpp \
insets/InsetIPAMacro.cpp \
insets/InsetLabel.cpp \ insets/InsetLabel.cpp \
insets/InsetLayout.cpp \ insets/InsetLayout.cpp \
insets/InsetLine.cpp \ insets/InsetLine.cpp \
@ -619,6 +620,7 @@ HEADERFILESINSETS = \
insets/InsetIndex.h \ insets/InsetIndex.h \
insets/InsetInfo.h \ insets/InsetInfo.h \
insets/InsetIPA.h \ insets/InsetIPA.h \
insets/InsetIPAMacro.h \
insets/InsetPreview.h \ insets/InsetPreview.h \
insets/InsetLabel.h \ insets/InsetLabel.h \
insets/InsetLayout.h \ insets/InsetLayout.h \

View File

@ -55,6 +55,7 @@
#include "insets/InsetNewline.h" #include "insets/InsetNewline.h"
#include "insets/InsetNewpage.h" #include "insets/InsetNewpage.h"
#include "insets/InsetArgument.h" #include "insets/InsetArgument.h"
#include "insets/InsetIPAMacro.h"
#include "insets/InsetSpace.h" #include "insets/InsetSpace.h"
#include "insets/InsetSpecialChar.h" #include "insets/InsetSpecialChar.h"
#include "insets/InsetTabular.h" #include "insets/InsetTabular.h"
@ -479,6 +480,12 @@ void Text::readParToken(Paragraph & par, Lexer & lex,
inset->read(lex); inset->read(lex);
inset->setBuffer(*buf); inset->setBuffer(*buf);
par.insertInset(par.size(), inset.release(), font, change); par.insertInset(par.size(), inset.release(), font, change);
} else if (token == "\\IPAChar") {
auto_ptr<Inset> inset;
inset.reset(new InsetIPAChar);
inset->read(lex);
inset->setBuffer(*buf);
par.insertInset(par.size(), inset.release(), font, change);
} else if (token == "\\backslash") { } else if (token == "\\backslash") {
par.appendChar('\\', font, change); par.appendChar('\\', font, change);
} else if (token == "\\LyXTable") { } else if (token == "\\LyXTable") {

View File

@ -58,6 +58,7 @@
#include "insets/InsetFloatList.h" #include "insets/InsetFloatList.h"
#include "insets/InsetGraphics.h" #include "insets/InsetGraphics.h"
#include "insets/InsetGraphicsParams.h" #include "insets/InsetGraphicsParams.h"
#include "insets/InsetIPAMacro.h"
#include "insets/InsetNewline.h" #include "insets/InsetNewline.h"
#include "insets/InsetQuotes.h" #include "insets/InsetQuotes.h"
#include "insets/InsetSpecialChar.h" #include "insets/InsetSpecialChar.h"
@ -227,6 +228,15 @@ static void specialChar(Cursor & cur, InsetSpecialChar::Kind kind)
} }
static void ipaChar(Cursor & cur, InsetIPAChar::Kind kind)
{
cur.recordUndo();
cap::replaceSelection(cur);
cur.insert(new InsetIPAChar(kind));
cur.posForward();
}
static bool doInsertInset(Cursor & cur, Text * text, static bool doInsertInset(Cursor & cur, Text * text,
FuncRequest const & cmd, bool edit, bool pastesel) FuncRequest const & cmd, bool edit, bool pastesel)
{ {
@ -1174,6 +1184,35 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
break; break;
} }
case LFUN_IPAMACRO_INSERT: {
string const arg = cmd.getArg(0);
if (arg == "deco") {
// Open the inset, and move the current selection
// inside it.
doInsertInset(cur, this, cmd, true, true);
cur.posForward();
// Some insets are numbered, others are shown in the outline pane so
// let's update the labels and the toc backend.
cur.forceBufferUpdate();
break;
}
if (arg == "tone-falling")
ipaChar(cur, InsetIPAChar::TONE_FALLING);
else if (arg == "tone-rising")
ipaChar(cur, InsetIPAChar::TONE_RISING);
else if (arg == "tone-high-rising")
ipaChar(cur, InsetIPAChar::TONE_HIGH_RISING);
else if (arg == "tone-low-rising")
ipaChar(cur, InsetIPAChar::TONE_LOW_RISING);
else if (arg == "tone-high-rising-falling")
ipaChar(cur, InsetIPAChar::TONE_HIGH_RISING_FALLING);
else if (arg.empty())
lyxerr << "LyX function 'ipamacro-insert' needs an argument." << endl;
else
lyxerr << "Wrong argument for LyX function 'ipamacro-insert'." << endl;
break;
}
case LFUN_WORD_UPCASE: case LFUN_WORD_UPCASE:
changeCase(cur, text_uppercase); changeCase(cur, text_uppercase);
break; break;
@ -2497,6 +2536,14 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
} }
code = HYPERLINK_CODE; code = HYPERLINK_CODE;
break; break;
case LFUN_IPAMACRO_INSERT: {
string const arg = cmd.getArg(0);
if (arg == "deco")
code = IPADECO_CODE;
else
code = IPACHAR_CODE;
break;
}
case LFUN_QUOTE_INSERT: case LFUN_QUOTE_INSERT:
// always allow this, since we will inset a raw quote // always allow this, since we will inset a raw quote
// if an inset is not allowed. // if an inset is not allowed.

View File

@ -39,6 +39,7 @@
#include "insets/InsetIndex.h" #include "insets/InsetIndex.h"
#include "insets/InsetInfo.h" #include "insets/InsetInfo.h"
#include "insets/InsetIPA.h" #include "insets/InsetIPA.h"
#include "insets/InsetIPAMacro.h"
#include "insets/InsetLabel.h" #include "insets/InsetLabel.h"
#include "insets/InsetLine.h" #include "insets/InsetLine.h"
#include "insets/InsetMarginal.h" #include "insets/InsetMarginal.h"
@ -131,6 +132,16 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd)
return new InsetPhantom(buf, arg); return new InsetPhantom(buf, arg);
} }
case LFUN_IPAMACRO_INSERT: {
string const arg1 = cmd.getArg(0);
string const arg2 = cmd.getArg(1);
if (arg1 != "deco") {
LYXERR0("LFUN_IPAMACRO_INSERT: wrong argument");
return 0;
}
return new InsetIPADeco(buf, arg2);
}
case LFUN_ERT_INSERT: case LFUN_ERT_INSERT:
return new InsetERT(buf); return new InsetERT(buf);
@ -621,6 +632,8 @@ Inset * readInset(Lexer & lex, Buffer * buf)
inset.reset(new InsetInfo(buf)); inset.reset(new InsetInfo(buf));
} else if (tmptok == "IPA") { } else if (tmptok == "IPA") {
inset.reset(new InsetIPA(buf)); inset.reset(new InsetIPA(buf));
} else if (tmptok == "IPADeco") {
inset.reset(new InsetIPADeco(buf, tmptok));
} else if (tmptok == "Preview") { } else if (tmptok == "Preview") {
inset.reset(new InsetPreview(buf)); inset.reset(new InsetPreview(buf));
} else { } else {

View File

@ -94,6 +94,9 @@ static void build_translator()
insetnames[FLOAT_CODE] = InsetName("float", _("Float")); insetnames[FLOAT_CODE] = InsetName("float", _("Float"));
insetnames[WRAP_CODE] = InsetName("wrap"); insetnames[WRAP_CODE] = InsetName("wrap");
insetnames[SPECIALCHAR_CODE] = InsetName("specialchar"); insetnames[SPECIALCHAR_CODE] = InsetName("specialchar");
insetnames[IPA_CODE] = InsetName("ipa");
insetnames[IPACHAR_CODE] = InsetName("ipachar");
insetnames[IPADECO_CODE] = InsetName("ipadeco");
insetnames[TABULAR_CODE] = InsetName("tabular", _("Table")); insetnames[TABULAR_CODE] = InsetName("tabular", _("Table"));
insetnames[EXTERNAL_CODE] = InsetName("external"); insetnames[EXTERNAL_CODE] = InsetName("external");
insetnames[CAPTION_CODE] = InsetName("caption"); insetnames[CAPTION_CODE] = InsetName("caption");

View File

@ -233,6 +233,10 @@ enum InsetCode {
/// ///
IPA_CODE, IPA_CODE,
/// ///
IPACHAR_CODE,
///
IPADECO_CODE,
///
INSET_CODE_SIZE INSET_CODE_SIZE
}; };

View File

@ -207,10 +207,10 @@ bool InsetIPA::notifyCursorLeaves(Cursor const & old, Cursor & cur)
void InsetIPA::validate(LaTeXFeatures & features) const void InsetIPA::validate(LaTeXFeatures & features) const
{ {
if (buffer_->params().useNonTeXFonts) if (!buffer_->params().useNonTeXFonts) {
return; features.require("tipa");
features.require("tipa"); features.require("tipx");
features.require("tipx"); }
InsetText::validate(features); InsetText::validate(features);
} }
@ -239,6 +239,8 @@ bool InsetIPA::insetAllowed(InsetCode code) const
switch (code) { switch (code) {
// code that is allowed // code that is allowed
case ERT_CODE: case ERT_CODE:
case IPACHAR_CODE:
case IPADECO_CODE:
case SCRIPT_CODE: case SCRIPT_CODE:
return true; return true;
default: default:

View File

@ -0,0 +1,614 @@
/**
* \file InsetIPAMacro.cpp
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Jürgen Spitzmüller
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "InsetIPAMacro.h"
#include "Buffer.h"
#include "BufferParams.h"
#include "Dimension.h"
#include "Encoding.h"
#include "Font.h"
#include "FuncRequest.h"
#include "FuncStatus.h"
#include "LaTeXFeatures.h"
#include "Lexer.h"
#include "MetricsInfo.h"
#include "output_xhtml.h"
#include "frontends/FontMetrics.h"
#include "frontends/Painter.h"
#include "support/debug.h"
#include "support/docstream.h"
#include "support/gettext.h"
#include "support/Translator.h"
using namespace std;
namespace lyx {
namespace {
typedef Translator<string, InsetIPADecoParams::Type> IPADecoTranslator;
typedef Translator<docstring, InsetIPADecoParams::Type> IPADecoTranslatorLoc;
IPADecoTranslator const init_ipadecotranslator()
{
IPADecoTranslator translator("toptiebar", InsetIPADecoParams::Toptiebar);
translator.addPair("bottomtiebar", InsetIPADecoParams::Bottomtiebar);
return translator;
}
IPADecoTranslatorLoc const init_ipadecotranslator_loc()
{
IPADecoTranslatorLoc translator(_("Top tie bar"), InsetIPADecoParams::Toptiebar);
translator.addPair(_("Bottom tie bar"), InsetIPADecoParams::Bottomtiebar);
return translator;
}
IPADecoTranslator const & ipadecotranslator()
{
static IPADecoTranslator decotranslator = init_ipadecotranslator();
return decotranslator;
}
IPADecoTranslatorLoc const & ipadecotranslator_loc()
{
static IPADecoTranslatorLoc translator = init_ipadecotranslator_loc();
return translator;
}
typedef Translator<string, InsetIPAChar::Kind> IPACharTranslator;
IPACharTranslator const init_ipachartranslator()
{
IPACharTranslator translator("\\tone{51}", InsetIPAChar::TONE_FALLING);
translator.addPair("\\tone{15}", InsetIPAChar::TONE_RISING);
translator.addPair("\\tone{45}", InsetIPAChar::TONE_HIGH_RISING);
translator.addPair("\\tone{12}", InsetIPAChar::TONE_LOW_RISING);
translator.addPair("\\tone{454}", InsetIPAChar::TONE_HIGH_RISING_FALLING);
return translator;
}
IPACharTranslator const & ipachartranslator()
{
static IPACharTranslator chartranslator = init_ipachartranslator();
return chartranslator;
}
} // anon
InsetIPADecoParams::InsetIPADecoParams()
: type(Bottomtiebar)
{}
void InsetIPADecoParams::write(ostream & os) const
{
string const label = ipadecotranslator().find(type);
os << "IPADeco " << label << "\n";
}
void InsetIPADecoParams::read(Lexer & lex)
{
string label;
lex >> label;
if (lex)
type = ipadecotranslator().find(label);
}
/////////////////////////////////////////////////////////////////////
//
// InsetIPADeco
//
/////////////////////////////////////////////////////////////////////
InsetIPADeco::InsetIPADeco(Buffer * buf, string const & label)
: InsetCollapsable(buf)
{
setDrawFrame(true);
setFrameColor(Color_insetframe);
params_.type = ipadecotranslator().find(label);
}
InsetIPADeco::~InsetIPADeco()
{}
docstring InsetIPADeco::layoutName() const
{
return from_ascii("IPADeco:" + ipadecotranslator().find(params_.type));
}
void InsetIPADeco::metrics(MetricsInfo & mi, Dimension & dim) const
{
InsetText::metrics(mi, dim);
if (params_.type == InsetIPADecoParams::Toptiebar) {
// consider width of the inset label
FontInfo font(getLayout().labelfont());
font.realize(sane_font);
font.decSize();
font.decSize();
int w = 0;
int a = 0;
int d = 0;
docstring const label(1, char_type(0x2040));
theFontMetrics(font).rectText(label, w, a, d);
dim.asc += a * 0.5;
}
if (params_.type == InsetIPADecoParams::Bottomtiebar) {
// consider width of the inset label
FontInfo font(getLayout().labelfont());
font.realize(sane_font);
font.decSize();
font.decSize();
int w = 0;
int a = 0;
int d = 0;
docstring const label(1, char_type(0x203f));
theFontMetrics(font).rectText(label, w, a, d);
dim.des += d * 1.5;
}
// cache the inset dimension
setDimCache(mi, dim);
}
void InsetIPADeco::draw(PainterInfo & pi, int x, int y) const
{
// draw the text
InsetCollapsable::draw(pi, x, y);
// draw the inset marker
drawMarkers(pi, x, y);
Dimension const dim = Inset::dimension(*pi.base.bv);
if (params_.type == InsetIPADecoParams::Toptiebar) {
FontInfo font(getLayout().labelfont());
font.realize(sane_font);
font.decSize();
font.decSize();
int w = 0;
int a = 0;
int d = 0;
int asc = dim.ascent();
docstring const label(1, char_type(0x2040));
theFontMetrics(font).rectText(label, w, a, d);
int const ww = max(dim.wid, w);
pi.pain.rectText(x + (ww - w) / 2, y - (asc / 2.5),
label, font, Color_none, Color_none);
}
if (params_.type == InsetIPADecoParams::Bottomtiebar) {
FontInfo font(getLayout().labelfont());
font.realize(sane_font);
font.decSize();
font.decSize();
int w = 0;
int a = 0;
int d = 0;
int desc = dim.descent();
docstring const label(1, char_type(0x203f));
theFontMetrics(font).rectText(label, w, a, d);
int const ww = max(dim.wid, w);
pi.pain.rectText(x + (ww - w) / 2, y + (desc / 1.5),
label, font, Color_none, Color_none);
}
}
void InsetIPADeco::write(ostream & os) const
{
params_.write(os);
InsetCollapsable::write(os);
}
void InsetIPADeco::read(Lexer & lex)
{
params_.read(lex);
InsetCollapsable::read(lex);
}
void InsetIPADeco::doDispatch(Cursor & cur, FuncRequest & cmd)
{
switch (cmd.action()) {
case LFUN_QUOTE_INSERT: {
FuncRequest fr(LFUN_SELF_INSERT, "\"");
InsetText::doDispatch(cur, fr);
break;
}
default:
InsetText::doDispatch(cur, cmd);
break;
}
}
bool InsetIPADeco::getStatus(Cursor & cur, FuncRequest const & cmd,
FuncStatus & flag) const
{
switch (cmd.action()) {
case LFUN_SCRIPT_INSERT: {
if (cmd.argument() == "subscript") {
flag.setEnabled(false);
return true;
}
break;
}
case LFUN_IN_IPA:
flag.setEnabled(true);
return true;
break;
default:
break;
}
return InsetText::getStatus(cur, cmd, flag);
}
void InsetIPADeco::latex(otexstream & os, OutputParams const & runparams) const
{
if (params_.type == InsetIPADecoParams::Toptiebar)
os << "\\texttoptiebar{";
else if (params_.type == InsetIPADecoParams::Bottomtiebar)
os << "\\textbottomtiebar{";
InsetCollapsable::latex(os, runparams);
os << "}";
}
int InsetIPADeco::plaintext(odocstream & os,
OutputParams const & runparams) const
{
// FIXME: Any plaintext option here?
return InsetCollapsable::plaintext(os, runparams);
}
int InsetIPADeco::docbook(odocstream & os, OutputParams const & runparams) const
{
// FIXME: Any docbook option here?
return InsetCollapsable::docbook(os, runparams);
}
docstring InsetIPADeco::xhtml(XHTMLStream & xs, OutputParams const & runparams) const
{
// FIXME: Any xhtml option here?
return InsetCollapsable::xhtml(xs, runparams);
}
docstring InsetIPADeco::toolTip(BufferView const &, int, int) const
{
return ipadecotranslator_loc().find(params_.type);
}
string InsetIPADeco::params2string(InsetIPADecoParams const & params)
{
ostringstream data;
data << "IPADeco" << ' ';
params.write(data);
return data.str();
}
void InsetIPADeco::string2params(string const & in, InsetIPADecoParams & params)
{
params = InsetIPADecoParams();
if (in.empty())
return;
istringstream data(in);
Lexer lex;
lex.setStream(data);
lex.setContext("InsetIPADeco::string2params");
lex >> "IPADeco" >> "toptiebar";
params.read(lex);
}
void InsetIPADeco::validate(LaTeXFeatures & features) const
{
if (!buffer_->params().useNonTeXFonts)
features.require("tipa");
InsetText::validate(features);
}
bool InsetIPADeco::insetAllowed(InsetCode code) const
{
switch (code) {
// code that is allowed
case ERT_CODE:
case IPACHAR_CODE:
case SCRIPT_CODE:
return true;
default:
return false;
}
}
/////////////////////////////////////////////////////////////////////////
//
// InsetIPAChar
//
/////////////////////////////////////////////////////////////////////////
InsetIPAChar::InsetIPAChar(Kind k)
: Inset(0), kind_(k)
{}
InsetIPAChar::Kind InsetIPAChar::kind() const
{
return kind_;
}
void InsetIPAChar::metrics(MetricsInfo & mi, Dimension & dim) const
{
frontend::FontMetrics const & fm =
theFontMetrics(mi.base.font);
dim.asc = fm.maxAscent();
dim.des = fm.maxDescent();
string s;
switch (kind_) {
case TONE_FALLING:
case TONE_RISING:
case TONE_HIGH_RISING:
case TONE_LOW_RISING:
case TONE_HIGH_RISING_FALLING:
s = "_";
break;
}
docstring ds(s.begin(), s.end());
dim.wid = fm.width(ds);
setDimCache(mi, dim);
}
void InsetIPAChar::draw(PainterInfo & pi, int x, int y) const
{
FontInfo font = pi.base.font;
frontend::FontMetrics const & fm =
theFontMetrics(font);
switch (kind_) {
case TONE_FALLING:
{
int w = fm.width(char_type('-'));
int h = fm.ascent(char_type('M'));
int x2 = x + w;
int y2 = y - h;
pi.pain.line(x2, y2, x2, y, Color_foreground);
pi.pain.line(x2, y, x, y2, Color_foreground);
break;
}
case TONE_RISING:
{
int w = fm.width(char_type('-'));
int h = fm.ascent(char_type('M'));
int x2 = x + w;
int y2 = y - h;
pi.pain.line(x2, y, x2, y2, Color_foreground);
pi.pain.line(x2, y2, x, y, Color_foreground);
break;
}
case TONE_HIGH_RISING:
{
int w = fm.width(char_type('-'));
int h = fm.ascent(char_type('M'));
int x2 = x + w;
int y2 = y - h;
int y3 = y - (h * 0.75);
pi.pain.line(x2, y, x2, y2, Color_foreground);
pi.pain.line(x2, y2, x, y3, Color_foreground);
break;
}
case TONE_LOW_RISING:
{
int w = fm.width(char_type('-'));
int h = fm.ascent(char_type('M'));
int x2 = x + w;
int y2 = y - h;
int y3 = y - (h * 0.25);
pi.pain.line(x2, y, x2, y2, Color_foreground);
pi.pain.line(x2, y3, x, y, Color_foreground);
break;
}
case TONE_HIGH_RISING_FALLING:
{
int w = fm.width(char_type('-'));
int h = fm.ascent(char_type('M'));
int x2 = x + w;
int y2 = y - h;
int x3 = x + (w * 0.5);
int y3 = y - (h * 0.75);
pi.pain.line(x2, y, x2, y2, Color_foreground);
pi.pain.line(x2, y3, x3, y2, Color_foreground);
pi.pain.line(x3, y2, x, y3, Color_foreground);
break;
}
}
}
void InsetIPAChar::write(ostream & os) const
{
string const command = ipachartranslator().find(kind_);
if (command.empty()) {
LYXERR0("InsetIPAChar::write: Unknown type");
return;
}
os << "\\IPAChar " << command << "\n";
}
void InsetIPAChar::read(Lexer & lex)
{
lex.next();
string const command = lex.getString();
kind_ = ipachartranslator().find(command);
}
void InsetIPAChar::latex(otexstream & os,
OutputParams const &) const
{
string const command = ipachartranslator().find(kind_);
os << command;
}
int InsetIPAChar::plaintext(odocstream & os, OutputParams const &) const
{
switch (kind_) {
case TONE_FALLING:
os.put(0x02e5);
os.put(0x02e9);
return 2;
case TONE_RISING:
os.put(0x02e9);
os.put(0x02e5);
return 2;
case TONE_HIGH_RISING:
os.put(0x02e7);
os.put(0x02e5);
return 2;
case TONE_LOW_RISING:
os.put(0x02e9);
os.put(0x02e7);
return 2;
case TONE_HIGH_RISING_FALLING:
os.put(0x02e8);
os.put(0x02e5);
os.put(0x02e8);
return 3;
}
return 0;
}
int InsetIPAChar::docbook(odocstream & /*os*/, OutputParams const &) const
{
switch (kind_) {
// FIXME
case TONE_FALLING:
case TONE_RISING:
case TONE_HIGH_RISING:
case TONE_LOW_RISING:
case TONE_HIGH_RISING_FALLING:
break;
}
return 0;
}
docstring InsetIPAChar::xhtml(XHTMLStream & xs, OutputParams const &) const
{
switch (kind_) {
case TONE_FALLING:
xs << XHTMLStream::ESCAPE_NONE << "&#x2e5;"
<< XHTMLStream::ESCAPE_NONE << "&#x2e9;";
break;
case TONE_RISING:
xs << XHTMLStream::ESCAPE_NONE << "&#x2e9;"
<< XHTMLStream::ESCAPE_NONE << "&#x2e5;";
break;
case TONE_HIGH_RISING:
xs << XHTMLStream::ESCAPE_NONE << "&#x2e7;"
<< XHTMLStream::ESCAPE_NONE << "&#x2e5;";
break;
case TONE_LOW_RISING:
xs << XHTMLStream::ESCAPE_NONE << "&#x2e9;"
<< XHTMLStream::ESCAPE_NONE << "&#x2e7;";
break;
case TONE_HIGH_RISING_FALLING:
xs << XHTMLStream::ESCAPE_NONE << "&#x2e8;"
<< XHTMLStream::ESCAPE_NONE << "&#x2e5;"
<< XHTMLStream::ESCAPE_NONE << "&#x2e8;";
break;
}
return docstring();
}
void InsetIPAChar::toString(odocstream & os) const
{
plaintext(os, OutputParams(0));
}
void InsetIPAChar::forToc(docstring & os, size_t) const
{
odocstringstream ods;
plaintext(ods, OutputParams(0));
os += ods.str();
}
void InsetIPAChar::validate(LaTeXFeatures & features) const
{
switch (kind_) {
case TONE_FALLING:
case TONE_RISING:
case TONE_HIGH_RISING:
case TONE_LOW_RISING:
case TONE_HIGH_RISING_FALLING:
if (!buffer_->params().useNonTeXFonts)
features.require("tone");
break;
default:
break;
}
}
bool InsetIPAChar::isLetter() const
{
return true;
}
bool InsetIPAChar::isLineSeparator() const
{
return false;
}
} // namespace lyx

181
src/insets/InsetIPAMacro.h Normal file
View File

@ -0,0 +1,181 @@
// -*- C++ -*-
/**
* \file InsetIPAMacro.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Jürgen Spitzmüller
*
* Full author contact details are available in file CREDITS.
*/
#ifndef INSET_IPAMACRO_H
#define INSET_IPAMACRO_H
#include "Inset.h"
#include "InsetCollapsable.h"
namespace lyx {
class LaTeXFeatures;
class InsetIPADecoParams
{
public:
enum Type {
Toptiebar,
Bottomtiebar
};
///
InsetIPADecoParams();
///
void write(std::ostream & os) const;
///
void read(Lexer & lex);
///
Type type;
};
/////////////////////////////////////////////////////////////////////////
//
// InsetIPADeco
//
/////////////////////////////////////////////////////////////////////////
/// Used to insert IPA decorations
class InsetIPADeco : public InsetCollapsable
{
public:
///
InsetIPADeco(Buffer *, std::string const &);
///
~InsetIPADeco();
///
static std::string params2string(InsetIPADecoParams const &);
///
static void string2params(std::string const &, InsetIPADecoParams &);
///
InsetIPADecoParams const & params() const { return params_; }
private:
///
InsetCode lyxCode() const { return IPADECO_CODE; }
///
docstring layoutName() const;
///
void metrics(MetricsInfo &, Dimension &) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///
void write(std::ostream &) const;
///
void read(Lexer & lex);
///
bool neverIndent() const { return true; }
///
void latex(otexstream &, OutputParams const &) const;
///
int plaintext(odocstream &, OutputParams const &) const;
///
int docbook(odocstream &, OutputParams const &) const;
///
docstring xhtml(XHTMLStream &, OutputParams const &) const;
///
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
///
void doDispatch(Cursor & cur, FuncRequest & cmd);
///
void validate(LaTeXFeatures & features) const;
///
bool allowSpellCheck() const { return false; }
///
bool insetAllowed(InsetCode code) const;
///
docstring toolTip(BufferView const & bv, int x, int y) const;
///
Inset * clone() const { return new InsetIPADeco(*this); }
/// used by the constructors
void init();
///
friend class InsetIPADecoParams;
///
InsetIPADecoParams params_;
};
/////////////////////////////////////////////////////////////////////////
//
// InsetIPAChar
//
/////////////////////////////////////////////////////////////////////////
/// Used to insert special IPA chars that are not available in unicode
class InsetIPAChar : public Inset {
public:
/// The different kinds of special chars we support
enum Kind {
/// falling tone mark
TONE_FALLING,
/// rising tone mark
TONE_RISING,
/// high-rising tone mark
TONE_HIGH_RISING,
/// low-rising tone mark
TONE_LOW_RISING,
/// high rising-falling tone mark
TONE_HIGH_RISING_FALLING
};
///
InsetIPAChar() : Inset(0) {}
///
explicit InsetIPAChar(Kind k);
///
Kind kind() const;
///
void metrics(MetricsInfo &, Dimension &) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///
void write(std::ostream &) const;
/// Will not be used when lyxf3
void read(Lexer & lex);
///
void latex(otexstream &, OutputParams const &) const;
///
int plaintext(odocstream &, OutputParams const &) const;
///
int docbook(odocstream &, OutputParams const &) const;
///
docstring xhtml(XHTMLStream &, OutputParams const &) const;
///
void toString(odocstream &) const;
///
void forToc(docstring &, size_t) const;
///
InsetCode lyxCode() const { return IPACHAR_CODE; }
/// We don't need \begin_inset and \end_inset
bool directWrite() const { return true; }
///
void validate(LaTeXFeatures &) const;
/// should this inset be handled like a normal character?
bool isChar() const { return true; }
/// is this equivalent to a letter?
bool isLetter() const;
/// should we break lines after this inset?
bool isLineSeparator() const;
private:
Inset * clone() const { return new InsetIPAChar(*this); };
/// And which kind is this?
Kind kind_;
};
} // namespace lyx
#endif

View File

@ -30,8 +30,8 @@ extern char const * const lyx_version_info;
// Do not remove the comment below, so we get merge conflict in // Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own. // independent branches. Instead add your own.
#define LYX_FORMAT_LYX 437 // spitz: support for the TeXGyre fonts #define LYX_FORMAT_LYX 438 // spitz: support IPA macros
#define LYX_FORMAT_TEX2LYX 437 // spitz: support for the TeXGyre fonts #define LYX_FORMAT_TEX2LYX 438 // spitz: support for IPA macros
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER #ifndef _MSC_VER