Merge "Use Fonts from property system" into new_text
authorPaul Wisbey <p.wisbey@samsung.com>
Mon, 16 Mar 2015 13:26:16 +0000 (06:26 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Mon, 16 Mar 2015 13:26:16 +0000 (06:26 -0700)
13 files changed:
README
build/tizen/configure.ac
build/tizen/dali-toolkit/Makefile.am
dali-toolkit/internal/file.list
dali-toolkit/internal/text/multi-language-support-impl.cpp
dali-toolkit/internal/text/text-controller.cpp
dali-toolkit/internal/text/text-controller.h
dali-toolkit/internal/text/text-io.cpp [new file with mode: 0644]
dali-toolkit/internal/text/text-io.h [new file with mode: 0644]
dali-toolkit/styles/mobile/tizen-dark-theme.json [new file with mode: 0644]
dali-toolkit/styles/mobile/tizen-default-theme.json [new symlink]
dali-toolkit/styles/tizen-dark-theme.json
packaging/dali-toolkit-mobile.spec [new file with mode: 0644]

diff --git a/README b/README
index dc7b5af..de9499c 100644 (file)
--- a/README
+++ b/README
@@ -23,7 +23,10 @@ T.O.C.
 
  gbs build -A [TARGET_ARCH] --define "%enable_dali_smack_rules 1"
 
+1.3. MOBILE Profile
+-------------------
 
+ gbs build -A [TARGET_ARCH] --spec dali-toolkit-mobile.spec
 
 2. Building for Ubuntu desktop
 ==============================
index 1d45d73..ee0034e 100644 (file)
@@ -85,6 +85,10 @@ else
   dataReadOnlyDir=${prefix}/share/dali/
 fi
 
+DALI_TOOLKIT_CFLAGS="$DALI_TOOLKIT_CFLAGS -DDALI_PROFILE_${enable_profile}"
+AM_CONDITIONAL([COMMON_PROFILE], [test x$enable_profile = xCOMMON])
+AM_CONDITIONAL([MOBILE_PROFILE], [test x$enable_profile = xMOBILE])
+
 AC_SUBST(dataReadWriteDir)
 AC_SUBST(dataReadOnlyDir)
 AC_SUBST(DALI_TOOLKIT_CFLAGS)
index ff48b23..18ed54d 100644 (file)
 
 toolkit_images_dir = ../../../dali-toolkit/images
 toolkit_sounds_dir = ../../../dali-toolkit/sounds
-toolkit_styles_dir = ../../../dali-toolkit/styles
 toolkit_src_dir    = ../../../dali-toolkit/internal
 public_api_src_dir = ../../../dali-toolkit/public-api
 
+if MOBILE_PROFILE
+toolkit_styles_dir = ../../../dali-toolkit/styles/mobile
+else
+toolkit_styles_dir = ../../../dali-toolkit/styles
+endif
+
 include ../../../dali-toolkit/images/file.list
 include ../../../dali-toolkit/sounds/file.list
 include ../../../dali-toolkit/styles/file.list
index 9391d2f..3293406 100644 (file)
@@ -84,6 +84,7 @@ toolkit_src_files = \
    $(toolkit_src_dir)/text/shaper.cpp \
    $(toolkit_src_dir)/text/text-control-interface.cpp \
    $(toolkit_src_dir)/text/text-controller.cpp \
+   $(toolkit_src_dir)/text/text-io.cpp \
    $(toolkit_src_dir)/text/text-view.cpp \
    $(toolkit_src_dir)/text/text-view-interface.cpp \
    $(toolkit_src_dir)/text/visual-model.cpp \
index 4c68a74..f251025 100644 (file)
@@ -29,6 +29,7 @@
 #include <dali-toolkit/internal/text/logical-model.h>
 #include <dali-toolkit/internal/text/font-run.h>
 #include <dali-toolkit/internal/text/script-run.h>
+#include <dali-toolkit/internal/text/text-io.h>
 
 namespace Dali
 {
@@ -484,7 +485,7 @@ void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
             // The font is not valid. Set to zero and a default one will be set.
             fontId = 0u;
           }
-          else
+          else if( !IsValidForAllScripts( character ) )
           {
             // Add the font to the valid font cache.
             validateFontsPerScript = new ValidateFontsPerScript();
@@ -494,7 +495,7 @@ void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
           }
         }
       }
-    }
+    } // !isDefault
 
     // The font has not been validated. Find a default one.
     if( 0u == fontId )
index 4395e1b..c302440 100644 (file)
@@ -553,6 +553,20 @@ float Controller::GetDefaultPointSize() const
   return 0.0f;
 }
 
+void Controller::GetDefaultFonts( Vector<FontRun>& fonts, Length numberOfCharacters )
+{
+  if( mImpl->mFontDefaults )
+  {
+    FontRun fontRun;
+    fontRun.characterRun.characterIndex = 0;
+    fontRun.characterRun.numberOfCharacters = numberOfCharacters;
+    fontRun.fontId = mImpl->mFontDefaults->GetFontId( mImpl->mFontClient );
+    fontRun.isDefault = true;
+
+    fonts.PushBack( fontRun );
+  }
+}
+
 void Controller::EnableTextInput( DecoratorPtr decorator )
 {
   if( !mImpl->mTextInput )
@@ -632,6 +646,8 @@ bool Controller::DoRelayout( const Vector2& size,
     text.clear();
   }
 
+  const Length numberOfCharacters = mImpl->mLogicalModel->GetNumberOfCharacters();
+
   Vector<LineBreakInfo> lineBreakInfo;
   if( GET_LINE_BREAKS & operations )
   {
@@ -663,12 +679,7 @@ bool Controller::DoRelayout( const Vector2& size,
   const bool validateFonts = VALIDATE_FONTS & operations;
 
   Vector<ScriptRun> scripts;
-  Vector<FontRun> fonts;
-
-  if( mImpl->mFontDefaults )
-  {
-    // TODO - pass into ValidateFonts
-  }
+  Vector<FontRun> validFonts;
 
   if( getScripts || validateFonts )
   {
@@ -689,14 +700,18 @@ bool Controller::DoRelayout( const Vector2& size,
 
     if( validateFonts )
     {
+      // Copy the requested font defaults received via the property system.
+      // These may not be valid i.e. may not contain glyphs for the necessary scripts.
+      GetDefaultFonts( validFonts, numberOfCharacters );
+
       // Validates the fonts. If there is a character with no assigned font it sets a default one.
       // After this call, fonts are validated.
       multilanguageSupport.ValidateFonts( utf32Characters,
                                           scripts,
-                                          fonts );
+                                          validFonts );
 
       // Sets the fonts into the model.
-      mImpl->mLogicalModel->SetFonts( fonts.Begin(), fonts.Count() );
+      mImpl->mLogicalModel->SetFonts( validFonts.Begin(), validFonts.Count() );
     }
   }
 
@@ -707,8 +722,6 @@ bool Controller::DoRelayout( const Vector2& size,
     // after the first time the text has been laid out.
     // Fill the vectors again.
 
-    const Length numberOfCharacters = mImpl->mLogicalModel->GetNumberOfCharacters();
-
     if( 0u == utf32Characters.Count() )
     {
       utf32Characters.Resize( numberOfCharacters );
@@ -767,11 +780,20 @@ bool Controller::DoRelayout( const Vector2& size,
   Vector<Length> charactersPerGlyph;
   if( SHAPE_TEXT & operations )
   {
+    if( 0u == validFonts.Count() )
+    {
+      validFonts.Resize( mImpl->mLogicalModel->GetNumberOfFontRuns( 0u,
+                                                                    numberOfCharacters ) );
+      mImpl->mLogicalModel->GetFontRuns( validFonts.Begin(),
+                                         0u,
+                                         numberOfCharacters );
+    }
+
     // Shapes the text.
     ShapeText( utf32Characters,
                lineBreakInfo,
                scripts,
-               fonts,
+               validFonts,
                glyphs,
                glyphsToCharactersMap,
                charactersPerGlyph );
index 5ffa531..9b38aca 100644 (file)
@@ -20,6 +20,7 @@
 
 // EXTERNAL INCLUDES
 #include <string>
+#include <dali/public-api/common/dali-vector.h>
 #include <dali/public-api/common/intrusive-ptr.h>
 #include <dali/public-api/events/key-event.h>
 #include <dali/public-api/math/vector3.h>
@@ -28,6 +29,7 @@
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/text/decorator/text-decorator.h>
+#include <dali-toolkit/internal/text/font-run.h>
 #include <dali-toolkit/internal/text/text-control-interface.h>
 #include <dali-toolkit/internal/text/text-view.h>
 
@@ -165,6 +167,14 @@ public:
    float GetDefaultPointSize() const;
 
   /**
+   * @brief Retrieve the default fonts.
+   *
+   * @param[out] fonts The default font family, style and point sizes.
+   * @param[in] numberOfCharacters The number of characters in the logical model.
+   */
+   void GetDefaultFonts( Dali::Vector<FontRun>& fonts, Length numberOfCharacters );
+
+  /**
    * @brief Called to enable text input.
    *
    * @note Only selectable or editable controls should calls this.
diff --git a/dali-toolkit/internal/text/text-io.cpp b/dali-toolkit/internal/text/text-io.cpp
new file mode 100644 (file)
index 0000000..9e0a0b5
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/internal/text/text-io.h>
+
+// EXTERNAL INCLUDES
+#include <iostream>
+#include <dali/public-api/text-abstraction/font-client.h>
+#include <dali/public-api/text-abstraction/script.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+std::ostream& operator<< (std::ostream& o, const Vector<Character>& text)
+{
+  o << std::hex;
+
+  for( unsigned int i=0; i<text.Count(); ++i )
+  {
+    o << text[i];
+    if( i+1 < text.Count() )
+    {
+      o << " ";
+    }
+  }
+
+  return o << std::dec;
+}
+
+std::ostream& operator<< (std::ostream& o, const Vector<ScriptRun>& scriptRun)
+{
+  for( unsigned int i=0; i<scriptRun.Count(); ++i )
+  {
+    // e.g. Print "0->9: LATIN" for a ten character run staring from beginning of the model
+    o << scriptRun[i].characterRun.characterIndex << "->" << (scriptRun[i].characterRun.characterIndex + scriptRun[i].characterRun.numberOfCharacters ) << ": ";
+    o << TextAbstraction::ScriptName[scriptRun[i].script];
+
+    if( i+1 < scriptRun.Count() )
+    {
+      o << ", ";
+    }
+  }
+
+  return o << std::dec;
+}
+
+std::ostream& operator<< (std::ostream& o, const Vector<FontRun>& fontRun)
+{
+  TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+
+  for( unsigned int i=0; i<fontRun.Count(); ++i )
+  {
+    // e.g. Print "0->9: ID:1 TizenSansKorean style:Regular size:10.0" for a ten character run staring from beginning of the model
+    o << fontRun[i].characterRun.characterIndex << "->" << (fontRun[i].characterRun.characterIndex + fontRun[i].characterRun.numberOfCharacters ) << ": ";
+
+    FontId id = fontRun[i].fontId;
+    TextAbstraction::FontDescription fontDescription;
+    fontClient.GetDescription( id, fontDescription );
+    o << "ID:" << id << ", " << fontDescription.family << " style:" << fontDescription.style << " size:" << (fontClient.GetPointSize(id) / 64);
+
+    if( i+1 < fontRun.Count() )
+    {
+      o << ", ";
+    }
+  }
+
+  return o << std::dec;
+}
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/internal/text/text-io.h b/dali-toolkit/internal/text/text-io.h
new file mode 100644 (file)
index 0000000..b65d917
--- /dev/null
@@ -0,0 +1,72 @@
+#ifndef __DALI_TEXT_ABSTRACTION_TEXT_IO_H__
+#define __DALI_TEXT_ABSTRACTION_TEXT_IO_H__
+
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <iosfwd>
+#include <dali/public-api/common/dali-vector.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/font-run.h>
+#include <dali-toolkit/internal/text/script-run.h>
+#include <dali-toolkit/internal/text/text-definitions.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+/**
+ * @brief Print a vector of characters.
+ *
+ * @param [in] o The output stream operator.
+ * @param [in] text The text to print.
+ * @return The output stream operator.
+ */
+std::ostream& operator<< (std::ostream& o, const Vector<Character>& text);
+
+/**
+ * @brief Print a vector of script runs.
+ *
+ * @param [in] o The output stream operator.
+ * @param [in] scriptRuns The script runs to print.
+ * @return The output stream operator.
+ */
+std::ostream& operator<< (std::ostream& o, const Vector<ScriptRun>& scriptRuns);
+
+/**
+ * @brief Print a vector of font runs.
+ *
+ * @param [in] o The output stream operator.
+ * @param [in] fontRuns The font runs to print.
+ * @return The output stream operator.
+ */
+std::ostream& operator<< (std::ostream& o, const Vector<FontRun>& fontRuns);
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TEXT_ABSTRACTION_TEXT_IO_H__
diff --git a/dali-toolkit/styles/mobile/tizen-dark-theme.json b/dali-toolkit/styles/mobile/tizen-dark-theme.json
new file mode 100644 (file)
index 0000000..238840c
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+Copyright (c) 2000-2014 Samsung Electronics Co., Ltd All Rights Reserved
+
+This file is part of Dali Toolkit
+
+PROPRIETARY/CONFIDENTIAL
+
+This software is the confidential and proprietary information of
+SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+disclose such Confidential Information and shall use it only in
+accordance with the terms of the license agreement you entered
+into with SAMSUNG ELECTRONICS.
+
+SAMSUNG make no representations or warranties about the suitability
+of the software, either express or implied, including but not limited
+to the implied warranties of merchantability, fitness for a particular
+purpose, or non-infringement. SAMSUNG shall not be liable for any
+damages suffered by licensee as a result of using, modifying or
+distributing this software or its derivatives.
+*/
+
+
+
+//******************************************************************************
+//
+// Default style theme for Tizen dark theme, The values should come from
+// UX design document.
+//
+//******************************************************************************
+
+{
+  "styles":
+  {
+    "textlabel":
+    {
+      "font-family":"SamsungSans",
+      "font-style":"Regular",
+      "point-size":12
+    },
+    "textfield":
+    {
+      "font-family":"SamsungSans",
+      "font-style":"Regular",
+      "point-size":12
+    },
+    "scrollview":
+    {
+      "overshoot-effect-color":"B018"
+    }
+  }
+}
diff --git a/dali-toolkit/styles/mobile/tizen-default-theme.json b/dali-toolkit/styles/mobile/tizen-default-theme.json
new file mode 120000 (symlink)
index 0000000..bdcd8ba
--- /dev/null
@@ -0,0 +1 @@
+./tizen-dark-theme.json
\ No newline at end of file
index a9e30d7..398ae2e 100644 (file)
@@ -33,13 +33,13 @@ distributing this software or its derivatives.
   {
     "textlabel":
     {
-      "font-family":"TizenSansFallback",
+      "font-family":"UbuntuMono",
       "font-style":"Regular",
-      "point-size":10
+      "point-size":13
     },
     "textfield":
     {
-      "font-family":"TizenSansFallback",
+      "font-family":"DejaVuSans",
       "font-style":"Regular",
       "point-size":10
     },
diff --git a/packaging/dali-toolkit-mobile.spec b/packaging/dali-toolkit-mobile.spec
new file mode 100644 (file)
index 0000000..cc27ae0
--- /dev/null
@@ -0,0 +1,108 @@
+Name:       dali-toolkit
+Summary:    The OpenGLES Canvas Core Library Toolkit
+Version:    1.0.33
+Release:    1
+Group:      System/Libraries
+License:    Apache-2.0
+URL:        https://review.tizen.org/git/?p=platform/core/uifw/dali-toolkit.git;a=summary
+Source0:    %{name}-%{version}.tar.gz
+
+%define dali_profile MOBILE
+
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+Requires:       dali
+# Do NOT put an adaptor here - it is an application choice which adaptor to use
+BuildRequires:  pkgconfig
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  boost-devel
+BuildRequires:  pkgconfig(dali)
+BuildRequires:  pkgconfig(dali-core)
+
+%description
+The OpenGLES Canvas Core Library Toolkit - a set of controls that provide
+user interface functionality.
+
+##############################
+# devel
+##############################
+%package devel
+Summary:    Application development package for the OpenGLES Canvas toolkit
+Group:      Development/Building
+Requires:   %{name} = %{version}-%{release}
+Requires:   boost-devel
+
+%description devel
+Application development package for the OpenGLES Canvas toolkit - headers and package config
+
+##############################
+# Preparation
+##############################
+%prep
+%setup -q
+%define dali_data_rw_dir            /opt/usr/share/dali/
+%define dali_data_ro_dir            /usr/share/dali/
+%define dali_toolkit_image_files    %{dali_data_ro_dir}/toolkit/images/
+%define dali_toolkit_sound_files    %{dali_data_ro_dir}/toolkit/sounds/
+%define dali_toolkit_style_files    %{dali_data_ro_dir}/toolkit/styles/
+%define dev_include_path %{_includedir}
+
+##############################
+# Build
+##############################
+%build
+PREFIX="/usr"
+CXXFLAGS+=" -Wall -g -Os -fPIC -fvisibility-inlines-hidden -fdata-sections -ffunction-sections "
+LDFLAGS+=" -Wl,--rpath=$PREFIX/lib -Wl,--as-needed -Wl,--gc-sections -Wl,-Bsymbolic-functions "
+
+libtoolize --force
+cd %{_builddir}/dali-toolkit-%{version}/build/tizen
+autoreconf --install
+DALI_DATA_RW_DIR="%{dali_data_rw_dir}" ; export DALI_DATA_RW_DIR
+DALI_DATA_RO_DIR="%{dali_data_ro_dir}" ; export DALI_DATA_RO_DIR
+%configure --enable-profile=%{dali_profile}
+make %{?jobs:-j%jobs}
+
+##############################
+# Installation
+##############################
+%install
+rm -rf %{buildroot}
+cd build/tizen
+%make_install DALI_DATA_RW_DIR="%{dali_data_rw_dir}" DALI_DATA_RO_DIR="%{dali_data_ro_dir}"
+
+# LICENSE
+mkdir -p %{buildroot}/usr/share/license
+cp -af %{_builddir}/%{name}-%{version}/LICENSE %{buildroot}/usr/share/license/%{name}
+
+##############################
+# Post Install
+##############################
+%post
+/sbin/ldconfig
+exit 0
+
+##############################
+# Post Uninstall
+##############################
+%postun
+/sbin/ldconfig
+exit 0
+
+##############################
+# Files in Binary Packages
+##############################
+%files
+%manifest dali-toolkit.manifest-smack
+%defattr(-,root,root,-)
+%{_libdir}/lib%{name}.so*
+%{dali_toolkit_image_files}/*
+%{dali_toolkit_sound_files}/*
+%{dali_toolkit_style_files}/*
+%{_datadir}/license/%{name}
+
+%files devel
+%defattr(-,root,root,-)
+%{dev_include_path}/%{name}/*
+%{_libdir}/pkgconfig/*.pc
+