Fix non-translated days of the week (#1455).
[dcpomatic.git] / src / lib / util.cc
index a1ea8f9f16c645436fc830cc9ada4e75c48bf4bb..0ad575b5599672d05e4b1c6b58746db9cf1bfb95 100644 (file)
@@ -358,6 +358,11 @@ dcpomatic_setup ()
 
        set_terminate (terminate);
 
+#ifdef DCPOMATIC_WINDOWS
+       putenv ("PANGOCAIRO_BACKEND=fontconfig");
+       putenv (String::compose("FONTCONFIG_PATH=%1", shared_path().string()).c_str());
+#endif
+
        Pango::init ();
        dcp::init ();
 
@@ -815,6 +820,48 @@ checked_fread (void* ptr, size_t size, FILE* stream, boost::filesystem::path pat
        }
 }
 
+size_t
+utf8_strlen (string s)
+{
+       size_t const len = s.length ();
+       int N = 0;
+       for (size_t i = 0; i < len; ++i) {
+               unsigned char c = s[i];
+               if ((c & 0xe0) == 0xc0) {
+                       ++i;
+               } else if ((c & 0xf0) == 0xe0) {
+                       i += 2;
+               } else if ((c & 0xf8) == 0xf0) {
+                       i += 3;
+               }
+               ++N;
+       }
+       return N;
+}
+
+string
+day_of_week_to_string (boost::gregorian::greg_weekday d)
+{
+       switch (d.as_enum()) {
+       case boost::date_time::Sunday:
+               return _("Sunday");
+       case boost::date_time::Monday:
+               return _("Monday");
+       case boost::date_time::Tuesday:
+               return _("Tuesday");
+       case boost::date_time::Wednesday:
+               return _("Wednesday");
+       case boost::date_time::Thursday:
+               return _("Thursday");
+       case boost::date_time::Friday:
+               return _("Friday");
+       case boost::date_time::Saturday:
+               return _("Saturday");
+       }
+
+       return d.as_long_string ();
+}
+
 #ifdef DCPOMATIC_VARIANT_SWAROOP
 
 /* Make up a key from the machine UUID */
@@ -888,8 +935,6 @@ read_swaroop_chain (boost::filesystem::path path)
 void
 write_swaroop_chain (shared_ptr<const dcp::CertificateChain> chain, boost::filesystem::path output)
 {
-       cout << "write " << output.string() << "\n";
-
        scoped_array<uint8_t> buffer (new uint8_t[65536]);
        Header* header = (Header *) buffer.get();
        memset (header, 0, sizeof(Header));