The branch, master, has been updated.

- Log -----------------------------------------------------------------

commit c713030edbfc09db59358e07711a169a1a65c7a4
Author: Richard Heck <[email protected]>
Date:   Mon May 13 11:58:52 2013 -0400

    Get font families working for XHTML.

diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index d3dc2d8..afdf203 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -2865,6 +2865,8 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & 
buf,
        bool wave_flag = false;
        // shape tags
        bool shap_flag = false;
+       // family tags
+       bool faml_flag = false;
 
        Layout const & style = *d->layout_;
 
@@ -2874,6 +2876,10 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & 
buf,
                style.labeltype == LABEL_MANUAL ? style.labelfont : style.font;
 
        FontShape curr_fs = INHERIT_SHAPE;
+       FontFamily curr_fam = INHERIT_FAMILY;
+       
+       string const default_family = 
+               buf.masterBuffer()->params().fonts_default_family;              
 
        vector<html::FontTag> tagsToOpen;
        vector<html::EndFontTag> tagsToClose;
@@ -2949,12 +2955,15 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & 
buf,
                        switch (curr_fs) {
                        case ITALIC_SHAPE:
                                
tagsToOpen.push_back(html::FontTag(html::FT_ITALIC));
+                               shap_flag = true;
                                break;
                        case SLANTED_SHAPE:
                                
tagsToOpen.push_back(html::FontTag(html::FT_SLANTED));
+                               shap_flag = true;
                                break;
                        case SMALLCAPS_SHAPE:
                                
tagsToOpen.push_back(html::FontTag(html::FT_SMALLCAPS));
+                               shap_flag = true;
                                break;
                        case UP_SHAPE:
                        case INHERIT_SHAPE:
@@ -2964,7 +2973,59 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & 
buf,
                                LATTEST(false);
                                break;
                        }
-                       shap_flag = true;
+               }
+
+               curr_fam = font.fontInfo().family();
+               FontFamily old_fam = font_old.family();
+               if (old_fam != curr_fam) {
+                       if (faml_flag) {
+                               switch (old_fam) {
+                               case ROMAN_FAMILY:
+                                       
tagsToClose.push_back(html::EndFontTag(html::FT_ROMAN));
+                                       break;
+                               case SANS_FAMILY:
+                                       
tagsToClose.push_back(html::EndFontTag(html::FT_SANS));
+                                       break;
+                               case TYPEWRITER_FAMILY:
+                                       
tagsToClose.push_back(html::EndFontTag(html::FT_TYPE));
+                                       break;
+                               case INHERIT_FAMILY:
+                                       break;
+                               default:
+                                       // the other tags are for internal use
+                                       LATTEST(false);
+                                       break;
+                               }
+                               faml_flag = false;
+                       }
+                       switch (curr_fam) {
+                       case ROMAN_FAMILY:
+                               // we will treat a "default" font family as 
roman, since we have
+                               // no other idea what to do.
+                               if (default_family != "rmdefault" && 
default_family != "default") {
+                                       
tagsToOpen.push_back(html::FontTag(html::FT_ROMAN));
+                                       faml_flag = true;
+                               }
+                               break;
+                       case SANS_FAMILY:
+                               if (default_family != "sfdefault") {
+                                       
tagsToOpen.push_back(html::FontTag(html::FT_SANS));
+                                       faml_flag = true;
+                               }
+                               break;
+                       case TYPEWRITER_FAMILY:
+                               if (default_family != "ttdefault") {
+                                       
tagsToOpen.push_back(html::FontTag(html::FT_TYPE));
+                                       faml_flag = true;
+                               }
+                               break;
+                       case INHERIT_FAMILY:
+                               break;
+                       default:
+                               // the other tags are for internal use
+                               LATTEST(false);
+                               break;
+                       }
                }
 
                // FIXME XHTML
diff --git a/src/output_xhtml.cpp b/src/output_xhtml.cpp
index 82fe373..e6d5366 100644
--- a/src/output_xhtml.cpp
+++ b/src/output_xhtml.cpp
@@ -600,7 +600,8 @@ XHTMLStream & XHTMLStream::operator<<(html::EndTag const & 
etag)
                                // it was pending, so we just erase it
                                writeError("Tried to close pending tag `" + 
etag.tag_ 
                                        + "' when other tags were pending. Last 
pending tag is `"
-                                       + pending_tags_.back()->tag_ + "'. Tag 
discarded.");
+                                       + 
to_utf8(pending_tags_.back()->writeTag()) 
+                                       + "'. Tag discarded.");
                                pending_tags_.erase(dit);
                                return *this;
                        }
@@ -617,7 +618,7 @@ XHTMLStream & XHTMLStream::operator<<(html::EndTag const & 
etag)
                string estr = "Closing tag `" + etag.tag_ 
                        + "' when other tags are pending. Discarded pending 
tags:\n";
                for (dit = pending_tags_.begin(); dit != den; ++dit)
-                       estr += (*dit)->tag_ + "\n";
+                       estr += to_utf8(html::htmlize((*dit)->writeTag(), 
XHTMLStream::ESCAPE_ALL)) + "\n";
                writeError(estr);
                // clear the pending tags...
                pending_tags_.clear();

-----------------------------------------------------------------------

Summary of changes:
 src/Paragraph.cpp    |   63 +++++++++++++++++++++++++++++++++++++++++++++++++-
 src/output_xhtml.cpp |    5 ++-
 2 files changed, 65 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
The LyX Source Repository

Reply via email to