[sword-devel] Japanese Ruby Characters

IAN WAGNER iwagn973 at students.bju.edu
Sun Dec 27 14:07:48 MST 2009


I probably should have submitted this information at least 6 months ago, but I have been swamped with school, so I apologize for not posting this sooner. During my work on PocketSword, I patched osishtmlhref.cpp to output proper ruby tags, and wrote some CSS to display it properly in browsers that do not yet support ruby tags (which is pretty much all of them for the moment). Below I have pasted the unified diff and my CSS stylesheet. I hope this is useful to everyone :)


--- /Users/ianthetechie/sword-svn/src/modules/filters/osishtmlhref.cpp	2009-12-27 12:39:38.000000000 -0800
+++ osishtmlhref.cpp	2009-12-27 12:55:37.000000000 -0800
@@ -194,11 +194,17 @@
					outText(val, buf, u);
				}
				if ((attrib = tag.getAttribute("gloss"))) {
+					// I'm sure this is not the cleanest way to do it, but it gets the job done
+					// for rendering ruby chars properly ^_^
+					buf -= lastText.length();
+					
+					outText("<ruby><rb>", buf, u);
+					outText(lastText, buf, u);
					val = strchr(attrib, ':');
					val = (val) ? (val + 1) : attrib;
-					outText("(", buf, u);
+					outText("</rb><rp>(</rp><rt>", buf, u);
					outText(val, buf, u);
-					outText(")", buf, u);
+					outText("</rt><rp>)</rp></ruby>", buf, u);
				}
				if (!morphFirst) {
					processLemma(u->suspendTextPassThru, tag, buf);



ruby
{
display: inline-table;
text-align: center;
white-space: nowrap;
text-indent: 0;
margin: 0;
vertical-align: -10%%;
}

ruby > rb, ruby > rbc
{
display: table-row-group;
line-height: 110%%;
}

ruby > rt, ruby > rbc + rtc
{
display: table-header-group;
valign: top;
font-size: 60%%;
line-height: 40%%;
letter-spacing: 0;
}

ruby > rbc + rtc + rtc
{
display: table-footer-group;
font-size: 60%%;
line-height: 40%%;
letter-spacing: 0;
}

rbc > rb, rtc > rt
{
display: table-cell;
letter-spacing: 0;
}

rtc > rt[rbspan] { display: table-caption; }

rp { display: none; }

Ian
---------------
May the source be with you
http://flynnsarcade.net/




More information about the sword-devel mailing list