Closed (fixed)
Project:
Typogrify
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
2 Jul 2007 at 21:30 UTC
Updated:
4 Sep 2007 at 03:03 UTC
Allow users the option of adding ligatures.
Why bother?
For situations where you know the browser can handle them and users don't need the find function, they're great.
Should be off by default because:
For more on browser support for ligatures: http://fawny.org/blog/2003/12/#f.u
Comments
Comment #1
fm commentedSimilarly, the option to use the medial s (or long s) would be a very welcome addition.
Comment #2
Tim Gambell commentedI've consulted a few sources (listed below) and this is what I can gather:
Perhaps you can clarify the rules?
http://en.wikipedia.org/wiki/Long_s
http://babelstone.blogspot.com/2006/06/rules-for-long-s.html
http://babelstone.blogspot.com/2006/07/long-and-short-of-letter-s.html
http://www.straightdope.com/classics/a1_110.html
Comment #3
fm commentedThe information you've gathered is definitely on track. In general, long-s is used at the beginning or in the middle of a word; and in general, the short-s is used at the end. There are a few notable exceptions though, as noted in BabelStone's "Rules for Long S" and the orbitals.com URL below.
Rules for long-s in English:
http://www.orbitals.com/self/ligature/ligature.htm
This contains both the rules for long-s and some guildlines for long-s ligatures; however, I doubt the guidelines for long-s ligatures are exhaustive.
Rules for long-s in German:
http://www.typophile.com/node/19025
http://download.linotype.com/free/howtouse/blackletter_e.pdf
I also understand there are rules for use in French, Spanish, Italian, and Polish; though I haven't been able to find any specifics.
I think it may be beneficial to organized the long-s rules to be modular by language, so that a new language may be added as the rules are uncovered. Also, apparently the long-s is easy to implement in English, but fairly difficult in German. Rolling out an English version sooner, and a German version later would make a great deal of sense.
Comment #4
Tim Gambell commentedFor reference:
A ligature hack on php smartypants
http://pages.cs.wisc.edu/~wolfson/ligatures.html
Fancypants implements ligatures in Scheme
http://www.jeroenvandoorn.nl/index.php/2006/12/20/ligatures-in-fonts
Comment #5
Tim Gambell commentedAdded preliminary support for ligatures. Please review code or install and test!
Does it work?
Does it break anything?
Are there any other ligatures you'd like to see? (I'd like to see "Th", but I can't figure out where it is in unicode)
Medial S support coming soon...
Comment #6
Tim Gambell commentedCode is available on CVS now, and should be available from the project page when the packaging script gets around to it, sometime tomorrow (July 10, 2007).
Comment #7
fm commentedI posted a test story with the filter activated and received the following warning:
warning: Invalid argument supplied for foreach() in ****/modules/typogrify/typogrify.module on line 100.
warning: Invalid argument supplied for foreach() in ****/modules/typogrify/typogrify.module on line 108.
warning: Invalid argument supplied for foreach() in ****/modules/typogrify/typogrify.module on line 100.
warning: Invalid argument supplied for foreach() in ****/modules/typogrify/typogrify.module on line 108.
warning: Invalid argument supplied for foreach() in ****/modules/typogrify/typogrify.module on line 100.
warning: Invalid argument supplied for foreach() in ****/modules/typogrify/typogrify.module on line 108.
The smart quotes swap worked. The small caps for unpunctuated initials and for punctuated initials worked. I didn't see any ligatures, but perhaps I will need to change the typeface. I think I'm configured for Veranda currently.
I am thinking it might be nice to toggle these typography features/substitutions on and off in an admin panel.
Comment #8
Tim Gambell commentedFeatures can be configured in an admin panel, it's just really hard to find!
First, go to Admin -> Site Configuration -> Input formats
Then, click on the configure link next to the Input format that Typogrify is a part of.
Then, click on the Configure tab at the top of the admin panel (the options are View, Configure, and Rearrange). (The URL should look like www.yoursite.com/admin/settings/filters/#/configure, where # is the filter number you're editing.)
There you have the option to turn each typogrify filter on or off, and to enable ligatures and arrows (they're off by default!).
Ligature support varies from font to font and browser to browser... good luck!
Comment #9
Tim Gambell commentedThat foreach bug has something to do with the ligature system, but I can't figure out what. Let me poke around my test installation to see if I can figure it out.
Here's a shot in the dark: is the file unicode-conversion.php in the modules/typogrify directory?
Comment #10
fm commentedGah! Sorry, my bad ... the admin panel is exactly where you said it was. I'll poke around with that and resubmit my observations, but the warnings I posted above still seem valid.
The file unicode-conversion.php is in my Typogrify folder.
Comment #11
fm commentedI am still receiving the warnings listed in my post above.
Most ligatures -- ffi, ffl, ff, fi, fl, st, and ss -- seem to work when a selected typeface includes that particular ligature glyph. When the typeface doesn't include the glyph, it retains a ligature glyph from a previously tested typeface.
I could not get the ligature ft to display with any typeface I tested; it displays a hollow box instead. It may mean that ligature glyph doesn't exist in those typefaces, or it could mean that the mod's code is defective. I suspect the former is true as I seem to recall seeing the hollow box on character charts from other sites.
I could not get the arrows to display under any circumstances.
The ampersand is successfully wrapped in a span tag with an accomanying "amp" class. NO showy ampersand in headlines.
Straight quotation marks are successfully converted to curly quotes. Both single and double quotation marks were successfully displayed in curly form and wrapped in span tag with correpsonding "quo"/"dquo" class.
Right-facing and left-facing apostrophes were successfully displayed in curly form.
Multiple hyphen to em/en dash conversion successful.
I have no information on widow management.
Comment #12
fm commentedI should note that I tested the ligatures on the following typefaces, mostly serif but others as well:
Academy Engraved LET
Baskerville
Big Caslon
Blackmoor LET
BlairMdITC
Bodoni Svtytwo ITC
Bordeaux Roman Bold LET
Cochin
Didot
FreeSerif
Georgia
Hoefler Text (particularly useful)
Jazz LET
Mona Lisa Solid ITC
Palatino
Papyrus
Party LET
Savoye LET
Times
Times New Roman
Veranda
Zapfino
Comment #13
Tim Gambell commentedThanks, fm, for your thorough review! Here are my thoughts:
The foreach() Bug
Still hunting... I'll let you know. Can you tell me anything more about it? Do you always get 6 repitions of the error?
Ligatures and Arrows
I'd say this feature isn't broken, but to be on the safe side, I'll leave those features off by default. Here's why:
I think browser support for Ligatures and Arrows is spotty. For example, the ft ligature and arrows all display properly on Safari on the Mac (I think it might be in some version of Caslon -- it looks weird). There may be some subset of ligatures that display in all browsers, and maybe those could be turned on by default?
(In my opinion, it's best to use the ligatures and arrows only in situations where you know a lot about the browser that will be used to access the site. I actually built the feature for use on in-gallery kiosks at my museum -- I know they'll be using Safari and they'll have Adobe Garamond Pro installed!)
(Oh, and there's the search engine friendliness issue -- does google see an fi ligature as exactly the same thing as an ascii fi character pair?)
Amp Wrapping
I think I misrepresented the feature in the project page. I'll fix that! Here's what actually happens:
The module currently wraps all ampersands in the amp class. The style sheet uses the fancy ampersand only within
<h1>-<h6>tags.Unfortunately, Drupal makes it difficult to apply filters to headlines. To get showy ampersands in post titles, you'll need to modify your theme.
Other Typogrify Features
Glad to hear they seem to be working properly! That widow management thing is pretty subtle... you'll notice that you never see one word alone at the end of a paragraph, it'll always be at least two words.
Thanks again for all your help! I'll let you know when I get that medial S thing working.
Comment #14
fm commentedYes, it always seems to be the same 6 repetions in the warning.
fwiw, I'm testing on Mac OSX 10.4.10 with Safari 2.0.4.
I'll see if I can't dig up some other typefaces for the tests, like Caslon and Garamond. This exercise has been informative for me, in that I've discovered when I recently re-installed my OS I forgot to re-install the myriad of fonts I have stockpiled.
Comment #15
Tim Gambell commentedSorry you've become the guinea pig! I can't for the life of me reproduce the bug on my personal machine, but here's another shot at a fix.
I know it has something to do with the arrays of ligatures and arrows passed into the foreach loops() there on lines 100 and 108. So I've added some code that double checks that those arrays are (1) actually arrays and (2) not empty.
The changed code looks like this (this code replaces lines 99 - 113 of typogrify.module):
// Build a list of ligatures to convert
if ((is_array($ligature_map)) && (count($ligature_map) > 0)) {
foreach ($ligature_map as $pair => $ligature) {
$setting = 'typogrify_use_' . $pair . '_ligature_' . $format;
if (variable_get($setting, 0) == 1) {
$characters_to_convert[] = $pair;
}
}
}
// Build a list of arrows to convert
if ((is_array($arrow_map)) && (count($arrow_map) > 0)) {
foreach ($arrow_map as $ascii => $unicode) {
$setting = 'typogrify_use_unicode_for_' . $ascii . '_' . $format;
if (variable_get($setting, 0) == 1) {
$characters_to_convert[] = $ascii;
}
}
}
If you get a chance to test this code, that would be great! (I've removed indenting because it can cause a weird bug when you copy and paste code out of safari and into your text editor.) Let me know how it goes. Fingers crossed!
Comment #16
Tim Gambell commentedI've attempted to fix this by making the array that the foreach is traversing into a global, and by double checking that the arrays are indeed what foreach is expecting them to be. Since I can't reproduce the bug, I can't be sure it's squashed. Let me know if this works.
The new code is available in CVS right now; should be available through the project page when the packaging script gets around to it.
Comment #17
Tim Gambell commentedComment #18
(not verified) commented