[Libreoffice-commits] core.git: 2 commits - libreofficekit/README

2014-07-17 Thread Khaled Hosny
 libreofficekit/README |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit eddd7646d672ea9b0561dacb09da224d098e531e
Author: Khaled Hosny 
Date:   Fri Jul 18 08:09:31 2014 +0200

Try to make some sense out of that sentence

Change-Id: Ibe9fedb3602d6c8ddbc007b214969c9960ba10b1

diff --git a/libreofficekit/README b/libreofficekit/README
index 624d67c..3242ae0 100644
--- a/libreofficekit/README
+++ b/libreofficekit/README
@@ -2,7 +2,7 @@ LibreOfficeKit
 **
 
 LibreOfficeKit can be used for accessing LibreOffice functionality
-without LibreOffice, through C/C++, without any need to use UNO.
+through C/C++, without any need to use UNO.
 
 For now it only offers document conversion (in addition to an experimental
 tiled rendering API).
commit 8f082e212de92348a3373cb5c6a1b32590fec418
Author: Khaled Hosny 
Date:   Fri Jul 18 08:05:43 2014 +0200

Typos

Change-Id: If91ed85a56c597f9aecbd5e469af4af83d256cfb

diff --git a/libreofficekit/README b/libreofficekit/README
index 267b20b..624d67c 100644
--- a/libreofficekit/README
+++ b/libreofficekit/README
@@ -2,7 +2,7 @@ LibreOfficeKit
 **
 
 LibreOfficeKit can be used for accessing LibreOffice functionality
-outwith LibreOffice, through C/C++, without any need to use UNO.
+without LibreOffice, through C/C++, without any need to use UNO.
 
 For now it only offers document conversion (in addition to an experimental
 tiled rendering API).
@@ -15,7 +15,7 @@ in order to be able to use LOK. You will then be able to 
access LOK via
 the functions in LibreOfficeKit.h[xx].
 
 (LibreOfficeKit.hxx is a simple and fully inlined C++ wrapper for the same
- functionality as in LibreOfficeKit.h.)
+functionality as in LibreOfficeKit.h.)
 
 An example program can be seen on:
 https://github.com/ojwb/lloconv
@@ -23,7 +23,7 @@ https://github.com/ojwb/lloconv
 Tiled Rendering
 ---
 
-To use LOK Tiled Rendering you will need the follwing before the LOK includes:
+To use LOK Tiled Rendering you will need the following before the LOK includes:
 #define LOK_USE_UNSTABLE_API
 
 Currently only bitmap-buffer rendering is supported, with a 32-bit RGBA
@@ -34,8 +34,8 @@ to bottom-up).
 LibreOfficeKitGtk
 *
 
-Currently consists of only a very basic gtk+ document viewer widget.
+Currently consists of only a very basic GTK+ document viewer widget.
 
 Currently this simply renders the entire document as one large tile (for
-writer) and/or entire sheet for calc, which can be somewhat slow with
+Writer) and/or entire sheet for Calc, which can be somewhat slow with
 larger documents.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


Re: Harbuzz requirements clarification

2014-06-20 Thread Khaled Hosny
On Fri, Jun 20, 2014 at 01:32:24PM +0200, Tomáš Chvátal wrote:
> Hello guys,
> 
> When trying to build 4.3 on openSUSE-12.3 I get this error:
> 
>  
> /home/abuild/rpmbuild/BUILD/libreoffice-4.3.0.0.beta2-buildfix1/vcl/generic/glyphs/gcach_layout.cxx:
> In member function 'virtual bool HbLayoutEngine::layout(ServerFontLayout&,
> ImplLayoutArgs&)':
> [ 2748s]
> /home/abuild/rpmbuild/BUILD/libreoffice-4.3.0.0.beta2-buildfix1/vcl/generic/glyphs/gcach_layout.cxx:423:28:
> error: 'HB_BUFFER_FLAG_DEFAULT' was not declared in this scope

This was fixed in master a few weeks ago (may be we can backport this)
but you can simply replace it with HB_BUFFER_FLAGS_DEFAULT.

> So I would like to know if this should be fixed or if the required version
> of harbuzz should be updated.

Personally I'd advice to always use the latest and greatest HarfBuzz
whenever possible.

Regards,
Khaled
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


[Libreoffice] Horizontal glyph adjustments are ignored with ICU layout

2011-01-05 Thread Khaled Hosny
Hi every one,

This my first message to the list, hopping it will be a fruitful
experience :)

I was trying to debug fdo#31016[1] since it breaks almost all my fonts,
it toke me few months but I think I finally got the root of it (I
started working on it few weeks before libreoffice was announced, what a
nice code base ;).

Anyway, it turned out that the issue is not specific to kerning nor
Arabic, but affects all horizontal glyph positioning in the ICU layout
path; the problem does not show on Windows nor with Graphite fonts and
of course not with con-CTL.

The X adjustment of glyph widths is simply ignored, and glyphs are drawn
stacked after each other baased on their original width, which results in
kerning being ignored as well as other forms of glyph positioning like
cursive anchors, however vertical glyph positions (in the Y access) are
OK.

In source/glyphs/gcach_layout.cxx, ICU's layoutChars() is called and new
glyph indices and positions are returned, which is then fed into
SalLayout in the form of GlyphItem's. Though GlyphItem has maLinearPos
which holds its absolute position, many places in the code re-calculate
glyph position from its mnOrigWidth (original glyph width) and mnNewWidth
(width after adjustments), but the ICU path simply sets mnNewWidth to
mnOrigWidth since ICU layout engine does not return individual glyph
widths, resulting in failure of glyph position re-calculation which
manifests in this bug.

As a prove of concept, the attached patch trays to set mnNewWidth in a
very hackish way by subtracting current glyph position from the of next
non-diacritic (+ve) glyph. It does indeed fix the problem (see the
attached screenshots), but it looks very unreliable to me. May be a
cleaner solution is to re-implement all the broken virtual methods to
eliminate the re-calculation part.

Hope this helps, and sorry for the broken terminology as I'm not really
a developer and less of C++ one (I can only do much of C++ that looks
like C, which I don't really "speak" either).

[1] https://bugs.freedesktop.org/show_bug.cgi?id=31016

Regards,
 Khaled

-- 
 Khaled Hosny
 Arabic localiser and member of Arabeyes.org team
 Free font developer
diff --git a/vcl/source/glyphs/gcach_layout.cxx b/vcl/source/glyphs/gcach_layout.cxx
index cda8749..7531d2b 100644
--- a/vcl/source/glyphs/gcach_layout.cxx
+++ b/vcl/source/glyphs/gcach_layout.cxx
@@ -534,12 +534,35 @@ bool IcuLayoutEngine::operator()( ServerFontLayout& rLayout, ImplLayoutArgs& rAr
 aNewPos = Point( (int)(pPos->fX+0.5), (int)(pPos->fY+0.5) );
 const GlyphMetric& rGM = rFont.GetGlyphMetric( nGlyphIndex );
 int nGlyphWidth = rGM.GetCharWidth();
+int nNewWidth = nGlyphWidth;
 if( nGlyphWidth <= 0 )
 bDiacritic |= true;
 // #i99367# force all diacritics to zero width
 // TODO: we need mnOrigWidth/mnLogicWidth/mnNewWidth
-else if( bDiacritic )
-nGlyphWidth = 0;
+else {
+if( bDiacritic ) {
+nGlyphWidth = 0;
+nNewWidth = 0;
+} else {
+// Hack, find next +ve width glyph and calculate current
+// glyph width by substracting the two posituons
+const IcuPosition* pNextPos = pPos+1;
+for ( int j = i + 1; j < nRawRunGlyphCount; ++j, ++pNextPos) {
+LEGlyphID nNextGlyphIndex = pIcuGlyphs[j];
+
+if( (nNextGlyphIndex == ICU_MARKED_GLYPH) || (nNextGlyphIndex == ICU_DELETED_GLYPH) )
+continue;
+
+const GlyphMetric& rNextGM = rFont.GetGlyphMetric( nNextGlyphIndex );
+int nNextGlyphWidth = rNextGM.GetCharWidth();
+
+if (nNextGlyphWidth>0) {
+nNewWidth = pNextPos->fX - pPos->fX;
+break;
+}
+}
+}
+}
 
 // heuristic to detect glyph clusters
 bool bInCluster = true;
@@ -593,7 +616,9 @@ bool IcuLayoutEngine::operator()( ServerFontLayout& rLayout, ImplLayoutArgs& rAr
 nGlyphFlags |= GlyphItem::IS_DIACRITIC;
 
 // add resulting glyph item to layout
-const GlyphItem aGI( nCharPos, nGlyphIndex, aNewPos, nGlyphFlags, nGlyphWidth );
+GlyphItem aGI( nCharPos, nGlyphIndex, aNewPos, nGlyphFlags, nGlyphWidth );
+aGI.mnNewWidth = nNewWidth;
+//printf("%ld: %d=>%d\n", aGI.mnGlyphIndex, aGI.mnOrigWidth, aGI.mnNewWidth);
 rLayout.AppendGlyph( aGI );
 ++nFilteredRunGlyphCount;
 nLastCharPos = nCharPos;
<><>___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [Libreoffice] Horizontal glyph adjustments are ignored with ICU layout

2011-01-08 Thread Khaled Hosny
On Fri, Jan 07, 2011 at 11:25:33PM +0100, Thorsten Behrens wrote:
> Khaled Hosny wrote:
> > Anyway, it turned out that the issue is not specific to kerning nor
> > Arabic, but affects all horizontal glyph positioning in the ICU layout
> > path; the problem does not show on Windows nor with Graphite fonts and
> > of course not with con-CTL.
> > 
> > The X adjustment of glyph widths is simply ignored, and glyphs are drawn
> > stacked after each other baased on their original width, which results in
> > kerning being ignored as well as other forms of glyph positioning like
> > cursive anchors, however vertical glyph positions (in the Y access) are
> > OK.
> > 
> Hi Khaled,
> 
> wow, many thanks for your detailed analysis - that's actually
> usually the hardest part for most of the bugs. :)
> 
> I'll look into this early next week.

Great, glade it helps and hop long standing bug will get fixed :)

Regards,
 Khaled

-- 
 Khaled Hosny
 Arabic localiser and member of Arabeyes.org team
 Free font developer


signature.asc
Description: Digital signature
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [Libreoffice] Oracle wordbook in LibO

2011-01-08 Thread Khaled Hosny
On Sat, Jan 08, 2011 at 12:43:43AM +0100, Andrea Pescetti wrote:
> Petr Mladek wrote:
> > Andrea Pescetti píše v Pá 07. 01. 2011 v 02:29 +0100:
> > > - It removes all the application names: Writer, Calc, Impress...
> > 
> > Hmm, I am not sure if these are language independent names. Sophie, what
> > do you think?
> 
> As far as I know, the application names are typically untranslated and I
> don't know of any localization using translated names. I can say for
> sure that they were never translated in the Italian version, in 1.x, 2.x
> or 3.x. But it's good to check with Sophie, French tend to translate
> much more technical terms than Italian do!

For language not written in Latin script they are likely to get
transliterated, we certainly do that in Arabic.

Regards,
 Khaled

-- 
 Khaled Hosny
 Arabic localiser and member of Arabeyes.org team
 Free font developer
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [Libreoffice] Horizontal glyph adjustments are ignored with ICU layout

2011-01-11 Thread Khaled Hosny
the nominal
> nNextGlyphWidth is positive, which could cause problems.

I've thought of that too, but shouldn't glyph output be in visual order?

> b) The glyphs are resorted a bit later in
> IcuLayoutEngine::operator() with a rLayout.SortGlyphItems(); call.
> This might upset the new width values. However, it seems to only
> reorder diacritics and those are skipped for the width calculation,
> so that is probably alright.
> 
> c) For the last glyph in a run, pNextPos will still be valid (see
> LayoutEngine::getGlyphPositions docs), so I think it should be used
> for the nNewWidth calculation.

The attached batch should do that (plus some clean up over the previous
one).

> It should be tested with some CTL scripts including reordering and
> lots of diacritics to check the edge cases are covered. The width
> will also affect font fallback (calls from MultiSalLayout), so that
> needs to be tested as well.

I've tested with fonts that make extensive use of combining marks and no
major problems so far, however width of fallback glyphs seems to be
miscalculated when followed by kerned glyphs but I'm yet to understand
what is going on with fallback. Testing with scripts that require glyph
reordering still needed, but I don't speak any.

Regards,
 Khaled

-- 
 Khaled Hosny
 Arabic localiser and member of Arabeyes.org team
 Free font developer
diff --git a/vcl/source/glyphs/gcach_layout.cxx b/vcl/source/glyphs/gcach_layout.cxx
index cda8749..cb0d342 100644
--- a/vcl/source/glyphs/gcach_layout.cxx
+++ b/vcl/source/glyphs/gcach_layout.cxx
@@ -534,12 +534,40 @@ bool IcuLayoutEngine::operator()( ServerFontLayout& rLayout, ImplLayoutArgs& rAr
 aNewPos = Point( (int)(pPos->fX+0.5), (int)(pPos->fY+0.5) );
 const GlyphMetric& rGM = rFont.GetGlyphMetric( nGlyphIndex );
 int nGlyphWidth = rGM.GetCharWidth();
+int nNewWidth = nGlyphWidth;
 if( nGlyphWidth <= 0 )
 bDiacritic |= true;
 // #i99367# force all diacritics to zero width
 // TODO: we need mnOrigWidth/mnLogicWidth/mnNewWidth
 else if( bDiacritic )
-nGlyphWidth = 0;
+nGlyphWidth = nNewWidth = 0;
+else
+{
+// Hack, find next +ve width glyph and calculate current
+// glyph width by substracting the two posituons
+const IcuPosition* pNextPos = pPos+1;
+for ( int j = i + 1; j <= nRawRunGlyphCount; ++j, ++pNextPos )
+{
+if ( j == nRawRunGlyphCount )
+{
+nNewWidth = pNextPos->fX - pPos->fX;
+break;
+}
+
+LEGlyphID nNextGlyphIndex = pIcuGlyphs[j];
+if( (nNextGlyphIndex == ICU_MARKED_GLYPH)
+||  (nNextGlyphIndex == ICU_DELETED_GLYPH) )
+continue;
+
+const GlyphMetric& rNextGM = rFont.GetGlyphMetric( nNextGlyphIndex );
+int nNextGlyphWidth = rNextGM.GetCharWidth();
+if ( nNextGlyphWidth > 0 )
+{
+nNewWidth = pNextPos->fX - pPos->fX;
+break;
+}
+}
+}
 
 // heuristic to detect glyph clusters
 bool bInCluster = true;
@@ -593,7 +621,8 @@ bool IcuLayoutEngine::operator()( ServerFontLayout& rLayout, ImplLayoutArgs& rAr
 nGlyphFlags |= GlyphItem::IS_DIACRITIC;
 
 // add resulting glyph item to layout
-const GlyphItem aGI( nCharPos, nGlyphIndex, aNewPos, nGlyphFlags, nGlyphWidth );
+GlyphItem aGI( nCharPos, nGlyphIndex, aNewPos, nGlyphFlags, nGlyphWidth );
+aGI.mnNewWidth = nNewWidth;
 rLayout.AppendGlyph( aGI );
 ++nFilteredRunGlyphCount;
 nLastCharPos = nCharPos;
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [Libreoffice] [FIXED] Re: debug build fails because graphite ./configure not up to date

2011-01-15 Thread Khaled Hosny
On Sat, Jan 15, 2011 at 08:16:55PM +, Caolán McNamara wrote:
> On Sat, 2011-01-15 at 00:43 +0100, Lionel Elie Mamane wrote:
> > Hi,
> > 
> > A build with --enable-debug (or is it --enable-dbgutil?) fails in
> > graphite... for a problem already corrected in graphite's
> > configure.ac, but its "configure" is outdated and thus the problem
> > still surfaces.
> 
> Ah, I see. So I've now added a patch into that graphite module to sync
> the configure.ac logic into configure.
> 
> > Before I got to the point of trying to disable -Werror (and
> > understanding why it was enabled in the first place), I fixed one of
> > the warnings. Patch attached, still does not hurt to apply janitorialy
> > :)
> 
> Well, we do occasionally patch those "external" modules, but try to
> avoid it. The ideal place to send patches to graphite would be to the
> upstream graphite project and poke them to release a new update at some
> stage and then just upgrade to the latest graphite.

BTW, Graphite engine is being re-written into a more stable engine (the
current engine is crashy, or so I read), so it might be a good time to
consider switching over to the new engine.

Regards,
 Khaled

-- 
 Khaled Hosny
 Arabic localiser and member of Arabeyes.org team
 Free font developer
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [Libreoffice] [libreoffice-users] Re: Which Unicode Standard LibreOffice uses...?

2011-01-25 Thread Khaled Hosny
On Tue, Jan 25, 2011 at 09:07:56PM +0100, Cor Nouws wrote:
> Hi amine,
> 
> amine amine wrote (24-01-11 21:24)
> >LibO renders well the characters of the
> >Arabic_Presentation_Forms-B<http://en.wiktionary.org/wiki/Appendix:Unicode/Arabic_Presentation_Forms-B>
> >.
> >
> >The problem is when reopening an exported PDF with
> >LibO-Draw+PDFImport-extension
> >
> >and this Unicode Block has just been added recetly to the Unicode standard,
> >that's why i'm asking.
> 
> Ah, understand this now.
> 
> Most likely is that LibO provides what OOo has in this area.
> Therefore I cc the dev-list.
> If necessary, a request at d...@openoffice.org (cc e...@openoffice.org,
> Eike Rathke), will help.

Sorry, but I don't see what the issue being discussed here? And Arabic
Presentation Forms have been in Unicode since version 2 or something.

Regards,
 Khaled

-- 
 Khaled Hosny
 Arabic localiser and member of Arabeyes.org team
 Free font developer
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [Libreoffice] [PUSHED] Re: Horizontal glyph adjustments are ignored with ICU layout

2011-02-03 Thread Khaled Hosny
On Fri, Jan 28, 2011 at 02:17:44PM +, Caolán McNamara wrote:
> Can we take it that your submission is under our recommended LGPLv3+/MPL
> licence ?

Sure, this and any future submissions are LGPLv3+/MPL licensed.

-- 
 Khaled Hosny
 Egyptian
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [Libreoffice] [PUSHED] Re: Horizontal glyph adjustments are ignored with ICU layout

2011-02-03 Thread Khaled Hosny
On Fri, Jan 28, 2011 at 02:17:44PM +, Caolán McNamara wrote:
> On Wed, 2011-01-26 at 17:03 +, Caolán McNamara wrote:
> > On Wed, 2011-01-26 at 11:22 +0100, Jan Holesovsky wrote:
> > > Anybody here with ideas what we can do so that the patch helps Khaled,
> > > and is as safe as possible? - so that we can commit it, and fix the
> > > consequences later if anything happens?
> > 
> > Where things are most likely to go wrong are with e.g. Indic text.
> > What's ideally needed is some before and after tests with e.g. Hindi,
> > Tamil, text that needs (the infamous) reordering processing.
> 
> Ok, so I pulled down our RedHat Indic test cases and they appear to be
> the same before and after for this, so it doesn't obviously break
> anything.
> 
> It seems more of a band-aid than a full fix to me, but it does improve
> the attached to fdo#31016 test case.

Indeed. A real long term "fix" is to drop ICU layout engine altogether
and switch to HarfBuzz, however HarfBuzz lacks Indic shaper right now
(promised to be there by March), once it have one we should consider
doing so (I'd try to give a hand).

> So I've pushed this now and added a
> little one-liner define around the relevant bit to make it easy to
> disable if any problems do arise.
> 
> So thanks for this, CTL rendering is rather tricky, and while there's
> been a fair amount of work on Indic languages, Arabic is probably the
> one in worst shape.

Next on the list is the horribly broken Kashida justification and make
it optional.

Regards,
 Khaled

-- 
 Khaled Hosny
 Egyptian
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [Libreoffice] [PUSHED] Re: Horizontal glyph adjustments are ignored with ICU layout

2011-02-04 Thread Khaled Hosny
On Fri, Feb 04, 2011 at 11:00:34AM +, Michael Meeks wrote:
> 
> On Thu, 2011-02-03 at 23:27 +0200, Khaled Hosny wrote:
> > Indeed. A real long term "fix" is to drop ICU layout engine altogether
> > and switch to HarfBuzz, however HarfBuzz lacks Indic shaper right now
> > (promised to be there by March), once it have one we should consider
> > doing so (I'd try to give a hand).
> 
>   Oooh ! :-) that would be brilliant :-) if we can get that great big (13
> +Mb) blob of ICU out of the codebase, and substitute harfbuzz I'd be
> thrilled :-)

HarfBuzz can do the layout part, but we still need a Unicode library
though it need not to be the monstrous ICU.

Regards,
 Khaled

-- 
 Khaled Hosny
 Egyptian
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


[Libreoffice] No full justification in master?

2011-03-01 Thread Khaled Hosny
In locally built libreoffice master I can't get full justification; text
is kept left aligned. I tested with the distro packaged 3.3.1 and
justification is fine. Can anyone confirm this, or it is just me?

Regards,
 Khaled

-- 
 Khaled Hosny
 Egyptian
 Arab
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [Libreoffice] No full justification in master?

2011-03-02 Thread Khaled Hosny
On Tue, Mar 01, 2011 at 05:19:36PM +0100, Thomas Arnhold wrote:
> Hi Khaled,
> 
> On 03/01/2011 05:10 PM, Khaled Hosny wrote:
> > In locally built libreoffice master I can't get full justification; text
> > is kept left aligned. I tested with the distro packaged 3.3.1 and
> > justification is fine. Can anyone confirm this, or it is just me?
> 
> Yes, I can confirm this! I've tested the 3.3.1 Gentoo version - works
> fine. But for git master it won't do anything.

Reported on bugzilla:
https://bugs.freedesktop.org/show_bug.cgi?id=34920


-- 
 Khaled Hosny
 Egyptian
 Arab
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [Libreoffice] fixing kashida insertion

2011-03-15 Thread Khaled Hosny
On Tue, Mar 15, 2011 at 10:32:59PM +0700, Martin Hosken wrote:
> Dear Arabic experts,
> 
> The current kashida insertion implementation in libo is, to put it
> mildly, a disaster.

Indeed!

> As I see it there are a few options open to us:
> 
> 1. Get it right. This is really hard and beyond my capabilities in the
> time I have available for this. But if someone wants to work out the
> preferred location for each word and then insert there, then go for
> it.
> 
> 2. Implement dumb kashida placement that says: you can insert a
> kashida at any joining of two characters. This should be doable
> (famous last words) based on Unicode properties.

There is a bit less dump "algorithm" used by IE and also implemented in
Qt:
http://www.microsoft.com/middleeast/msdn/JustifyingText-CSS.aspx
It shouldn't be hard to implement (though I don't completely agree with
priority 5 in the table; a Baa followed by Yaa should never ever get a
Kashida in a Naskh or Nastaliq font).

> 3. Don't do kashida insertion at all. This is probably better than the
> bad insertion we currently have.

In either case this should be an option, there are many high quality
fonts that any non highly sophosticated Kashida algorithm will fail for
them (any good Nastaliq font for example).

> I'm willing to have a go at 2 or 3. An alternative would be to add a
> switch in say Options/Language Settings/Writing Aids/Options or
> Options/Language Settings/Complex Text Layout to enable/disable
> kashida insertion. Such UI stuff is beyond me at the moment.

I'd suggest having a more accessible option (MS Office 2007 combines the
three full justification settings in the same full justification button
in the toolbar which makes it very accessible IMO), but it is up to who
will actually right the code.

This is one of the most broken aspects of OOo/LO for Arabic users, I was
planing to play with it but unfortunately I'll not be able to put much
effort into this.

Regards,
 Khaled

-- 
 Khaled Hosny
 Egyptian
 Arab
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: A little info about ligatures and e.g. Calibri

2013-02-03 Thread Khaled Hosny
On Sun, Feb 03, 2013 at 03:39:36PM +, Caolán McNamara wrote:
> FWIW, as it came up as a question in the main track FOSDEM LibreOffice
> talk, in vcl/generic/glyphs/gcach_layout.cxx see IcuLayoutEngine::layout
> and...
> if (rArgs.mnFlags & SAL_LAYOUT_ENABLE_LIGATURES)
> nLayoutFlags |= LayoutEngine::kTypoFlagLiga;
> so ligatures are disabled by default unless SAL_LAYOUT_ENABLE_LIGATURES
> is enabled, and SAL_LAYOUT_ENABLE_LIGATURES is only set if
> TEXT_LAYOUT_ENABLE_LIGATURES is set on the outputdevice, and that
> doesn't happen anywhere as of yet :-(

I was wondering about this a while ago, but thought it was just me not
finding where the magic is.

> It would be no major problem to e.g. bubble up allowing those ligatures
> to be set explicitly via the UI, or e.g. defaulted on via a new
> compatibility flag for new docs, but the last time I played around with
> it I ran into the snag that with our current Linux rendering stack via
> cairo we get the unfortunate visual effect that ligatures appear bold in
> Calibri, etc.

I see Calibri only, no etc's :), so blocking ligature support (which is
so 80s, even MS Office now supports OpenType features for Latin) because
is of a bug in a single font in certain configurations is overreacting
IMHO.

Regards,
Khaled
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: A little info about ligatures and e.g. Calibri

2013-02-03 Thread Khaled Hosny
On Sun, Feb 03, 2013 at 04:15:00PM +, Caolán McNamara wrote:
> On Sun, 2013-02-03 at 17:58 +0200, Khaled Hosny wrote:
> > I see Calibri only, no etc's :), so blocking ligature support (which is
> > so 80s, even MS Office now supports OpenType features for Latin) because
> > is of a bug in a single font in certain configurations is overreacting
> > IMHO.
> 
> *shrug*, its why I wasn't motivated to go and figure out a UI to
> enable/disable ligatures or see if a compatibility option was a better
> idea etc because I'd just get a slew of bugs that "my text is bold".

GTK have been enabling ligatures and other default OpenType features
since ages (since before I started using computers :p), so probably the
situation is not that bad.

Regards,
Khaled
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: A little info about ligatures and e.g. Calibri

2013-02-18 Thread Khaled Hosny
On Tue, Feb 05, 2013 at 10:36:38AM +, Caolán McNamara wrote:
> On Sun, 2013-02-03 at 18:26 +0200, Khaled Hosny wrote:
> > GTK have been enabling ligatures and other default OpenType features
> > since ages (since before I started using computers :p), so probably the
> > situation is not that bad.
> 
> oh, I forgot, we also don't have proper cursor positions for ligatures
> either!, that's another epic lack.

Cursor positioning inside ligatures seems to work for Arabic when using
OpenType fonts, but not with Latin ligature when using Graphite fonts
(couldn't find Arabic Graphite fonts with ligatures), so may be it is an
issue with Graphite integration.

Regards,
Khaled
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


[Libreoffice-commits] core.git: 4 commits - vcl/coretext

2013-05-17 Thread Khaled Hosny
 vcl/coretext/salcoretextlayout.cxx |  107 +++--
 1 file changed, 46 insertions(+), 61 deletions(-)

New commits:
commit e4088a68aa3d69da60f5a1e93c06ca8be3ff764f
Author: Khaled Hosny 
Date:   Fri May 17 23:23:02 2013 +0200

Drop unused mpGlyphPositions array

Change-Id: I858832a41ef140fa9916e05548edf2df6b0af451

diff --git a/vcl/coretext/salcoretextlayout.cxx 
b/vcl/coretext/salcoretextlayout.cxx
index 650506d..d2c2d48 100644
--- a/vcl/coretext/salcoretextlayout.cxx
+++ b/vcl/coretext/salcoretextlayout.cxx
@@ -81,7 +81,6 @@ private:
 
 mutable CGSize* mpGlyphAdvances;
 
-mutable CGPoint* mpGlyphPositions;
 mutable CTTypesetterRef mpTypesetter;
 mutable CTLineRef mpLine;
 mutable bool mbHasBoundRectangle;
@@ -108,7 +107,6 @@ CoreTextLayout::CoreTextLayout(CoreTextStyleInfo* style) :
 mpCharWidths(NULL),
 mpGlyphs2Chars(NULL),
 mpGlyphAdvances(NULL),
-mpGlyphPositions(NULL),
 mpTypesetter(NULL),
 mpLine(NULL),
 mbHasBoundRectangle(false),
@@ -196,10 +194,6 @@ void CoreTextLayout::InvalidateMeasurements()
 delete[] mpGlyphAdvances;
 mpGlyphAdvances = NULL;
 }
-if( mpGlyphPositions ) {
-delete[] mpGlyphPositions;
-mpGlyphPositions = NULL;
-}
 mbHasBoundRectangle = false;
 }
 
@@ -601,7 +595,6 @@ void CoreTextLayout::GetMeasurements()
 mpCharWidths = new CGFloat[ mnCharCount ];
 mpGlyphs2Chars = new int[ mnGlyphCount ];
 mpGlyphAdvances = new CGSize[ mnGlyphCount ];
-mpGlyphPositions = new CGPoint[ mnGlyphCount ];
 
 CFArrayRef runs = CTLineGetGlyphRuns( mpLine );
 const CFIndex nRuns = CFArrayGetCount( runs );
@@ -630,7 +623,6 @@ void CoreTextLayout::GetMeasurements()
 
 CTRunGetGlyphs( run, CFRangeMake( 0, 0 ), &mpGlyphs[ lineGlyphIx ] 
);
 
-CTRunGetPositions( run, CFRangeMake( 0, 0 ), &mpGlyphPositions[ 
lineGlyphIx ] );
 CTRunGetAdvances( run, CFRangeMake( 0, 0 ), &mpGlyphAdvances[ 
lineGlyphIx ] );
 
 for ( CFIndex runGlyphIx = 0 ; runGlyphIx < runGlyphCount; 
lineGlyphIx++, runGlyphIx++ )
@@ -645,7 +637,7 @@ void CoreTextLayout::GetMeasurements()
 for ( int i = 0; i < runGlyphCount; i++ ) {
 const int ix = lineRunGlyphStartIx + i;
 if ( i < 7 ) {
-glyphPositionInfo << " " << mpGlyphs[ ix ] << "@" << 
mpGlyphPositions[ ix ];
+glyphPositionInfo << " " << mpGlyphs[ ix ];
 glyphAdvancesInfo << " " << mpGlyphAdvances[ ix ];
 } else if (i == 7 ) {
     glyphPositionInfo << "...";
commit 81ec93f8448d32933e2697613449baf573b63e42
Author: Khaled Hosny 
Date:   Fri May 17 23:17:54 2013 +0200

Simplify Core Text drawing

No need to keep a fonts array around; we don’t modify the glyph array in
anyway so we can just query the CTLine directly.

Change-Id: I24fd49b8fcc8391de7fe132db60bc81bc9941a81

diff --git a/vcl/coretext/salcoretextlayout.cxx 
b/vcl/coretext/salcoretextlayout.cxx
index e4afc8d..650506d 100644
--- a/vcl/coretext/salcoretextlayout.cxx
+++ b/vcl/coretext/salcoretextlayout.cxx
@@ -75,8 +75,6 @@ private:
 // mutable members since these details are all lazy initialized
 mutable int mnGlyphCount;
 
-mutable CTFontRef* mpGlyphFonts;
-
 mutable CGGlyph* mpGlyphs;
 mutable CGFloat* mpCharWidths;
 mutable int* mpGlyphs2Chars;
@@ -106,7 +104,6 @@ CoreTextLayout::CoreTextLayout(CoreTextStyleInfo* style) :
 mpStyle(style),
 mnCharCount(-1),
 mnGlyphCount(-1),
-mpGlyphFonts(NULL),
 mpGlyphs(NULL),
 mpCharWidths(NULL),
 mpGlyphs2Chars(NULL),
@@ -183,10 +180,6 @@ void CoreTextLayout::Justify( long nNewWidth )
 
 void CoreTextLayout::InvalidateMeasurements()
 {
-if( mpGlyphFonts ) {
-delete[] mpGlyphFonts;
-mpGlyphFonts = NULL;
-}
 if( mpGlyphs ) {
 delete[] mpGlyphs;
 mpGlyphs = NULL;
@@ -243,29 +236,37 @@ void CoreTextLayout::DrawText( SalGraphics& rGraphics ) 
const
 
 CGContextTranslateCTM(gr.mrContext, pos.X(), pos.Y());
 
-int i = 0;
-while (i < mnGlyphCount)
-{
-CTFontRef pCTFont = mpGlyphFonts[i];
+CFArrayRef pRuns = CTLineGetGlyphRuns(mpLine);
+const CFIndex nRuns = CFArrayGetCount(pRuns);
 
-// Find the number of glyphs using the same font
-int nGlyphs = 1;
-while ((i + nGlyphs < mnGlyphCount) && CFEqual(mpGlyphFonts[i + 
nGlyphs], pCTFont))
-nGlyphs++;
-
-CGFontRef pCGFont = CTFontCopyGraphicsFont(pCTFont, NULL);
-if (!pCGFont) {
-SAL_INFO("vcl.coretext.layout", "Error pCGFont is NULL");
-return;
-}
+for (CFIndex nRun = 0; nRun < nRuns; nRun++)
+

[Libreoffice-commits] core.git: sw/source

2013-05-20 Thread Khaled Hosny
 sw/source/ui/docvw/HeaderFooterWin.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit c761fcfd7ec95090cde2fb2b6b9b891f3e1337ab
Author: Khaled Hosny 
Date:   Mon May 20 15:58:47 2013 +0200

Fix fdo#64751 – Header & footer blue tags empty

No idea FontMetric::GetHeight() is supposed to mean, probably the code
here meant GetLineHeight(). What it actually need is GetAscent(), so use
it instead (which is the same as GetLineHeight() - GetDescent()).

Change-Id: Ic467e56ed6b8d245ac7800f94e6d40030833328b
Reviewed-on: https://gerrit.libreoffice.org/3980
Reviewed-by: Fridrich Strba 
Tested-by: Fridrich Strba 

diff --git a/sw/source/ui/docvw/HeaderFooterWin.cxx 
b/sw/source/ui/docvw/HeaderFooterWin.cxx
index 970e541..eb88d53 100644
--- a/sw/source/ui/docvw/HeaderFooterWin.cxx
+++ b/sw/source/ui/docvw/HeaderFooterWin.cxx
@@ -291,7 +291,7 @@ void SwHeaderFooterWin::Paint( const Rectangle& )
 GetTextBoundRect( aTextRect, String( m_sLabel ) );
 
 FontMetric aFontMetric = GetFontMetric( GetFont() );
-double nTextOffsetY = aFontMetric.GetHeight() - aFontMetric.GetDescent() + 
TEXT_PADDING;
+double nTextOffsetY = aFontMetric.GetAscent() + TEXT_PADDING;
 Point aTextPos( TEXT_PADDING, nTextOffsetY );
 
 basegfx::B2DHomMatrix aTextMatrix( createScaleTranslateB2DHomMatrix(
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: download.lst harfbuzz/harfbuzz.configure.patch.1

2013-05-21 Thread Khaled Hosny
 download.lst|2 +-
 harfbuzz/harfbuzz.configure.patch.1 |8 +---
 2 files changed, 2 insertions(+), 8 deletions(-)

New commits:
commit b1167d96bd70a9e820525a3e6189772cf1b7852a
Author: Khaled Hosny 
Date:   Tue May 21 19:46:06 2013 +0200

Update HarfBuzz to 0.9.17

Change-Id: If84a1eb7dbd54b4f1e3d876eb63cc3f2f8e51938
Reviewed-on: https://gerrit.libreoffice.org/3993
Reviewed-by: Fridrich Strba 
Tested-by: Fridrich Strba 

diff --git a/download.lst b/download.lst
index f02392e..f827956 100644
--- a/download.lst
+++ b/download.lst
@@ -38,7 +38,7 @@ export GRAPHITE_TARBALL := 
f5ef3f7f10fa8c3542c6a085a233080b-graphite2-1.2.0.tgz
 export GLIBC_TARBALL := 
4a660ce8466c9df01f19036435425c3a-glibc-2.1.3-stub.tar.gz
 export HSQLDB_TARBALL := 17410483b5b5f267aa18b7e00b65e6e0-hsqldb_1_8_0.zip
 export HUNSPELL_TARBALL := 
3121aaf3e13e5d88dfff13fb4a5f1ab8-hunspell-1.3.2.tar.gz
-export HARFBUZZ_TARBALL := 
90855e670c790c1fec4592908be3c0b8-harfbuzz-0.9.16.tar.bz2
+export HARFBUZZ_TARBALL := 
c48827713e93539dc7285f9e86ffbdc5-harfbuzz-0.9.17.tar.bz2
 export HYPHEN_TARBALL := a2f6010987e1c601274ab5d63b72c944-hyphen-2.8.4.tar.gz
 export ICU_TARBALL := 6eef33b229d0239d654983028c9c7053-icu4c-51_1-src.tgz
 export ICU_51_LAYOUT_FIX_TARBALL := 
7650341b04f05ff2595bf064f3e41f41-icu-51-layout-fix-10107.tgz
diff --git a/harfbuzz/harfbuzz.configure.patch.1 
b/harfbuzz/harfbuzz.configure.patch.1
index ffabde5..937a06e 100644
--- a/harfbuzz/harfbuzz.configure.patch.1
+++ b/harfbuzz/harfbuzz.configure.patch.1
@@ -64,7 +64,7 @@ diff -ur harfbuzz.org/configure harfbuzz/configure
  fi
  if test "$have_icu_le" != "true"; then
if test -n "$ac_tool_prefix"; then
-@@ -17555,12 +17555,12 @@
+@@ -17555,7 +17555,7 @@
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ICU_LE by using 
icu-config fallback" >&5
  $as_echo_n "checking for ICU_LE by using icu-config fallback... " >&6; }
if test "$ICU_CONFIG" != "no" && "$ICU_CONFIG" --version >/dev/null; 
then
@@ -73,12 +73,6 @@ diff -ur harfbuzz.org/configure harfbuzz/configure
# We don't use --cflags as this gives us a lot of things that 
we don't
# necessarily want, like debugging and optimization flags
# See man (1) icu-config for more info.
-   ICU_LE_CFLAGS=`$ICU_CONFIG --cppflags`
--  ICU_LE_LIBS=`$ICU_CONFIG --ldflags-libsonly --ldflags-layout`
-+  ICU_LE_LIBS=`$ICU_CONFIG --ldflags-libsonly --ldflags-layout | 
tr "\n" " "`
- 
- 
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 @@ -17654,7 +17654,7 @@
GRAPHITE2_LIBS=$pkg_cv_GRAPHITE2_LIBS
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: harfbuzz/harfbuzz.configure.patch.1

2013-05-22 Thread Khaled Hosny
 harfbuzz/harfbuzz.configure.patch.1 |8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

New commits:
commit a2e3f7786f78234a5b5d0fe19ea715c2ad2f3ad7
Author: Khaled Hosny 
Date:   Wed May 22 12:04:22 2013 +0200

Blind attempt to fix HarfBuzz build

Change-Id: Iaa61bc2c82ab6bd6391c8c81951ca55c5ce133ab

diff --git a/harfbuzz/harfbuzz.configure.patch.1 
b/harfbuzz/harfbuzz.configure.patch.1
index 937a06e..c66e2b7 100644
--- a/harfbuzz/harfbuzz.configure.patch.1
+++ b/harfbuzz/harfbuzz.configure.patch.1
@@ -64,7 +64,7 @@ diff -ur harfbuzz.org/configure harfbuzz/configure
  fi
  if test "$have_icu_le" != "true"; then
if test -n "$ac_tool_prefix"; then
-@@ -17555,7 +17555,7 @@
+@@ -17555,12 +17555,12 @@
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ICU_LE by using 
icu-config fallback" >&5
  $as_echo_n "checking for ICU_LE by using icu-config fallback... " >&6; }
if test "$ICU_CONFIG" != "no" && "$ICU_CONFIG" --version >/dev/null; 
then
@@ -73,6 +73,12 @@ diff -ur harfbuzz.org/configure harfbuzz/configure
# We don't use --cflags as this gives us a lot of things that 
we don't
# necessarily want, like debugging and optimization flags
# See man (1) icu-config for more info.
+   ICU_LE_CFLAGS=`$ICU_CONFIG --cppflags`
+-  ICU_LE_LIBS=`$ICU_CONFIG --ldflags-searchpath 
--ldflags-libsonly --ldflags-layout`
++  ICU_LE_LIBS=`$ICU_CONFIG --ldflags-searchpath 
--ldflags-libsonly --ldflags-layout | tr "\n" " "`
+
+
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 @@ -17654,7 +17654,7 @@
GRAPHITE2_LIBS=$pkg_cv_GRAPHITE2_LIBS
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - 2 commits - download.lst harfbuzz/harfbuzz.configure.patch.1

2013-05-22 Thread Khaled Hosny
 download.lst|2 +-
 harfbuzz/harfbuzz.configure.patch.1 |8 
 2 files changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 0ba159e33bb8f47250f57f377af40f7ca941c89c
Author: Khaled Hosny 
Date:   Wed May 22 12:04:22 2013 +0200

Blind attempt to fix HarfBuzz build

Change-Id: Iaa61bc2c82ab6bd6391c8c81951ca55c5ce133ab

diff --git a/harfbuzz/harfbuzz.configure.patch.1 
b/harfbuzz/harfbuzz.configure.patch.1
index 937a06e..c66e2b7 100644
--- a/harfbuzz/harfbuzz.configure.patch.1
+++ b/harfbuzz/harfbuzz.configure.patch.1
@@ -64,7 +64,7 @@ diff -ur harfbuzz.org/configure harfbuzz/configure
  fi
  if test "$have_icu_le" != "true"; then
if test -n "$ac_tool_prefix"; then
-@@ -17555,7 +17555,7 @@
+@@ -17555,12 +17555,12 @@
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ICU_LE by using 
icu-config fallback" >&5
  $as_echo_n "checking for ICU_LE by using icu-config fallback... " >&6; }
if test "$ICU_CONFIG" != "no" && "$ICU_CONFIG" --version >/dev/null; 
then
@@ -73,6 +73,12 @@ diff -ur harfbuzz.org/configure harfbuzz/configure
# We don't use --cflags as this gives us a lot of things that 
we don't
# necessarily want, like debugging and optimization flags
# See man (1) icu-config for more info.
+   ICU_LE_CFLAGS=`$ICU_CONFIG --cppflags`
+-  ICU_LE_LIBS=`$ICU_CONFIG --ldflags-searchpath 
--ldflags-libsonly --ldflags-layout`
++  ICU_LE_LIBS=`$ICU_CONFIG --ldflags-searchpath 
--ldflags-libsonly --ldflags-layout | tr "\n" " "`
+
+
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 @@ -17654,7 +17654,7 @@
GRAPHITE2_LIBS=$pkg_cv_GRAPHITE2_LIBS
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
commit 1cabbe033b395d5de985dd77ecd26dfc39a6feeb
Author: Khaled Hosny 
Date:   Tue May 21 19:46:06 2013 +0200

Update HarfBuzz to 0.9.17

Change-Id: If84a1eb7dbd54b4f1e3d876eb63cc3f2f8e51938
Reviewed-on: https://gerrit.libreoffice.org/3993
Reviewed-by: Fridrich Strba 
Tested-by: Fridrich Strba 

diff --git a/download.lst b/download.lst
index f02392e..f827956 100644
--- a/download.lst
+++ b/download.lst
@@ -38,7 +38,7 @@ export GRAPHITE_TARBALL := 
f5ef3f7f10fa8c3542c6a085a233080b-graphite2-1.2.0.tgz
 export GLIBC_TARBALL := 
4a660ce8466c9df01f19036435425c3a-glibc-2.1.3-stub.tar.gz
 export HSQLDB_TARBALL := 17410483b5b5f267aa18b7e00b65e6e0-hsqldb_1_8_0.zip
 export HUNSPELL_TARBALL := 
3121aaf3e13e5d88dfff13fb4a5f1ab8-hunspell-1.3.2.tar.gz
-export HARFBUZZ_TARBALL := 
90855e670c790c1fec4592908be3c0b8-harfbuzz-0.9.16.tar.bz2
+export HARFBUZZ_TARBALL := 
c48827713e93539dc7285f9e86ffbdc5-harfbuzz-0.9.17.tar.bz2
 export HYPHEN_TARBALL := a2f6010987e1c601274ab5d63b72c944-hyphen-2.8.4.tar.gz
 export ICU_TARBALL := 6eef33b229d0239d654983028c9c7053-icu4c-51_1-src.tgz
 export ICU_51_LAYOUT_FIX_TARBALL := 
7650341b04f05ff2595bf064f3e41f41-icu-51-layout-fix-10107.tgz
diff --git a/harfbuzz/harfbuzz.configure.patch.1 
b/harfbuzz/harfbuzz.configure.patch.1
index ffabde5..937a06e 100644
--- a/harfbuzz/harfbuzz.configure.patch.1
+++ b/harfbuzz/harfbuzz.configure.patch.1
@@ -64,7 +64,7 @@ diff -ur harfbuzz.org/configure harfbuzz/configure
  fi
  if test "$have_icu_le" != "true"; then
if test -n "$ac_tool_prefix"; then
-@@ -17555,12 +17555,12 @@
+@@ -17555,7 +17555,7 @@
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ICU_LE by using 
icu-config fallback" >&5
  $as_echo_n "checking for ICU_LE by using icu-config fallback... " >&6; }
if test "$ICU_CONFIG" != "no" && "$ICU_CONFIG" --version >/dev/null; 
then
@@ -73,12 +73,6 @@ diff -ur harfbuzz.org/configure harfbuzz/configure
# We don't use --cflags as this gives us a lot of things that 
we don't
# necessarily want, like debugging and optimization flags
# See man (1) icu-config for more info.
-   ICU_LE_CFLAGS=`$ICU_CONFIG --cppflags`
--  ICU_LE_LIBS=`$ICU_CONFIG --ldflags-libsonly --ldflags-layout`
-+  ICU_LE_LIBS=`$ICU_CONFIG --ldflags-libsonly --ldflags-layout | 
tr "\n" " "`
- 
- 
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 @@ -17654,7 +17654,7 @@
GRAPHITE2_LIBS=$pkg_cv_GRAPHITE2_LIBS
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/generic vcl/inc vcl/source

2013-05-23 Thread Khaled Hosny
 vcl/generic/glyphs/gcach_layout.cxx |   96 
 vcl/inc/generic/glyphcache.hxx  |1 
 vcl/source/gdi/sallayout.cxx|4 -
 3 files changed, 2 insertions(+), 99 deletions(-)

New commits:
commit 736adbb4687eaa6b6a7a350a6452df2eceaad960
Author: Khaled Hosny 
Date:   Thu May 23 09:34:27 2013 +0200

Fix left to right full justification

I was overloading ApplyDXArray() with a HarfBuzz specific implementation
because the GenericSalLayout one was screwing right to left kerning, but
it seems to have broken left to right full justifications. Since
mnXOffset was introduced a bit earlier to fix a similar issue, it can
now be used here as well to minimize the possible side effects.

Seems to work fine for both left to right and right to left text now,
but at least one of my Arabic tests is regressing, so might need some
tweaking.

Change-Id: I1239b0ec77a4978f981a480400a6d01cda18af79

diff --git a/vcl/generic/glyphs/gcach_layout.cxx 
b/vcl/generic/glyphs/gcach_layout.cxx
index 07f9f76..6ac7fd4 100644
--- a/vcl/generic/glyphs/gcach_layout.cxx
+++ b/vcl/generic/glyphs/gcach_layout.cxx
@@ -90,102 +90,6 @@ void ServerFontLayout::AdjustLayout( ImplLayoutArgs& rArgs )
 }
 }
 
-// apply adjustments to glyph advances, e.g. as a result of justification.
-void ServerFontLayout::ApplyDXArray(ImplLayoutArgs& rArgs)
-{
-if (bUseHarfBuzz)
-{
-if (m_GlyphItems.empty())
-return;
-
-// determine cluster boundaries and x base offset
-const int nCharCount = rArgs.mnEndCharPos - rArgs.mnMinCharPos;
-int* pLogCluster = (int*)alloca(nCharCount * sizeof(int));
-size_t i;
-int n,p;
-long nBasePointX = -1;
-if (mnLayoutFlags & SAL_LAYOUT_FOR_FALLBACK)
-nBasePointX = 0;
-for (p = 0; p < nCharCount; ++p)
-pLogCluster[p] = -1;
-
-for (i = 0; i < m_GlyphItems.size(); ++i)
-{
-n = m_GlyphItems[i].mnCharPos - rArgs.mnMinCharPos;
-if ((n < 0) || (nCharCount <= n))
-continue;
-if (pLogCluster[n] < 0)
-pLogCluster[n] = i;
-if (nBasePointX < 0)
-nBasePointX = m_GlyphItems[i].maLinearPos.X();
-}
-// retarget unresolved pLogCluster[n] to a glyph inside the cluster
-// TODO: better do it while the deleted-glyph markers are still there
-for (n = 0; n < nCharCount; ++n)
-if ((p = pLogCluster[0]) >= 0)
-break;
-if (n >= nCharCount)
-return;
-for (n = 0; n < nCharCount; ++n)
-{
-if (pLogCluster[n] < 0)
-pLogCluster[n] = p;
-else
-p = pLogCluster[n];
-}
-
-// calculate adjusted cluster widths
-sal_Int32* pNewGlyphWidths = (sal_Int32*)alloca(m_GlyphItems.size() * 
sizeof(sal_Int32));
-for (i = 0; i < m_GlyphItems.size(); ++i)
-pNewGlyphWidths[i] = 0;
-
-bool bRTL;
-for (int nCharPos = p = -1; rArgs.GetNextPos(&nCharPos, &bRTL); )
-{
-n = nCharPos - rArgs.mnMinCharPos;
-if ((n < 0) || (nCharCount <= n))  continue;
-
-if (pLogCluster[n] >= 0)
-p = pLogCluster[n];
-if (p >= 0)
-{
-long nDelta = rArgs.mpDXArray[n];
-if(n > 0)
-nDelta -= rArgs.mpDXArray[n - 1];
-pNewGlyphWidths[p] += nDelta * mnUnitsPerPixel;
-}
-}
-
-// move cluster positions using the adjusted widths
-long nDelta = 0;
-for (i = 0; i < m_GlyphItems.size(); ++i)
-{
-if (m_GlyphItems[i].IsClusterStart())
-{
-// calculate original and adjusted cluster width
-int nOldClusterWidth = m_GlyphItems[i].mnNewWidth;
-int nNewClusterWidth = pNewGlyphWidths[i];
-size_t j;
-for (j = i; ++j < m_GlyphItems.size(); )
-{
-if (m_GlyphItems[j].IsClusterStart())
-break;
-if (!m_GlyphItems[j].IsDiacritic()) // #i99367# ignore 
diacritics
-nOldClusterWidth += m_GlyphItems[j].mnNewWidth;
-nNewClusterWidth += pNewGlyphWidths[j];
-}
-nDelta += nNewClusterWidth - nOldClusterWidth;
-}
-m_GlyphItems[i].mnNewWidth = pNewGlyphWidths[i];
-m_GlyphItems[i].maLinearPos.X() += nDelta;
-}
-}
-else
-{
-GenericSalLayout::ApplyDXArray(rArgs);
-}
-}
-
 // ===
 
 static bool lcl_CharIsJoiner(sal_Unicode cChar)
diff --git a/vcl/inc/generic/

[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - vcl/generic vcl/inc vcl/source

2013-05-23 Thread Khaled Hosny
 vcl/generic/glyphs/gcach_layout.cxx |   96 
 vcl/inc/generic/glyphcache.hxx  |1 
 vcl/source/gdi/sallayout.cxx|4 -
 3 files changed, 2 insertions(+), 99 deletions(-)

New commits:
commit 6a46cd31a44bd52fb9838a0d1937255a120a49ff
Author: Khaled Hosny 
Date:   Thu May 23 09:34:27 2013 +0200

Fix left to right full justification

I was overloading ApplyDXArray() with a HarfBuzz specific implementation
because the GenericSalLayout one was screwing right to left kerning, but
it seems to have broken left to right full justifications. Since
mnXOffset was introduced a bit earlier to fix a similar issue, it can
now be used here as well to minimize the possible side effects.

Seems to work fine for both left to right and right to left text now,
but at least one of my Arabic tests is regressing, so might need some
tweaking.

Change-Id: I1239b0ec77a4978f981a480400a6d01cda18af79

diff --git a/vcl/generic/glyphs/gcach_layout.cxx 
b/vcl/generic/glyphs/gcach_layout.cxx
index 07f9f76..6ac7fd4 100644
--- a/vcl/generic/glyphs/gcach_layout.cxx
+++ b/vcl/generic/glyphs/gcach_layout.cxx
@@ -90,102 +90,6 @@ void ServerFontLayout::AdjustLayout( ImplLayoutArgs& rArgs )
 }
 }
 
-// apply adjustments to glyph advances, e.g. as a result of justification.
-void ServerFontLayout::ApplyDXArray(ImplLayoutArgs& rArgs)
-{
-if (bUseHarfBuzz)
-{
-if (m_GlyphItems.empty())
-return;
-
-// determine cluster boundaries and x base offset
-const int nCharCount = rArgs.mnEndCharPos - rArgs.mnMinCharPos;
-int* pLogCluster = (int*)alloca(nCharCount * sizeof(int));
-size_t i;
-int n,p;
-long nBasePointX = -1;
-if (mnLayoutFlags & SAL_LAYOUT_FOR_FALLBACK)
-nBasePointX = 0;
-for (p = 0; p < nCharCount; ++p)
-pLogCluster[p] = -1;
-
-for (i = 0; i < m_GlyphItems.size(); ++i)
-{
-n = m_GlyphItems[i].mnCharPos - rArgs.mnMinCharPos;
-if ((n < 0) || (nCharCount <= n))
-continue;
-if (pLogCluster[n] < 0)
-pLogCluster[n] = i;
-if (nBasePointX < 0)
-nBasePointX = m_GlyphItems[i].maLinearPos.X();
-}
-// retarget unresolved pLogCluster[n] to a glyph inside the cluster
-// TODO: better do it while the deleted-glyph markers are still there
-for (n = 0; n < nCharCount; ++n)
-if ((p = pLogCluster[0]) >= 0)
-break;
-if (n >= nCharCount)
-return;
-for (n = 0; n < nCharCount; ++n)
-{
-if (pLogCluster[n] < 0)
-pLogCluster[n] = p;
-else
-p = pLogCluster[n];
-}
-
-// calculate adjusted cluster widths
-sal_Int32* pNewGlyphWidths = (sal_Int32*)alloca(m_GlyphItems.size() * 
sizeof(sal_Int32));
-for (i = 0; i < m_GlyphItems.size(); ++i)
-pNewGlyphWidths[i] = 0;
-
-bool bRTL;
-for (int nCharPos = p = -1; rArgs.GetNextPos(&nCharPos, &bRTL); )
-{
-n = nCharPos - rArgs.mnMinCharPos;
-if ((n < 0) || (nCharCount <= n))  continue;
-
-if (pLogCluster[n] >= 0)
-p = pLogCluster[n];
-if (p >= 0)
-{
-long nDelta = rArgs.mpDXArray[n];
-if(n > 0)
-nDelta -= rArgs.mpDXArray[n - 1];
-pNewGlyphWidths[p] += nDelta * mnUnitsPerPixel;
-}
-}
-
-// move cluster positions using the adjusted widths
-long nDelta = 0;
-for (i = 0; i < m_GlyphItems.size(); ++i)
-{
-if (m_GlyphItems[i].IsClusterStart())
-{
-// calculate original and adjusted cluster width
-int nOldClusterWidth = m_GlyphItems[i].mnNewWidth;
-int nNewClusterWidth = pNewGlyphWidths[i];
-size_t j;
-for (j = i; ++j < m_GlyphItems.size(); )
-{
-if (m_GlyphItems[j].IsClusterStart())
-break;
-if (!m_GlyphItems[j].IsDiacritic()) // #i99367# ignore 
diacritics
-nOldClusterWidth += m_GlyphItems[j].mnNewWidth;
-nNewClusterWidth += pNewGlyphWidths[j];
-}
-nDelta += nNewClusterWidth - nOldClusterWidth;
-}
-m_GlyphItems[i].mnNewWidth = pNewGlyphWidths[i];
-m_GlyphItems[i].maLinearPos.X() += nDelta;
-}
-}
-else
-{
-GenericSalLayout::ApplyDXArray(rArgs);
-}
-}
-
 // ===
 
 static bool lcl_CharIsJoiner(sal_Unicode cChar)
diff --git a/vcl/inc/generic/

[Libreoffice-commits] core.git: vcl/source

2013-05-23 Thread Khaled Hosny
 vcl/source/gdi/sallayout.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 989225a89b109ca1497021dd4855a2450d13e8b9
Author: Khaled Hosny 
Date:   Thu May 23 22:32:14 2013 +0200

Fix improper glyph positioning with old fonts

Apparently this second mnXOffset is not needed, further more it breaks
some old Microsoft fonts.

Change-Id: Ice033cb6bcb3f1bdfeef31a8406a7a2e5487da97

diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index e795090..31b01b9 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -1098,7 +1098,7 @@ void GenericSalLayout::ApplyDXArray( ImplLayoutArgs& 
rArgs )
 if( m_GlyphItems[j].IsClusterStart() )
 break;
 if( !m_GlyphItems[j].IsDiacritic() ) // #i99367# ignore 
diacritics
-nOldClusterWidth += m_GlyphItems[j].mnNewWidth -  
m_GlyphItems[j].mnXOffset;
+nOldClusterWidth += m_GlyphItems[j].mnNewWidth;
 nNewClusterWidth += pNewGlyphWidths[j];
 }
 const int nDiff = nNewClusterWidth - nOldClusterWidth;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - vcl/source

2013-05-23 Thread Khaled Hosny
 vcl/source/gdi/sallayout.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit cef3f3aac2f7a372e796deac4ee3e8155c5eb697
Author: Khaled Hosny 
Date:   Thu May 23 22:32:14 2013 +0200

Fix improper glyph positioning with old fonts

Apparently this second mnXOffset is not needed, further more it breaks
some old Microsoft fonts.

Change-Id: Ice033cb6bcb3f1bdfeef31a8406a7a2e5487da97

diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index e795090..31b01b9 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -1098,7 +1098,7 @@ void GenericSalLayout::ApplyDXArray( ImplLayoutArgs& 
rArgs )
 if( m_GlyphItems[j].IsClusterStart() )
 break;
 if( !m_GlyphItems[j].IsDiacritic() ) // #i99367# ignore 
diacritics
-nOldClusterWidth += m_GlyphItems[j].mnNewWidth -  
m_GlyphItems[j].mnXOffset;
+nOldClusterWidth += m_GlyphItems[j].mnNewWidth;
 nNewClusterWidth += pNewGlyphWidths[j];
 }
 const int nDiff = nNewClusterWidth - nOldClusterWidth;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - 2 commits - vcl/generic vcl/source

2013-05-25 Thread Khaled Hosny
 vcl/generic/glyphs/gcach_layout.cxx |   20 +++-
 vcl/source/gdi/sallayout.cxx|2 +-
 2 files changed, 20 insertions(+), 2 deletions(-)

New commits:
commit c72955bcb196574f7bc682e7aa301264a8a54635
Author: Khaled Hosny 
Date:   Sat May 25 11:12:56 2013 +0200

Revert "Fix improper glyph positioning with old fonts"

This reverts commit cef3f3aac2f7a372e796deac4ee3e8155c5eb697.

The previous commit addressed the real issue.

Change-Id: I802e5f19e4a4991c316135f3984a1b9a6533a104

diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index 31b01b9..bd7a326 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -1098,7 +1098,7 @@ void GenericSalLayout::ApplyDXArray( ImplLayoutArgs& 
rArgs )
 if( m_GlyphItems[j].IsClusterStart() )
 break;
 if( !m_GlyphItems[j].IsDiacritic() ) // #i99367# ignore 
diacritics
-nOldClusterWidth += m_GlyphItems[j].mnNewWidth;
+nOldClusterWidth += m_GlyphItems[j].mnNewWidth - 
m_GlyphItems[j].mnXOffset;
 nNewClusterWidth += pNewGlyphWidths[j];
 }
 const int nDiff = nNewClusterWidth - nOldClusterWidth;
commit 90c6531caa3ec530ef6e9bf1081d289b16fe53ba
Author: Khaled Hosny 
Date:   Sat May 25 02:24:36 2013 +0200

A hack to fix mark placement in old fonts

We need a way to recognize non spacing marks in fonts lacking GDEF table
(like old Arabic fonts), so I just check for zero advance width and hope
nothing elsewhere will break...

Change-Id: I6fa848e97ba24d71fc9a381ae439e0fb98e50419

diff --git a/vcl/generic/glyphs/gcach_layout.cxx 
b/vcl/generic/glyphs/gcach_layout.cxx
index 6ac7fd4..4fd4cf4 100644
--- a/vcl/generic/glyphs/gcach_layout.cxx
+++ b/vcl/generic/glyphs/gcach_layout.cxx
@@ -428,7 +428,25 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, 
ImplLayoutArgs& rArgs)
 if (bInCluster)
 nGlyphFlags |= GlyphItem::IS_IN_CLUSTER;
 
-if (hb_ot_layout_get_glyph_class(mpHbFace, nGlyphIndex) == 
HB_OT_LAYOUT_GLYPH_CLASS_MARK)
+bool bDiacritic = false;
+if (hb_ot_layout_has_glyph_classes(mpHbFace))
+{
+// the font has GDEF table
+if (hb_ot_layout_get_glyph_class(mpHbFace, nGlyphIndex) == 
HB_OT_LAYOUT_GLYPH_CLASS_MARK)
+bDiacritic = true;
+}
+else
+{
+// the font lacks GDEF table
+// HACK: if the resolved glyph advance is zero assume it is a
+// combining mark.  The whole IS_DIACRITIC concept is a hack to
+// fix the other hacks we use to second-guess glyph advances in
+// ApplyDXArray and the likes and it needs to die
+if (pHbPositions[i].x_advance == 0)
+bDiacritic = true;
+}
+
+if (bDiacritic)
 nGlyphFlags |= GlyphItem::IS_DIACRITIC;
 
 int32_t nXOffset =  pHbPositions[i].x_offset >> 6;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - vcl/generic vcl/source

2013-05-25 Thread Khaled Hosny
 vcl/generic/glyphs/gcach_layout.cxx |   20 +++-
 vcl/source/gdi/sallayout.cxx|2 +-
 2 files changed, 20 insertions(+), 2 deletions(-)

New commits:
commit 0e533770125d57d38e8b5505027ac5359abe40b2
Author: Khaled Hosny 
Date:   Sat May 25 11:12:56 2013 +0200

Revert "Fix improper glyph positioning with old fonts"

This reverts commit cef3f3aac2f7a372e796deac4ee3e8155c5eb697.

The previous commit addressed the real issue.

Change-Id: I802e5f19e4a4991c316135f3984a1b9a6533a104

diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index 31b01b9..bd7a326 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -1098,7 +1098,7 @@ void GenericSalLayout::ApplyDXArray( ImplLayoutArgs& 
rArgs )
 if( m_GlyphItems[j].IsClusterStart() )
 break;
 if( !m_GlyphItems[j].IsDiacritic() ) // #i99367# ignore 
diacritics
-nOldClusterWidth += m_GlyphItems[j].mnNewWidth;
+nOldClusterWidth += m_GlyphItems[j].mnNewWidth - 
m_GlyphItems[j].mnXOffset;
 nNewClusterWidth += pNewGlyphWidths[j];
 }
 const int nDiff = nNewClusterWidth - nOldClusterWidth;
commit 4f3d63efb5d87d93171eb542d28fa83a74cdfcd8
Author: Khaled Hosny 
Date:   Sat May 25 02:24:36 2013 +0200

A hack to fix mark placement in old fonts

We need a way to recognize non spacing marks in fonts lacking GDEF table
(like old Arabic fonts), so I just check for zero advance width and hope
nothing elsewhere will break...

Change-Id: I6fa848e97ba24d71fc9a381ae439e0fb98e50419

diff --git a/vcl/generic/glyphs/gcach_layout.cxx 
b/vcl/generic/glyphs/gcach_layout.cxx
index 6ac7fd4..4fd4cf4 100644
--- a/vcl/generic/glyphs/gcach_layout.cxx
+++ b/vcl/generic/glyphs/gcach_layout.cxx
@@ -428,7 +428,25 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, 
ImplLayoutArgs& rArgs)
 if (bInCluster)
 nGlyphFlags |= GlyphItem::IS_IN_CLUSTER;
 
-if (hb_ot_layout_get_glyph_class(mpHbFace, nGlyphIndex) == 
HB_OT_LAYOUT_GLYPH_CLASS_MARK)
+bool bDiacritic = false;
+if (hb_ot_layout_has_glyph_classes(mpHbFace))
+{
+// the font has GDEF table
+if (hb_ot_layout_get_glyph_class(mpHbFace, nGlyphIndex) == 
HB_OT_LAYOUT_GLYPH_CLASS_MARK)
+bDiacritic = true;
+}
+else
+{
+// the font lacks GDEF table
+// HACK: if the resolved glyph advance is zero assume it is a
+// combining mark.  The whole IS_DIACRITIC concept is a hack to
+// fix the other hacks we use to second-guess glyph advances in
+// ApplyDXArray and the likes and it needs to die
+if (pHbPositions[i].x_advance == 0)
+bDiacritic = true;
+}
+
+if (bDiacritic)
 nGlyphFlags |= GlyphItem::IS_DIACRITIC;
 
 int32_t nXOffset =  pHbPositions[i].x_offset >> 6;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - vcl/generic

2013-05-25 Thread Khaled Hosny
 vcl/generic/glyphs/gcach_ftyp.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 5e2d59e4b910631c802d5c7c42b7411e5a8b8db6
Author: Khaled Hosny 
Date:   Sat May 25 13:14:59 2013 +0200

Fix fdo#64972 - strikethrough displays too high

I was calculating the leading before setting the ascent and descent,
oops.

Change-Id: Ic58ecb1a65cb33715ea06f5e3214c4acbcff1e40

diff --git a/vcl/generic/glyphs/gcach_ftyp.cxx 
b/vcl/generic/glyphs/gcach_ftyp.cxx
index 162ba11..e34b38d 100644
--- a/vcl/generic/glyphs/gcach_ftyp.cxx
+++ b/vcl/generic/glyphs/gcach_ftyp.cxx
@@ -940,7 +940,6 @@ void ServerFont::FetchFontMetric( ImplFontMetricData& rTo, 
long& rFactor ) const
 rTo.mnDescent = 0;
 rTo.mnExtLeading = 0;
 rTo.mnSlant = 0;
-rTo.mnIntLeading = (rTo.mnAscent + rTo.mnDescent) - 
((maFaceFT->units_per_EM + 32) >> 6);
 rTo.mnWidth = mnWidth;
 
 // Calculating ascender and descender:
@@ -994,6 +993,8 @@ void ServerFont::FetchFontMetric( ImplFontMetricData& rTo, 
long& rFactor ) const
 }
 }
 
+rTo.mnIntLeading = (rTo.mnAscent + rTo.mnDescent) - 
((maFaceFT->units_per_EM + 32) >> 6);
+
 if( pOS2 && (pOS2->version != 0x) )
 {
 // map the panose info from the OS2 table to their VCL counterparts
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/generic

2013-05-25 Thread Khaled Hosny
 vcl/generic/glyphs/gcach_ftyp.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 753f5721970805224e8bdfc5b9fdb2611ba9aa34
Author: Khaled Hosny 
Date:   Sat May 25 13:14:59 2013 +0200

Fix fdo#64972 - strikethrough displays too high

I was calculating the leading before setting the ascent and descent,
oops.

Change-Id: Ic58ecb1a65cb33715ea06f5e3214c4acbcff1e40

diff --git a/vcl/generic/glyphs/gcach_ftyp.cxx 
b/vcl/generic/glyphs/gcach_ftyp.cxx
index 162ba11..e34b38d 100644
--- a/vcl/generic/glyphs/gcach_ftyp.cxx
+++ b/vcl/generic/glyphs/gcach_ftyp.cxx
@@ -940,7 +940,6 @@ void ServerFont::FetchFontMetric( ImplFontMetricData& rTo, 
long& rFactor ) const
 rTo.mnDescent = 0;
 rTo.mnExtLeading = 0;
 rTo.mnSlant = 0;
-rTo.mnIntLeading = (rTo.mnAscent + rTo.mnDescent) - 
((maFaceFT->units_per_EM + 32) >> 6);
 rTo.mnWidth = mnWidth;
 
 // Calculating ascender and descender:
@@ -994,6 +993,8 @@ void ServerFont::FetchFontMetric( ImplFontMetricData& rTo, 
long& rFactor ) const
 }
 }
 
+rTo.mnIntLeading = (rTo.mnAscent + rTo.mnDescent) - 
((maFaceFT->units_per_EM + 32) >> 6);
+
 if( pOS2 && (pOS2->version != 0x) )
 {
 // map the panose info from the OS2 table to their VCL counterparts
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sw/source

2013-05-27 Thread Khaled Hosny
 sw/source/core/txtnode/swfont.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 6e6b028164176e39219dccbe1b84380b10b6e64f
Author: Khaled Hosny 
Date:   Sat May 25 14:33:46 2013 +0200

Fix fdo#64685 - Superscript broken in master

After f22006dc6ac34a35a060e15466cf6b2d2058617d the position member of
SwDrawTextInfo is no longer a pointer, so changing the passed Point
after calling SetPos() has no effect, but some code seems to be relying
on it being pointer. Moving SetPos() to after changing the point seems
to do the trick, but there may be other similarly broken code like
SwSubFont::_DrawStretchText() below.

Change-Id: I2f563c1543ff7bff68e573f69fce39694181b370
Reviewed-on: https://gerrit.libreoffice.org/4032
Reviewed-by: David Tardon 
Tested-by: David Tardon 

diff --git a/sw/source/core/txtnode/swfont.cxx 
b/sw/source/core/txtnode/swfont.cxx
index 02b5add..068fd71 100644
--- a/sw/source/core/txtnode/swfont.cxx
+++ b/sw/source/core/txtnode/swfont.cxx
@@ -850,12 +850,12 @@ void SwSubFont::_DrawText( SwDrawTextInfo &rInf, const 
sal_Bool bGrey )
 SwDigitModeModifier aDigitModeModifier( rInf.GetOut(), 
rInf.GetFont()->GetLanguage() );
 
 Point aPos( rInf.GetPos() );
-const Point &rOld = rInf.GetPos();
-rInf.SetPos( aPos );
 
 if( GetEscapement() )
 CalcEsc( rInf, aPos );
 
+const Point &rOld = rInf.GetPos();
+rInf.SetPos( aPos );
 rInf.SetKern( CheckKerning() + rInf.GetSperren() / 
SPACING_PRECISION_FACTOR );
 
 if( IsCapital() )
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - sw/source

2013-05-27 Thread Khaled Hosny
 sw/source/core/txtnode/swfont.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 0c0e7f1bd48d1a89ccdba3f5e773186123943e43
Author: Khaled Hosny 
Date:   Sat May 25 14:33:46 2013 +0200

Fix fdo#64685 - Superscript broken in master

After f22006dc6ac34a35a060e15466cf6b2d2058617d the position member of
SwDrawTextInfo is no longer a pointer, so changing the passed Point
after calling SetPos() has no effect, but some code seems to be relying
on it being pointer. Moving SetPos() to after changing the point seems
to do the trick, but there may be other similarly broken code like
SwSubFont::_DrawStretchText() below.

Change-Id: I2f563c1543ff7bff68e573f69fce39694181b370
Reviewed-on: https://gerrit.libreoffice.org/4032
Reviewed-by: David Tardon 
Tested-by: David Tardon 
(cherry picked from commit 6e6b028164176e39219dccbe1b84380b10b6e64f)

Signed-off-by: David Tardon 

diff --git a/sw/source/core/txtnode/swfont.cxx 
b/sw/source/core/txtnode/swfont.cxx
index 02b5add..068fd71 100644
--- a/sw/source/core/txtnode/swfont.cxx
+++ b/sw/source/core/txtnode/swfont.cxx
@@ -850,12 +850,12 @@ void SwSubFont::_DrawText( SwDrawTextInfo &rInf, const 
sal_Bool bGrey )
 SwDigitModeModifier aDigitModeModifier( rInf.GetOut(), 
rInf.GetFont()->GetLanguage() );
 
 Point aPos( rInf.GetPos() );
-const Point &rOld = rInf.GetPos();
-rInf.SetPos( aPos );
 
 if( GetEscapement() )
 CalcEsc( rInf, aPos );
 
+const Point &rOld = rInf.GetPos();
+rInf.SetPos( aPos );
 rInf.SetKern( CheckKerning() + rInf.GetSperren() / 
SPACING_PRECISION_FACTOR );
 
 if( IsCapital() )
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


Re: On which platforms is graphite not supported ?

2013-05-29 Thread Khaled Hosny
On Wed, May 29, 2013 at 09:43:29AM +0200, Francois Tigeot wrote:
> On which platform(s) can't we use graphite ? Mac OS X ?

Yes, AFAICT, that is the only platform where VCL does not has a
Graphite-enabled layout.
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


[Libreoffice-commits] core.git: Changes to 'feature/dematurize01'

2013-06-02 Thread Khaled Hosny
New branch 'feature/dematurize01' available with the following commits:
commit 8ae39ee1f49ee86b01e3a5d36f236a22b1c1d95c
Author: Khaled Hosny 
Date:   Sun Jun 2 15:20:47 2013 +0200

WaE: -Wunused-parameter

Change-Id: I9e14a245d75943750678441210374f9259c5b6b8

commit 41e1305ff9dc77aa783c9750782041e94e9f3930
Author: Khaled Hosny 
Date:   Sun Jun 2 14:33:46 2013 +0200

Incomplete attempt to fix ATSUI code

Still not buildable, but I'm not going to put too much effort into this.

Change-Id: Ibd93e7613bffbb13018951061a3a48582c5d640f

commit d860439c6d1d9f18c5419cb722038064053d2231
Author: Khaled Hosny 
Date:   Sun Jun 2 12:43:36 2013 +0200

Make it compile

Change-Id: I592158bd60afcbe756c6f0e11aa69a44768a0985

commit 610cbfcb1761d37d3e1269ea13f04055bdc363fb
Author: Khaled Hosny 
Date:   Sat Jun 1 17:12:29 2013 +0200

Cherry-pick Core Text port from AOO

Manually picked from:

http://svn.apache.org/viewvc?view=revision&sortby=log&revision=1480384

Author: hdu
Date:   Wed May 8 18:14:34 2013 UTC (3 weeks, 2 days ago)
Changed paths:  55
Log Message:#i122195# add VCL support for 64bit OSX>=10.7

Change-Id: Ia799d7fdeb257e9bfd311338dcfdf97caf9d191f

commit 9d49269893630bdc882bd4c3d79c0ac3ceba5888
Author: Khaled Hosny 
Date:   Sat Jun 1 15:16:40 2013 +0200

Prepare for next commit

Change-Id: I7d709373bb875de22ec0c233af11d6203b6405a8

___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: cui/uiconfig

2013-06-03 Thread Khaled Hosny
 cui/uiconfig/ui/paragalignpage.ui |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit cfd41ac7e7084e1eacfec9fa08a099510058791b
Author: Khaled Hosny 
Date:   Mon Jun 3 14:18:19 2013 +0200

Fix typo after conversion to .ui

The last item in the list was Justified not Right before the conversion.

Change-Id: I6bf8446963df67d26bc8c210bdbdde73a1d3b6e1

diff --git a/cui/uiconfig/ui/paragalignpage.ui 
b/cui/uiconfig/ui/paragalignpage.ui
index 0119414..68238bc 100644
--- a/cui/uiconfig/ui/paragalignpage.ui
+++ b/cui/uiconfig/ui/paragalignpage.ui
@@ -447,7 +447,7 @@
 2
   
   
-Right
+Justified
 3
   
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - vcl/coretext

2013-06-03 Thread Khaled Hosny
 vcl/coretext/salgdi2.cxx |   87 +--
 1 file changed, 17 insertions(+), 70 deletions(-)

New commits:
commit 5e33f1c09b5dcfaa9cabdf1711c9a173514a1c7b
Author: Khaled Hosny 
Date:   Mon Jun 3 23:55:58 2013 +0200

Use Core Text font manager instead of deprecated ATS

Change-Id: I660a895a227da3d28a0b410c56f2395961a5bc4f

diff --git a/vcl/coretext/salgdi2.cxx b/vcl/coretext/salgdi2.cxx
index c543912..2f7da5b 100644
--- a/vcl/coretext/salgdi2.cxx
+++ b/vcl/coretext/salgdi2.cxx
@@ -54,11 +54,6 @@ SystemFontList::~SystemFontList( void )
 {}
 
 
-// ATSUI is deprecated in 10.6 (or already 10.5?)
-#if HAVE_GCC_PRAGMA_DIAGNOSTIC_MODIFY
-#pragma GCC diagnostic warning "-Wdeprecated-declarations"
-#endif
-
 // ===
 
 ImplMacTextStyle::ImplMacTextStyle( const FontSelectPattern& rReqFont )
@@ -377,22 +372,17 @@ sal_uLong AquaSalGraphics::GetKernPairs( sal_uLong, 
ImplKernPairData* )
 
 static bool AddTempFontDir( const char* pDir )
 {
-FSRef aPathFSRef;
-Boolean bIsDirectory = true;
-OSStatus eStatus = FSPathMakeRef( reinterpret_cast(pDir), 
&aPathFSRef, &bIsDirectory );
-DBG_ASSERTWARNING( (eStatus==noErr) && bIsDirectory, "vcl AddTempFontDir() 
with invalid directory name!" );
-if( eStatus != noErr )
-return false;
+CFStringRef rDir = CFStringCreateWithCString(NULL, pDir, 
kCFStringEncodingUTF8);
+CFURLRef rDirURL = CFURLCreateWithFileSystemPath(NULL, rDir, 
kCFURLPOSIXPathStyle, true);
 
-// TODO: deactivate ATSFontContainerRef when closing app
-ATSFontContainerRef aATSFontContainer;
+CFErrorRef error;
+bool success = CTFontManagerRegisterFontsForURL(rDirURL, 
kCTFontManagerScopeProcess, &error);
 
-const ATSFontContext eContext = kATSFontContextLocal; // TODO: *Global???
-eStatus = ::ATSFontActivateFromFileReference( &aPathFSRef,
-eContext, kATSFontFormatUnspecified, NULL, kATSOptionFlagsDefault,
-&aATSFontContainer );
-if( eStatus != noErr )
+if (!success)
+{
+CFRelease(error);
 return false;
+}
 
 return true;
 }
@@ -454,26 +444,20 @@ bool AquaSalGraphics::AddTempDevFont( ImplDevFontList*,
 {
 OUString aUSytemPath;
 OSL_VERIFY( !osl::FileBase::getSystemPathFromFileURL( rFontFileURL, 
aUSytemPath ) );
-
-FSRef aNewRef;
-Boolean bIsDirectory = true;
 OString aCFileName = OUStringToOString( aUSytemPath, RTL_TEXTENCODING_UTF8 
);
-OSStatus eStatus = FSPathMakeRef( (UInt8*)aCFileName.getStr(), &aNewRef, 
&bIsDirectory );
-DBG_ASSERT( (eStatus==noErr) && !bIsDirectory, "vcl AddTempDevFont() with 
invalid fontfile name!" );
-if( eStatus != noErr )
-return false;
 
-ATSFontContainerRef oContainer;
+CFStringRef rDir = CFStringCreateWithCString(NULL, aCFileName.getStr(), 
kCFStringEncodingUTF8);
+CFURLRef rDirURL = CFURLCreateWithFileSystemPath(NULL, rDir, 
kCFURLPOSIXPathStyle, true);
+
+CFErrorRef error;
+bool success = CTFontManagerRegisterFontsForURL(rDirURL, 
kCTFontManagerScopeProcess, &error);
 
-const ATSFontContext eContext = kATSFontContextLocal; // TODO: *Global???
-eStatus = ::ATSFontActivateFromFileReference( &aNewRef,
-eContext, kATSFontFormatUnspecified, NULL, kATSOptionFlagsDefault,
-&oContainer );
-if( eStatus != noErr )
+if (!success)
+{
+CFRelease(error);
 return false;
+}
 
-// TODO: ATSFontDeactivate( oContainer ) when fonts are no longer needed
-// TODO: register new ImplMacFontdata in pFontList
 return true;
 }
 
commit 06fe77331d1ad8eb2e5a158bb1cb083daaf1f910
Author: Khaled Hosny 
Date:   Mon Jun 3 23:01:56 2013 +0200

Drop ENABLE_CORETEXT

This file is Core Text only already.

Change-Id: Ic4c1f44296eaae582091e515d3ca1b4aa227301e

diff --git a/vcl/coretext/salgdi2.cxx b/vcl/coretext/salgdi2.cxx
index 74c906f..c543912 100644
--- a/vcl/coretext/salgdi2.cxx
+++ b/vcl/coretext/salgdi2.cxx
@@ -38,11 +38,7 @@
 
 #include "coretext/salgdi2.h"
 #include "aqua/salframe.h"
-#ifdef ENABLE_CORETEXT
 #include "ctfonts.hxx"
-#else
-#include "atsfonts.hxx"
-#endif
 
 #include "fontsubset.hxx"
 #include "impfont.hxx"
@@ -436,15 +432,9 @@ void AquaSalGraphics::GetDevFontList( ImplDevFontList* 
pFontList )
 // through it as should be all event handlers
 
 SalData* pSalData = GetSalData();
-#ifdef ENABLE_CORETEXT
 SystemFontList* GetCoretextFontList(void); // forward declaration
 if( !pSalData->mpFontList )
 pSalData->mpFontList = GetCoretextFontList();
-#else
-SystemFontList* GetAtsFontList(void);  // forward declaration
-if( !pSalData->mpFontList )
-pSalData->mpFontList = GetAtsFontList();
-#endif
 
 // Copy all PhysicalFontFace o

[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - 2 commits - vcl/coretext

2013-06-03 Thread Khaled Hosny
 vcl/coretext/salgdi2.cxx |   87 +--
 1 file changed, 17 insertions(+), 70 deletions(-)

New commits:
commit eddf277c992b80282e0b49325b3138de5a3a2509
Author: Khaled Hosny 
Date:   Mon Jun 3 23:01:56 2013 +0200

Drop ENABLE_CORETEXT

This file is Core Text only already.

Change-Id: Ic4c1f44296eaae582091e515d3ca1b4aa227301e

diff --git a/vcl/coretext/salgdi2.cxx b/vcl/coretext/salgdi2.cxx
index ba076a7..2f7da5b 100644
--- a/vcl/coretext/salgdi2.cxx
+++ b/vcl/coretext/salgdi2.cxx
@@ -38,11 +38,7 @@
 
 #include "coretext/salgdi2.h"
 #include "aqua/salframe.h"
-#ifdef ENABLE_CORETEXT
 #include "ctfonts.hxx"
-#else
-#include "atsfonts.hxx"
-#endif
 
 #include "fontsubset.hxx"
 #include "impfont.hxx"
@@ -426,15 +422,9 @@ void AquaSalGraphics::GetDevFontList( ImplDevFontList* 
pFontList )
 // through it as should be all event handlers
 
 SalData* pSalData = GetSalData();
-#ifdef ENABLE_CORETEXT
 SystemFontList* GetCoretextFontList(void); // forward declaration
 if( !pSalData->mpFontList )
 pSalData->mpFontList = GetCoretextFontList();
-#else
-SystemFontList* GetAtsFontList(void);  // forward declaration
-if( !pSalData->mpFontList )
-pSalData->mpFontList = GetAtsFontList();
-#endif
 
 // Copy all PhysicalFontFace objects contained in the SystemFontList
 pSalData->mpFontList->AnnounceFonts( *pFontList );
@@ -854,33 +844,6 @@ SystemFontData AquaSalGraphics::GetSysFontData( int /* 
nFallbacklevel */ ) const
 SystemFontData aSysFontData;
 aSysFontData.nSize = sizeof( SystemFontData );
 
-#ifndef ENABLE_CORETEXT
-// NOTE: Native ATSU font fallbacks are used, not the VCL fallbacks.
-ATSUFontID fontId;
-OSStatus err;
-err = ATSUGetAttribute( maATSUStyle, kATSUFontTag, sizeof(fontId), 
&fontId, 0 );
-if (err) fontId = 0;
-aSysFontData.aATSUFontID = (void *) fontId;
-
-Boolean bFbold;
-err = ATSUGetAttribute( maATSUStyle, kATSUQDBoldfaceTag, sizeof(bFbold), 
&bFbold, 0 );
-if (err) bFbold = FALSE;
-aSysFontData.bFakeBold = (bool) bFbold;
-
-Boolean bFItalic;
-err = ATSUGetAttribute( maATSUStyle, kATSUQDItalicTag, sizeof(bFItalic), 
&bFItalic, 0 );
-if (err) bFItalic = FALSE;
-aSysFontData.bFakeItalic = (bool) bFItalic;
-
-ATSUVerticalCharacterType aVerticalCharacterType;
-err = ATSUGetAttribute( maATSUStyle, kATSUVerticalCharacterTag, 
sizeof(aVerticalCharacterType), &aVerticalCharacterType, 0 );
-if (!err && aVerticalCharacterType == kATSUStronglyVertical) {
-aSysFontData.bVerticalCharacterType = true;
-} else {
-aSysFontData.bVerticalCharacterType = false;
-}
-#endif
-
 aSysFontData.bAntialias = !mbNonAntialiasedText;
 
 return aSysFontData;
commit b0dc4032e746575cc3a66155782a57774890e94d
Author: Khaled Hosny 
Date:   Mon Jun 3 23:55:58 2013 +0200

Use Core Text font manager instead of deprecated ATS

Change-Id: I660a895a227da3d28a0b410c56f2395961a5bc4f

diff --git a/vcl/coretext/salgdi2.cxx b/vcl/coretext/salgdi2.cxx
index 74c906f..ba076a7 100644
--- a/vcl/coretext/salgdi2.cxx
+++ b/vcl/coretext/salgdi2.cxx
@@ -58,11 +58,6 @@ SystemFontList::~SystemFontList( void )
 {}
 
 
-// ATSUI is deprecated in 10.6 (or already 10.5?)
-#if HAVE_GCC_PRAGMA_DIAGNOSTIC_MODIFY
-#pragma GCC diagnostic warning "-Wdeprecated-declarations"
-#endif
-
 // ===
 
 ImplMacTextStyle::ImplMacTextStyle( const FontSelectPattern& rReqFont )
@@ -381,22 +376,17 @@ sal_uLong AquaSalGraphics::GetKernPairs( sal_uLong, 
ImplKernPairData* )
 
 static bool AddTempFontDir( const char* pDir )
 {
-FSRef aPathFSRef;
-Boolean bIsDirectory = true;
-OSStatus eStatus = FSPathMakeRef( reinterpret_cast(pDir), 
&aPathFSRef, &bIsDirectory );
-DBG_ASSERTWARNING( (eStatus==noErr) && bIsDirectory, "vcl AddTempFontDir() 
with invalid directory name!" );
-if( eStatus != noErr )
-return false;
+CFStringRef rDir = CFStringCreateWithCString(NULL, pDir, 
kCFStringEncodingUTF8);
+CFURLRef rDirURL = CFURLCreateWithFileSystemPath(NULL, rDir, 
kCFURLPOSIXPathStyle, true);
 
-// TODO: deactivate ATSFontContainerRef when closing app
-ATSFontContainerRef aATSFontContainer;
+CFErrorRef error;
+bool success = CTFontManagerRegisterFontsForURL(rDirURL, 
kCTFontManagerScopeProcess, &error);
 
-const ATSFontContext eContext = kATSFontContextLocal; // TODO: *Global???
-eStatus = ::ATSFontActivateFromFileReference( &aPathFSRef,
-eContext, kATSFontFormatUnspecified, NULL, kATSOptionFlagsDefault,
-&aATSFontContainer );
-if( eStatus != noErr )
+if (!success)
+{
+CFRelease(error);
 return false;
+}
 
 return true;
 }
@@ -464,26 

[Libreoffice-commits] core.git: vcl/aqua vcl/coretext vcl/inc

2013-06-03 Thread Khaled Hosny
 vcl/aqua/source/gdi/atsui/salgdi.cxx |   42 --
 vcl/coretext/salgdi2.cxx |   43 ---
 vcl/inc/aqua/atsui/salgdi.h  |2 -
 vcl/inc/coretext/salgdi2.h   |2 -
 4 files changed, 89 deletions(-)

New commits:
commit a3e97576aa0a7d7c5d51a8ca2f9d220e7d342d87
Author: Khaled Hosny 
Date:   Tue Jun 4 00:16:06 2013 +0200

Drop "CJK extra leading" crack

It have been unused on Mac OS X since since 2008 (commit
da4d070d9d2d563f6e1401496957b22b51c81ff9).

Change-Id: I4b3eabe71a54021903009310a87319c9caecfd4c

diff --git a/vcl/aqua/source/gdi/atsui/salgdi.cxx 
b/vcl/aqua/source/gdi/atsui/salgdi.cxx
index f4518f9..7a6ce95 100644
--- a/vcl/aqua/source/gdi/atsui/salgdi.cxx
+++ b/vcl/aqua/source/gdi/atsui/salgdi.cxx
@@ -66,7 +66,6 @@ ImplMacFontData::ImplMacFontData( const 
ImplDevFontAttributes& rDFA, ATSUFontID
 ,   mbOs2Read( false )
 ,   mbHasOs2Table( false )
 ,   mbCmapEncodingRead( false )
-,   mbHasCJKSupport( false )
 ,   mbFontCapabilitiesRead( false )
 {}
 
@@ -110,7 +109,6 @@ inline FourCharCode GetTag(const char aTagName[5])
 }
 
 static unsigned GetUShort( const unsigned char* p ){return((p[0]<<8)+p[1]);}
-static unsigned GetUInt( const unsigned char* p ) { 
return((p[0]<<24)+(p[1]<<16)+(p[2]<<8)+p[3]);}
 
 #if MACOSX_SDK_VERSION >= 1070
 extern "C" {
@@ -240,16 +238,6 @@ void ImplMacFontData::ReadOs2Table( void ) const
 
 // parse the OS/2 raw data
 // TODO: also analyze panose info, etc.
-
-// check if the fonts needs the "CJK extra leading" heuristic
-const unsigned char* pOS2map = &aBuffer[0];
-const sal_uInt32 nVersion = GetUShort( pOS2map );
-if( nVersion >= 0x0001 )
-{
-sal_uInt32 ulUnicodeRange2 = GetUInt( pOS2map + 46 );
-if( ulUnicodeRange2 & 0x2DF0 )
-mbHasCJKSupport = true;
-}
 }
 
 void ImplMacFontData::ReadMacCmapEncoding( void ) const
@@ -281,36 +269,6 @@ void ImplMacFontData::ReadMacCmapEncoding( void ) const
 return;
 if( GetUShort( pCmap ) != 0x )
 return;
-
-// check if the fonts needs the "CJK extra leading" heuristic
-int nSubTables = GetUShort( pCmap + 2 );
-
-for( const unsigned char* p = pCmap + 4; --nSubTables >= 0; p += 8 )
-{
-int nPlatform = GetUShort( p );
-if( nPlatform == kFontMacintoshPlatform ) {
-int nEncoding = GetUShort (p + 2 );
-if( nEncoding == kFontJapaneseScript ||
-nEncoding == kFontTraditionalChineseScript ||
-nEncoding == kFontKoreanScript ||
-nEncoding == kFontSimpleChineseScript )
-{
-mbHasCJKSupport = true;
-break;
-}
-}
-}
-}
-
-// ---
-
-bool ImplMacFontData::HasCJKSupport( void ) const
-{
-ReadOs2Table();
-if( !mbHasOs2Table )
-ReadMacCmapEncoding();
-
-return mbHasCJKSupport;
 }
 
 // ===
diff --git a/vcl/coretext/salgdi2.cxx b/vcl/coretext/salgdi2.cxx
index 2f7da5b..774c1d7 100644
--- a/vcl/coretext/salgdi2.cxx
+++ b/vcl/coretext/salgdi2.cxx
@@ -77,7 +77,6 @@ ImplMacFontData::ImplMacFontData( const ImplMacFontData& rSrc 
)
 ,   mbOs2Read( rSrc.mbOs2Read )
 ,   mbHasOs2Table( rSrc.mbHasOs2Table )
 ,   mbCmapEncodingRead( rSrc.mbCmapEncodingRead )
-,   mbHasCJKSupport( rSrc.mbHasCJKSupport )
 {
 if( mpCharMap )
 mpCharMap->AddReference();
@@ -92,7 +91,6 @@ ImplMacFontData::ImplMacFontData( const 
ImplDevFontAttributes& rDFA, sal_IntPtr
 ,   mbOs2Read( false )
 ,   mbHasOs2Table( false )
 ,   mbCmapEncodingRead( false )
-,   mbHasCJKSupport( false )
 ,   mbFontCapabilitiesRead( false )
 {}
 
@@ -121,7 +119,6 @@ ImplFontEntry* 
ImplMacFontData::CreateFontInstance(FontSelectPattern& rFSD) cons
 // ---
 
 static unsigned GetUShort( const unsigned char* p ){return((p[0]<<8)+p[1]);}
-static unsigned GetUInt( const unsigned char* p ) { 
return((p[0]<<24)+(p[1]<<16)+(p[2]<<8)+p[3]);}
 
 const ImplFontCharMap* ImplMacFontData::GetImplFontCharMap() const
 {
@@ -233,16 +230,6 @@ void ImplMacFontData::ReadOs2Table( void ) const
 
 // parse the OS/2 raw data
 // TODO: also analyze panose info, etc.
-
-// check if the fonts needs the "CJK extra leading" heuristic
-const unsigned char* pOS2map = &aBuffer[0];
-const sal_uInt32 nVersion = GetUShort( pOS2map );
-if( nVersion >= 0x0001 )
-{
-sal_uInt32 ulUnicodeRange2 = GetUInt( pOS2map + 46 );
-if( ulUnicodeRange2 & 0x2DF0 )
-mbHasCJKSupport = true;
-}
 }
 
 void ImplMacFontData::ReadMacCmapEncoding( void ) cons

[Libreoffice-commits] core.git: vcl/coretext

2013-06-04 Thread Khaled Hosny
 vcl/coretext/ctlayout.cxx |   27 +++
 1 file changed, 3 insertions(+), 24 deletions(-)

New commits:
commit 46c4e2463d517a7e4f74ee1759d837c799140fc7
Author: Khaled Hosny 
Date:   Tue Jun 4 12:05:33 2013 +0200

Drop the trailing white space crack

Whatever this is, all it seems to do it to cause jitter when editing
text. The only place where this has any use is when editing RTL text
since Core Text seems to always place the trailing space on the right.

Change-Id: I35726775fb2a11761d264238fe702e58bbafd7fd

diff --git a/vcl/coretext/ctlayout.cxx b/vcl/coretext/ctlayout.cxx
index b043747..03ec1bb 100644
--- a/vcl/coretext/ctlayout.cxx
+++ b/vcl/coretext/ctlayout.cxx
@@ -59,7 +59,6 @@ private:
 CTLineRef mpCTLine;
 
 int mnCharCount;// ==mnEndCharPos-mnMinCharPos
-int mnTrailingSpaces;
 
 // to prevent overflows
 // font requests get size limited by downscaling huge fonts
@@ -69,7 +68,6 @@ private:
 // cached details about the resulting layout
 // mutable members since these details are all lazy initialized
 mutable double  mfCachedWidth;  // cached value of resulting 
typographical width
-mutable double  mfTrailingSpaceWidth;   // in Pixels
 
 // x-offset relative to layout origin
 // currently only used in RTL-layouts
@@ -83,10 +81,8 @@ CTLayout::CTLayout( const CTTextStyle* pTextStyle )
 ,   mpAttrString( NULL )
 ,   mpCTLine( NULL )
 ,   mnCharCount( 0 )
-,   mnTrailingSpaces( 0 )
 ,   mfFontScale( pTextStyle->mfFontScale )
 ,   mfCachedWidth( -1 )
-,   mfTrailingSpaceWidth( 0 )
 ,   mnBaseAdv( 0 )
 {
 CFRetain( mpTextStyle->GetStyleDict() );
@@ -127,11 +123,6 @@ bool CTLayout::LayoutText( ImplLayoutArgs& rArgs )
 mpCTLine = CTLineCreateWithAttributedString( mpAttrString );
 CFRelease( aCFText);
 
-// get info about trailing whitespace to prepare for text justification in 
AdjustLayout()
-mnTrailingSpaces = 0;
-for( int i = mnEndCharPos; --i >= mnMinCharPos; ++mnTrailingSpaces )
-if( !IsSpacingGlyph( rArgs.mpStr[i] | GF_ISCHAR ))
-break;
 return true;
 }
 
@@ -142,17 +133,10 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs )
 if( !mpCTLine)
 return;
 
-// CoreText fills trailing space during justification so we have to
-// take that into account when requesting CT to justify something
-mfTrailingSpaceWidth = CTLineGetTrailingWhitespaceWidth( mpCTLine );
-const int nTrailingSpaceWidth = rint( mfFontScale * mfTrailingSpaceWidth );
-
 int nOrigWidth = GetTextWidth();
-nOrigWidth -= nTrailingSpaceWidth;
 int nPixelWidth = rArgs.mnLayoutWidth;
 if( nPixelWidth )
 {
-nPixelWidth -= nTrailingSpaceWidth;
 if( nPixelWidth <= 0)
 return;
 }
@@ -160,13 +144,13 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs )
 {
 // for now we are only interested in the layout width
 // TODO: use all mpDXArray elements for layouting
-nPixelWidth = rArgs.mpDXArray[ mnCharCount - 1 - mnTrailingSpaces ];
+nPixelWidth = rArgs.mpDXArray[ mnCharCount - 1 ];
 }
 
 // in RTL-layouts trailing spaces are leftmost
 // TODO: use BiDi-algorithm to thoroughly check this assumption
 if( rArgs.mnFlags & SAL_LAYOUT_BIDI_RTL)
-mnBaseAdv = nTrailingSpaceWidth;
+mnBaseAdv = rint( CTLineGetTrailingWhitespaceWidth( mpCTLine ) * 
mfFontScale );
 
 // return early if there is nothing to do
 if( nPixelWidth <= 0 )
@@ -189,7 +173,6 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs )
 CFRelease( mpCTLine );
 mpCTLine = pNewCTLine;
 mfCachedWidth = -1; // TODO: can we set it directly to target width we 
requested? For now we re-measure
-mfTrailingSpaceWidth = 0;
 }
 
 // ---
@@ -341,10 +324,9 @@ long CTLayout::GetTextWidth() const
 
 if( mfCachedWidth < 0.0 ) {
 mfCachedWidth = CTLineGetTypographicBounds( mpCTLine, NULL, NULL, 
NULL);
-mfTrailingSpaceWidth = CTLineGetTrailingWhitespaceWidth( mpCTLine);
 }
 
-const long nScaledWidth = lrint( mfFontScale * (mfCachedWidth + 
mfTrailingSpaceWidth));
+const long nScaledWidth = lrint( mfFontScale * mfCachedWidth );
 return nScaledWidth;
 }
 
@@ -356,9 +338,6 @@ long CTLayout::FillDXArray( sal_Int32* pDXArray ) const
 if( !pDXArray )
 return GetTextWidth();
 
-// check assumptions
-DBG_ASSERT( mfTrailingSpaceWidth==0.0, "CTLayout::FillDXArray() with 
fTSW!=0" );
-
 long nPixWidth = GetTextWidth();
 if( pDXArray ) {
 // initialize the result array
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - vcl/coretext

2013-06-06 Thread Khaled Hosny
 vcl/coretext/ctlayout.cxx |   27 +++
 1 file changed, 3 insertions(+), 24 deletions(-)

New commits:
commit 2132e8e2145562499f31bfad5e3997cea4042b52
Author: Khaled Hosny 
Date:   Tue Jun 4 12:05:33 2013 +0200

Drop the trailing white space crack

Whatever this is, all it seems to do it to cause jitter when editing
text. The only place where this has any use is when editing RTL text
since Core Text seems to always place the trailing space on the right.

Change-Id: I35726775fb2a11761d264238fe702e58bbafd7fd

diff --git a/vcl/coretext/ctlayout.cxx b/vcl/coretext/ctlayout.cxx
index be9f0e3..e2b44c1 100644
--- a/vcl/coretext/ctlayout.cxx
+++ b/vcl/coretext/ctlayout.cxx
@@ -58,7 +58,6 @@ private:
 CTLineRef mpCTLine;
 
 int mnCharCount;// ==mnEndCharPos-mnMinCharPos
-int mnTrailingSpaces;
 
 // to prevent overflows
 // font requests get size limited by downscaling huge fonts
@@ -68,7 +67,6 @@ private:
 // cached details about the resulting layout
 // mutable members since these details are all lazy initialized
 mutable double  mfCachedWidth;  // cached value of resulting 
typographical width
-mutable double  mfTrailingSpaceWidth;   // in Pixels
 
 // x-offset relative to layout origin
 // currently only used in RTL-layouts
@@ -82,10 +80,8 @@ CTLayout::CTLayout( const CTTextStyle* pTextStyle )
 ,   mpAttrString( NULL )
 ,   mpCTLine( NULL )
 ,   mnCharCount( 0 )
-,   mnTrailingSpaces( 0 )
 ,   mfFontScale( pTextStyle->mfFontScale )
 ,   mfCachedWidth( -1 )
-,   mfTrailingSpaceWidth( 0 )
 ,   mnBaseAdv( 0 )
 {
 CFRetain( mpTextStyle->GetStyleDict() );
@@ -126,11 +122,6 @@ bool CTLayout::LayoutText( ImplLayoutArgs& rArgs )
 mpCTLine = CTLineCreateWithAttributedString( mpAttrString );
 CFRelease( aCFText);
 
-// get info about trailing whitespace to prepare for text justification in 
AdjustLayout()
-mnTrailingSpaces = 0;
-for( int i = mnEndCharPos; --i >= mnMinCharPos; ++mnTrailingSpaces )
-if( !IsSpacingGlyph( rArgs.mpStr[i] | GF_ISCHAR ))
-break;
 return true;
 }
 
@@ -141,17 +132,10 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs )
 if( !mpCTLine)
 return;
 
-// CoreText fills trailing space during justification so we have to
-// take that into account when requesting CT to justify something
-mfTrailingSpaceWidth = CTLineGetTrailingWhitespaceWidth( mpCTLine );
-const int nTrailingSpaceWidth = rint( mfFontScale * mfTrailingSpaceWidth );
-
 int nOrigWidth = GetTextWidth();
-nOrigWidth -= nTrailingSpaceWidth;
 int nPixelWidth = rArgs.mnLayoutWidth;
 if( nPixelWidth )
 {
-nPixelWidth -= nTrailingSpaceWidth;
 if( nPixelWidth <= 0)
 return;
 }
@@ -159,13 +143,13 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs )
 {
 // for now we are only interested in the layout width
 // TODO: use all mpDXArray elements for layouting
-nPixelWidth = rArgs.mpDXArray[ mnCharCount - 1 - mnTrailingSpaces ];
+nPixelWidth = rArgs.mpDXArray[ mnCharCount - 1 ];
 }
 
 // in RTL-layouts trailing spaces are leftmost
 // TODO: use BiDi-algorithm to thoroughly check this assumption
 if( rArgs.mnFlags & SAL_LAYOUT_BIDI_RTL)
-mnBaseAdv = nTrailingSpaceWidth;
+mnBaseAdv = rint( CTLineGetTrailingWhitespaceWidth( mpCTLine ) * 
mfFontScale );
 
 // return early if there is nothing to do
 if( nPixelWidth <= 0 )
@@ -188,7 +172,6 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs )
 CFRelease( mpCTLine );
 mpCTLine = pNewCTLine;
 mfCachedWidth = -1; // TODO: can we set it directly to target width we 
requested? For now we re-measure
-mfTrailingSpaceWidth = 0;
 }
 
 // ---
@@ -340,10 +323,9 @@ long CTLayout::GetTextWidth() const
 
 if( mfCachedWidth < 0.0 ) {
 mfCachedWidth = CTLineGetTypographicBounds( mpCTLine, NULL, NULL, 
NULL);
-mfTrailingSpaceWidth = CTLineGetTrailingWhitespaceWidth( mpCTLine);
 }
 
-const long nScaledWidth = lrint( mfFontScale * (mfCachedWidth + 
mfTrailingSpaceWidth));
+const long nScaledWidth = lrint( mfFontScale * mfCachedWidth );
 return nScaledWidth;
 }
 
@@ -355,9 +337,6 @@ long CTLayout::FillDXArray( sal_Int32* pDXArray ) const
 if( !pDXArray )
 return GetTextWidth();
 
-// check assumptions
-DBG_ASSERT( mfTrailingSpaceWidth==0.0, "CTLayout::FillDXArray() with 
fTSW!=0" );
-
 long nPixWidth = GetTextWidth();
 if( pDXArray ) {
 // initialize the result array
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


Re: [PATCH] Add HarfBuzz support to the build system

2013-04-21 Thread Khaled Hosny
Hi,

I didn't know that it will submit each commit separately (git review),
should I abandon this and the next commits and squash them into one?

Also, there are some unresolved issues that I can't handle, may be
submitting to gerrit wasn't the best idea after all.

Regards,
Khaled

On Sun, Apr 21, 2013 at 08:19:15AM +0000, Khaled Hosny (via Code Review) wrote:
> Hi,
> 
> I have submitted a patch for review:
> 
> https://gerrit.libreoffice.org/3517
> 
> To pull it, you can do:
> 
> git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/17/3517/1
> 
> Add HarfBuzz support to the build system
> 
> To be used in the next commit. No support for non-system build, yet.
> 
> Change-Id: I6ee286d0c050a5ca650e7fb3692b0facccb5f0c0
> ---
> M RepositoryExternal.mk
> M config_host.mk.in
> A config_host/config_harfbuzz.h.in
> M configure.ac
> M vcl/Library_vcl.mk
> 5 files changed, 64 insertions(+), 0 deletions(-)
> 
> 
> 
> diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
> index df44d2d..2707a23 100644
> --- a/RepositoryExternal.mk
> +++ b/RepositoryExternal.mk
> @@ -1186,6 +1186,39 @@
>  
>  endif # SYSTEM_ICU
>  
> +ifeq ($(SYSTEM_HARFBUZZ),YES)
> +
> +define gb_LinkTarget__use_harfbuzz
> +$(call gb_LinkTarget_set_include,$(1),\
> + $$(INCLUDE) \
> + $(HARFBUZZ_CFLAGS) \
> +)
> +$(call gb_LinkTarget_add_libs,$(1),$(HARFBUZZ_LIBS))
> +
> +endef
> +
> +else ifeq ($(SYSTEM_HARFBUZZ),NO)
> +
> +$(eval $(call gb_Helper_register_static_libraries,PLAINLIBS, \
> + harfbuzz \
> +))
> +define gb_LinkTarget__use_harfbuzz
> +$(call gb_LinkTarget_use_unpacked,$(1),harfbuzz)
> +$(call gb_LinkTarget_set_include,$(1),\
> + -I$(call gb_UnpackedTarball_get_dir,harfbuzz/include) \
> + $$(INCLUDE) \
> +)
> +$(call gb_LinkTarget_use_static_libraries,$(1),\
> +harfbuzz \
> +)
> +
> +endef
> +
> +else # DISABLED HARFBUZZ
> +
> +gb_LinkTarget__use_harfbuzz :=
> +
> +endif # SYSTEM_HARFBUZZ
>  
>  ifeq ($(DISABLE_OPENSSL),YES)
>  
> diff --git a/config_host.mk.in b/config_host.mk.in
> index 4256fa7..ad33e7d 100644
> --- a/config_host.mk.in
> +++ b/config_host.mk.in
> @@ -122,6 +122,7 @@
>  export ENABLE_GIO=@ENABLE_GIO@
>  export ENABLE_GNOMEVFS=@ENABLE_GNOMEVFS@
>  export ENABLE_GRAPHITE=@ENABLE_GRAPHITE@
> +export ENABLE_HARFBUZZ=@ENABLE_HARFBUZZ@
>  export ENABLE_GSTREAMER=@ENABLE_GSTREAMER@
>  export ENABLE_GSTREAMER_0_10=@ENABLE_GSTREAMER_0_10@
>  export ENABLE_GTK3=@ENABLE_GTK3@
> @@ -196,6 +197,8 @@
>  export GPERF=@GPERF@
>  export GRAPHITE_CFLAGS=$(gb_SPACE)@GRAPHITE_CFLAGS@
>  export GRAPHITE_LIBS=$(gb_SPACE)@GRAPHITE_LIBS@
> +export HARFBUZZ_CFLAGS=$(gb_SPACE)@HARFBUZZ_CFLAGS@
> +export HARFBUZZ_LIBS=$(gb_SPACE)@HARFBUZZ_LIBS@
>  @x_Cygwin@ export GREP=@WIN_GREP@
>  export GSSAPI_LIBS=@GSSAPI_LIBS@
>  export GSTREAMER_0_10_CFLAGS=$(gb_SPACE)@GSTREAMER_0_10_CFLAGS@
> @@ -478,6 +481,7 @@
>  export SYSTEM_GENCCODE=@SYSTEM_GENCCODE@
>  export SYSTEM_GENCMN=@SYSTEM_GENCMN@
>  export SYSTEM_GRAPHITE=@SYSTEM_GRAPHITE@
> +export SYSTEM_HARFBUZZ=@SYSTEM_HARFBUZZ@
>  export SYSTEM_HSQLDB=@SYSTEM_HSQLDB@
>  export SYSTEM_HUNSPELL=@SYSTEM_HUNSPELL@
>  export SYSTEM_HYPH=@SYSTEM_HYPH@
> diff --git a/config_host/config_harfbuzz.h.in 
> b/config_host/config_harfbuzz.h.in
> new file mode 100644
> index 000..b408f52
> --- /dev/null
> +++ b/config_host/config_harfbuzz.h.in
> @@ -0,0 +1,6 @@
> +#ifndef CONFIG_HARFBUZZ_H
> +#define CONFIG_HARFBUZZ_H
> +
> +#define ENABLE_HARFBUZZ 0
> +
> +#endif
> diff --git a/configure.ac b/configure.ac
> index 2152487..6b844d6 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -720,6 +720,11 @@
>  [Enables the compilation of Graphite smart font rendering.])
>  )
>  
> +AC_ARG_ENABLE(harfbuzz,
> +AS_HELP_STRING([--enable-harfbuzz],
> +[Determines whether to use HarfBuzz text layout engine.])
> +)
> +
>  AC_ARG_ENABLE(fetch-external,
>  AS_HELP_STRING([--disable-fetch-external],
>  [Disables fetching external tarballs from web sources.])
> @@ -8378,6 +8383,20 @@
>  AC_SUBST(ENABLE_GRAPHITE)
>  
>  dnl ===
> +dnl HarfBuzz
> +dnl ===
> +AC_MSG_CHECKING([whether to enable HarfBuzz support])
> +if test "$_os" != "WINNT" -a "$_os" != "Darwin" && test "$enable_harfbuzz" = 
> "" -o "$enable_harfbuzz" != "no"; then
> +AC_MSG_RESULT([yes])
> +ENABLE_HARFBUZZ="TRUE"
> +AC_DEFINE(E

[Libreoffice-commits] core.git: config_host/config_harfbuzz.h.in config_host.mk.in configure.ac download.lst harfbuzz/ExternalPackage_harfbuzz.mk harfbuzz/ExternalProject_harfbuzz.mk harfbuzz/harfbuzz

2013-04-23 Thread Khaled Hosny
 Makefile.fetch   |1 
 RepositoryExternal.mk|   33 
 RepositoryModule_host.mk |1 
 config_host.mk.in|4 +
 config_host/config_harfbuzz.h.in |6 ++
 configure.ac |   20 +++
 download.lst |1 
 harfbuzz/ExternalPackage_harfbuzz.mk |   34 
 harfbuzz/ExternalProject_harfbuzz.mk |   37 +
 harfbuzz/Makefile|7 ++
 harfbuzz/Module_harfbuzz.mk  |   22 
 harfbuzz/README  |1 
 harfbuzz/UnpackedTarball_harfbuzz.mk |   18 ++
 harfbuzz/harfbuzz.configure.patch.1  |   93 +++
 vcl/Library_vcl.mk   |1 
 vcl/Library_vclplug_gen.mk   |1 
 16 files changed, 280 insertions(+)

New commits:
commit 7e389f4def1964ee38bb93b575926a089e84bae6
Author: Khaled Hosny 
Date:   Sat Apr 20 13:00:56 2013 +0200

Add HarfBuzz support to the build system

To be used in the next commit.

Change-Id: I6ee286d0c050a5ca650e7fb3692b0facccb5f0c0
Reviewed-on: https://gerrit.libreoffice.org/3517
Reviewed-by: Fridrich Strba 
Tested-by: Fridrich Strba 

diff --git a/Makefile.fetch b/Makefile.fetch
index bfc882d..e683f28 100644
--- a/Makefile.fetch
+++ b/Makefile.fetch
@@ -112,6 +112,7 @@ $(WORKDIR)/download: $(BUILDDIR)/config_host.mk 
$(SRCDIR)/download.lst $(SRCDIR)
$(call fetch_Optional,GLIBC,$(GLIBC_TARBALL)) \
$(call fetch_Optional,HSQLDB,$(HSQLDB_TARBALL)) \
$(call fetch_Optional,HUNSPELL,$(HUNSPELL_TARBALL)) \
+   $(call fetch_Optional,HARFBUZZ,$(HARFBUZZ_TARBALL)) \
$(call fetch_Optional,HYPHEN,$(HYPHEN_TARBALL)) \
$(call fetch_Optional,ICU,$(ICU_TARBALL)) \
$(call 
fetch_Optional,JFREEREPORT,$(JFREEREPORT_FLOW_ENGINE_TARBALL)) \
diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
index f3ee5dd..807150d 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -1186,6 +1186,39 @@ endef
 
 endif # SYSTEM_ICU
 
+ifeq ($(ENABLE_HARFBUZZ),YES)
+ifeq ($(SYSTEM_HARFBUZZ),YES)
+
+define gb_LinkTarget__use_harfbuzz
+$(call gb_LinkTarget_set_include,$(1),\
+   $$(INCLUDE) \
+   $(HARFBUZZ_CFLAGS) \
+)
+$(call gb_LinkTarget_add_libs,$(1),$(HARFBUZZ_LIBS))
+
+endef
+
+else # SYSTEM_HARFBUZZ != YES
+
+$(eval $(call gb_Helper_register_static_libraries,PLAINLIBS, \
+   harfbuzz \
+))
+define gb_LinkTarget__use_harfbuzz
+$(call gb_LinkTarget_use_package,$(1),\
+   harfbuzz \
+)
+$(call gb_LinkTarget_use_static_libraries,$(1),\
+   harfbuzz \
+)
+
+endef
+
+endif # SYSTEM_HARFBUZZ
+else # ENABLE_HARFBUZZ != YES
+
+gb_LinkTarget__use_harfbuzz :=
+
+endif # ENABLE_HARFBUZZ
 
 ifeq ($(DISABLE_OPENSSL),YES)
 
diff --git a/RepositoryModule_host.mk b/RepositoryModule_host.mk
index b9854f7..1b939f1 100644
--- a/RepositoryModule_host.mk
+++ b/RepositoryModule_host.mk
@@ -72,6 +72,7 @@ $(eval $(call gb_Module_add_moduledirs,libreoffice,\
framework \
$(call gb_Helper_optional,FREETYPE,freetype) \
$(call gb_Helper_optional,GRAPHITE,graphite) \
+   $(call gb_Helper_optional,HARFBUZZ,harfbuzz) \
$(call gb_Helper_optional,DESKTOP,helpcompiler) \
$(call gb_Helper_optional,HELP,helpcontent2) \
$(call gb_Helper_optional,HSQLDB,hsqldb) \
diff --git a/config_host.mk.in b/config_host.mk.in
index 4256fa7..ad33e7d 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -122,6 +122,7 @@ export ENABLE_GCONF=@ENABLE_GCONF@
 export ENABLE_GIO=@ENABLE_GIO@
 export ENABLE_GNOMEVFS=@ENABLE_GNOMEVFS@
 export ENABLE_GRAPHITE=@ENABLE_GRAPHITE@
+export ENABLE_HARFBUZZ=@ENABLE_HARFBUZZ@
 export ENABLE_GSTREAMER=@ENABLE_GSTREAMER@
 export ENABLE_GSTREAMER_0_10=@ENABLE_GSTREAMER_0_10@
 export ENABLE_GTK3=@ENABLE_GTK3@
@@ -196,6 +197,8 @@ export GPERF=@GPERF@
 export GPERF=@GPERF@
 export GRAPHITE_CFLAGS=$(gb_SPACE)@GRAPHITE_CFLAGS@
 export GRAPHITE_LIBS=$(gb_SPACE)@GRAPHITE_LIBS@
+export HARFBUZZ_CFLAGS=$(gb_SPACE)@HARFBUZZ_CFLAGS@
+export HARFBUZZ_LIBS=$(gb_SPACE)@HARFBUZZ_LIBS@
 @x_Cygwin@ export GREP=@WIN_GREP@
 export GSSAPI_LIBS=@GSSAPI_LIBS@
 export GSTREAMER_0_10_CFLAGS=$(gb_SPACE)@GSTREAMER_0_10_CFLAGS@
@@ -478,6 +481,7 @@ export SYSTEM_GENBRK=@SYSTEM_GENBRK@
 export SYSTEM_GENCCODE=@SYSTEM_GENCCODE@
 export SYSTEM_GENCMN=@SYSTEM_GENCMN@
 export SYSTEM_GRAPHITE=@SYSTEM_GRAPHITE@
+export SYSTEM_HARFBUZZ=@SYSTEM_HARFBUZZ@
 export SYSTEM_HSQLDB=@SYSTEM_HSQLDB@
 export SYSTEM_HUNSPELL=@SYSTEM_HUNSPELL@
 export SYSTEM_HYPH=@SYSTEM_HYPH@
diff --git a/config_host/config_harfbuzz.h.in b/config_host/config_harfbuzz.h.in
new file mode 100644
index 000..b408f52
--- /dev/null
+++ b/config_host/config_harfbuzz.h.in
@@ -0,0 +1,6 @@
+#ifndef CONFIG_HARFBUZZ_H
+#define CONFIG_HARFBUZZ_H
+
+#define ENABLE_HARFBUZZ 0
+
+#endif
diff --git a/configure.ac b/configure.ac
index

[Libreoffice-commits] core.git: vcl/generic

2013-04-23 Thread Khaled Hosny
 vcl/generic/glyphs/gcach_layout.cxx |  395 ++--
 1 file changed, 379 insertions(+), 16 deletions(-)

New commits:
commit b760eff8cb65aba99b4527232140926bb4e11e82
Author: Khaled Hosny 
Date:   Sat Apr 20 19:16:54 2013 +0200

Add support for using HarfBuzz instead of ICU LE

HarfBuzz is an up to date, actively maintained OpenType layout engine,
while the ICU LayoutEngine we use now has been unmaintained for a
while now, and existing users are encouraged to switch to HarfBuzz.

This is work in progress, text layout mostly works, but the handling
of combining marks is broken and needs further work, so it is kept
optional for now, with SAL_USE_HARFBUZZ env variable to enable it at
runtime.

Change-Id: I07e698f7486379bae68329771695cd94d6e561b5
Reviewed-on: https://gerrit.libreoffice.org/3518
Reviewed-by: Fridrich Strba 
Tested-by: Fridrich Strba 

diff --git a/vcl/generic/glyphs/gcach_layout.cxx 
b/vcl/generic/glyphs/gcach_layout.cxx
index ddf6d7c..1f9f3d0 100644
--- a/vcl/generic/glyphs/gcach_layout.cxx
+++ b/vcl/generic/glyphs/gcach_layout.cxx
@@ -17,6 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -30,6 +31,10 @@
 #include 
 #include 
 
+#if ENABLE_HARFBUZZ
+#include 
+#include 
+#endif
 #include 
 #include 
 #include 
@@ -87,6 +92,371 @@ void ServerFontLayout::AdjustLayout( ImplLayoutArgs& rArgs )
 }
 
 // ===
+
+static bool lcl_CharIsJoiner(sal_Unicode cChar)
+{
+return ((cChar == 0x200C) || (cChar == 0x200D));
+}
+
+static bool needPreviousCode(sal_Unicode cChar)
+{
+return lcl_CharIsJoiner(cChar) || U16_IS_LEAD(cChar);
+}
+
+static bool needNextCode(sal_Unicode cChar)
+{
+return lcl_CharIsJoiner(cChar) || U16_IS_TRAIL(cChar);
+}
+
+#if ENABLE_HARFBUZZ
+static hb_blob_t *getFontTable(hb_face_t* /*face*/, hb_tag_t nTableTag, void* 
userData)
+{
+char pTagName[5];
+pTagName[0] = (char)(nTableTag >> 24);
+pTagName[1] = (char)(nTableTag >> 16);
+pTagName[2] = (char)(nTableTag >>  8);
+pTagName[3] = (char)(nTableTag);
+pTagName[4] = 0;
+
+ServerFont* rFont = (ServerFont*) userData;
+sal_uLong nLength;
+const unsigned char* pBuffer = rFont->GetTable(pTagName, &nLength);
+
+hb_blob_t* pBlob = NULL;
+if (pBuffer != NULL)
+pBlob = hb_blob_create((const char*) pBuffer, nLength, 
HB_MEMORY_MODE_WRITABLE, (void*) pBuffer, free);
+
+return pBlob;
+}
+
+static hb_bool_t getFontGlyph(hb_font_t* /*font*/, void* fontData,
+hb_codepoint_t ch, hb_codepoint_t vs,
+hb_codepoint_t* nGlyphIndex,
+void* /*userData*/)
+{
+ServerFont* rFont = (ServerFont*) fontData;
+*nGlyphIndex = 0;
+
+if (vs)
+*nGlyphIndex = rFont->GetRawGlyphIndex(ch /*, vs*/); // XXX handle 
variation selectors
+
+if (*nGlyphIndex == 0)
+*nGlyphIndex = rFont->GetRawGlyphIndex(ch);
+
+return *nGlyphIndex != 0;
+}
+
+static hb_position_t getGlyphAdvanceH(hb_font_t* /*font*/, void* fontData,
+hb_codepoint_t nGlyphIndex,
+void* /*userData*/)
+{
+ServerFont* rFont = (ServerFont*) fontData;
+const GlyphMetric& rGM = rFont->GetGlyphMetric(nGlyphIndex);
+return rGM.GetCharWidth();
+}
+
+static hb_position_t getGlyphAdvanceV(hb_font_t* /*font*/, void* /*fontData*/,
+hb_codepoint_t /*nGlyphIndex*/,
+void* /*userData*/)
+{
+// XXX: vertical metrics
+return 0;
+}
+
+static hb_bool_t getGlyphOriginH(hb_font_t* /*font*/, void* /*fontData*/,
+hb_codepoint_t /*nGlyphIndex*/,
+hb_position_t* /*x*/, hb_position_t* /*y*/,
+void* /*userData*/)
+{
+// the horizontal origin is always (0, 0)
+return true;
+}
+
+static hb_bool_t getGlyphOriginV(hb_font_t* /*font*/, void* /*fontData*/,
+hb_codepoint_t /*nGlyphIndex*/,
+hb_position_t* /*x*/, hb_position_t* /*y*/,
+void* /*userData*/)
+{
+// XXX: vertical origin
+return true;
+}
+
+static hb_position_t getGlyphKerningH(hb_font_t* /*font*/, void* fontData,
+hb_codepoint_t nGlyphIndex1, hb_codepoint_t nGlyphIndex2,
+void* /*userData*/)
+{
+// This callback is for old style 'kern' table, GPOS kerning is handled by 
HarfBuzz directly
+
+// XXX: there is ServerFont::GetKernPairs() but it does many "smart" things
+// that I'm not sure about, so I'm using FreeType directly
+// P.S. if we decided not to use ServerFont::GetKernPairs() then it and all
+// other implementattions should be removed, don't seem to be used
+// anywhere.
+
+ServerFont* rFont = (ServerFont*) fontData;
+FT_Face aFace = rFont->GetFtFace();
+
+FT_Error error;
+FT_Vector kerning;
+hb_position_t ret;
+
+error = FT_Get_Kerning(aFace, nGlyphIndex1

[Libreoffice-commits] core.git: vcl/generic

2013-04-23 Thread Khaled Hosny
 vcl/generic/glyphs/gcach_layout.cxx |   12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

New commits:
commit 9d4395540a10916d471579618d7bf3b60cd49140
Author: Khaled Hosny 
Date:   Tue Apr 23 12:39:07 2013 +0200

Fix glyph width calculation in HarfBuzz

Make sure everything is using 16.16 fixed point values consistently.

Change-Id: Icdcd94775d3860d57bb446a3f237c31e35e0710a
Reviewed-on: https://gerrit.libreoffice.org/3573
Reviewed-by: Fridrich Strba 
Tested-by: Fridrich Strba 

diff --git a/vcl/generic/glyphs/gcach_layout.cxx 
b/vcl/generic/glyphs/gcach_layout.cxx
index 1f9f3d0..ca40e9d 100644
--- a/vcl/generic/glyphs/gcach_layout.cxx
+++ b/vcl/generic/glyphs/gcach_layout.cxx
@@ -152,7 +152,7 @@ static hb_position_t getGlyphAdvanceH(hb_font_t* /*font*/, 
void* fontData,
 {
 ServerFont* rFont = (ServerFont*) fontData;
 const GlyphMetric& rGM = rFont->GetGlyphMetric(nGlyphIndex);
-return rGM.GetCharWidth();
+return rGM.GetCharWidth() << 6;
 }
 
 static hb_position_t getGlyphAdvanceV(hb_font_t* /*font*/, void* /*fontData*/,
@@ -415,10 +415,10 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, 
ImplLayoutArgs& rArgs)
 if (hb_ot_layout_get_glyph_class(maHbFace, nGlyphIndex) == 
HB_OT_LAYOUT_GLYPH_CLASS_MARK)
 nGlyphFlags |= GlyphItem::IS_DIACRITIC;
 
-aHbPositions[i].x_offset /= 64;
-aHbPositions[i].y_offset /= 64;
-aHbPositions[i].x_advance /= 64;
-aHbPositions[i].y_advance /= 64;
+aHbPositions[i].x_offset =  aHbPositions[i].x_offset >> 6;
+aHbPositions[i].y_offset =  aHbPositions[i].y_offset >> 6;
+aHbPositions[i].x_advance = aHbPositions[i].x_advance >> 6;
+aHbPositions[i].y_advance = aHbPositions[i].y_advance >> 6;
 
 aNewPos = Point(aNewPos.X() + aHbPositions[i].x_offset, 
aNewPos.Y() - aHbPositions[i].y_offset);
 
@@ -429,7 +429,7 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, 
ImplLayoutArgs& rArgs)
 // instead of nGlyphWidth above, and leave mnNewWidth alone
 // (whatever it is meant for)
 if (i + 1 < nRunGlyphCount)
-aGI.mnNewWidth = nGlyphWidth + (aHbPositions[i + 1].x_offset / 
64);
+aGI.mnNewWidth = nGlyphWidth + (aHbPositions[i + 1].x_offset 
>> 6);
 
 rLayout.AppendGlyph(aGI);
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


Re: Mirroring gtk buttons

2013-03-06 Thread Khaled Hosny
On Wed, Mar 06, 2013 at 05:45:57AM +, Issa Alkurtass wrote:
> Hello world,
> 
> Any idea how to mirror gtk buttons in vcl? I need to mirror the combo
> box buttons in vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx for the RTL
> interface.  (screenshot: http://i.imgur.com/XAnvum8.png)

I thought this issue has been already fixed in 3.5, commit 0608cb3. You
probably have LibreOffice and GTK using two different locales (e.g.
LibreOffice is set to a right-to-left while the system locale is set to
a left-to-right language).

Regards,
Khaled
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: Mirroring gtk buttons

2013-03-06 Thread Khaled Hosny
On Wed, Mar 06, 2013 at 11:38:14AM +, Issa Alkurtass wrote:
> Michael Meeks wrote on March 06, 2013 2:13 PM:
> >Urk - so - then I guess it is a matter of persuading each of our
> >captive gtk2 widgets to have the right RTL setting via:
> >
> >   void gtk_widget_set_direction (GtkWidget*widget,
> >  GtkTextDirection  dir);
> >
> >or perhaps I'm missing something ?
> 
> Something like that yes, but this function is only concerned with text
> direction and ordering of items, not "graphical orientation." We need
> something that flips or mirrors the widgets.

AFAIK, gtk_widget_set_direction () controls the layout of UI elements as
well.

Regards,
Khaled
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: Mirroring gtk buttons

2013-03-06 Thread Khaled Hosny
On Wed, Mar 06, 2013 at 12:05:23PM +, Michael Meeks wrote:
> 
> On Wed, 2013-03-06 at 11:38 +, Issa Alkurtass wrote:
> > Something like that yes, but this function is only concerned with text
> > direction and ordering of items, not "graphical orientation." We need
> > something that flips or mirrors the widgets.
> 
>   Well - I'd have a read around inside the gtk+ widget implementations
> themselves to see what they are using themselves to orient
> themselves :-) then we'll need to clobber that. widget_direction as you
> point out only sounds plausible ;-)

The default direction of GTK widgets is locale dependant; it is set by a
string in GTK's gettext catalogue, so if we can somehow trick GTK to use
the same locale as LibreOffice UI, that would be a solution.

Regards,
Khaled
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [PATCH] fdo#35320 A fix for Arabic justification problem caused by k...

2013-04-28 Thread Khaled Hosny
On Sun, Apr 28, 2013 at 06:04:04AM +, Ahmad Harthi (via Code Review) wrote:
> Hi,
> 
> I have submitted a patch for review:
> 
> https://gerrit.libreoffice.org/3644
> 
> To pull it, you can do:
> 
> git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/44/3644/1
> 
> fdo#35320 A fix for Arabic justification problem caused by kashidas
> 
> diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
> index 9d315e3..d4696c7 100644
> --- a/vcl/source/gdi/sallayout.cxx
> +++ b/vcl/source/gdi/sallayout.cxx
> @@ -1274,7 +1274,7 @@
>  // calculate gap, ignore if too small
>  int nGapWidth = pG->mnNewWidth - pG->mnOrigWidth;
>  // worst case is one kashida even for mini-gaps
> -if( 3 * nGapWidth < nKashidaWidth )
> +if( nGapWidth < nKashidaWidth )
>  continue;
>  
>  nKashidaCount = 0;

Can we have some explanation what the patch is doing? Neither the commit
message nor the bugzilla issue explain the fix.

Regards,
Khaled
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


[Libreoffice-commits] core.git: 9 commits - vcl/generic vcl/inc

2013-04-29 Thread Khaled Hosny
 vcl/generic/glyphs/gcach_layout.cxx |  280 +++-
 vcl/inc/generic/glyphcache.hxx  |   11 +
 vcl/inc/sallayout.hxx   |3 
 3 files changed, 198 insertions(+), 96 deletions(-)

New commits:
commit c559b13b80ab4c8ca4e6ca713bce388ea650e02c
Author: Khaled Hosny 
Date:   Sun Apr 28 15:56:26 2013 +0200

[harfbuzz] Re-enable text justification

It turned out that ApplyDXArray() is need to apply advance width
adjustments after justification, so we can't just bypass it.

So I just copied GenericSalLayout::ApplyDXArray() and stripped it of
ICUism so it does not break with HarfBuzz, but I had to make
m_GlyphItems non-private, so I'm not sure this is the right approach.

Change-Id: I66d647c3590fdf912c39d0cf23ac72bcc7ca72c9

diff --git a/vcl/generic/glyphs/gcach_layout.cxx 
b/vcl/generic/glyphs/gcach_layout.cxx
index f147ab2..abd1ab8 100644
--- a/vcl/generic/glyphs/gcach_layout.cxx
+++ b/vcl/generic/glyphs/gcach_layout.cxx
@@ -106,13 +106,85 @@ void ServerFontLayout::AdjustLayout( ImplLayoutArgs& 
rArgs )
 }
 }
 
+// apply adjustments to glyph advances, e.g. as a result of justification.
 void ServerFontLayout::ApplyDXArray(ImplLayoutArgs& rArgs)
 {
-// No idea what issue ApplyDXArray() was supposed to fix, but whatever
-// GenericSalLayout::ApplyDXArray() does it just breaks our perfectly
-// positioned text.
-if (!bUseHarfBuzz)
+if (bUseHarfBuzz)
+{
+if (m_GlyphItems.empty())
+return;
+
+// determine cluster boundaries and x base offset
+const int nCharCount = rArgs.mnEndCharPos - rArgs.mnMinCharPos;
+int* pLogCluster = (int*)alloca(nCharCount * sizeof(int));
+size_t i;
+int n,p;
+long nBasePointX = -1;
+if (mnLayoutFlags & SAL_LAYOUT_FOR_FALLBACK)
+nBasePointX = 0;
+for (p = 0; p < nCharCount; ++p)
+pLogCluster[p] = -1;
+
+for (i = 0; i < m_GlyphItems.size(); ++i)
+{
+n = m_GlyphItems[i].mnCharPos - rArgs.mnMinCharPos;
+if ((n < 0) || (nCharCount <= n))
+continue;
+if (pLogCluster[n] < 0)
+pLogCluster[n] = i;
+if (nBasePointX < 0)
+nBasePointX = m_GlyphItems[i].maLinearPos.X();
+}
+// retarget unresolved pLogCluster[n] to a glyph inside the cluster
+// TODO: better do it while the deleted-glyph markers are still there
+for (n = 0; n < nCharCount; ++n)
+if ((p = pLogCluster[0]) >= 0)
+break;
+if (n >= nCharCount)
+return;
+for (n = 0; n < nCharCount; ++n)
+{
+if (pLogCluster[n] < 0)
+pLogCluster[n] = p;
+else
+p = pLogCluster[n];
+}
+
+// calculate adjusted cluster widths
+sal_Int32* pNewGlyphWidths = (sal_Int32*)alloca(m_GlyphItems.size() * 
sizeof(sal_Int32));
+for (i = 0; i < m_GlyphItems.size(); ++i)
+pNewGlyphWidths[i] = 0;
+
+bool bRTL;
+for (int nCharPos = p = -1; rArgs.GetNextPos(&nCharPos, &bRTL); )
+{
+n = nCharPos - rArgs.mnMinCharPos;
+if ((n < 0) || (nCharCount <= n))  continue;
+
+if (pLogCluster[n] >= 0)
+p = pLogCluster[n];
+if (p >= 0)
+{
+long nDelta = rArgs.mpDXArray[n];
+if(n > 0)
+nDelta -= rArgs.mpDXArray[n - 1];
+pNewGlyphWidths[p] += nDelta * mnUnitsPerPixel;
+}
+}
+
+// move cluster positions using the adjusted widths
+long nDelta = 0;
+for (i = 0; i < m_GlyphItems.size(); ++i)
+{
+nDelta += pNewGlyphWidths[i] - m_GlyphItems[i].mnNewWidth;
+m_GlyphItems[i].mnNewWidth = pNewGlyphWidths[i];
+m_GlyphItems[i].maLinearPos.X() += nDelta;
+}
+}
+else
+{
 GenericSalLayout::ApplyDXArray(rArgs);
+}
 }
 
 // ===
diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx
index ad6cd94..5d99acb 100644
--- a/vcl/inc/sallayout.hxx
+++ b/vcl/inc/sallayout.hxx
@@ -367,8 +367,9 @@ protected:
 
 boolGetCharWidths( sal_Int32* pCharWidths ) const;
 
-private:
 GlyphVector m_GlyphItems;
+
+private:
 mutable Point   maBasePoint;
 
 // enforce proper copy semantic
commit ca0b580e2a21999d75bcd39ae5b6f81e9e42897b
Author: Khaled Hosny 
Date:   Sun Apr 28 23:06:45 2013 +0200

[harfbuzz] Fix shaping across text runs

The 3rd parameter to hb_buffer_add_utf() should be the length of the
whole text not the current run, so that HarfBuzz can take the context
into account when shaping.

Change-Id: I9e4e928d40078

[Libreoffice-commits] core.git: vcl/generic

2013-04-29 Thread Khaled Hosny
 vcl/generic/glyphs/gcach_layout.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 3719396649c8c944727f89c517a8191cd37b2499
Author: Khaled Hosny 
Date:   Mon Apr 29 22:13:44 2013 +0200

[harfbuzz] Don't crash when closing LibreOffice

We shouldn't be trying to free the font table buffer when destroying the
blob, so pass NULL for destroy function instead of free(), and also use
HB_MEMORY_MODE_READONLY just to be safe.

Change-Id: I85b5a575249b4efc0f5799db205ee17cbeb66d22

diff --git a/vcl/generic/glyphs/gcach_layout.cxx 
b/vcl/generic/glyphs/gcach_layout.cxx
index abd1ab8..5fea884 100644
--- a/vcl/generic/glyphs/gcach_layout.cxx
+++ b/vcl/generic/glyphs/gcach_layout.cxx
@@ -220,7 +220,7 @@ static hb_blob_t *getFontTable(hb_face_t* /*face*/, 
hb_tag_t nTableTag, void* pU
 
 hb_blob_t* pBlob = NULL;
 if (pBuffer != NULL)
-pBlob = hb_blob_create((const char*) pBuffer, nLength, 
HB_MEMORY_MODE_WRITABLE, (void*) pBuffer, free);
+pBlob = hb_blob_create((const char*) pBuffer, nLength, 
HB_MEMORY_MODE_READONLY, (void*) pBuffer, NULL);
 
 return pBlob;
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/generic

2013-05-01 Thread Khaled Hosny
 vcl/generic/glyphs/gcach_layout.cxx |   14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

New commits:
commit 84a8f817e174855ef72f0bafc734847690c5d736
Author: Khaled Hosny 
Date:   Tue Apr 30 17:16:17 2013 +0200

[harfbuzz] Simplify cluster detection

Change-Id: I48c11fad175fe40f48baaa47238f6087b91e6a37

diff --git a/vcl/generic/glyphs/gcach_layout.cxx 
b/vcl/generic/glyphs/gcach_layout.cxx
index 5fea884..a849d9d 100644
--- a/vcl/generic/glyphs/gcach_layout.cxx
+++ b/vcl/generic/glyphs/gcach_layout.cxx
@@ -474,11 +474,9 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, 
ImplLayoutArgs& rArgs)
 hb_glyph_info_t *pHbGlyphInfos = hb_buffer_get_glyph_infos(pHbBuffer, 
NULL);
 hb_glyph_position_t *pHbPositions = 
hb_buffer_get_glyph_positions(pHbBuffer, NULL);
 
-int32_t nLastCluster = -1;
 for (int i = 0; i < nRunGlyphCount; ++i) {
 int32_t nGlyphIndex = pHbGlyphInfos[i].codepoint;
-int32_t nCluster = pHbGlyphInfos[i].cluster;
-int32_t nCharPos = nCluster;
+int32_t nCharPos = pHbGlyphInfos[i].cluster;
 
 // if needed request glyph fallback by updating LayoutArgs
 if (!nGlyphIndex)
@@ -500,16 +498,14 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, 
ImplLayoutArgs& rArgs)
 continue;
 }
 
+bool bInCluster = false;
+if (i > 0 && pHbGlyphInfos[i].cluster == pHbGlyphInfos[i - 
1].cluster)
+bInCluster = true;
+
 long nGlyphFlags = 0;
 if (bRightToLeft)
 nGlyphFlags |= GlyphItem::IS_RTL_GLYPH;
 
-// what is this for?
-// XXX: rtl clusters
-bool bInCluster = false;
-if (nCluster == nLastCluster)
-bInCluster = true;
-nLastCluster = nCluster;
 if (bInCluster)
 nGlyphFlags |= GlyphItem::IS_IN_CLUSTER;
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - vcl/generic

2013-05-01 Thread Khaled Hosny
 vcl/generic/glyphs/gcach_layout.cxx |   16 ++--
 1 file changed, 2 insertions(+), 14 deletions(-)

New commits:
commit 76abedd3bd1c91cac9b239f746243df00a58d060
Author: Khaled Hosny 
Date:   Thu May 2 06:19:38 2013 +0200

[harfbuzz] Fix shaping across text runs, take 2

The 3rd parameter of hb_buffer_add_utf() should be the length of the
whole text not the current run, so that HarfBuzz can take the context
into account when shaping.

Change-Id: I369deb27176cbb136de12872b8a70453d5721bea

diff --git a/vcl/generic/glyphs/gcach_layout.cxx 
b/vcl/generic/glyphs/gcach_layout.cxx
index d562d3b..ad93b9a 100644
--- a/vcl/generic/glyphs/gcach_layout.cxx
+++ b/vcl/generic/glyphs/gcach_layout.cxx
@@ -465,7 +465,7 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, 
ImplLayoutArgs& rArgs)
 hb_buffer_set_direction(pHbBuffer, bRightToLeft ? HB_DIRECTION_RTL: 
HB_DIRECTION_LTR);
 hb_buffer_set_script(pHbBuffer, hb_icu_script_to_script(eScriptCode));
 hb_buffer_set_language(pHbBuffer, 
hb_language_from_string(sLanguage.getStr(), -1));
-hb_buffer_add_utf16(pHbBuffer, rArgs.mpStr, nRunLen, nMinRunPos, 
nRunLen);
+hb_buffer_add_utf16(pHbBuffer, rArgs.mpStr, rArgs.mnLength, 
nMinRunPos, nRunLen);
 hb_shape(pHbFont, pHbBuffer, NULL, 0);
 
 int nRunGlyphCount = hb_buffer_get_length(pHbBuffer);
@@ -480,15 +480,7 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, 
ImplLayoutArgs& rArgs)
 if (!nGlyphIndex)
 {
 if (nCharPos >= 0)
-{
 rArgs.NeedFallback(nCharPos, bRightToLeft);
-// XXX: do we need this? HarfBuzz can take context into
-// account when shaping
-if  ((nCharPos > 0) && 
needPreviousCode(rArgs.mpStr[nCharPos-1]))
-rArgs.NeedFallback(nCharPos-1, bRightToLeft);
-else if  ((nCharPos + 1 < nEndRunPos) && 
needNextCode(rArgs.mpStr[nCharPos+1]))
-rArgs.NeedFallback(nCharPos+1, bRightToLeft);
-}
 
 if (SAL_LAYOUT_FOR_FALLBACK & rArgs.mnFlags)
 continue;
commit 69a120ccc6a8afdb239912f9b4fbbc123e69d4ca
Author: Khaled Hosny 
Date:   Thu May 2 06:13:58 2013 +0200

Revert "[harfbuzz] Fix shaping across text runs"

This reverts commit ca0b580e2a21999d75bcd39ae5b6f81e9e42897b.

diff --git a/vcl/generic/glyphs/gcach_layout.cxx 
b/vcl/generic/glyphs/gcach_layout.cxx
index a849d9d..d562d3b 100644
--- a/vcl/generic/glyphs/gcach_layout.cxx
+++ b/vcl/generic/glyphs/gcach_layout.cxx
@@ -422,10 +422,8 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, 
ImplLayoutArgs& rArgs)
 ((uint64_t) aFtFace->size->metrics.y_scale * (uint64_t) 
fUnitsPerEM) >> 16);
 hb_font_set_ppem(pHbFont, aFtFace->size->metrics.x_ppem, 
aFtFace->size->metrics.y_ppem);
 
-int nTextLen = rArgs.mnEndCharPos - rArgs.mnMinCharPos;
-
 // allocate temporary arrays, note: round to even
-int nGlyphCapacity = (3 * nTextLen | 15) + 1;
+int nGlyphCapacity = (3 * (rArgs.mnEndCharPos - rArgs.mnMinCharPos) | 15) 
+ 1;
 
 rLayout.Reserve(nGlyphCapacity);
 
@@ -467,7 +465,7 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, 
ImplLayoutArgs& rArgs)
 hb_buffer_set_direction(pHbBuffer, bRightToLeft ? HB_DIRECTION_RTL: 
HB_DIRECTION_LTR);
 hb_buffer_set_script(pHbBuffer, hb_icu_script_to_script(eScriptCode));
 hb_buffer_set_language(pHbBuffer, 
hb_language_from_string(sLanguage.getStr(), -1));
-hb_buffer_add_utf16(pHbBuffer, rArgs.mpStr, nTextLen, nMinRunPos, 
nRunLen);
+hb_buffer_add_utf16(pHbBuffer, rArgs.mpStr, nRunLen, nMinRunPos, 
nRunLen);
 hb_shape(pHbFont, pHbBuffer, NULL, 0);
 
 int nRunGlyphCount = hb_buffer_get_length(pHbBuffer);
@@ -484,14 +482,12 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, 
ImplLayoutArgs& rArgs)
 if (nCharPos >= 0)
 {
 rArgs.NeedFallback(nCharPos, bRightToLeft);
-#if 0
 // XXX: do we need this? HarfBuzz can take context into
 // account when shaping
 if  ((nCharPos > 0) && 
needPreviousCode(rArgs.mpStr[nCharPos-1]))
 rArgs.NeedFallback(nCharPos-1, bRightToLeft);
 else if  ((nCharPos + 1 < nEndRunPos) && 
needNextCode(rArgs.mpStr[nCharPos+1]))
 rArgs.NeedFallback(nCharPos+1, bRightToLeft);
-#endif
 }
 
 if (SAL_LAYOUT_FOR_FALLBACK & rArgs.mnFlags)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/generic

2013-05-03 Thread Khaled Hosny
 vcl/generic/glyphs/gcach_layout.cxx |   17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

New commits:
commit 405dc9d241f617853c77e60b0b0d41c36b5af33d
Author: Khaled Hosny 
Date:   Fri May 3 23:39:19 2013 +0200

[harfbuzz] Fix placement of multi-glyph clusters

Calculate the delta based on the whole cluster width no just the first
glyph.

This whole ApplyDXArray() business is completely flawed, it is just
trying to second guess information we already had, and then workaround
all bugs it is introducing.

Change-Id: I5f719d7addcb89c9d5662b48ca7cf55cd388b41e

diff --git a/vcl/generic/glyphs/gcach_layout.cxx 
b/vcl/generic/glyphs/gcach_layout.cxx
index fa04dca..fab66ac 100644
--- a/vcl/generic/glyphs/gcach_layout.cxx
+++ b/vcl/generic/glyphs/gcach_layout.cxx
@@ -176,7 +176,22 @@ void ServerFontLayout::ApplyDXArray(ImplLayoutArgs& rArgs)
 long nDelta = 0;
 for (i = 0; i < m_GlyphItems.size(); ++i)
 {
-nDelta += pNewGlyphWidths[i] - m_GlyphItems[i].mnNewWidth;
+if (m_GlyphItems[i].IsClusterStart())
+{
+// calculate original and adjusted cluster width
+int nOldClusterWidth = m_GlyphItems[i].mnNewWidth;
+int nNewClusterWidth = pNewGlyphWidths[i];
+size_t j;
+for (j = i; ++j < m_GlyphItems.size(); )
+{
+if (m_GlyphItems[j].IsClusterStart())
+break;
+if (!m_GlyphItems[j].IsDiacritic()) // #i99367# ignore 
diacritics
+nOldClusterWidth += m_GlyphItems[j].mnNewWidth;
+nNewClusterWidth += pNewGlyphWidths[j];
+}
+nDelta += nNewClusterWidth - nOldClusterWidth;
+}
 m_GlyphItems[i].mnNewWidth = pNewGlyphWidths[i];
 m_GlyphItems[i].maLinearPos.X() += nDelta;
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/generic

2013-05-05 Thread Khaled Hosny
 vcl/generic/glyphs/gcach_layout.cxx |9 +
 1 file changed, 9 insertions(+)

New commits:
commit 784cd10c31e4378e5b9d03791154e01d23867120
Author: Khaled Hosny 
Date:   Sun May 5 21:10:52 2013 +0200

[harfbuzz] Fix vertical text layout

"Fixed" in the sense that it works exactly like the non-HarfBuzz case,
but that is already a bit broken. Need to get rid if the little OpenType
layout engine in ServerFont::ApplyGSUB() and use HarfBuzz's vertical
text layout capabilities.

Change-Id: I32abe385575bd5d1b66e573dfe2fc7f412d02254

diff --git a/vcl/generic/glyphs/gcach_layout.cxx 
b/vcl/generic/glyphs/gcach_layout.cxx
index fab66ac..f7b6907 100644
--- a/vcl/generic/glyphs/gcach_layout.cxx
+++ b/vcl/generic/glyphs/gcach_layout.cxx
@@ -501,6 +501,15 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, 
ImplLayoutArgs& rArgs)
 continue;
 }
 
+// apply vertical flags and glyph substitution
+// XXX: Use HB_DIRECTION_TTB above and apply whatever flags magic
+// FixupGlyphIndex() is doing, minus the GSUB part.
+if (nCharPos >= 0)
+{
+sal_UCS4 aChar = rArgs.mpStr[nCharPos];
+nGlyphIndex = rFont.FixupGlyphIndex(nGlyphIndex, aChar);
+}
+
 bool bInCluster = false;
 if (i > 0 && pHbGlyphInfos[i].cluster == pHbGlyphInfos[i - 
1].cluster)
 bInCluster = true;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - vcl/generic vcl/inc vcl/source

2013-05-05 Thread Khaled Hosny
 vcl/generic/glyphs/gcach_ftyp.cxx   |   29 +++--
 vcl/generic/glyphs/gcach_layout.cxx |8 +---
 vcl/inc/generic/glyphcache.hxx  |2 +-
 vcl/source/gdi/sallayout.cxx|5 -
 4 files changed, 21 insertions(+), 23 deletions(-)

New commits:
commit 9a8f125fa7e63b829471a6722dae3006bb1f57d2
Author: Khaled Hosny 
Date:   Mon May 6 01:40:06 2013 +0200

[harfbuzz] Support Unicode variation selectors

Change-Id: I8c56f45505327857613c39b28da3ae7cc3ad201c

diff --git a/vcl/generic/glyphs/gcach_ftyp.cxx 
b/vcl/generic/glyphs/gcach_ftyp.cxx
index 09a00db..c1d6ddb 100644
--- a/vcl/generic/glyphs/gcach_ftyp.cxx
+++ b/vcl/generic/glyphs/gcach_ftyp.cxx
@@ -1177,7 +1177,7 @@ int ServerFont::ApplyGlyphTransform( int nGlyphFlags,
 
 // ---
 
-int ServerFont::GetRawGlyphIndex( sal_UCS4 aChar ) const
+int ServerFont::GetRawGlyphIndex(sal_UCS4 aChar, sal_UCS4 aVS) const
 {
 if( mpFontInfo->IsSymbolFont() )
 {
@@ -1216,18 +1216,27 @@ int ServerFont::GetRawGlyphIndex( sal_UCS4 aChar ) const
 aChar = aChar*256 + (aTempArray[i] & 0xFF);
 }
 
-// cache glyph indexes in font info to share between different sizes
-int nGlyphIndex = mpFontInfo->GetGlyphIndex( aChar );
-if( nGlyphIndex < 0 )
+int nGlyphIndex = 0;
+// If asked, check first for variant glyph with the given Unicode variation
+// selector. This is quite uncommon so we don't bother with caching here.
+if (aVS)
+nGlyphIndex = FT_Face_GetCharVariantIndex(maFaceFT, aChar, aVS);
+
+if (nGlyphIndex == 0)
 {
-nGlyphIndex = FT_Get_Char_Index( maFaceFT, aChar );
-if( !nGlyphIndex)
+// cache glyph indexes in font info to share between different sizes
+nGlyphIndex = mpFontInfo->GetGlyphIndex( aChar );
+if( nGlyphIndex < 0 )
 {
-// check if symbol aliasing helps
-if( (aChar <= 0x00FF) && mpFontInfo->IsSymbolFont() )
-nGlyphIndex = FT_Get_Char_Index( maFaceFT, aChar | 0xF000 );
+nGlyphIndex = FT_Get_Char_Index( maFaceFT, aChar );
+if( !nGlyphIndex)
+{
+// check if symbol aliasing helps
+if( (aChar <= 0x00FF) && mpFontInfo->IsSymbolFont() )
+nGlyphIndex = FT_Get_Char_Index( maFaceFT, aChar | 0xF000 
);
+}
+mpFontInfo->CacheGlyphIndex( aChar, nGlyphIndex );
 }
-mpFontInfo->CacheGlyphIndex( aChar, nGlyphIndex );
 }
 
 return nGlyphIndex;
diff --git a/vcl/generic/glyphs/gcach_layout.cxx 
b/vcl/generic/glyphs/gcach_layout.cxx
index f7b6907..cb6c195 100644
--- a/vcl/generic/glyphs/gcach_layout.cxx
+++ b/vcl/generic/glyphs/gcach_layout.cxx
@@ -246,13 +246,7 @@ static hb_bool_t getFontGlyph(hb_font_t* /*font*/, void* 
pFontData,
 void* /*pUserData*/)
 {
 ServerFont* pFont = (ServerFont*) pFontData;
-*nGlyphIndex = 0;
-
-if (vs)
-*nGlyphIndex = pFont->GetRawGlyphIndex(ch /*, vs*/); // XXX handle 
variation selectors
-
-if (*nGlyphIndex == 0)
-*nGlyphIndex = pFont->GetRawGlyphIndex(ch);
+*nGlyphIndex = pFont->GetRawGlyphIndex(ch, vs);
 
 return *nGlyphIndex != 0;
 }
diff --git a/vcl/inc/generic/glyphcache.hxx b/vcl/inc/generic/glyphcache.hxx
index cb4ffce..a7e52d9 100644
--- a/vcl/inc/generic/glyphcache.hxx
+++ b/vcl/inc/generic/glyphcache.hxx
@@ -211,7 +211,7 @@ public:
 #endif
 
 int GetGlyphIndex( sal_UCS4 ) const;
-int GetRawGlyphIndex( sal_UCS4 ) const;
+int GetRawGlyphIndex( sal_UCS4, sal_UCS4 = 0 ) const;
 int FixupGlyphIndex( int nGlyphIndex, sal_UCS4 ) const;
 boolGetGlyphOutline( int nGlyphIndex, 
::basegfx::B2DPolyPolygon& ) const;
 boolGetAntialiasAdvice( void ) const;
commit 26ec39fc9f4fecd826983b08b64990ca608e48c4
Author: Khaled Hosny 
Date:   Mon May 6 01:29:33 2013 +0200

Revert "#i103131# in doubt treat unicode variation selectors as 
invisible(cherry picked from commit 179f88dfe5a1eb2ebd051d73b50f1e0af9c12fd9)"

This reverts commit 6840ba613cc46ee65d58612ecabe748d539de9f5.

We don't want this since we can now support variation selectors with
HarfBuzz.

diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index d4696c7..e90f782 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -337,11 +337,6 @@ inline bool IsControlChar( sal_UCS4 cChar )
 // byte order markers and invalid unicode
 if( (cChar == 0xFEFF) || (cChar == 0xFFFE) || (cChar == 0x) )
 return true;
-// variation selectors
-if( (0xFE00 <= cChar) && (cChar <= 0xFE0F) )
-return true;
-if( (0xE0100 <= cChar) && (cChar <= 0x

[Libreoffice-commits] core.git: 3 commits - config_host/config_harfbuzz.h.in configure.ac vcl/generic vcl/inc vcl/source

2013-05-06 Thread Khaled Hosny
 config_host/config_harfbuzz.h.in|6 --
 configure.ac|9 +
 vcl/generic/glyphs/gcach_ftyp.cxx   |2 --
 vcl/generic/glyphs/gcach_layout.cxx |   29 -
 vcl/inc/generic/glyphcache.hxx  |8 
 vcl/inc/sallayout.hxx   |   11 +++
 vcl/source/gdi/sallayout.cxx|2 +-
 7 files changed, 17 insertions(+), 50 deletions(-)

New commits:
commit bff8fa97e16f0f06fddc5545ea36c8bd2b18a580
Author: Khaled Hosny 
Date:   Mon May 6 11:08:29 2013 +0200

Enable HarfBuzz by default

HarfBuzz integration should be functional now, so to give it more wider
testing it is made now a required dependency on non-Windows non-Mac OSs.
By default text layout is now done by HarfBuzz but ICU LayoutEngine is
kept as a fallback and can be enabled with SAL_USE_ICULE env variable.

After 4.1.x is branched, ICU LayoutEngine should be removed completely.

Change-Id: I4fe3beeaf6092f33dd436906c11b83aeafdfbd5d

diff --git a/config_host/config_harfbuzz.h.in b/config_host/config_harfbuzz.h.in
deleted file mode 100644
index b408f52..000
--- a/config_host/config_harfbuzz.h.in
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef CONFIG_HARFBUZZ_H
-#define CONFIG_HARFBUZZ_H
-
-#define ENABLE_HARFBUZZ 0
-
-#endif
diff --git a/configure.ac b/configure.ac
index 75e26bd..cda53d4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -720,11 +720,6 @@ AC_ARG_ENABLE(graphite,
 [Enables the compilation of Graphite smart font rendering.])
 )
 
-AC_ARG_ENABLE(harfbuzz,
-AS_HELP_STRING([--enable-harfbuzz],
-[Determines whether to use HarfBuzz text layout engine.])
-)
-
 AC_ARG_ENABLE(fetch-external,
 AS_HELP_STRING([--disable-fetch-external],
 [Disables fetching external tarballs from web sources.])
@@ -8482,10 +8477,9 @@ dnl 
===
 dnl HarfBuzz
 dnl ===
 AC_MSG_CHECKING([whether to enable HarfBuzz support])
-if test "$_os" != "WINNT" -a "$_os" != "Darwin" && test "$enable_harfbuzz" = 
"" -o "$enable_harfbuzz" != "no"; then
+if test "$_os" != "WINNT" -a "$_os" != "Darwin"; then
 AC_MSG_RESULT([yes])
 ENABLE_HARFBUZZ="TRUE"
-AC_DEFINE(ENABLE_HARFBUZZ)
 libo_CHECK_SYSTEM_MODULE([harfbuzz],[HARFBUZZ],[harfbuzz >= 0.9.10])
 else
 AC_MSG_RESULT([no])
@@ -11978,7 +11972,6 @@ AC_CONFIG_HEADERS([config_host/config_clang.h])
 AC_CONFIG_HEADERS([config_host/config_features.h])
 AC_CONFIG_HEADERS([config_host/config_global.h])
 AC_CONFIG_HEADERS([config_host/config_graphite.h])
-AC_CONFIG_HEADERS([config_host/config_harfbuzz.h])
 AC_CONFIG_HEADERS([config_host/config_lgpl.h])
 AC_CONFIG_HEADERS([config_host/config_kde4.h])
 AC_CONFIG_HEADERS([config_host/config_mingw.h])
diff --git a/vcl/generic/glyphs/gcach_layout.cxx 
b/vcl/generic/glyphs/gcach_layout.cxx
index 935a0e5..7df803f 100644
--- a/vcl/generic/glyphs/gcach_layout.cxx
+++ b/vcl/generic/glyphs/gcach_layout.cxx
@@ -17,7 +17,6 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include 
 #include 
 #include 
 #include 
@@ -31,10 +30,9 @@
 #include 
 #include 
 
-#if ENABLE_HARFBUZZ
 #include 
 #include 
-#endif
+
 #include 
 #include 
 #include 
@@ -50,10 +48,7 @@
 ServerFontLayout::ServerFontLayout( ServerFont& rFont )
 :   mrServerFont( rFont )
 {
-bUseHarfBuzz = false;
-#if ENABLE_HARFBUZZ
-bUseHarfBuzz = (getenv("SAL_USE_HARFBUZZ") != NULL);
-#endif
+bUseHarfBuzz = (getenv("SAL_USE_ICULE") == NULL);
 }
 
 void ServerFontLayout::DrawText( SalGraphics& rSalGraphics ) const
@@ -208,7 +203,6 @@ static bool needNextCode(sal_Unicode cChar)
 return lcl_CharIsJoiner(cChar) || U16_IS_TRAIL(cChar);
 }
 
-#if ENABLE_HARFBUZZ
 static hb_blob_t *getFontTable(hb_face_t* /*face*/, hb_tag_t nTableTag, void* 
pUserData)
 {
 char pTagName[5];
@@ -537,7 +531,6 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, 
ImplLayoutArgs& rArgs)
 
 return true;
 }
-#endif // ENABLE_HARFBUZZ
 
 // ===
 // bridge to ICU LayoutEngine
@@ -1214,12 +1207,10 @@ ServerFontLayoutEngine* 
ServerFont::GetLayoutEngine(bool bUseHarfBuzz)
 {
 // find best layout engine for font, platform, script and language
 if (!mpLayoutEngine) {
-#if ENABLE_HARFBUZZ
 if (bUseHarfBuzz)
 mpLayoutEngine = new HbLayoutEngine(*this);
 else
-#endif
-mpLayoutEngine = new IcuLayoutEngine(*this);
+mpLayoutEngine = new IcuLayoutEngine(*this);
 }
 return mpLayoutEngine;
 }
commit f0393d7ff69011a16b100541ef18e5090544e4a1
Author: Khaled Hosny 
Date:   Mon May 6 16:54:53 2013 +0200

[harfbuzz] Fix text 

[Libreoffice-commits] core.git: vcl/source

2013-05-06 Thread Khaled Hosny
 vcl/source/gdi/outdev3.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 7556ba312ff3a7409b7da55f220d3ff877505a3b
Author: Khaled Hosny 
Date:   Mon May 6 21:41:14 2013 +0200

Surely the intent was to check for !pFallback here

Change-Id: Ia583cfe1d123903ac8f61ad4a224364af7c77ef7

diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx
index c1ee2f0..ffd140c 100644
--- a/vcl/source/gdi/outdev3.cxx
+++ b/vcl/source/gdi/outdev3.cxx
@@ -5967,7 +5967,7 @@ SalLayout* 
OutputDevice::getFallbackFontThatFits(ImplFontEntry &rFallbackFont,
 pFallback->Release();
 pFallback = NULL;
 }
-SAL_WARN_IF(pFallback, "vcl.gdi", "we couldn't layout text with a 
smaller point size that worked with a bigger one");
+SAL_WARN_IF(!pFallback, "vcl.gdi", "we couldn't layout text with a 
smaller point size that worked with a bigger one");
 }
 }
 return pFallback;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - vcl/coretext

2013-05-09 Thread Khaled Hosny
 vcl/coretext/salgdi.cxx |8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

New commits:
commit 543ac5596d0ef3a052973c1ec89a9329d1073dc8
Author: Khaled Hosny 
Date:   Thu May 9 23:49:45 2013 +0200

Minor

Change-Id: I31b95844234135d14f117ae74124350eedf7d20a

diff --git a/vcl/coretext/salgdi.cxx b/vcl/coretext/salgdi.cxx
index 227a5c4..58e850d 100644
--- a/vcl/coretext/salgdi.cxx
+++ b/vcl/coretext/salgdi.cxx
@@ -149,10 +149,10 @@ void QuartzSalGraphics::GetFontMetric( 
ImplFontMetricData* pMetric, int nFallbac
 CTFontRef font = m_style->GetFont();
 DBG_ASSERT(font, "GetFontMetric without font set in style");
 
-pMetric->mnAscent = static_cast( CTFontGetAscent(font) * 
mfFakeDPIScale + 0.5);
+pMetric->mnAscent = static_cast(CTFontGetAscent(font) * 
mfFakeDPIScale + 0.5);
 pMetric->mnDescent = static_cast(CTFontGetDescent(font) * 
mfFakeDPIScale + 0.5);
 pMetric->mnExtLeading = static_cast(CTFontGetLeading(font) * 
mfFakeDPIScale + 0.5);
-pMetric->mnIntLeading   = 0;
+pMetric->mnIntLeading = 0;
 pMetric->mnWidth = m_style->GetFontStretchedSize();
 
 SAL_INFO( "vcl.coretext.gr",
commit 924aeb3d039f4ce554b795532e6948fa9065010b
Author: Khaled Hosny 
Date:   Thu May 9 23:24:17 2013 +0200

[coretext] Fix line spacing

It should have been nExtDescent + pMetric->mnDescent, but then the whole
thing does not make any sense; why add the descent to the leading and
then calculate the leading by subtracting the descent! (well, the ATSUI
code was doing this but it makes no sense either).

Just use CTFontGetLeading() directly.

Change-Id: Ia54648f6c02c11359865f4aa6476adf40b27f906

diff --git a/vcl/coretext/salgdi.cxx b/vcl/coretext/salgdi.cxx
index a462c37..227a5c4 100644
--- a/vcl/coretext/salgdi.cxx
+++ b/vcl/coretext/salgdi.cxx
@@ -151,9 +151,7 @@ void QuartzSalGraphics::GetFontMetric( ImplFontMetricData* 
pMetric, int nFallbac
 
 pMetric->mnAscent = static_cast( CTFontGetAscent(font) * 
mfFakeDPIScale + 0.5);
 pMetric->mnDescent = static_cast(CTFontGetDescent(font) * 
mfFakeDPIScale + 0.5);
-const long nExtDescent  = static_cast((CTFontGetLeading(font) + 
CTFontGetDescent(font)) *
-mfFakeDPIScale + 0.5);
-pMetric->mnExtLeading   = nExtDescent + pMetric->mnDescent;
+pMetric->mnExtLeading = static_cast(CTFontGetLeading(font) * 
mfFakeDPIScale + 0.5);
 pMetric->mnIntLeading   = 0;
 pMetric->mnWidth = m_style->GetFontStretchedSize();
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/coretext

2013-05-10 Thread Khaled Hosny
 vcl/coretext/salcoretextlayout.cxx |   47 +
 1 file changed, 38 insertions(+), 9 deletions(-)

New commits:
commit f2b92a9ab5d1b0c7d3d01db675268b0e1925cdc6
Author: Khaled Hosny 
Date:   Fri May 10 17:05:24 2013 +0200

[coretext] Fix drawing fallback fonts

Core Text will apply its font fallback mechanism when typesetting a
CTLine, and we can't assume that the returned run all use the original
font. This fixes the random glyphs drawn when we hit font fallback.

Change-Id: Id4d7098cb7bd3464cba6abab22be3ac3942c8889
Reviewed-on: https://gerrit.libreoffice.org/3846
Reviewed-by: Tor Lillqvist 
Tested-by: Tor Lillqvist 

diff --git a/vcl/coretext/salcoretextlayout.cxx 
b/vcl/coretext/salcoretextlayout.cxx
index e324ef7..5599747 100644
--- a/vcl/coretext/salcoretextlayout.cxx
+++ b/vcl/coretext/salcoretextlayout.cxx
@@ -76,6 +76,8 @@ private:
 // mutable members since these details are all lazy initialized
 mutable int mnGlyphCount;
 
+mutable CTFontRef* mpGlyphFonts;
+
 mutable CGGlyph* mpGlyphs;
 mutable CGFloat* mpCharWidths;
 mutable int* mpGlyphs2Chars;
@@ -106,6 +108,7 @@ CoreTextLayout::CoreTextLayout(QuartzSalGraphics* graphics, 
CoreTextStyleInfo* s
 mpStyle(style),
 mnCharCount(-1),
 mnGlyphCount(-1),
+mpGlyphFonts(NULL),
 mpGlyphs(NULL),
 mpCharWidths(NULL),
 mpGlyphs2Chars(NULL),
@@ -182,6 +185,10 @@ void CoreTextLayout::Justify( long nNewWidth )
 
 void CoreTextLayout::InvalidateMeasurements()
 {
+if( mpGlyphFonts ) {
+delete[] mpGlyphFonts;
+mpGlyphFonts = NULL;
+}
 if( mpGlyphs ) {
 delete[] mpGlyphs;
 mpGlyphs = NULL;
@@ -213,14 +220,7 @@ void CoreTextLayout::DrawText( SalGraphics& rGraphics ) 
const
 if( mnCharCount <= 0 || !gr.CheckContext() )
 return;
 
-CGFontRef cg_font = CTFontCopyGraphicsFont(mpStyle->GetFont(), NULL);
-if( !cg_font ) {
-SAL_INFO( "vcl.coretext.layout", "Error cg_font is NULL" );
-return;
-}
 CGContextSaveGState( gr.mrContext );
-CGContextSetFont(gr.mrContext, cg_font);
-CGContextSetFontSize(gr.mrContext, CTFontGetSize(mpStyle->GetFont()));
 CGContextSetTextDrawingMode(gr.mrContext, kCGTextFill);
 CGContextSetShouldAntialias( gr.mrContext, true );
 CGContextSetShouldSubpixelPositionFonts( gr.mrContext, false );
@@ -231,7 +231,7 @@ void CoreTextLayout::DrawText( SalGraphics& rGraphics ) 
const
 else {
 CGContextSetRGBFillColor(gr.mrContext, 0.0, 0.0, 0.0, 1.0);
 }
-CFRelease(cg_font);
+
 CGContextSetTextMatrix(gr.mrContext, CGAffineTransformMakeScale(1.0, 
-1.0));
 CGContextSetShouldAntialias( gr.mrContext, !gr.mbNonAntialiasedText );
 
@@ -245,7 +245,30 @@ void CoreTextLayout::DrawText( SalGraphics& rGraphics ) 
const
 
 CGContextTranslateCTM(gr.mrContext, pos.X(), pos.Y());
 
-CGContextShowGlyphsWithAdvances(gr.mrContext, mpGlyphs, mpGlyphAdvances, 
mnGlyphCount);
+int i = 0;
+while (i < mnGlyphCount)
+{
+CTFontRef pCTFont = mpGlyphFonts[i];
+
+// Find the number of glyphs using the same font
+int nGlyphs = 1;
+while ((i + nGlyphs < mnGlyphCount) && CFEqual(mpGlyphFonts[i + 
nGlyphs], pCTFont))
+nGlyphs++;
+
+CGFontRef pCGFont = CTFontCopyGraphicsFont(pCTFont, NULL);
+if (!pCGFont) {
+SAL_INFO("vcl.coretext.layout", "Error pCGFont is NULL");
+return;
+}
+
+CGContextSetFont(gr.mrContext, pCGFont);
+CFRelease(pCGFont);
+CGContextSetFontSize(gr.mrContext, CTFontGetSize(pCTFont));
+
+CGContextShowGlyphsWithAdvances(gr.mrContext, &mpGlyphs[i], 
&mpGlyphAdvances[i], nGlyphs);
+
+i += nGlyphs;
+}
 
 #ifndef IOS
 // Request an update of the changed window area. Like in the ATSUI
@@ -572,6 +595,7 @@ void CoreTextLayout::GetMeasurements()
 {
 InvalidateMeasurements();
 
+mpGlyphFonts = new CTFontRef[ mnGlyphCount ];
 mpGlyphs = new CGGlyph[ mnGlyphCount ];
 mpCharWidths = new CGFloat[ mnCharCount ];
 mpGlyphs2Chars = new int[ mnGlyphCount ];
@@ -588,6 +612,9 @@ void CoreTextLayout::GetMeasurements()
 if ( !run )
 continue;
 
+CFDictionaryRef runAttributes = CTRunGetAttributes(run);
+CTFontRef runFont = (CTFontRef)CFDictionaryGetValue(runAttributes, 
kCTFontAttributeName);
+
 std::ostringstream glyphPositionInfo;
 std::ostringstream glyphAdvancesInfo;
 std::ostringstream charWidthInfo;
@@ -622,6 +649,8 @@ void CoreTextLayout::GetMeasurements()
 mpGlyphs2Chars[ lineGlyphIx ] = charIx;
 
 mpCharWidths[ charIx ] = mpGlyphAdvances[ lineGlyphIx ].width;
+
+mpGlyphFonts[ lineGlyphIx ] = runFont;
 }
 #ifdef SAL_LOG_INFO
 for ( int i = 0

[Libreoffice-commits] core.git: 5 commits - config_host.mk.in configure.ac vcl/generic

2013-05-11 Thread Khaled Hosny
 config_host.mk.in |1 
 configure.ac  |   27 +---
 vcl/generic/glyphs/gcach_ftyp.cxx |  240 +-
 3 files changed, 66 insertions(+), 202 deletions(-)

New commits:
commit fe9def183be4025f8c2ebba5f486fff1c20ecc80
Author: Khaled Hosny 
Date:   Sat May 11 08:44:11 2013 +0200

USE_FT_EMBOLDEN has never been used

Change-Id: Idd30f6fcf9d1e4d2af5f49caffa91d6ce30bb196

diff --git a/config_host.mk.in b/config_host.mk.in
index cfe407c..76ac1a7 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -540,7 +540,6 @@ export UNIXWRAPPERNAME=@UNIXWRAPPERNAME@
 export UNOWINREG_DLL=@UNOWINREG_DLL@
 export UPD=@UPD@
 export URELIBS=@URELIBS@
-export USE_FT_EMBOLDEN=@USE_FT_EMBOLDEN@
 export USE_XINERAMA=@USE_XINERAMA@
 export use_shl_version=@use_shl_version@
 export UUIDGEN=@UUIDGEN@
diff --git a/configure.ac b/configure.ac
index 5aba388..10d0648 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7308,23 +7308,6 @@ dnl Check for system libwpg
 dnl ===
 
libo_CHECK_SYSTEM_MODULE([libwpg],[WPG],[libwpg-0.2],["-I${OUTDIR}/inc/external"],["-L${OUTDIR}/lib
 -lwpglib"])
 
-dnl ===
-dnl Check whether freetype2 supports emboldening
-dnl ===
-if test  "$test_freetype" = "yes"; then
-save_CPPFLAGS="$CPPFLAGS"
-save_LDFLAGS="$LDFLAGS"
-save_LIBS="$LIBS"
-CPPFLAGS="$CPPFLAGS $FREETYPE_CFLAGS"
-LDFLAGS="$LDFLAGS $FREETYPE_LIBS"
-AC_CHECK_LIB(freetype, FT_GlyphSlot_Embolden,
- [USE_FT_EMBOLDEN="YES"], [USE_FT_EMBOLDEN="NO"], [])
-LDFLAGS="$save_LDFLAGS"
-CPPFLAGS="$save_CPPFLAGS"
-LIBS="$save_LIBS"
-fi
-AC_SUBST(USE_FT_EMBOLDEN)
-
 # ===
 # Check for system libxslt
 # to prevent incompatibilities between internal libxml2 and external libxslt,
commit 96137f1ef8e1e2c8787b899edf8b2969c2eff5dc
Author: Khaled Hosny 
Date:   Sat May 11 08:29:46 2013 +0200

Drop code for FreeTyope version we don't support

Change-Id: I404ac35010c243fad65b6d83c10c75665a0568f0

diff --git a/vcl/generic/glyphs/gcach_ftyp.cxx 
b/vcl/generic/glyphs/gcach_ftyp.cxx
index 1b31f2c..9995964 100644
--- a/vcl/generic/glyphs/gcach_ftyp.cxx
+++ b/vcl/generic/glyphs/gcach_ftyp.cxx
@@ -63,13 +63,8 @@
 #endif
 #include "rtl/instance.hxx"
 
-#ifndef FREETYPE_PATCH
-// VERSION_MINOR in freetype.h is too coarse
-// if patch-level is not available we need to fine-tune the version 
ourselves
-#define FTVERSION 2005
-#else
-#define FTVERSION (1000*FREETYPE_MAJOR + 100*FREETYPE_MINOR + 
FREETYPE_PATCH)
-#endif
+#define FTVERSION (1000*FREETYPE_MAJOR + 100*FREETYPE_MINOR + FREETYPE_PATCH)
+
 #if FTVERSION >= 2200
 typedef const FT_Vector* FT_Vector_CPtr;
 #else // FTVERSION < 2200
@@ -521,11 +516,6 @@ FreetypeManager::FreetypeManager()
 pFTLibraryVersion( aLibFT, &nMajor, &nMinor, &nPatch );
 nFTVERSION = nMajor * 1000 + nMinor * 100 + nPatch;
 
-// disable embedded bitmaps for Freetype-2.1.3 unless explicitly
-// requested by env var below because it crashes StarOffice on RH9
-// reason: double free in freetype's embedded bitmap handling
-if( nFTVERSION == 2103 )
-nDefaultPrioEmbedded = 0;
 // disable artificial emboldening with the Freetype API for older versions
 if( nFTVERSION < 2110 )
 pFTEmbolden = NULL;
@@ -716,14 +706,10 @@ ServerFont::ServerFont( const FontSelectPattern& rFSD, 
FtFontInfo* pFI )
 FT_Encoding eEncoding = FT_ENCODING_UNICODE;
 if( mpFontInfo->IsSymbolFont() )
 {
-#if (FTVERSION < 2000)
-eEncoding = FT_ENCODING_NONE;
-#else
 if( FT_IS_SFNT( maFaceFT ) )
 eEncoding = ft_encoding_symbol;
 else
 eEncoding = FT_ENCODING_ADOBE_CUSTOM; // freetype wants this for 
PS symbol fonts
-#endif
 }
 rc = FT_Select_Charmap( maFaceFT, eEncoding );
 // no standard encoding applies => we need an encoding converter
@@ -854,13 +840,11 @@ void ServerFont::SetFontOptions( 
boost::shared_ptr pFontOptions
 if( mpFontOptions->DontUseHinting() )
   mnPrioAutoHint = 0;
 
-#if (FTVERSION >= 2005) || defined(TT_CONFIG_OPTION_BYTECODE_INTERPRETER)
 if( mnPrioAutoHint <= 0 )
-#endif
 mnLoadFlags |= FT_LOAD_NO_HINTING;
 
 #if defined(FT_LOAD_TARGET_LIGHT) && defined(FT_LOAD_TARGET_NORMAL)
-if( !(mnLoadFlags & FT_LOAD_NO_HINTING) && (nFTVERSION >= 2103))
+if( !(mnLoadFlags & FT_LOAD_NO_HINTING) )
 {
mnLoadFlags |= FT_LOAD_TARGET_NORMAL;
switch( mpFontOptions->GetHin

[Libreoffice-commits] core.git: vcl/coretext

2013-05-11 Thread Khaled Hosny
 vcl/coretext/salcoretextlayout.cxx |   62 +
 1 file changed, 30 insertions(+), 32 deletions(-)

New commits:
commit c049df6fdd14fdfd88ded76ac9396efa8877f2c5
Author: Khaled Hosny 
Date:   Sat May 11 21:04:45 2013 +0200

[coretext] Attempt to fix jumping lines

No more jumping and spaces between text runs are not eaten, but text
selection is still broken, as well as editing.

Change-Id: Ic9d2a6df0add20b63d6edf0ddf84b7d6f8de0983

diff --git a/vcl/coretext/salcoretextlayout.cxx 
b/vcl/coretext/salcoretextlayout.cxx
index 5599747..109900f 100644
--- a/vcl/coretext/salcoretextlayout.cxx
+++ b/vcl/coretext/salcoretextlayout.cxx
@@ -308,34 +308,37 @@ void CoreTextLayout::DropGlyph( int /*nStart*/ )
 
 long CoreTextLayout::FillDXArray( sal_Int32* pDXArray ) const
 {
-// Short circuit requests which don't need full details
-if( !pDXArray ) {
-return GetTextWidth();
-}
+if (pDXArray)
+{
+for (int i = 0; i < mnCharCount; i++)
+pDXArray[i] = 0;
 
-// Distribute the widths among the string elements
-long width = 0;
-float scale = mpStyle->GetFontStretchFactor();
-CGFloat accumulatedWidth = 0;
-
-std::ostringstream DXArrayInfo;
-for( int i = 0; i < mnCharCount; ++i ) {
-// Convert and adjust for accumulated rounding errors
-accumulatedWidth += mpCharWidths[ i ];
-const long old_width = width;
-width = round_to_long( accumulatedWidth * scale );
-pDXArray[i] = width - old_width;
-#ifdef SAL_LOG_INFO
-if ( i < 7 )
-DXArrayInfo << " " << pDXArray[i];
-else if ( i == 7 )
-DXArrayInfo << "...";
-#endif
-}
+CFArrayRef runs = CTLineGetGlyphRuns(mpLine);
+const CFIndex nRuns = CFArrayGetCount(runs);
+
+for (CFIndex runIndex = 0; runIndex < nRuns; runIndex++)
+{
+CTRunRef run = (CTRunRef)CFArrayGetValueAtIndex(runs, runIndex);
+if (!run)
+continue;
 
-SAL_INFO( "vcl.coretext.layout", "FillDXArray(" << this << "):" << 
DXArrayInfo.str() << ", result=" << width );
+const CFIndex runGlyphCount = CTRunGetGlyphCount(run);
+if (runGlyphCount)
+{
+CFIndex runStringIndices[runGlyphCount];
+CGSize runGlyphAdvances[runGlyphCount];
+CTRunGetStringIndices(run, CFRangeMake(0, 0), 
runStringIndices);
+CTRunGetAdvances(run, CFRangeMake(0, 0), runGlyphAdvances);
+for (int i = 0; i < runGlyphCount; i++)
+{
+const CFIndex charIndex = runStringIndices[i];
+pDXArray[charIndex] += runGlyphAdvances[i].width;
+}
+}
+}
+}
 
-return width;
+return GetTextWidth();
 }
 
 bool CoreTextLayout::GetBoundRect( SalGraphics& rGraphics, Rectangle& rVCLRect 
) const
@@ -508,13 +511,8 @@ int CoreTextLayout::GetTextBreak( long nMaxWidth, long 
nCharExtra, int nFactor )
 
 long CoreTextLayout::GetTextWidth() const
 {
-CGContextRef context = mpGraphics->GetContext();
-if (!context) {
-SAL_INFO( "vcl.coretext.layout", "GetTextWidth(): no context!?");
-return 0;
-}
-CGRect bound_rect = CTLineGetImageBounds(mpLine, context);
-long w = round_to_long((bound_rect.size.width + 
CTLineGetTrailingWhitespaceWidth(mpLine)) * mpStyle->GetFontStretchFactor());
+double width = CTLineGetTypographicBounds(mpLine, NULL, NULL, NULL);
+long w = round_to_long(width + CTLineGetTrailingWhitespaceWidth(mpLine));
 
 SAL_INFO( "vcl.coretext.layout", "GetTextWidth(" << this << ") returning " 
<< w );
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/generic

2013-05-12 Thread Khaled Hosny
 vcl/generic/glyphs/gcach_layout.cxx |   32 +---
 1 file changed, 29 insertions(+), 3 deletions(-)

New commits:
commit 2ede6c95e6481c92cc199e7d74fd36c841636304
Author: Khaled Hosny 
Date:   Sun May 12 17:59:50 2013 +0200

Some logging

Change-Id: I4515d4d6760e22ce4d77fbb3cbce93e3ce097b98

diff --git a/vcl/generic/glyphs/gcach_layout.cxx 
b/vcl/generic/glyphs/gcach_layout.cxx
index 55ddaee..07f9f76 100644
--- a/vcl/generic/glyphs/gcach_layout.cxx
+++ b/vcl/generic/glyphs/gcach_layout.cxx
@@ -203,6 +203,21 @@ static bool needNextCode(sal_Unicode cChar)
 return lcl_CharIsJoiner(cChar) || U16_IS_TRAIL(cChar);
 }
 
+std::ostream &operator <<(std::ostream& s, ServerFont* pFont)
+{
+#ifndef SAL_LOG_INFO
+(void) pFont;
+#else
+FT_Face aFace = pFont->GetFtFace();
+const char* pName = FT_Get_Postscript_Name(aFace);
+if (pName)
+s << pName;
+else
+s << pFont->GetFontFileName();
+#endif
+return s;
+}
+
 static hb_blob_t *getFontTable(hb_face_t* /*face*/, hb_tag_t nTableTag, void* 
pUserData)
 {
 char pTagName[5];
@@ -213,6 +228,9 @@ static hb_blob_t *getFontTable(hb_face_t* /*face*/, 
hb_tag_t nTableTag, void* pU
 pTagName[4] = 0;
 
 ServerFont* pFont = (ServerFont*) pUserData;
+
+SAL_INFO("vcl.harfbuzz.layout", "getFontTable(" << pFont << ", " << 
pTagName << ")");
+
 sal_uLong nLength;
 const unsigned char* pBuffer = pFont->GetTable(pTagName, &nLength);
 
@@ -284,6 +302,8 @@ static hb_position_t getGlyphKerningH(hb_font_t* /*font*/, 
void* pFontData,
 ServerFont* pFont = (ServerFont*) pFontData;
 FT_Face aFace = pFont->GetFtFace();
 
+SAL_INFO("vcl.harfbuzz.layout", "getGlyphKerningH(" << pFont << ", " << 
nGlyphIndex1 << ", " << nGlyphIndex2 << ")");
+
 FT_Error error;
 FT_Vector kerning;
 hb_position_t ret;
@@ -312,8 +332,10 @@ static hb_bool_t getGlyphExtents(hb_font_t* /*font*/, 
void* pFontData,
 {
 ServerFont* pFont = (ServerFont*) pFontData;
 FT_Face aFace = pFont->GetFtFace();
-FT_Error error;
 
+SAL_INFO("vcl.harfbuzz.layout", "getGlyphExtents(" << pFont << ", " << 
nGlyphIndex << ")");
+
+FT_Error error;
 error = FT_Load_Glyph(aFace, nGlyphIndex, FT_LOAD_DEFAULT);
 if (!error)
 {
@@ -331,11 +353,13 @@ static hb_bool_t getGlyphContourPoint(hb_font_t* 
/*font*/, void* pFontData,
 hb_position_t *x, hb_position_t *y,
 void* /*pUserData*/)
 {
+bool ret = false;
 ServerFont* pFont = (ServerFont*) pFontData;
 FT_Face aFace = pFont->GetFtFace();
-FT_Error error;
-bool ret = false;
 
+SAL_INFO("vcl.harfbuzz.layout", "getGlyphContourPoint(" << pFont << ", " 
<< nGlyphIndex << ", " << nPointIndex << ")");
+
+FT_Error error;
 error = FT_Load_Glyph(aFace, nGlyphIndex, FT_LOAD_DEFAULT);
 if (!error)
 {
@@ -407,6 +431,8 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, 
ImplLayoutArgs& rArgs)
 ServerFont& rFont = rLayout.GetServerFont();
 FT_Face aFtFace = rFont.GetFtFace();
 
+SAL_INFO("vcl.harfbuzz.layout", "layout(" << this << ",rArgs=" << rArgs << 
")");
+
 hb_font_t *pHbFont = hb_font_create(mpHbFace);
 hb_font_set_funcs(pHbFont, getFontFuncs(), &rFont, NULL);
 hb_font_set_scale(pHbFont,
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/generic

2013-05-12 Thread Khaled Hosny
 vcl/generic/glyphs/gcach_ftyp.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit c0417e82174297ace604c68fc577c831929f3573
Author: Khaled Hosny 
Date:   Mon May 13 02:33:14 2013 +0200

Typo

Change-Id: I28ea63722f542a79aef904f9be40645baac191e4

diff --git a/vcl/generic/glyphs/gcach_ftyp.cxx 
b/vcl/generic/glyphs/gcach_ftyp.cxx
index 9995964..bd1ef26 100644
--- a/vcl/generic/glyphs/gcach_ftyp.cxx
+++ b/vcl/generic/glyphs/gcach_ftyp.cxx
@@ -978,7 +978,7 @@ void ServerFont::FetchFontMetric( ImplFontMetricData& rTo, 
long& rFactor ) const
 {
 rTo.mnAscent = pOS2->usWinAscent * fScale + 0.5;
 rTo.mnDescent = pOS2->usWinDescent * fScale + 0.5;
-rTo.mnDescent = 0;
+rTo.mnExtLeading = 0;
 }
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits



[Libreoffice-commits] core.git: vcl/generic

2013-05-13 Thread Khaled Hosny
 vcl/generic/glyphs/gcach_ftyp.cxx |   14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

New commits:
commit dd5b15ebd868e21b4c948ccb7978136a91a7992c
Author: Khaled Hosny 
Date:   Mon May 13 16:32:20 2013 +0200

Handle fonts without hhea or OS/2 table e.g. Type1

Change-Id: Ib7245e9f8b7874087966cb1098e63d1f83acaa6a

diff --git a/vcl/generic/glyphs/gcach_ftyp.cxx 
b/vcl/generic/glyphs/gcach_ftyp.cxx
index bd1ef26..162ba11 100644
--- a/vcl/generic/glyphs/gcach_ftyp.cxx
+++ b/vcl/generic/glyphs/gcach_ftyp.cxx
@@ -945,8 +945,10 @@ void ServerFont::FetchFontMetric( ImplFontMetricData& rTo, 
long& rFactor ) const
 
 // Calculating ascender and descender:
 // FreeType >= 2.4.6 does the right thing, so we just use what it gives us,
-// for earlier versions we emulate its behaviour; take them from 'hhea'
-// table, if zero take them from 'OS/2' table.
+// for earlier versions we emulate its behaviour;
+// take them from 'hhea' table,
+// if zero take them from 'OS/2' table,
+// if zero take them from FreeType's font metrics
 if (nFTVERSION >= 2406)
 {
 const FT_Size_Metrics& rMetrics = maFaceFT->size->metrics;
@@ -982,6 +984,14 @@ void ServerFont::FetchFontMetric( ImplFontMetricData& rTo, 
long& rFactor ) const
 }
 }
 }
+
+if (!(rTo.mnAscent || rTo.mnDescent))
+{
+const FT_Size_Metrics& rMetrics = maFaceFT->size->metrics;
+rTo.mnAscent = (rMetrics.ascender + 32) >> 6;
+rTo.mnDescent = (-rMetrics.descender + 32) >> 6;
+rTo.mnExtLeading = ((rMetrics.height + 32) >> 6) - (rTo.mnAscent + 
rTo.mnDescent);
+}
 }
 
 if( pOS2 && (pOS2->version != 0x) )
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/commonsallayout' - 2 commits - vcl/inc vcl/source

2016-10-09 Thread Khaled Hosny
 vcl/inc/CommonSalLayout.hxx|2 
 vcl/source/gdi/CommonSalLayout.cxx |  107 +++--
 2 files changed, 92 insertions(+), 17 deletions(-)

New commits:
commit 7a897b1d181ad23c3d2249c05c9047ced4ace11b
Author: Khaled Hosny 
Date:   Mon Oct 10 00:54:00 2016 +0200

Validate Kashida positions in CommonSalLayout

Currently checks only for ligatures, but that is a big improvement over
al code that didn’t do any validation except on Windows.

Change-Id: I035248f4ccc23134ea27b40c2dd6197130749f14

diff --git a/vcl/inc/CommonSalLayout.hxx b/vcl/inc/CommonSalLayout.hxx
index e9116ba..8ee1255 100644
--- a/vcl/inc/CommonSalLayout.hxx
+++ b/vcl/inc/CommonSalLayout.hxx
@@ -68,4 +68,6 @@ public:
 
 virtual boolGetCharWidths(DeviceCoordinate* pCharWidths) const 
override;
 virtual voidApplyDXArray(ImplLayoutArgs&) override;
+
+virtual boolIsKashidaPosValid(int nCharPos) const override;
 };
diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index 188472e..ea64d05 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -609,3 +609,30 @@ void CommonSalLayout::ApplyDXArray(ImplLayoutArgs& rArgs)
 }
 }
 }
+
+bool CommonSalLayout::IsKashidaPosValid(int nCharPos) const
+{
+for (auto pIter = m_GlyphItems.begin(); pIter != m_GlyphItems.end(); 
++pIter)
+{
+if (pIter->mnCharPos == nCharPos)
+{
+// Search backwards for previous glyph belonging to a different
+// character. We are looking backwards because we are dealing with
+// RTL glyphs, which will be in visual order.
+for (auto pPrev = pIter - 1; pPrev != m_GlyphItems.begin(); 
--pPrev)
+{
+if (pPrev->mnCharPos != nCharPos)
+{
+// Check if the found glyph belongs to the next character,
+// otherwise the current glyph will be a ligature which is
+// invalid kashida position.
+if (pPrev->mnCharPos == (nCharPos + 1))
+return true;
+break;
+}
+}
+}
+}
+
+return false;
+}
commit da53eeb58bb6b510daf51c7e1edc20a5c1ef8b9a
Author: Khaled Hosny 
Date:   Sun Oct 9 23:23:45 2016 +0200

Re-enable Kashida insertion in CommonSalLayout

We now do Kashida insertion in ApplyDXArray(), no need for a separate
step. This simplifies the code greatly (old code is in
GenericSalLayout::KashidaJustify()).

Change-Id: Ie31c8969e26f1f293820f1e90f963a5ba1fc9eb1

diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index 7bcbf1d..188472e 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -283,27 +283,18 @@ void CommonSalLayout::SetNeedFallback(ImplLayoutArgs& 
rArgs, sal_Int32 nCharPos,
 
 void CommonSalLayout::AdjustLayout(ImplLayoutArgs& rArgs)
 {
-GenericSalLayout::AdjustLayout(rArgs);
+SalLayout::AdjustLayout(rArgs);
+
+if (rArgs.mpDXArray)
+ApplyDXArray(rArgs);
+else if (rArgs.mnLayoutWidth)
+Justify(rArgs.mnLayoutWidth);
 
 // apply asian kerning if the glyphs are not already formatted
 if( (rArgs.mnFlags & SalLayoutFlags::KerningAsian)
 && !(rArgs.mnFlags & SalLayoutFlags::Vertical) )
 if( (rArgs.mpDXArray != nullptr) || (rArgs.mnLayoutWidth != 0) )
 ApplyAsianKerning(rArgs.mrStr);
-
-if((rArgs.mnFlags & SalLayoutFlags::KashidaJustification) && 
rArgs.mpDXArray)
-{
-hb_codepoint_t nKashidaCodePoint = 0x0640;
-hb_codepoint_t nKashidaGlyphIndex;
-
-if(hb_font_get_glyph(mpHbFont, nKashidaCodePoint, 0, 
&nKashidaGlyphIndex))
-{
-if(nKashidaGlyphIndex)
-{
-KashidaJustify(nKashidaGlyphIndex, 
hb_font_get_glyph_h_advance(mpHbFont, nKashidaGlyphIndex) >> 6);
-}
-}
-}
 }
 
 void CommonSalLayout::DrawText( SalGraphics& rSalGraphics ) const
@@ -543,6 +534,16 @@ void CommonSalLayout::ApplyDXArray(ImplLayoutArgs& rArgs)
   pNewCharWidths[i] = rArgs.mpDXArray[i] - rArgs.mpDXArray[i - 1];
 }
 
+DeviceCoordinate nKashidaWidth = 0;
+hb_codepoint_t nKashidaIndex;
+if (rArgs.mnFlags & SalLayoutFlags::KashidaJustification)
+{
+if (hb_font_get_glyph(mpHbFont, 0x0640, 0, &nKashidaIndex))
+nKashidaWidth = hb_font_get_glyph_h_advance(mpHbFont, 
nKashidaIndex) / 64;
+}
+
+std::map pKashidas;
+
 DeviceCoordinate nDelta = 0;
 size_t i = 0;
 while (i < m_GlyphItems.size())
@@ -550,16 +551,61 @@ void CommonSalLayout::ApplyDXArray(ImplLayoutArgs& rArgs)
 int nCharPos = m_GlyphItems[i].mnCharPos - mnMinCharPos;
 DeviceCoordinate n

[Libreoffice-commits] core.git: Branch 'feature/commonsallayout' - 13 commits - config_host.mk.in configure.ac external/harfbuzz RepositoryExternal.mk vcl/CppunitTest_vcl_wmf_test.mk vcl/inc vcl/Libra

2016-10-09 Thread Khaled Hosny
Rebased ref, commits from common ancestor:
commit c74ddf0d07c34dc5b20853be752508bce7a67578
Author: Khaled Hosny 
Date:   Mon Oct 10 00:54:00 2016 +0200

Validate Kashida positions in CommonSalLayout

Currently checks only for ligatures, but that is a big improvement over
al code that didn’t do any validation except on Windows.

Change-Id: I035248f4ccc23134ea27b40c2dd6197130749f14

diff --git a/vcl/inc/CommonSalLayout.hxx b/vcl/inc/CommonSalLayout.hxx
index e9116ba..8ee1255 100644
--- a/vcl/inc/CommonSalLayout.hxx
+++ b/vcl/inc/CommonSalLayout.hxx
@@ -68,4 +68,6 @@ public:
 
 virtual boolGetCharWidths(DeviceCoordinate* pCharWidths) const 
override;
 virtual voidApplyDXArray(ImplLayoutArgs&) override;
+
+virtual boolIsKashidaPosValid(int nCharPos) const override;
 };
diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index e338261..0bbab99 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -612,3 +612,30 @@ void CommonSalLayout::ApplyDXArray(ImplLayoutArgs& rArgs)
 }
 }
 }
+
+bool CommonSalLayout::IsKashidaPosValid(int nCharPos) const
+{
+for (auto pIter = m_GlyphItems.begin(); pIter != m_GlyphItems.end(); 
++pIter)
+{
+if (pIter->mnCharPos == nCharPos)
+{
+// Search backwards for previous glyph belonging to a different
+// character. We are looking backwards because we are dealing with
+// RTL glyphs, which will be in visual order.
+for (auto pPrev = pIter - 1; pPrev != m_GlyphItems.begin(); 
--pPrev)
+{
+if (pPrev->mnCharPos != nCharPos)
+{
+// Check if the found glyph belongs to the next character,
+// otherwise the current glyph will be a ligature which is
+// invalid kashida position.
+if (pPrev->mnCharPos == (nCharPos + 1))
+return true;
+break;
+}
+}
+}
+}
+
+return false;
+}
commit 7b36271ca9095c60c01a3810df2e42334e02a8de
Author: Khaled Hosny 
Date:   Sun Oct 9 23:23:45 2016 +0200

Re-enable Kashida insertion in CommonSalLayout

We now do Kashida insertion in ApplyDXArray(), no need for a separate
step. This simplifies the code greatly (old code is in
GenericSalLayout::KashidaJustify()).

Change-Id: Ie31c8969e26f1f293820f1e90f963a5ba1fc9eb1

diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index 433fbee..e338261 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -283,27 +283,18 @@ void CommonSalLayout::SetNeedFallback(ImplLayoutArgs& 
rArgs, sal_Int32 nCharPos,
 
 void CommonSalLayout::AdjustLayout(ImplLayoutArgs& rArgs)
 {
-GenericSalLayout::AdjustLayout(rArgs);
+SalLayout::AdjustLayout(rArgs);
+
+if (rArgs.mpDXArray)
+ApplyDXArray(rArgs);
+else if (rArgs.mnLayoutWidth)
+Justify(rArgs.mnLayoutWidth);
 
 // apply asian kerning if the glyphs are not already formatted
 if( (rArgs.mnFlags & SalLayoutFlags::KerningAsian)
 && !(rArgs.mnFlags & SalLayoutFlags::Vertical) )
 if( (rArgs.mpDXArray != nullptr) || (rArgs.mnLayoutWidth != 0) )
 ApplyAsianKerning(rArgs.mrStr);
-
-if((rArgs.mnFlags & SalLayoutFlags::KashidaJustification) && 
rArgs.mpDXArray)
-{
-hb_codepoint_t nKashidaCodePoint = 0x0640;
-hb_codepoint_t nKashidaGlyphIndex;
-
-if(hb_font_get_glyph(mpHbFont, nKashidaCodePoint, 0, 
&nKashidaGlyphIndex))
-{
-if(nKashidaGlyphIndex)
-{
-KashidaJustify(nKashidaGlyphIndex, 
hb_font_get_glyph_h_advance(mpHbFont, nKashidaGlyphIndex) >> 6);
-}
-}
-}
 }
 
 void CommonSalLayout::DrawText( SalGraphics& rSalGraphics ) const
@@ -546,6 +537,16 @@ void CommonSalLayout::ApplyDXArray(ImplLayoutArgs& rArgs)
 pNewCharWidths[i] = rArgs.mpDXArray[i] - rArgs.mpDXArray[i - 1];
 }
 
+DeviceCoordinate nKashidaWidth = 0;
+hb_codepoint_t nKashidaIndex;
+if (rArgs.mnFlags & SalLayoutFlags::KashidaJustification)
+{
+if (hb_font_get_glyph(mpHbFont, 0x0640, 0, &nKashidaIndex))
+nKashidaWidth = hb_font_get_glyph_h_advance(mpHbFont, 
nKashidaIndex) / 64;
+}
+
+std::map pKashidas;
+
 DeviceCoordinate nDelta = 0;
 size_t i = 0;
 while (i < m_GlyphItems.size())
@@ -553,16 +554,61 @@ void CommonSalLayout::ApplyDXArray(ImplLayoutArgs& rArgs)
 int nCharPos = m_GlyphItems[i].mnCharPos - mnMinCharPos;
 DeviceCoordinate nDiff = pNewCharWidths[nCharPos] - 
pOldCharWidths[nCharPos];
 
-m_GlyphItems[i].maLinearPos.X() += nDelta;
+if (nKashidaWidth &am

[Libreoffice-commits] core.git: Branch 'feature/commonsallayout' - vcl/source

2016-10-09 Thread Khaled Hosny
 vcl/source/gdi/CommonSalLayout.cxx |   12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

New commits:
commit 7710affe4b15fd6ba6f79a69fa2521e08881e23f
Author: Khaled Hosny 
Date:   Mon Oct 10 01:36:45 2016 +0200

Just call ICU directly and cut the middle layers

Change-Id: I7603d03fef8ca227c3e6fe25239281d18801522a

diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index 0bbab99..7de1a80 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #if defined(_WIN32)
 struct WinSalGraphicsWithIDFace
@@ -116,14 +117,14 @@ static void scaleHbFont(hb_font_t* pHbFont, const 
FontSelectPattern& aFontSelDat
 hb_font_set_scale(pHbFont, nXScale, nYScale);
 }
 
+#if !HB_VERSION_ATLEAST(1, 1, 0)
 static hb_unicode_funcs_t* getUnicodeFuncs()
 {
 static hb_unicode_funcs_t* ufuncs = 
hb_unicode_funcs_create(hb_icu_get_unicode_funcs());
-#if !HB_VERSION_ATLEAST(1, 1, 0)
 hb_unicode_funcs_set_decompose_compatibility_func(ufuncs, 
unicodeDecomposeCompatibility, nullptr, nullptr);
-#endif
 return ufuncs;
 }
+#endif
 
 #if defined(_WIN32)
 CommonSalLayout::CommonSalLayout(WinSalGraphics* WSL, WinFontInstance& 
rWinFontInstance, const WinFontFace& rWinFontFace)
@@ -389,8 +390,8 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
 nHbFlags |= HB_BUFFER_FLAG_EOT; /* End-of-text */
 
 hb_buffer_t *pHbBuffer = hb_buffer_create();
-static hb_unicode_funcs_t* pHbUnicodeFuncs = getUnicodeFuncs();
 #if !HB_VERSION_ATLEAST(1, 1, 0)
+static hb_unicode_funcs_t* pHbUnicodeFuncs = getUnicodeFuncs();
 hb_buffer_set_unicode_funcs(pHbBuffer, pHbUnicodeFuncs);
 #endif
 if (SAL_UNLIKELY(bVertical))
@@ -449,7 +450,7 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
 else
 {
 #if HB_VERSION_ATLEAST(0, 9, 42)
-if(hb_unicode_general_category (pHbUnicodeFuncs, aChar) == 
HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)
+if (u_getIntPropertyValue(aChar, UCHAR_GENERAL_CATEGORY) 
== U_NON_SPACING_MARK)
 bDiacritic = true;
 #else
 // the font lacks GDEF table
@@ -585,8 +586,7 @@ void CommonSalLayout::ApplyDXArray(ImplLayoutArgs& rArgs)
 
 sal_Int32 indexUtf16 = pGlyphIter->mnCharPos;
 sal_UCS4 aChar = rArgs.mrStr.iterateCodePoints(&indexUtf16, 0);
-static hb_unicode_funcs_t* pHbUnicodeFuncs = getUnicodeFuncs();
-if (hb_unicode_general_category (pHbUnicodeFuncs, aChar) == 
HB_UNICODE_GENERAL_CATEGORY_SPACE_SEPARATOR)
+if (u_isUWhiteSpace(aChar))
 continue;
 
 DeviceCoordinate nGapWidth = pKashida.second;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/commonsallayout' - 392 commits - accessibility/inc accessibility/source apple_remote/source avmedia/inc avmedia/source basctl/source basegfx/source base

2016-10-09 Thread Khaled Hosny
Rebased ref, commits from common ancestor:
commit c81fb933b89bbba18a1197f67b9325bbfb44648d
Author: Khaled Hosny 
Date:   Mon Oct 10 01:36:45 2016 +0200

Just call ICU directly and cut the middle layers

Change-Id: I7603d03fef8ca227c3e6fe25239281d18801522a

diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index 0bbab99..7de1a80 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #if defined(_WIN32)
 struct WinSalGraphicsWithIDFace
@@ -116,14 +117,14 @@ static void scaleHbFont(hb_font_t* pHbFont, const 
FontSelectPattern& aFontSelDat
 hb_font_set_scale(pHbFont, nXScale, nYScale);
 }
 
+#if !HB_VERSION_ATLEAST(1, 1, 0)
 static hb_unicode_funcs_t* getUnicodeFuncs()
 {
 static hb_unicode_funcs_t* ufuncs = 
hb_unicode_funcs_create(hb_icu_get_unicode_funcs());
-#if !HB_VERSION_ATLEAST(1, 1, 0)
 hb_unicode_funcs_set_decompose_compatibility_func(ufuncs, 
unicodeDecomposeCompatibility, nullptr, nullptr);
-#endif
 return ufuncs;
 }
+#endif
 
 #if defined(_WIN32)
 CommonSalLayout::CommonSalLayout(WinSalGraphics* WSL, WinFontInstance& 
rWinFontInstance, const WinFontFace& rWinFontFace)
@@ -389,8 +390,8 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
 nHbFlags |= HB_BUFFER_FLAG_EOT; /* End-of-text */
 
 hb_buffer_t *pHbBuffer = hb_buffer_create();
-static hb_unicode_funcs_t* pHbUnicodeFuncs = getUnicodeFuncs();
 #if !HB_VERSION_ATLEAST(1, 1, 0)
+static hb_unicode_funcs_t* pHbUnicodeFuncs = getUnicodeFuncs();
 hb_buffer_set_unicode_funcs(pHbBuffer, pHbUnicodeFuncs);
 #endif
 if (SAL_UNLIKELY(bVertical))
@@ -449,7 +450,7 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
 else
 {
 #if HB_VERSION_ATLEAST(0, 9, 42)
-if(hb_unicode_general_category (pHbUnicodeFuncs, aChar) == 
HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)
+if (u_getIntPropertyValue(aChar, UCHAR_GENERAL_CATEGORY) 
== U_NON_SPACING_MARK)
 bDiacritic = true;
 #else
 // the font lacks GDEF table
@@ -585,8 +586,7 @@ void CommonSalLayout::ApplyDXArray(ImplLayoutArgs& rArgs)
 
 sal_Int32 indexUtf16 = pGlyphIter->mnCharPos;
 sal_UCS4 aChar = rArgs.mrStr.iterateCodePoints(&indexUtf16, 0);
-static hb_unicode_funcs_t* pHbUnicodeFuncs = getUnicodeFuncs();
-if (hb_unicode_general_category (pHbUnicodeFuncs, aChar) == 
HB_UNICODE_GENERAL_CATEGORY_SPACE_SEPARATOR)
+if (u_isUWhiteSpace(aChar))
 continue;
 
 DeviceCoordinate nGapWidth = pKashida.second;
commit 9773148d02c9c4f816ea21eabf292c4cf9cdad5f
Author: Khaled Hosny 
Date:   Mon Oct 10 00:54:00 2016 +0200

Validate Kashida positions in CommonSalLayout

Currently checks only for ligatures, but that is a big improvement over
al code that didn’t do any validation except on Windows.

Change-Id: I035248f4ccc23134ea27b40c2dd6197130749f14

diff --git a/vcl/inc/CommonSalLayout.hxx b/vcl/inc/CommonSalLayout.hxx
index e9116ba..8ee1255 100644
--- a/vcl/inc/CommonSalLayout.hxx
+++ b/vcl/inc/CommonSalLayout.hxx
@@ -68,4 +68,6 @@ public:
 
 virtual boolGetCharWidths(DeviceCoordinate* pCharWidths) const 
override;
 virtual voidApplyDXArray(ImplLayoutArgs&) override;
+
+virtual boolIsKashidaPosValid(int nCharPos) const override;
 };
diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index e338261..0bbab99 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -612,3 +612,30 @@ void CommonSalLayout::ApplyDXArray(ImplLayoutArgs& rArgs)
 }
 }
 }
+
+bool CommonSalLayout::IsKashidaPosValid(int nCharPos) const
+{
+for (auto pIter = m_GlyphItems.begin(); pIter != m_GlyphItems.end(); 
++pIter)
+{
+if (pIter->mnCharPos == nCharPos)
+{
+// Search backwards for previous glyph belonging to a different
+// character. We are looking backwards because we are dealing with
+// RTL glyphs, which will be in visual order.
+for (auto pPrev = pIter - 1; pPrev != m_GlyphItems.begin(); 
--pPrev)
+{
+if (pPrev->mnCharPos != nCharPos)
+{
+// Check if the found glyph belongs to the next character,
+// otherwise the current glyph will be a ligature which is
+// invalid kashida position.
+if (pPrev->mnCharPos == (nCharPos + 1))
+return true;
+break;
+}
+}
+}
+}
+
+return false;
+}
commit 6046b7630785d87f240dce92e1d2901de86a66

[Libreoffice-commits] core.git: 2 commits - vcl/source vcl/unx

2016-10-11 Thread Khaled Hosny
 vcl/source/gdi/sallayout.cxx|4 
 vcl/unx/generic/glyphs/gcach_layout.cxx |   30 +++---
 2 files changed, 11 insertions(+), 23 deletions(-)

New commits:
commit f48cbaac0a2a7278f366a3b0118b399c0a938a44
Author: Khaled Hosny 
Date:   Tue Oct 11 14:53:06 2016 +0200

tdf#103103: Many Arabic fonts dont render correctly

Revert the remaining bits of 1da9b4c24e806ad2447b4a656e2a7192755bb6a8,
the rest was reverted in 6323e6628668849438e6e19ba7ad2c6598263261.

This break many assumptions made by GenericSalLayout::ApplyDXArray().

Change-Id: I25fbafe06032ab1e8860df6c5932a7157575aa32

diff --git a/vcl/unx/generic/glyphs/gcach_layout.cxx 
b/vcl/unx/generic/glyphs/gcach_layout.cxx
index 38d7e84..46420cb 100644
--- a/vcl/unx/generic/glyphs/gcach_layout.cxx
+++ b/vcl/unx/generic/glyphs/gcach_layout.cxx
@@ -21,7 +21,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 
@@ -309,16 +308,14 @@ static unsigned int 
unicodeDecomposeCompatibility(hb_unicode_funcs_t* /*ufuncs*/
 {
 return 0;
 }
-#endif
 
 static hb_unicode_funcs_t* getUnicodeFuncs()
 {
 static hb_unicode_funcs_t* ufuncs = 
hb_unicode_funcs_create(hb_icu_get_unicode_funcs());
-#if !HB_VERSION_ATLEAST(1, 1, 0)
 hb_unicode_funcs_set_decompose_compatibility_func(ufuncs, 
unicodeDecomposeCompatibility, nullptr, nullptr);
-#endif
 return ufuncs;
 }
+#endif
 
 class HbLayoutEngine : public ServerFontLayoutEngine
 {
@@ -492,8 +489,8 @@ bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, 
ImplLayoutArgs& rArgs)
 nHbFlags |= HB_BUFFER_FLAG_EOT; /* End-of-text */
 
 hb_buffer_t *pHbBuffer = hb_buffer_create();
-static hb_unicode_funcs_t* pHbUnicodeFuncs = getUnicodeFuncs();
 #if !HB_VERSION_ATLEAST(1, 1, 0)
+static hb_unicode_funcs_t* pHbUnicodeFuncs = getUnicodeFuncs();
 hb_buffer_set_unicode_funcs(pHbBuffer, pHbUnicodeFuncs);
 #endif
 hb_buffer_set_direction(pHbBuffer, bRightToLeft ? 
HB_DIRECTION_RTL: HB_DIRECTION_LTR);
@@ -503,9 +500,6 @@ bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, 
ImplLayoutArgs& rArgs)
 hb_buffer_add_utf16(
 pHbBuffer, reinterpret_cast(pStr), nLength,
 nMinRunPos, nRunLen);
-#if HB_VERSION_ATLEAST(0, 9, 42)
-hb_buffer_set_cluster_level(pHbBuffer, 
HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS);
-#endif
 hb_shape(pHbFont, pHbBuffer, nullptr, 0);
 
 int nRunGlyphCount = hb_buffer_get_length(pHbBuffer);
@@ -554,12 +548,15 @@ bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, 
ImplLayoutArgs& rArgs)
 //   but usually harmless), so we try to sniff what HarfBuzz 
thinks
 //   about this glyph by checking if it gives it a zero advance
 //   width.
-// * If the font has no GDEF table, we then check the unicode 
class
-//   of the glyph. If it is a non spacing mark then the glyph 
is a
-//   diacritic. This is only done if the HarfBuzz version is 
>= 0.9.42
-//   Else, we fallback to setting bDiacritic to true if the x 
advance
-//   of the glyph is zero. This maybe wrong in some cases but 
needs to
-//   be kept until the base version of HarfBuzz can be updated.
+// * If the font has no GDEF table, we just check if the glyph 
has
+//   zero advance width, but this is stupid and can be wrong. A
+//   better way would to check the character's Unicode 
combining
+//   class, but unfortunately HarfBuzz gives combining marks 
the
+//   cluster value of its base character, so nCharPos will be
+//   pointing to the wrong character (but HarfBuzz might change
+//   this in the future).
+//   Newer versions of HarfBuzz can control this behaviour with
+//   hb_buffer_set_cluster_level().
 bool bDiacritic = false;
 if (hb_ot_layout_has_glyph_classes(mpHbFace))
 {
@@ -570,14 +567,9 @@ bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, 
ImplLayoutArgs& rArgs)
 }
 else
 {
-#if HB_VERSION_ATLEAST(0, 9, 42)
-if(hb_unicode_general_category (pHbUnicodeFuncs, aChar) == 
HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)
-bDiacritic = true;
-#else
 // the font lacks GDEF table
 if (pHbPositions[i].x_advance == 0)
 bDiacritic = true;
-#endif
 }
 
 if (bDiacritic)
commit faddf2aefd5874b2bbd6c3b7bbed0812de911f47
Author: Khaled Hosny 
Date:   Tue Oct 11 15:11:58 2016 +0200

Revert "Hack to make Arabic subtending marks work"

This rever

[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - vcl/unx

2016-10-12 Thread Khaled Hosny
 vcl/unx/generic/glyphs/gcach_layout.cxx |   30 +++---
 1 file changed, 11 insertions(+), 19 deletions(-)

New commits:
commit ed761146be3a274e0f24ab2c02c68e4e6c33e8b4
Author: Khaled Hosny 
Date:   Tue Oct 11 18:38:57 2016 +0200

tdf#103103: Many Arabic fonts dont render correctly

Revert the remaining bits of 1da9b4c24e806ad2447b4a656e2a7192755bb6a8,
the rest was reverted in 6323e6628668849438e6e19ba7ad2c6598263261.

This break many assumptions made by GenericSalLayout::ApplyDXArray().

(cherry picked from commit f48cbaac0a2a7278f366a3b0118b399c0a938a44)

Change-Id: I25fbafe06032ab1e8860df6c5932a7157575aa32
Reviewed-on: https://gerrit.libreoffice.org/29698
Reviewed-by: Michael Stahl 
Tested-by: Michael Stahl 

diff --git a/vcl/unx/generic/glyphs/gcach_layout.cxx 
b/vcl/unx/generic/glyphs/gcach_layout.cxx
index d8bf44b..77e8b43 100644
--- a/vcl/unx/generic/glyphs/gcach_layout.cxx
+++ b/vcl/unx/generic/glyphs/gcach_layout.cxx
@@ -21,7 +21,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 
@@ -309,16 +308,14 @@ static unsigned int 
unicodeDecomposeCompatibility(hb_unicode_funcs_t* /*ufuncs*/
 {
 return 0;
 }
-#endif
 
 static hb_unicode_funcs_t* getUnicodeFuncs()
 {
 static hb_unicode_funcs_t* ufuncs = 
hb_unicode_funcs_create(hb_icu_get_unicode_funcs());
-#if !HB_VERSION_ATLEAST(1, 1, 0)
 hb_unicode_funcs_set_decompose_compatibility_func(ufuncs, 
unicodeDecomposeCompatibility, nullptr, nullptr);
-#endif
 return ufuncs;
 }
+#endif
 
 class HbLayoutEngine : public ServerFontLayoutEngine
 {
@@ -492,8 +489,8 @@ bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, 
ImplLayoutArgs& rArgs)
 nHbFlags |= HB_BUFFER_FLAG_EOT; /* End-of-text */
 
 hb_buffer_t *pHbBuffer = hb_buffer_create();
-static hb_unicode_funcs_t* pHbUnicodeFuncs = getUnicodeFuncs();
 #if !HB_VERSION_ATLEAST(1, 1, 0)
+static hb_unicode_funcs_t* pHbUnicodeFuncs = getUnicodeFuncs();
 hb_buffer_set_unicode_funcs(pHbBuffer, pHbUnicodeFuncs);
 #endif
 hb_buffer_set_direction(pHbBuffer, bRightToLeft ? 
HB_DIRECTION_RTL: HB_DIRECTION_LTR);
@@ -503,9 +500,6 @@ bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, 
ImplLayoutArgs& rArgs)
 hb_buffer_add_utf16(
 pHbBuffer, reinterpret_cast(pStr), nLength,
 nMinRunPos, nRunLen);
-#if HB_VERSION_ATLEAST(0, 9, 42)
-hb_buffer_set_cluster_level(pHbBuffer, 
HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS);
-#endif
 hb_shape(pHbFont, pHbBuffer, nullptr, 0);
 
 int nRunGlyphCount = hb_buffer_get_length(pHbBuffer);
@@ -554,12 +548,15 @@ bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, 
ImplLayoutArgs& rArgs)
 //   but usually harmless), so we try to sniff what HarfBuzz 
thinks
 //   about this glyph by checking if it gives it a zero advance
 //   width.
-// * If the font has no GDEF table, we then check the unicode 
class
-//   of the glyph. If it is a non spacing mark then the glyph 
is a
-//   diacritic. This is only done if the HarfBuzz version is 
>= 0.9.42
-//   Else, we fallback to setting bDiacritic to true if the x 
advance
-//   of the glyph is zero. This maybe wrong in some cases but 
needs to
-//   be kept until the base version of HarfBuzz can be updated.
+// * If the font has no GDEF table, we just check if the glyph 
has
+//   zero advance width, but this is stupid and can be wrong. A
+//   better way would to check the character's Unicode 
combining
+//   class, but unfortunately HarfBuzz gives combining marks 
the
+//   cluster value of its base character, so nCharPos will be
+//   pointing to the wrong character (but HarfBuzz might change
+//   this in the future).
+//   Newer versions of HarfBuzz can control this behaviour with
+//   hb_buffer_set_cluster_level().
 bool bDiacritic = false;
 if (hb_ot_layout_has_glyph_classes(mpHbFace))
 {
@@ -570,14 +567,9 @@ bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, 
ImplLayoutArgs& rArgs)
 }
 else
 {
-#if HB_VERSION_ATLEAST(0, 9, 42)
-if(hb_unicode_general_category (pHbUnicodeFuncs, aChar) == 
HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)
-bDiacritic = true;
-#else
 // the font lacks GDEF table
 if (pHbPositions[i].x_advance == 0)
 bDiacritic = true;
-#endif
 }
 
 if (bDiacritic)
___
Libreoffi

[Libreoffice-commits] core.git: Branch 'feature/commonsallayout' - 30 commits - config_host.mk.in configure.ac external/harfbuzz RepositoryExternal.mk vcl/CppunitTest_vcl_wmf_test.mk vcl/headless vcl/

2016-10-13 Thread Khaled Hosny
Rebased ref, commits from common ancestor:
commit 4f0fede6364bac10705a4bde325e9ab35ad5b5fd
Author: Khaled Hosny 
Date:   Thu Oct 13 22:46:28 2016 +0200

Check SAL_USE_COMMON_LAYOUT envar in one place

Makes it easier to flip the switch in the future (or even do something
more fancy other than checking envvar).

Change-Id: Ie42ca012c167b2108f0fca1ce9ff7beee95f1be7

diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx
index 1050943..364bd48 100644
--- a/vcl/inc/sallayout.hxx
+++ b/vcl/inc/sallayout.hxx
@@ -201,6 +201,8 @@ public:
 virtual std::shared_ptr
 CreateTextLayoutCache(OUString const&) const;
 
+static bool UseCommonLayout();
+
 protected:
 // used by layout engines
 SalLayout();
diff --git a/vcl/quartz/ctlayout.cxx b/vcl/quartz/ctlayout.cxx
index f7fe0af..856e066 100644
--- a/vcl/quartz/ctlayout.cxx
+++ b/vcl/quartz/ctlayout.cxx
@@ -782,7 +782,7 @@ void CTLayout::Simplify( bool /*bIsBase*/ ) {}
 
 SalLayout* CoreTextStyle::GetTextLayout() const
 {
-if (getenv("SAL_USE_COMMON_LAYOUT"))
+if (SalLayout::UseCommonLayout())
 return new CommonSalLayout(*this);
 else
 return new CTLayout(this);
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index ea16f4f..86b3ab1d 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -768,6 +768,12 @@ bool SalLayout::IsSpacingGlyph( sal_GlyphId nGlyph )
 return bRet;
 }
 
+bool SalLayout::UseCommonLayout()
+{
+static bool bUse = getenv("SAL_USE_COMMON_LAYOUT") != nullptr;
+return bUse;
+}
+
 GenericSalLayout::GenericSalLayout()
 {}
 
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx 
b/vcl/unx/generic/gdi/cairotextrender.cxx
index 46b9326..35d086d 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -532,7 +532,7 @@ SalLayout* CairoTextRender::GetTextLayout( ImplLayoutArgs& 
rArgs, int nFallbackL
 if( mpServerFont[ nFallbackLevel ]
 && !(rArgs.mnFlags & SalLayoutFlags::DisableGlyphProcessing) )
 {
-if (getenv("SAL_USE_COMMON_LAYOUT"))
+if (SalLayout::UseCommonLayout())
 {
 pLayout = new CommonSalLayout(*mpServerFont[nFallbackLevel]);
 }
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index de0b4bf..9681986 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -3900,7 +3900,7 @@ SalLayout* WinSalGraphics::GetTextLayout( ImplLayoutArgs& 
rArgs, int nFallbackLe
 const WinFontFace& rFontFace = *mpWinFontData[ nFallbackLevel ];
 WinFontInstance& rFontInstance = *mpWinFontEntry[ nFallbackLevel ];
 
-if (getenv("SAL_USE_COMMON_LAYOUT"))
+if (SalLayout::UseCommonLayout())
 {
 return new CommonSalLayout(this, rFontInstance, rFontFace);
     }
commit aba6d0bd84f8f36dcbe50eacbfd72d0d6182cc2d
Author: Khaled Hosny 
Date:   Mon Oct 10 01:36:45 2016 +0200

Just call ICU directly and cut the middle layers

Change-Id: I7603d03fef8ca227c3e6fe25239281d18801522a

diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index 6f24f30..3583b79 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #if defined(_WIN32)
 struct WinSalGraphicsWithIDFace
@@ -116,14 +117,14 @@ static void scaleHbFont(hb_font_t* pHbFont, const 
FontSelectPattern& aFontSelDat
 hb_font_set_scale(pHbFont, nXScale, nYScale);
 }
 
+#if !HB_VERSION_ATLEAST(1, 1, 0)
 static hb_unicode_funcs_t* getUnicodeFuncs()
 {
 static hb_unicode_funcs_t* ufuncs = 
hb_unicode_funcs_create(hb_icu_get_unicode_funcs());
-#if !HB_VERSION_ATLEAST(1, 1, 0)
 hb_unicode_funcs_set_decompose_compatibility_func(ufuncs, 
unicodeDecomposeCompatibility, nullptr, nullptr);
-#endif
 return ufuncs;
 }
+#endif
 
 #if defined(_WIN32)
 CommonSalLayout::CommonSalLayout(WinSalGraphics* WSL, WinFontInstance& 
rWinFontInstance, const WinFontFace& rWinFontFace)
@@ -392,8 +393,8 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
 nHbFlags |= HB_BUFFER_FLAG_EOT; /* End-of-text */
 
 hb_buffer_t *pHbBuffer = hb_buffer_create();
-static hb_unicode_funcs_t* pHbUnicodeFuncs = getUnicodeFuncs();
 #if !HB_VERSION_ATLEAST(1, 1, 0)
+static hb_unicode_funcs_t* pHbUnicodeFuncs = getUnicodeFuncs();
 hb_buffer_set_unicode_funcs(pHbBuffer, pHbUnicodeFuncs);
 #endif
 if (SAL_UNLIKELY(bVertical))
@@ -452,7 +453,7 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
 else
 {
 #if HB_VERSION_ATLEAST(0, 9, 42)
-if (hb_unicode_general_category (pHbUnicodeFuncs, aChar) 
== HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)
+if (u_getIntPropertyValu

[Libreoffice-commits] core.git: Branch 'feature/commonsallayout' - vcl/quartz

2016-10-13 Thread Khaled Hosny
 vcl/quartz/salgdi.cxx |   42 ++
 1 file changed, 42 insertions(+)

New commits:
commit 28bfc0984b1728b5a82c6b630277646b4c0a2794
Author: Khaled Hosny 
Date:   Fri Oct 14 02:19:32 2016 +0200

Untested first part of macOS font fallback

Change-Id: I0d9a5b9f951755e8f12d26116ee2c99bda1d42ce

diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index bb99737..37982a8 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -55,6 +55,45 @@
 
 using namespace vcl;
 
+class CoreTextGlyphFallbackSubstititution
+:public ImplGlyphFallbackFontSubstitution
+{
+public:
+bool FindFontSubstitute(FontSelectPattern&, OUString&) const override;
+}
+
+bool 
CoreTextGlyphFallbackSubstititution::FindFontSubstitute(FontSelectPattern& 
rPattern,
+OUString& rMissingChars) const
+{
+bool bFound = false;
+CoreTextStyle rStyle(rPattern);
+CTFontRef pFont = 
static_cast(CFDictionaryGetValue(rStyle.GetStyleDict(), 
kCTFontAttributeName));
+CFStringRef pStr = CreateCFString(rMissingChars);
+if (pStr)
+{
+CTFontRef pFallback = CTFontCreateForString(pFont, pStr, 
CFRangeMake(0, CFStringGetLength(pStr)));
+if (pFallback)
+{
+bFound = true;
+
+CTFontDescriptorRef pDesc = CTFontCopyFontDescriptor(pFallback);
+FontAttributes rAttr = DevFontFromCTFontDescriptor(pDesc, nullptr);
+
+rPattern.maSearchName = rAttr.GetFamilyName();
+
+rPattern.SetWeight(rAttr.GetWeight());
+rPattern.SetItalic(rAttr.GetItalic());
+rPattern.SetPitch(rAttr.GetPitch());
+rPattern.SetWidthType(rAttr.GetWidthType());
+
+CFRelease(pFallback);
+}
+CFRelease(pStr);
+}
+
+return bFound;
+}
+
 CoreTextFontFace::CoreTextFontFace( const CoreTextFontFace& rSrc )
   : PhysicalFontFace( rSrc )
   , mnFontId( rSrc.mnFontId )
@@ -387,6 +426,9 @@ void AquaSalGraphics::GetDevFontList( 
PhysicalFontCollection* pFontCollection )
 
 // Copy all PhysicalFontFace objects contained in the SystemFontList
 pSalData->mpFontList->AnnounceFonts( *pFontCollection );
+
+static CoreTextGlyphFallbackSubstititution aSubstFallback;
+pFontCollection->SetFallbackHook(&aSubstFallback);
 }
 
 void AquaSalGraphics::ClearDevFontCache()
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/commonsallayout' - vcl/inc vcl/quartz

2016-10-14 Thread Khaled Hosny
Rebased ref, commits from common ancestor:
commit 8a4aba454b3c3bb657b837cc6b2296313e28d7b0
Author: Khaled Hosny 
Date:   Fri Oct 14 02:50:27 2016 -0700

Support font fallback on macOS for CommonSalLayout

Change-Id: Ifd26b7f14ed77a3aa2a38e5961cac5f9bbb6d796

diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index f7e5156..6958541 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -102,6 +102,8 @@ public:
 hb_font_t* GetHbFont() const { return mpHbFont; }
 void   SetHbFont(hb_font_t* pHbFont) const { mpHbFont = pHbFont; }
 
+CFMutableDictionaryRef  GetStyleDict( void ) const { return mpStyleDict; }
+
 const CoreTextFontFace*  mpFontData;
 /// <1.0: font is squeezed, >1.0 font is stretched, else 1.0
 float   mfFontStretch;
@@ -113,11 +115,6 @@ private:
 /// CoreText text style object
 CFMutableDictionaryRef  mpStyleDict;
 mutable hb_font_t*  mpHbFont;
-
-friend class CTLayout;
-friend class AquaSalGraphics;
-friend class CommonSalLayout;
-CFMutableDictionaryRef  GetStyleDict( void ) const { return mpStyleDict; }
 };
 
 // TODO: move into cross-platform headers
@@ -172,8 +169,8 @@ protected:
 RGBAColor   maFillColor;
 
 // Device Font settings
-const CoreTextFontFace* mpFontData;
-CoreTextStyle*  mpTextStyle;
+const CoreTextFontFace* mpFontData[MAX_FALLBACK];
+CoreTextStyle*  mpTextStyle[MAX_FALLBACK];
 RGBAColor   maTextColor;
 /// allows text to be rendered without antialiasing
 boolmbNonAntialiasedText;
diff --git a/vcl/quartz/ctlayout.cxx b/vcl/quartz/ctlayout.cxx
index 856e066..983f50b 100644
--- a/vcl/quartz/ctlayout.cxx
+++ b/vcl/quartz/ctlayout.cxx
@@ -28,7 +28,6 @@
 #include "quartz/ctfonts.hxx"
 #include "CTRunData.hxx"
 #include "quartz/utils.h"
-#include "CommonSalLayout.hxx"
 
 
 class CTLayout : public SalLayout
@@ -782,10 +781,7 @@ void CTLayout::Simplify( bool /*bIsBase*/ ) {}
 
 SalLayout* CoreTextStyle::GetTextLayout() const
 {
-if (SalLayout::UseCommonLayout())
-return new CommonSalLayout(*this);
-else
-return new CTLayout(this);
+return new CTLayout(this);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index bb99737..bb28cdf 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -42,6 +42,8 @@
 #include "impfontcharmap.hxx"
 #include "impfontmetricdata.hxx"
 #include "CommonSalLayout.hxx"
+#include "outdev.h"
+#include "PhysicalFontCollection.hxx"
 
 #ifdef MACOSX
 #include "osx/salframe.h"
@@ -55,6 +57,49 @@
 
 using namespace vcl;
 
+class CoreTextGlyphFallbackSubstititution
+:public ImplGlyphFallbackFontSubstitution
+{
+public:
+bool FindFontSubstitute(FontSelectPattern&, OUString&) const override;
+};
+
+bool 
CoreTextGlyphFallbackSubstititution::FindFontSubstitute(FontSelectPattern& 
rPattern,
+OUString& rMissingChars) const
+{
+bool bFound = false;
+CoreTextStyle rStyle(rPattern);
+CTFontRef pFont = 
static_cast(CFDictionaryGetValue(rStyle.GetStyleDict(), 
kCTFontAttributeName));
+CFStringRef pStr = CreateCFString(rMissingChars);
+if (pStr)
+{
+CTFontRef pFallback = CTFontCreateForString(pFont, pStr, 
CFRangeMake(0, CFStringGetLength(pStr)));
+if (pFallback)
+{
+bFound = true;
+
+CTFontDescriptorRef pDesc = CTFontCopyFontDescriptor(pFallback);
+FontAttributes rAttr = DevFontFromCTFontDescriptor(pDesc, nullptr);
+
+rPattern.maSearchName = rAttr.GetFamilyName();
+
+rPattern.SetWeight(rAttr.GetWeight());
+rPattern.SetItalic(rAttr.GetItalic());
+rPattern.SetPitch(rAttr.GetPitch());
+rPattern.SetWidthType(rAttr.GetWidthType());
+
+SalData* pSalData = GetSalData();
+if (pSalData->mpFontList != nullptr)
+rPattern.mpFontData = 
pSalData->mpFontList->GetFontDataFromId(reinterpret_cast(pDesc));
+
+CFRelease(pFallback);
+}
+CFRelease(pStr);
+}
+
+return bFound;
+}
+
 CoreTextFontFace::CoreTextFontFace( const CoreTextFontFace& rSrc )
   : PhysicalFontFace( rSrc )
   , mnFontId( rSrc.mnFontId )
@@ -245,8 +290,6 @@ AquaSalGraphics::AquaSalGraphics()
 , mxClipPath( nullptr )
 , maLineColor( COL_WHITE )
 , maFillColor( COL_BLACK )
-, mpFontData( nullptr )
-, mpTextStyle( nullptr )
 , maTextColor( COL_BLACK )
 , mbNonAntialiasedText( false )
 , mbPrinter( false )
@@ -258,6 +301,12 @@ AquaSalGraphics::AquaSalGraphics()
 #endif
 {
 SAL_INFO( "vcl.quartz&quo

[Libreoffice-commits] core.git: Branch 'feature/commonsallayout' - vcl/inc vcl/quartz

2016-10-14 Thread Khaled Hosny
Rebased ref, commits from common ancestor:
commit 06971a9d9a17e73c8f589df1f9a0402c8ce8cab7
Author: Khaled Hosny 
Date:   Fri Oct 14 02:50:27 2016 -0700

Support font fallback on macOS for CommonSalLayout

Change-Id: Ifd26b7f14ed77a3aa2a38e5961cac5f9bbb6d796

diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index f7e5156..6958541 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -102,6 +102,8 @@ public:
 hb_font_t* GetHbFont() const { return mpHbFont; }
 void   SetHbFont(hb_font_t* pHbFont) const { mpHbFont = pHbFont; }
 
+CFMutableDictionaryRef  GetStyleDict( void ) const { return mpStyleDict; }
+
 const CoreTextFontFace*  mpFontData;
 /// <1.0: font is squeezed, >1.0 font is stretched, else 1.0
 float   mfFontStretch;
@@ -113,11 +115,6 @@ private:
 /// CoreText text style object
 CFMutableDictionaryRef  mpStyleDict;
 mutable hb_font_t*  mpHbFont;
-
-friend class CTLayout;
-friend class AquaSalGraphics;
-friend class CommonSalLayout;
-CFMutableDictionaryRef  GetStyleDict( void ) const { return mpStyleDict; }
 };
 
 // TODO: move into cross-platform headers
@@ -172,8 +169,8 @@ protected:
 RGBAColor   maFillColor;
 
 // Device Font settings
-const CoreTextFontFace* mpFontData;
-CoreTextStyle*  mpTextStyle;
+const CoreTextFontFace* mpFontData[MAX_FALLBACK];
+CoreTextStyle*  mpTextStyle[MAX_FALLBACK];
 RGBAColor   maTextColor;
 /// allows text to be rendered without antialiasing
 boolmbNonAntialiasedText;
diff --git a/vcl/quartz/ctlayout.cxx b/vcl/quartz/ctlayout.cxx
index 856e066..983f50b 100644
--- a/vcl/quartz/ctlayout.cxx
+++ b/vcl/quartz/ctlayout.cxx
@@ -28,7 +28,6 @@
 #include "quartz/ctfonts.hxx"
 #include "CTRunData.hxx"
 #include "quartz/utils.h"
-#include "CommonSalLayout.hxx"
 
 
 class CTLayout : public SalLayout
@@ -782,10 +781,7 @@ void CTLayout::Simplify( bool /*bIsBase*/ ) {}
 
 SalLayout* CoreTextStyle::GetTextLayout() const
 {
-if (SalLayout::UseCommonLayout())
-return new CommonSalLayout(*this);
-else
-return new CTLayout(this);
+return new CTLayout(this);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index bb99737..a7895c3 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -42,6 +42,8 @@
 #include "impfontcharmap.hxx"
 #include "impfontmetricdata.hxx"
 #include "CommonSalLayout.hxx"
+#include "outdev.h"
+#include "PhysicalFontCollection.hxx"
 
 #ifdef MACOSX
 #include "osx/salframe.h"
@@ -55,6 +57,49 @@
 
 using namespace vcl;
 
+class CoreTextGlyphFallbackSubstititution
+:public ImplGlyphFallbackFontSubstitution
+{
+public:
+bool FindFontSubstitute(FontSelectPattern&, OUString&) const override;
+};
+
+bool 
CoreTextGlyphFallbackSubstititution::FindFontSubstitute(FontSelectPattern& 
rPattern,
+OUString& rMissingChars) const
+{
+bool bFound = false;
+CoreTextStyle rStyle(rPattern);
+CTFontRef pFont = 
static_cast(CFDictionaryGetValue(rStyle.GetStyleDict(), 
kCTFontAttributeName));
+CFStringRef pStr = CreateCFString(rMissingChars);
+if (pStr)
+{
+CTFontRef pFallback = CTFontCreateForString(pFont, pStr, 
CFRangeMake(0, CFStringGetLength(pStr)));
+if (pFallback)
+{
+bFound = true;
+
+CTFontDescriptorRef pDesc = CTFontCopyFontDescriptor(pFallback);
+FontAttributes rAttr = DevFontFromCTFontDescriptor(pDesc, nullptr);
+
+rPattern.maSearchName = rAttr.GetFamilyName();
+
+rPattern.SetWeight(rAttr.GetWeight());
+rPattern.SetItalic(rAttr.GetItalic());
+rPattern.SetPitch(rAttr.GetPitch());
+rPattern.SetWidthType(rAttr.GetWidthType());
+
+SalData* pSalData = GetSalData();
+if (pSalData->mpFontList)
+rPattern.mpFontData = 
pSalData->mpFontList->GetFontDataFromId(reinterpret_cast(pDesc));
+
+CFRelease(pFallback);
+}
+CFRelease(pStr);
+}
+
+return bFound;
+}
+
 CoreTextFontFace::CoreTextFontFace( const CoreTextFontFace& rSrc )
   : PhysicalFontFace( rSrc )
   , mnFontId( rSrc.mnFontId )
@@ -245,8 +290,6 @@ AquaSalGraphics::AquaSalGraphics()
 , mxClipPath( nullptr )
 , maLineColor( COL_WHITE )
 , maFillColor( COL_BLACK )
-, mpFontData( nullptr )
-, mpTextStyle( nullptr )
 , maTextColor( COL_BLACK )
 , mbNonAntialiasedText( false )
 , mbPrinter( false )
@@ -258,6 +301,12 @@ AquaSalGraphics::AquaSalGraphics()
 #endif
 {
 SAL_INFO( "vcl.quartz", "AquaSalGraphi

[Libreoffice-commits] core.git: Branch 'feature/commonsallayout' - vcl/inc vcl/quartz

2016-10-14 Thread Khaled Hosny
Rebased ref, commits from common ancestor:
commit 7ea4cca3d3a1912e59e113d756ed3fe1662f96fb
Author: Khaled Hosny 
Date:   Fri Oct 14 02:50:27 2016 -0700

Support font fallback on macOS for CommonSalLayout

Change-Id: Ifd26b7f14ed77a3aa2a38e5961cac5f9bbb6d796

diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index f7e5156..6958541 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -102,6 +102,8 @@ public:
 hb_font_t* GetHbFont() const { return mpHbFont; }
 void   SetHbFont(hb_font_t* pHbFont) const { mpHbFont = pHbFont; }
 
+CFMutableDictionaryRef  GetStyleDict( void ) const { return mpStyleDict; }
+
 const CoreTextFontFace*  mpFontData;
 /// <1.0: font is squeezed, >1.0 font is stretched, else 1.0
 float   mfFontStretch;
@@ -113,11 +115,6 @@ private:
 /// CoreText text style object
 CFMutableDictionaryRef  mpStyleDict;
 mutable hb_font_t*  mpHbFont;
-
-friend class CTLayout;
-friend class AquaSalGraphics;
-friend class CommonSalLayout;
-CFMutableDictionaryRef  GetStyleDict( void ) const { return mpStyleDict; }
 };
 
 // TODO: move into cross-platform headers
@@ -172,8 +169,8 @@ protected:
 RGBAColor   maFillColor;
 
 // Device Font settings
-const CoreTextFontFace* mpFontData;
-CoreTextStyle*  mpTextStyle;
+const CoreTextFontFace* mpFontData[MAX_FALLBACK];
+CoreTextStyle*  mpTextStyle[MAX_FALLBACK];
 RGBAColor   maTextColor;
 /// allows text to be rendered without antialiasing
 boolmbNonAntialiasedText;
diff --git a/vcl/quartz/ctlayout.cxx b/vcl/quartz/ctlayout.cxx
index 856e066..983f50b 100644
--- a/vcl/quartz/ctlayout.cxx
+++ b/vcl/quartz/ctlayout.cxx
@@ -28,7 +28,6 @@
 #include "quartz/ctfonts.hxx"
 #include "CTRunData.hxx"
 #include "quartz/utils.h"
-#include "CommonSalLayout.hxx"
 
 
 class CTLayout : public SalLayout
@@ -782,10 +781,7 @@ void CTLayout::Simplify( bool /*bIsBase*/ ) {}
 
 SalLayout* CoreTextStyle::GetTextLayout() const
 {
-if (SalLayout::UseCommonLayout())
-return new CommonSalLayout(*this);
-else
-return new CTLayout(this);
+return new CTLayout(this);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index bb99737..caa7e35 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -42,6 +42,8 @@
 #include "impfontcharmap.hxx"
 #include "impfontmetricdata.hxx"
 #include "CommonSalLayout.hxx"
+#include "outdev.h"
+#include "PhysicalFontCollection.hxx"
 
 #ifdef MACOSX
 #include "osx/salframe.h"
@@ -55,6 +57,49 @@
 
 using namespace vcl;
 
+class CoreTextGlyphFallbackSubstititution
+:public ImplGlyphFallbackFontSubstitution
+{
+public:
+bool FindFontSubstitute(FontSelectPattern&, OUString&) const override;
+};
+
+bool 
CoreTextGlyphFallbackSubstititution::FindFontSubstitute(FontSelectPattern& 
rPattern,
+OUString& rMissingChars) const
+{
+bool bFound = false;
+CoreTextStyle rStyle(rPattern);
+CTFontRef pFont = 
static_cast(CFDictionaryGetValue(rStyle.GetStyleDict(), 
kCTFontAttributeName));
+CFStringRef pStr = CreateCFString(rMissingChars);
+if (pStr)
+{
+CTFontRef pFallback = CTFontCreateForString(pFont, pStr, 
CFRangeMake(0, CFStringGetLength(pStr)));
+if (pFallback)
+{
+bFound = true;
+
+CTFontDescriptorRef pDesc = CTFontCopyFontDescriptor(pFallback);
+FontAttributes rAttr = DevFontFromCTFontDescriptor(pDesc, nullptr);
+
+rPattern.maSearchName = rAttr.GetFamilyName();
+
+rPattern.SetWeight(rAttr.GetWeight());
+rPattern.SetItalic(rAttr.GetItalic());
+rPattern.SetPitch(rAttr.GetPitch());
+rPattern.SetWidthType(rAttr.GetWidthType());
+
+SalData* pSalData = GetSalData();
+if (pSalData->mpFontList)
+rPattern.mpFontData = 
pSalData->mpFontList->GetFontDataFromId(reinterpret_cast(pDesc));
+
+CFRelease(pFallback);
+}
+CFRelease(pStr);
+}
+
+return bFound;
+}
+
 CoreTextFontFace::CoreTextFontFace( const CoreTextFontFace& rSrc )
   : PhysicalFontFace( rSrc )
   , mnFontId( rSrc.mnFontId )
@@ -245,8 +290,6 @@ AquaSalGraphics::AquaSalGraphics()
 , mxClipPath( nullptr )
 , maLineColor( COL_WHITE )
 , maFillColor( COL_BLACK )
-, mpFontData( nullptr )
-, mpTextStyle( nullptr )
 , maTextColor( COL_BLACK )
 , mbNonAntialiasedText( false )
 , mbPrinter( false )
@@ -258,6 +301,12 @@ AquaSalGraphics::AquaSalGraphics()
 #endif
 {
 SAL_INFO( "vcl.quartz", "AquaSalGraphi

[Libreoffice-commits] core.git: Branch 'feature/commonsallayout' - 7 commits - vcl/inc vcl/quartz vcl/source vcl/unx vcl/win

2016-10-14 Thread Khaled Hosny
Rebased ref, commits from common ancestor:
commit c8e0298987f12f732c686f3ccd2ee4e342d8f89c
Author: Khaled Hosny 
Date:   Fri Oct 14 02:50:27 2016 -0700

Support font fallback on macOS for CommonSalLayout

Change-Id: Ifd26b7f14ed77a3aa2a38e5961cac5f9bbb6d796

diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index f7e5156..6958541 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -102,6 +102,8 @@ public:
 hb_font_t* GetHbFont() const { return mpHbFont; }
 void   SetHbFont(hb_font_t* pHbFont) const { mpHbFont = pHbFont; }
 
+CFMutableDictionaryRef  GetStyleDict( void ) const { return mpStyleDict; }
+
 const CoreTextFontFace*  mpFontData;
 /// <1.0: font is squeezed, >1.0 font is stretched, else 1.0
 float   mfFontStretch;
@@ -113,11 +115,6 @@ private:
 /// CoreText text style object
 CFMutableDictionaryRef  mpStyleDict;
 mutable hb_font_t*  mpHbFont;
-
-friend class CTLayout;
-friend class AquaSalGraphics;
-friend class CommonSalLayout;
-CFMutableDictionaryRef  GetStyleDict( void ) const { return mpStyleDict; }
 };
 
 // TODO: move into cross-platform headers
@@ -172,8 +169,8 @@ protected:
 RGBAColor   maFillColor;
 
 // Device Font settings
-const CoreTextFontFace* mpFontData;
-CoreTextStyle*  mpTextStyle;
+const CoreTextFontFace* mpFontData[MAX_FALLBACK];
+CoreTextStyle*  mpTextStyle[MAX_FALLBACK];
 RGBAColor   maTextColor;
 /// allows text to be rendered without antialiasing
 boolmbNonAntialiasedText;
diff --git a/vcl/quartz/ctlayout.cxx b/vcl/quartz/ctlayout.cxx
index 856e066..983f50b 100644
--- a/vcl/quartz/ctlayout.cxx
+++ b/vcl/quartz/ctlayout.cxx
@@ -28,7 +28,6 @@
 #include "quartz/ctfonts.hxx"
 #include "CTRunData.hxx"
 #include "quartz/utils.h"
-#include "CommonSalLayout.hxx"
 
 
 class CTLayout : public SalLayout
@@ -782,10 +781,7 @@ void CTLayout::Simplify( bool /*bIsBase*/ ) {}
 
 SalLayout* CoreTextStyle::GetTextLayout() const
 {
-if (SalLayout::UseCommonLayout())
-return new CommonSalLayout(*this);
-else
-return new CTLayout(this);
+return new CTLayout(this);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index bb99737..caa7e35 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -42,6 +42,8 @@
 #include "impfontcharmap.hxx"
 #include "impfontmetricdata.hxx"
 #include "CommonSalLayout.hxx"
+#include "outdev.h"
+#include "PhysicalFontCollection.hxx"
 
 #ifdef MACOSX
 #include "osx/salframe.h"
@@ -55,6 +57,49 @@
 
 using namespace vcl;
 
+class CoreTextGlyphFallbackSubstititution
+:public ImplGlyphFallbackFontSubstitution
+{
+public:
+bool FindFontSubstitute(FontSelectPattern&, OUString&) const override;
+};
+
+bool 
CoreTextGlyphFallbackSubstititution::FindFontSubstitute(FontSelectPattern& 
rPattern,
+OUString& rMissingChars) const
+{
+bool bFound = false;
+CoreTextStyle rStyle(rPattern);
+CTFontRef pFont = 
static_cast(CFDictionaryGetValue(rStyle.GetStyleDict(), 
kCTFontAttributeName));
+CFStringRef pStr = CreateCFString(rMissingChars);
+if (pStr)
+{
+CTFontRef pFallback = CTFontCreateForString(pFont, pStr, 
CFRangeMake(0, CFStringGetLength(pStr)));
+if (pFallback)
+{
+bFound = true;
+
+CTFontDescriptorRef pDesc = CTFontCopyFontDescriptor(pFallback);
+FontAttributes rAttr = DevFontFromCTFontDescriptor(pDesc, nullptr);
+
+rPattern.maSearchName = rAttr.GetFamilyName();
+
+rPattern.SetWeight(rAttr.GetWeight());
+rPattern.SetItalic(rAttr.GetItalic());
+rPattern.SetPitch(rAttr.GetPitch());
+rPattern.SetWidthType(rAttr.GetWidthType());
+
+SalData* pSalData = GetSalData();
+if (pSalData->mpFontList)
+rPattern.mpFontData = 
pSalData->mpFontList->GetFontDataFromId(reinterpret_cast(pDesc));
+
+CFRelease(pFallback);
+}
+CFRelease(pStr);
+}
+
+return bFound;
+}
+
 CoreTextFontFace::CoreTextFontFace( const CoreTextFontFace& rSrc )
   : PhysicalFontFace( rSrc )
   , mnFontId( rSrc.mnFontId )
@@ -245,8 +290,6 @@ AquaSalGraphics::AquaSalGraphics()
 , mxClipPath( nullptr )
 , maLineColor( COL_WHITE )
 , maFillColor( COL_BLACK )
-, mpFontData( nullptr )
-, mpTextStyle( nullptr )
 , maTextColor( COL_BLACK )
 , mbNonAntialiasedText( false )
 , mbPrinter( false )
@@ -258,6 +301,12 @@ AquaSalGraphics::AquaSalGraphics()
 #endif
 {
 SAL_INFO( "vcl.quartz", "AquaSalGraphi

[Libreoffice-commits] core.git: Branch 'feature/commonsallayout' - vcl/source vcl/unx

2016-10-14 Thread Khaled Hosny
 vcl/source/gdi/CommonSalLayout.cxx  |   92 
 vcl/unx/generic/gdi/cairotextrender.cxx |5 +
 2 files changed, 86 insertions(+), 11 deletions(-)

New commits:
commit b2fef34ef91b155d21b07cd6c0a0233810b80db9
Author: Khaled Hosny 
Date:   Mon Sep 26 19:09:52 2016 +0200

Support vertical text in CommonSalLayout

Change-Id: I52a71c9c21ad75c7cb9c8574e5e7e3b7c1c0c0c3

diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index feb37eb..7ee034a 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -212,12 +212,12 @@ struct HbScriptRun
 {
 int32_t mnMin;
 int32_t mnEnd;
-hb_script_t maScript;
+UScriptCode maScript;
 
 HbScriptRun(int32_t nMin, int32_t nEnd, UScriptCode aScript)
   : mnMin(nMin)
   , mnEnd(nEnd)
-  , maScript(hb_icu_script_to_script(aScript))
+  , maScript(aScript)
 {}
 };
 
@@ -307,6 +307,47 @@ void CommonSalLayout::DrawText(SalGraphics& rSalGraphics) 
const
 rSalGraphics.DrawSalLayout( *this );
 }
 
+/* https://drafts.csswg.org/css-writing-modes-3/#script-orientations */
+static int GetVerticalFlagsForScript(UScriptCode aScript)
+{
+int nFlag = GF_NONE;
+
+switch (aScript)
+{
+/* ttb 0° */
+case USCRIPT_BOPOMOFO:
+case USCRIPT_EGYPTIAN_HIEROGLYPHS:
+case USCRIPT_HAN:
+case USCRIPT_HANGUL:
+case USCRIPT_HIRAGANA:
+case USCRIPT_KATAKANA:
+case USCRIPT_MEROITIC_CURSIVE:
+case USCRIPT_MEROITIC_HIEROGLYPHS:
+case USCRIPT_YI:
+nFlag = GF_ROTL;
+break;
+#if 0
+/* ttb 90° */
+case USCRIPT_MONGOLIAN:
+case USCRIPT_PHAGS_PA:
+nFlag = ??;
+break;
+/* ttb -90° */
+case USCRIPT_ORKHON:
+nFlag = ??;
+break;
+/* btt -90° */
+case USCRIPT_MONGOLIAN:
+nFlag = ??;
+break;
+#endif
+default:
+break;
+}
+
+return nFlag;
+}
+
 bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
 {
 hb_script_t aHbScript = HB_SCRIPT_INVALID;
@@ -371,11 +412,19 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
 int nMinRunPos = aScriptRun.mnMin;
 int nEndRunPos = aScriptRun.mnEnd;
 int nRunLen = nEndRunPos - nMinRunPos;
-aHbScript = aScriptRun.maScript;
+aHbScript = hb_icu_script_to_script(aScriptRun.maScript);
+
 // hb_language_from_string() accept ISO639-3 language tag except 
for Chinese.
 LanguageTag &rTag = rArgs.maLanguageTag;
 OString sLanguage = OUStringToOString(rTag.getBcp47(), 
RTL_TEXTENCODING_ASCII_US);
 
+bool bVertical = false;
+if ((rArgs.mnFlags & SalLayoutFlags::Vertical) &&
+GetVerticalFlagsForScript(aScriptRun.maScript) == GF_ROTL)
+{
+bVertical = true;
+}
+
 int nHbFlags = HB_BUFFER_FLAGS_DEFAULT;
 if (nMinRunPos == 0)
 nHbFlags |= HB_BUFFER_FLAG_BOT; /* Beginning-of-text */
@@ -387,7 +436,10 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
 static hb_unicode_funcs_t* pHbUnicodeFuncs = getUnicodeFuncs();
 hb_buffer_set_unicode_funcs(pHbBuffer, pHbUnicodeFuncs);
 #endif
-hb_buffer_set_direction(pHbBuffer, bRightToLeft ? 
HB_DIRECTION_RTL: HB_DIRECTION_LTR);
+if (bVertical)
+hb_buffer_set_direction(pHbBuffer, HB_DIRECTION_TTB);
+else
+hb_buffer_set_direction(pHbBuffer, bRightToLeft ? 
HB_DIRECTION_RTL: HB_DIRECTION_LTR);
 hb_buffer_set_script(pHbBuffer, aHbScript);
 hb_buffer_set_language(pHbBuffer, 
hb_language_from_string(sLanguage.getStr(), -1));
 hb_buffer_set_flags(pHbBuffer, (hb_buffer_flags_t) nHbFlags);
@@ -452,17 +504,35 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
 if (bDiacritic)
 nGlyphFlags |= GlyphItem::IS_DIACRITIC;
 
-int32_t nXOffset =  pHbPositions[i].x_offset >> 6;
-int32_t nYOffset =  pHbPositions[i].y_offset >> 6;
-int32_t nXAdvance = pHbPositions[i].x_advance >> 6;
-int32_t nYAdvance = pHbPositions[i].y_advance >> 6;
+int32_t nAdvance, nXOffset, nYOffset;
+if (bVertical)
+{
+int nVertFlag;
+#if 0   /* XXX: does not work as expected for Common script */
+UErrorCode error = U_ZERO_ERROR;
+nVertFlag = 
GetVerticalFlagsForScript(uscript_getScript(aChar, &error));
+#else
+nVertFlag = GetVerticalFlags(aChar);
+if (nVertFlag == GF_ROTR)
+nVertFlag 

[Libreoffice-commits] core.git: Branch 'feature/commonsallayout' - vcl/quartz

2016-10-15 Thread Khaled Hosny
 vcl/quartz/salgdi.cxx |   85 +-
 1 file changed, 63 insertions(+), 22 deletions(-)

New commits:
commit d557cae6d36faa6bde6a66c085ae009e7a276eeb
Author: Khaled Hosny 
Date:   Sat Oct 15 06:11:26 2016 -0700

Rewrite AquaSalGraphics::DrawSalLayout()

Slightly cleaner code and now handles glyph rotation for vertical text.

Change-Id: I98cc8fd7df5e73068294e4d7dd6b38a71dcbdcc7

diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index caa7e35..1f156e0 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -485,37 +485,78 @@ bool AquaSalGraphics::GetGlyphBoundRect( sal_GlyphId 
aGlyphId, Rectangle& rRect
 
 void AquaSalGraphics::DrawSalLayout(const CommonSalLayout& rLayout)
 {
-CGContextRef context = mrContext;
-SAL_INFO("vcl.ct", "CGContextSaveGState(" << context << ")");
-CGContextSaveGState(context);
-SAL_INFO("vcl.ct", "CGContextScaleCTM(" << context << ",1.0,-1.0)");
-const CoreTextStyle& rCTStyle = rLayout.getFontData();
-
-CTFontRef pFont = 
static_cast(CFDictionaryGetValue(rCTStyle.GetStyleDict(), 
kCTFontAttributeName));
-CGContextScaleCTM(context, 1.0, -1.0);
-CGContextSetShouldAntialias(context, !mbNonAntialiasedText);
-// rotate the matrix
-const CGFloat fRadians = rCTStyle.mfFontRotation;
-CGContextRotateCTM(context, +fRadians);
-const CGAffineTransform aInvMatrix = 
CGAffineTransformMakeRotation(-fRadians);
-CGContextSetFillColor(context, maTextColor.AsArray());
-
-// draw the text
+const CoreTextStyle& rStyle = rLayout.getFontData();
+const FontSelectPattern& rFontSelect = rStyle.maFontSelData;
+if (rFontSelect.mnHeight == 0)
+return;
+
+CTFontRef pFont = 
static_cast(CFDictionaryGetValue(rStyle.GetStyleDict(), 
kCTFontAttributeName));
+
 Point aPos;
 sal_GlyphId aGlyphId;
 std::vector aGlyphIds;
 std::vector aGlyphPos;
+std::vector aGlyphRotation;
 int nStart = 0;
-for (; rLayout.GetNextGlyphs(1, &aGlyphId, aPos, nStart); )
+while (rLayout.GetNextGlyphs(1, &aGlyphId, aPos, nStart))
 {
+CGAffineTransform aMatrix = 
CGAffineTransformMakeRotation(-rStyle.mfFontRotation);
+bool nGlyphRotation = false;
+if ((aGlyphId & GF_ROTMASK) == GF_ROTL)
+{
+nGlyphRotation = true;
+double nYdiff = CTFontGetAscent(pFont) - CTFontGetDescent(pFont);
+aMatrix = CGAffineTransformTranslate(aMatrix, 0, -nYdiff);
+}
+
 aGlyphIds.push_back(aGlyphId & GF_IDXMASK);
-aGlyphPos.push_back(CGPointApplyAffineTransform(CGPointMake(aPos.X(), 
-1*aPos.Y()), aInvMatrix));
+aGlyphPos.push_back(CGPointApplyAffineTransform(CGPointMake(aPos.X(), 
-aPos.Y()), aMatrix));
+aGlyphRotation.push_back(nGlyphRotation);
+}
+
+if (aGlyphIds.empty())
+return;
+
+CGContextSaveGState(mrContext);
+
+CTFontRef pRotatedFont = nullptr;
+if (rStyle.mfFontRotation)
+{
+CTFontDescriptorRef pDesc = CTFontCopyFontDescriptor(pFont);
+CGFloat nSize = CTFontGetSize(pFont);
+CGAffineTransform aMatrix = CTFontGetMatrix(pFont);
+aMatrix = CGAffineTransformRotate(aMatrix, -rStyle.mfFontRotation);
+pRotatedFont = CTFontCreateWithFontDescriptor(pDesc, nSize, &aMatrix);
+CFRelease(pDesc);
+}
+
+CGContextScaleCTM(mrContext, 1.0, -1.0);
+CGContextRotateCTM(mrContext, rStyle.mfFontRotation);
+CGContextSetShouldAntialias(mrContext, !mbNonAntialiasedText);
+CGContextSetFillColor(mrContext, maTextColor.AsArray());
+
+std::vector::const_iterator aStart = aGlyphRotation.begin();
+std::vector::const_iterator aEnd = aGlyphRotation.end();
+std::vector::const_iterator aI = aStart;
+while (aI != aEnd)
+{
+bool nGlyphRotation = *aI;
+std::vector::const_iterator aNext = std::find(aI + 1, aEnd, 
!nGlyphRotation);
+
+size_t nStartIndex = std::distance(aStart, aI);
+size_t nLen = std::distance(aI, aNext);
+
+if (nGlyphRotation && pRotatedFont)
+CTFontDrawGlyphs(pRotatedFont, &aGlyphIds[nStartIndex], 
&aGlyphPos[nStartIndex], nLen, mrContext);
+else
+CTFontDrawGlyphs(pFont, &aGlyphIds[nStartIndex], 
&aGlyphPos[nStartIndex], nLen, mrContext);
+
+aI = aNext;
 }
-CTFontDrawGlyphs(pFont, aGlyphIds.data(), aGlyphPos.data(), nStart, 
context);
 
-// restore the original graphic context transformations
-SAL_INFO("vcl.ct", "CGContextRestoreGState(" << context << ")");
-CGContextRestoreGState(context);
+if (pRotatedFont)
+CFRelease(pRotatedFont);
+CGContextRestoreGState(mrContext);
 }
 
 void AquaSalGraphics::SetFont(FontSelectPattern* pReqFont, int nFallbackLevel)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/commonsallayout' - 404 commits - accessibility/inc accessibility/source avmedia/Module_avmedia.mk basctl/inc basctl/source basctl/uiconfig basegfx/sourc

2016-10-15 Thread Khaled Hosny
Rebased ref, commits from common ancestor:
commit 23c9ccfd1b6fc5cdee4913e96cd02e04c68459fe
Author: Khaled Hosny 
Date:   Sat Oct 15 06:11:26 2016 -0700

Rewrite AquaSalGraphics::DrawSalLayout()

Slightly cleaner code and now handles glyph rotation for vertical text.

Change-Id: I98cc8fd7df5e73068294e4d7dd6b38a71dcbdcc7

diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index 787ddbf..28e7e99 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -485,37 +485,78 @@ bool AquaSalGraphics::GetGlyphBoundRect( sal_GlyphId 
aGlyphId, Rectangle& rRect
 
 void AquaSalGraphics::DrawSalLayout(const CommonSalLayout& rLayout)
 {
-CGContextRef context = mrContext;
-SAL_INFO("vcl.ct", "CGContextSaveGState(" << context << ")");
-CGContextSaveGState(context);
-SAL_INFO("vcl.ct", "CGContextScaleCTM(" << context << ",1.0,-1.0)");
-const CoreTextStyle& rCTStyle = rLayout.getFontData();
-
-CTFontRef pFont = 
static_cast(CFDictionaryGetValue(rCTStyle.GetStyleDict(), 
kCTFontAttributeName));
-CGContextScaleCTM(context, 1.0, -1.0);
-CGContextSetShouldAntialias(context, !mbNonAntialiasedText);
-// rotate the matrix
-const CGFloat fRadians = rCTStyle.mfFontRotation;
-CGContextRotateCTM(context, +fRadians);
-const CGAffineTransform aInvMatrix = 
CGAffineTransformMakeRotation(-fRadians);
-CGContextSetFillColor(context, maTextColor.AsArray());
-
-// draw the text
+const CoreTextStyle& rStyle = rLayout.getFontData();
+const FontSelectPattern& rFontSelect = rStyle.maFontSelData;
+if (rFontSelect.mnHeight == 0)
+return;
+
+CTFontRef pFont = 
static_cast(CFDictionaryGetValue(rStyle.GetStyleDict(), 
kCTFontAttributeName));
+
 Point aPos;
 sal_GlyphId aGlyphId;
 std::vector aGlyphIds;
 std::vector aGlyphPos;
+std::vector aGlyphRotation;
 int nStart = 0;
-for (; rLayout.GetNextGlyphs(1, &aGlyphId, aPos, nStart); )
+while (rLayout.GetNextGlyphs(1, &aGlyphId, aPos, nStart))
 {
+CGAffineTransform aMatrix = 
CGAffineTransformMakeRotation(-rStyle.mfFontRotation);
+bool nGlyphRotation = false;
+if ((aGlyphId & GF_ROTMASK) == GF_ROTL)
+{
+nGlyphRotation = true;
+double nYdiff = CTFontGetAscent(pFont) - CTFontGetDescent(pFont);
+aMatrix = CGAffineTransformTranslate(aMatrix, 0, -nYdiff);
+}
+
 aGlyphIds.push_back(aGlyphId & GF_IDXMASK);
-aGlyphPos.push_back(CGPointApplyAffineTransform(CGPointMake(aPos.X(), 
-1*aPos.Y()), aInvMatrix));
+aGlyphPos.push_back(CGPointApplyAffineTransform(CGPointMake(aPos.X(), 
-aPos.Y()), aMatrix));
+aGlyphRotation.push_back(nGlyphRotation);
+}
+
+if (aGlyphIds.empty())
+return;
+
+CGContextSaveGState(mrContext);
+
+CTFontRef pRotatedFont = nullptr;
+if (rStyle.mfFontRotation)
+{
+CTFontDescriptorRef pDesc = CTFontCopyFontDescriptor(pFont);
+CGFloat nSize = CTFontGetSize(pFont);
+CGAffineTransform aMatrix = CTFontGetMatrix(pFont);
+aMatrix = CGAffineTransformRotate(aMatrix, -rStyle.mfFontRotation);
+pRotatedFont = CTFontCreateWithFontDescriptor(pDesc, nSize, &aMatrix);
+CFRelease(pDesc);
+}
+
+CGContextScaleCTM(mrContext, 1.0, -1.0);
+CGContextRotateCTM(mrContext, rStyle.mfFontRotation);
+CGContextSetShouldAntialias(mrContext, !mbNonAntialiasedText);
+CGContextSetFillColor(mrContext, maTextColor.AsArray());
+
+std::vector::const_iterator aStart = aGlyphRotation.begin();
+std::vector::const_iterator aEnd = aGlyphRotation.end();
+std::vector::const_iterator aI = aStart;
+while (aI != aEnd)
+{
+bool nGlyphRotation = *aI;
+std::vector::const_iterator aNext = std::find(aI + 1, aEnd, 
!nGlyphRotation);
+
+size_t nStartIndex = std::distance(aStart, aI);
+size_t nLen = std::distance(aI, aNext);
+
+if (nGlyphRotation && pRotatedFont)
+CTFontDrawGlyphs(pRotatedFont, &aGlyphIds[nStartIndex], 
&aGlyphPos[nStartIndex], nLen, mrContext);
+else
+CTFontDrawGlyphs(pFont, &aGlyphIds[nStartIndex], 
&aGlyphPos[nStartIndex], nLen, mrContext);
+
+aI = aNext;
 }
-CTFontDrawGlyphs(pFont, aGlyphIds.data(), aGlyphPos.data(), nStart, 
context);
 
-// restore the original graphic context transformations
-SAL_INFO("vcl.ct", "CGContextRestoreGState(" << context << ")");
-CGContextRestoreGState(context);
+if (pRotatedFont)
+CFRelease(pRotatedFont);
+    CGContextRestoreGState(mrContext);
 }
 
 void AquaSalGraphics::SetFont(FontSelectPattern* pReqFont, int nFallbackLevel)
commit 3c7f4735cd1c1e5d9f594699447bbf0eabe8e2f3
Author: Khaled Hosny 
Date:   Mon Sep 26 19:0

[Libreoffice-commits] core.git: Branch 'feature/commonsallayout' - 7 commits - vcl/inc vcl/quartz vcl/source vcl/unx vcl/win

2016-10-15 Thread Khaled Hosny
Rebased ref, commits from common ancestor:
commit bf7119d9217ba08c716af4f080623d2d167b989a
Author: Khaled Hosny 
Date:   Sat Oct 15 06:11:26 2016 -0700

Rewrite AquaSalGraphics::DrawSalLayout()

Slightly cleaner code and now handles glyph rotation for vertical text.

Change-Id: I98cc8fd7df5e73068294e4d7dd6b38a71dcbdcc7

diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index 787ddbf..28e7e99 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -485,37 +485,78 @@ bool AquaSalGraphics::GetGlyphBoundRect( sal_GlyphId 
aGlyphId, Rectangle& rRect
 
 void AquaSalGraphics::DrawSalLayout(const CommonSalLayout& rLayout)
 {
-CGContextRef context = mrContext;
-SAL_INFO("vcl.ct", "CGContextSaveGState(" << context << ")");
-CGContextSaveGState(context);
-SAL_INFO("vcl.ct", "CGContextScaleCTM(" << context << ",1.0,-1.0)");
-const CoreTextStyle& rCTStyle = rLayout.getFontData();
-
-CTFontRef pFont = 
static_cast(CFDictionaryGetValue(rCTStyle.GetStyleDict(), 
kCTFontAttributeName));
-CGContextScaleCTM(context, 1.0, -1.0);
-CGContextSetShouldAntialias(context, !mbNonAntialiasedText);
-// rotate the matrix
-const CGFloat fRadians = rCTStyle.mfFontRotation;
-CGContextRotateCTM(context, +fRadians);
-const CGAffineTransform aInvMatrix = 
CGAffineTransformMakeRotation(-fRadians);
-CGContextSetFillColor(context, maTextColor.AsArray());
-
-// draw the text
+const CoreTextStyle& rStyle = rLayout.getFontData();
+const FontSelectPattern& rFontSelect = rStyle.maFontSelData;
+if (rFontSelect.mnHeight == 0)
+return;
+
+CTFontRef pFont = 
static_cast(CFDictionaryGetValue(rStyle.GetStyleDict(), 
kCTFontAttributeName));
+
 Point aPos;
 sal_GlyphId aGlyphId;
 std::vector aGlyphIds;
 std::vector aGlyphPos;
+std::vector aGlyphRotation;
 int nStart = 0;
-for (; rLayout.GetNextGlyphs(1, &aGlyphId, aPos, nStart); )
+while (rLayout.GetNextGlyphs(1, &aGlyphId, aPos, nStart))
 {
+CGAffineTransform aMatrix = 
CGAffineTransformMakeRotation(-rStyle.mfFontRotation);
+bool nGlyphRotation = false;
+if ((aGlyphId & GF_ROTMASK) == GF_ROTL)
+{
+nGlyphRotation = true;
+double nYdiff = CTFontGetAscent(pFont) - CTFontGetDescent(pFont);
+aMatrix = CGAffineTransformTranslate(aMatrix, 0, -nYdiff);
+}
+
 aGlyphIds.push_back(aGlyphId & GF_IDXMASK);
-aGlyphPos.push_back(CGPointApplyAffineTransform(CGPointMake(aPos.X(), 
-1*aPos.Y()), aInvMatrix));
+aGlyphPos.push_back(CGPointApplyAffineTransform(CGPointMake(aPos.X(), 
-aPos.Y()), aMatrix));
+aGlyphRotation.push_back(nGlyphRotation);
+}
+
+if (aGlyphIds.empty())
+return;
+
+CGContextSaveGState(mrContext);
+
+CTFontRef pRotatedFont = nullptr;
+if (rStyle.mfFontRotation)
+{
+CTFontDescriptorRef pDesc = CTFontCopyFontDescriptor(pFont);
+CGFloat nSize = CTFontGetSize(pFont);
+CGAffineTransform aMatrix = CTFontGetMatrix(pFont);
+aMatrix = CGAffineTransformRotate(aMatrix, -rStyle.mfFontRotation);
+pRotatedFont = CTFontCreateWithFontDescriptor(pDesc, nSize, &aMatrix);
+CFRelease(pDesc);
+}
+
+CGContextScaleCTM(mrContext, 1.0, -1.0);
+CGContextRotateCTM(mrContext, rStyle.mfFontRotation);
+CGContextSetShouldAntialias(mrContext, !mbNonAntialiasedText);
+CGContextSetFillColor(mrContext, maTextColor.AsArray());
+
+std::vector::const_iterator aStart = aGlyphRotation.begin();
+std::vector::const_iterator aEnd = aGlyphRotation.end();
+std::vector::const_iterator aI = aStart;
+while (aI != aEnd)
+{
+bool nGlyphRotation = *aI;
+std::vector::const_iterator aNext = std::find(aI + 1, aEnd, 
!nGlyphRotation);
+
+size_t nStartIndex = std::distance(aStart, aI);
+size_t nLen = std::distance(aI, aNext);
+
+if (nGlyphRotation && pRotatedFont)
+CTFontDrawGlyphs(pRotatedFont, &aGlyphIds[nStartIndex], 
&aGlyphPos[nStartIndex], nLen, mrContext);
+else
+CTFontDrawGlyphs(pFont, &aGlyphIds[nStartIndex], 
&aGlyphPos[nStartIndex], nLen, mrContext);
+
+aI = aNext;
 }
-CTFontDrawGlyphs(pFont, aGlyphIds.data(), aGlyphPos.data(), nStart, 
context);
 
-// restore the original graphic context transformations
-SAL_INFO("vcl.ct", "CGContextRestoreGState(" << context << ")");
-CGContextRestoreGState(context);
+if (pRotatedFont)
+CFRelease(pRotatedFont);
+    CGContextRestoreGState(mrContext);
 }
 
 void AquaSalGraphics::SetFont(FontSelectPattern* pReqFont, int nFallbackLevel)
commit 8e0d41fcae628582a01f50d0510d2e0daf3077fc
Author: Khaled Hosny 
Date:   Mon Sep 26 19:0

[Libreoffice-commits] core.git: Branch 'feature/commonsallayout' - 24 commits - config_host.mk.in configure.ac external/harfbuzz RepositoryExternal.mk vcl/CppunitTest_vcl_wmf_test.mk vcl/inc vcl/Libra

2016-10-16 Thread Khaled Hosny
Rebased ref, commits from common ancestor:
commit f0fdd3d62700040b32347b4637b1520ce9113903
Author: Khaled Hosny 
Date:   Sat Oct 15 06:11:26 2016 -0700

Rewrite AquaSalGraphics::DrawSalLayout()

Slightly cleaner code and now handles glyph rotation for vertical text.

Change-Id: I98cc8fd7df5e73068294e4d7dd6b38a71dcbdcc7

diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index 787ddbf..12dc1f1 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -485,37 +485,82 @@ bool AquaSalGraphics::GetGlyphBoundRect( sal_GlyphId 
aGlyphId, Rectangle& rRect
 
 void AquaSalGraphics::DrawSalLayout(const CommonSalLayout& rLayout)
 {
-CGContextRef context = mrContext;
-SAL_INFO("vcl.ct", "CGContextSaveGState(" << context << ")");
-CGContextSaveGState(context);
-SAL_INFO("vcl.ct", "CGContextScaleCTM(" << context << ",1.0,-1.0)");
-const CoreTextStyle& rCTStyle = rLayout.getFontData();
-
-CTFontRef pFont = 
static_cast(CFDictionaryGetValue(rCTStyle.GetStyleDict(), 
kCTFontAttributeName));
-CGContextScaleCTM(context, 1.0, -1.0);
-CGContextSetShouldAntialias(context, !mbNonAntialiasedText);
-// rotate the matrix
-const CGFloat fRadians = rCTStyle.mfFontRotation;
-CGContextRotateCTM(context, +fRadians);
-const CGAffineTransform aInvMatrix = 
CGAffineTransformMakeRotation(-fRadians);
-CGContextSetFillColor(context, maTextColor.AsArray());
-
-// draw the text
+const CoreTextStyle& rStyle = rLayout.getFontData();
+const FontSelectPattern& rFontSelect = rStyle.maFontSelData;
+if (rFontSelect.mnHeight == 0)
+return;
+
+CTFontRef pFont = 
static_cast(CFDictionaryGetValue(rStyle.GetStyleDict(), 
kCTFontAttributeName));
+
 Point aPos;
 sal_GlyphId aGlyphId;
 std::vector aGlyphIds;
 std::vector aGlyphPos;
+std::vector aGlyphRotation;
 int nStart = 0;
-for (; rLayout.GetNextGlyphs(1, &aGlyphId, aPos, nStart); )
+while (rLayout.GetNextGlyphs(1, &aGlyphId, aPos, nStart))
 {
+// Transform the position of non-vertical glyphs.
+CGAffineTransform aMatrix = 
CGAffineTransformMakeRotation(-rStyle.mfFontRotation);
+
+// Transform the position of vertical glyphs.
+// We don’t handle GF_ROTR as it is not used in CommonSalLayout.
+bool nGlyphRotation = false;
+if ((aGlyphId & GF_ROTMASK) == GF_ROTL)
+{
+nGlyphRotation = true;
+double nYdiff = CTFontGetAscent(pFont) - CTFontGetDescent(pFont);
+aMatrix = CGAffineTransformTranslate(aMatrix, 0, -nYdiff);
+}
+
 aGlyphIds.push_back(aGlyphId & GF_IDXMASK);
-aGlyphPos.push_back(CGPointApplyAffineTransform(CGPointMake(aPos.X(), 
-1*aPos.Y()), aInvMatrix));
+aGlyphPos.push_back(CGPointApplyAffineTransform(CGPointMake(aPos.X(), 
-aPos.Y()), aMatrix));
+aGlyphRotation.push_back(nGlyphRotation);
+}
+
+if (aGlyphIds.empty())
+return;
+
+CGContextSaveGState(mrContext);
+
+// Create a transformed font for drawing vertical glyphs.
+CTFontRef pRotatedFont = nullptr;
+if (rStyle.mfFontRotation)
+{
+CTFontDescriptorRef pDesc = CTFontCopyFontDescriptor(pFont);
+CGFloat nSize = CTFontGetSize(pFont);
+CGAffineTransform aMatrix = CTFontGetMatrix(pFont);
+aMatrix = CGAffineTransformRotate(aMatrix, -rStyle.mfFontRotation);
+pRotatedFont = CTFontCreateWithFontDescriptor(pDesc, nSize, &aMatrix);
+CFRelease(pDesc);
+}
+
+CGContextScaleCTM(mrContext, 1.0, -1.0);
+CGContextRotateCTM(mrContext, rStyle.mfFontRotation);
+CGContextSetShouldAntialias(mrContext, !mbNonAntialiasedText);
+CGContextSetFillColor(mrContext, maTextColor.AsArray());
+
+auto aIt = aGlyphRotation.cbegin();
+while (aIt != aGlyphRotation.cend())
+{
+bool nGlyphRotation = *aIt;
+// Find the boundary of the run of glyphs with the same rotation, to be
+// drawn together.
+auto aNext = std::find(aIt, aGlyphRotation.cend(), !nGlyphRotation);
+size_t nStartIndex = std::distance(aGlyphRotation.cbegin(), aIt);
+size_t nLen = std::distance(aIt, aNext);
+
+if (nGlyphRotation && pRotatedFont)
+CTFontDrawGlyphs(pRotatedFont, &aGlyphIds[nStartIndex], 
&aGlyphPos[nStartIndex], nLen, mrContext);
+else
+CTFontDrawGlyphs(pFont, &aGlyphIds[nStartIndex], 
&aGlyphPos[nStartIndex], nLen, mrContext);
+
+aIt = aNext;
 }
-CTFontDrawGlyphs(pFont, aGlyphIds.data(), aGlyphPos.data(), nStart, 
context);
 
-// restore the original graphic context transformations
-SAL_INFO("vcl.ct", "CGContextRestoreGState(" << context << ")");
-CGContextRestoreGState(context)

[Libreoffice-commits] core.git: Branch 'feature/commonsallayout' - 83 commits - avmedia/source basic/qa basic/source bean/native bridges/inc bridges/source canvas/source codemaker/source comphelper/so

2016-10-16 Thread Khaled Hosny
Rebased ref, commits from common ancestor:
commit 9f6be93b1d9013dbdc84c46466d0fa6a4ed10dec
Author: Khaled Hosny 
Date:   Sat Oct 15 06:11:26 2016 -0700

Rewrite AquaSalGraphics::DrawSalLayout()

Slightly cleaner code and now handles glyph rotation for vertical text.

Change-Id: I98cc8fd7df5e73068294e4d7dd6b38a71dcbdcc7

diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index 787ddbf..12dc1f1 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -485,37 +485,82 @@ bool AquaSalGraphics::GetGlyphBoundRect( sal_GlyphId 
aGlyphId, Rectangle& rRect
 
 void AquaSalGraphics::DrawSalLayout(const CommonSalLayout& rLayout)
 {
-CGContextRef context = mrContext;
-SAL_INFO("vcl.ct", "CGContextSaveGState(" << context << ")");
-CGContextSaveGState(context);
-SAL_INFO("vcl.ct", "CGContextScaleCTM(" << context << ",1.0,-1.0)");
-const CoreTextStyle& rCTStyle = rLayout.getFontData();
-
-CTFontRef pFont = 
static_cast(CFDictionaryGetValue(rCTStyle.GetStyleDict(), 
kCTFontAttributeName));
-CGContextScaleCTM(context, 1.0, -1.0);
-CGContextSetShouldAntialias(context, !mbNonAntialiasedText);
-// rotate the matrix
-const CGFloat fRadians = rCTStyle.mfFontRotation;
-CGContextRotateCTM(context, +fRadians);
-const CGAffineTransform aInvMatrix = 
CGAffineTransformMakeRotation(-fRadians);
-CGContextSetFillColor(context, maTextColor.AsArray());
-
-// draw the text
+const CoreTextStyle& rStyle = rLayout.getFontData();
+const FontSelectPattern& rFontSelect = rStyle.maFontSelData;
+if (rFontSelect.mnHeight == 0)
+return;
+
+CTFontRef pFont = 
static_cast(CFDictionaryGetValue(rStyle.GetStyleDict(), 
kCTFontAttributeName));
+
 Point aPos;
 sal_GlyphId aGlyphId;
 std::vector aGlyphIds;
 std::vector aGlyphPos;
+std::vector aGlyphRotation;
 int nStart = 0;
-for (; rLayout.GetNextGlyphs(1, &aGlyphId, aPos, nStart); )
+while (rLayout.GetNextGlyphs(1, &aGlyphId, aPos, nStart))
 {
+// Transform the position of non-vertical glyphs.
+CGAffineTransform aMatrix = 
CGAffineTransformMakeRotation(-rStyle.mfFontRotation);
+
+// Transform the position of vertical glyphs.
+// We don’t handle GF_ROTR as it is not used in CommonSalLayout.
+bool nGlyphRotation = false;
+if ((aGlyphId & GF_ROTMASK) == GF_ROTL)
+{
+nGlyphRotation = true;
+double nYdiff = CTFontGetAscent(pFont) - CTFontGetDescent(pFont);
+aMatrix = CGAffineTransformTranslate(aMatrix, 0, -nYdiff);
+}
+
 aGlyphIds.push_back(aGlyphId & GF_IDXMASK);
-aGlyphPos.push_back(CGPointApplyAffineTransform(CGPointMake(aPos.X(), 
-1*aPos.Y()), aInvMatrix));
+aGlyphPos.push_back(CGPointApplyAffineTransform(CGPointMake(aPos.X(), 
-aPos.Y()), aMatrix));
+aGlyphRotation.push_back(nGlyphRotation);
+}
+
+if (aGlyphIds.empty())
+return;
+
+CGContextSaveGState(mrContext);
+
+// Create a transformed font for drawing vertical glyphs.
+CTFontRef pRotatedFont = nullptr;
+if (rStyle.mfFontRotation)
+{
+CTFontDescriptorRef pDesc = CTFontCopyFontDescriptor(pFont);
+CGFloat nSize = CTFontGetSize(pFont);
+CGAffineTransform aMatrix = CTFontGetMatrix(pFont);
+aMatrix = CGAffineTransformRotate(aMatrix, -rStyle.mfFontRotation);
+pRotatedFont = CTFontCreateWithFontDescriptor(pDesc, nSize, &aMatrix);
+CFRelease(pDesc);
+}
+
+CGContextScaleCTM(mrContext, 1.0, -1.0);
+CGContextRotateCTM(mrContext, rStyle.mfFontRotation);
+CGContextSetShouldAntialias(mrContext, !mbNonAntialiasedText);
+CGContextSetFillColor(mrContext, maTextColor.AsArray());
+
+auto aIt = aGlyphRotation.cbegin();
+while (aIt != aGlyphRotation.cend())
+{
+bool nGlyphRotation = *aIt;
+// Find the boundary of the run of glyphs with the same rotation, to be
+// drawn together.
+auto aNext = std::find(aIt, aGlyphRotation.cend(), !nGlyphRotation);
+size_t nStartIndex = std::distance(aGlyphRotation.cbegin(), aIt);
+size_t nLen = std::distance(aIt, aNext);
+
+if (nGlyphRotation && pRotatedFont)
+CTFontDrawGlyphs(pRotatedFont, &aGlyphIds[nStartIndex], 
&aGlyphPos[nStartIndex], nLen, mrContext);
+else
+CTFontDrawGlyphs(pFont, &aGlyphIds[nStartIndex], 
&aGlyphPos[nStartIndex], nLen, mrContext);
+
+aIt = aNext;
 }
-CTFontDrawGlyphs(pFont, aGlyphIds.data(), aGlyphPos.data(), nStart, 
context);
 
-// restore the original graphic context transformations
-SAL_INFO("vcl.ct", "CGContextRestoreGState(" << context << ")");
-CGContextRestoreGState(context)

[Libreoffice-commits] core.git: Branch 'feature/commonsallayout' - vcl/inc vcl/source

2016-10-17 Thread Khaled Hosny
 vcl/inc/CommonSalLayout.hxx|8 
 vcl/source/gdi/CommonSalLayout.cxx |   34 --
 2 files changed, 20 insertions(+), 22 deletions(-)

New commits:
commit 754fcf66f203f33840cfe08707a740db956fca12
Author: Khaled Hosny 
Date:   Mon Oct 17 19:59:23 2016 +0200

Fix debug build and few cleanups

Change-Id: I805962667c3ef2dcaf07a0acebeacca74c74892a

diff --git a/vcl/inc/CommonSalLayout.hxx b/vcl/inc/CommonSalLayout.hxx
index abc5ea7..cd43bec 100644
--- a/vcl/inc/CommonSalLayout.hxx
+++ b/vcl/inc/CommonSalLayout.hxx
@@ -50,9 +50,10 @@ class CommonSalLayout : public GenericSalLayout
 #else
 ServerFont& mrServerFont;
 #endif
-OString mLang;
-hb_feature_t * mpFeatures;
-unsigned int mnFeats;
+
+voidParseFeatures(const OUString& name);
+OString msLanguage;
+std::vector maFeatures;
 
 public:
 #if defined(_WIN32)
@@ -66,7 +67,6 @@ public:
 const ServerFont&   getFontData() const { return mrServerFont; };
 #endif
 
-voidParseFeatures(OUString name);
 voidSetNeedFallback(ImplLayoutArgs&, sal_Int32, bool);
 voidAdjustLayout(ImplLayoutArgs&) override;
 boolLayoutText(ImplLayoutArgs&) override;
diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index 0966b29..f6088b8 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -126,18 +126,16 @@ static hb_unicode_funcs_t* getUnicodeFuncs()
 }
 #endif
 
-void CommonSalLayout::ParseFeatures(OUString name)
+void CommonSalLayout::ParseFeatures(const OUString& name)
 {
-mnFeats = 0;
-mpFeatures = 0;
-mLang = OString("");
+int nFeatures = 0;
 int nStart = name.indexOf(':');
 if (nStart < 0)
 return;
 OString oName = OUStringToOString(name, RTL_TEXTENCODING_ASCII_US);
 for (int nNext = nStart; nNext > 0; nNext = name.indexOf('&', nNext + 1))
 {
-if (name.match("lang=", nNext+1))
+if (name.match("lang=", nNext + 1))
 {
 int endamp = name.indexOf('&', nNext+1);
 int enddelim = name.indexOf(' ', nNext+1);
@@ -151,23 +149,23 @@ void CommonSalLayout::ParseFeatures(OUString name)
 end = endamp;
 else
 end = enddelim;
-mLang = oName.copy(nNext+6, end-nNext-6);
+msLanguage = oName.copy(nNext + 6, end - nNext - 6);
 }
 else
-++mnFeats;
+++nFeatures;
 }
-if (mnFeats == 0)
+if (nFeatures == 0)
 return;
 
-mpFeatures = new hb_feature_t[mnFeats];
-mnFeats = 0;
-for (int nThis = nStart, nNext = name.indexOf('&', nStart+1); nThis > 0; 
nThis = nNext, nNext = name.indexOf('&', nNext + 1))
+maFeatures.reserve(nFeatures);
+for (int nThis = nStart, nNext = name.indexOf('&', nStart + 1); nThis > 0; 
nThis = nNext, nNext = name.indexOf('&', nNext + 1))
 {
-if (!name.match("lang=", nThis+1))
+if (!name.match("lang=", nThis + 1))
 {
 int end = nNext > 0 ? nNext : name.getLength();
-if (hb_feature_from_string(oName.getStr() + nThis + 1, end - nThis 
- 1, &mpFeatures[mnFeats]))
-++mnFeats;
+hb_feature_t aFeature;
+if (hb_feature_from_string(oName.getStr() + nThis + 1, end - nThis 
- 1, &aFeature))
+maFeatures.push_back(aFeature);
 }
 }
 }
@@ -463,9 +461,9 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
 int nRunLen = nEndRunPos - nMinRunPos;
 aHbScript = hb_icu_script_to_script(aScriptRun.maScript);
 
-// hb_language_from_string() accept ISO639-3 language tag except 
for Chinese.
-LanguageTag &rTag = rArgs.maLanguageTag;
-OString sLanguage = mLang.getLength() ? mLang : 
OUStringToOString(rTag.getBcp47(), RTL_TEXTENCODING_ASCII_US);
+OString sLanguage = msLanguage;
+if (sLanguage.isEmpty())
+sLanguage = OUStringToOString(rArgs.maLanguageTag.getBcp47(), 
RTL_TEXTENCODING_ASCII_US);
 
 bool bVertical = false;
 if ((rArgs.mnFlags & SalLayoutFlags::Vertical) &&
@@ -498,7 +496,7 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
 #if HB_VERSION_ATLEAST(0, 9, 42)
 hb_buffer_set_cluster_level(pHbBuffer, 
HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS);
 #endif
-hb_shape(mpHbFont, pHbBuffer, mpFeatures, mnFeats);
+hb_shape(mpHbFont, pHbBuffer, maFeatures.data(), 
maFeatures.size());
 
 int nRunGlyphCount = hb_buffer_get_length(pHbBu

Merging feature/commonsallayout branch

2016-10-17 Thread Khaled Hosny
I believe that feature/commonsallayout (AKA unified text layout) is now
feature complete with no known major bugs, and should be ready to be
merged on master. I’ll try merge it tomorrow night and hope for the
best, unless someone objects loudly.

Currently the new layout is off by default and can be enabled at runtime
by setting SAL_USE_COMMON_LAYOUT env variable. After merging with
master, I’m going to wait a week or so for any potential build issues
then swap the default.

There are too main issues with the new code:
- Type 1 fonts are not supported. They can be supported with some
  effort, but Type 1 fonts have been obsolete for more than 15 years and
  I’d like to use this opportunity to drop support for them and cleanup
  some of the ugly code we have.
- We use a bit of DirectWrite to load fonts on Windows, so Windows XP is
  not supported as well. Again it can be fixed with some effort, but I
  don’t think anyone will miss XP. Ideally we should do a full switch to
  DirectWrite and modernise our Windows font rendering, but that is
  another story.

Regards,
Khaled
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: Merging feature/commonsallayout branch

2016-10-17 Thread Khaled Hosny
Not directly, but you can now control OpenType features using the same
syntax used for OpenType features.

It should be easy to turn of ligatures in VCL when characters spacing is
used, except that character spacing is not applied by VCL but by the
client and we have no clue about it at all. I tried fixing this before,
but I couldn’t even figure out where character spacing is stored or when
it is applied.

Regards,
Khaled

On Mon, Oct 17, 2016 at 09:47:12PM +0200, Stephan van den Akker wrote:
> Congratulations when this gets merged! It's a big chunk of work.
> 
> One question is on my mind that I was meaning to ask before: Is issue
> tdf#66819 "Setting additional spacing between characters does not
> prevent automatic ligature substitution." solved in this branch?
> 
> Greetings,
> 
> Stephan
> 
> 2016-10-17 21:30 GMT+02:00 Khaled Hosny :
> > I believe that feature/commonsallayout (AKA unified text layout) is now
> > feature complete with no known major bugs, and should be ready to be
> > merged on master. I’ll try merge it tomorrow night and hope for the
> > best, unless someone objects loudly.
> >
> > Currently the new layout is off by default and can be enabled at runtime
> > by setting SAL_USE_COMMON_LAYOUT env variable. After merging with
> > master, I’m going to wait a week or so for any potential build issues
> > then swap the default.
> >
> > There are too main issues with the new code:
> > - Type 1 fonts are not supported. They can be supported with some
> >   effort, but Type 1 fonts have been obsolete for more than 15 years and
> >   I’d like to use this opportunity to drop support for them and cleanup
> >   some of the ugly code we have.
> > - We use a bit of DirectWrite to load fonts on Windows, so Windows XP is
> >   not supported as well. Again it can be fixed with some effort, but I
> >   don’t think anyone will miss XP. Ideally we should do a full switch to
> >   DirectWrite and modernise our Windows font rendering, but that is
> >   another story.
> >
> > Regards,
> > Khaled
> > ___
> > LibreOffice mailing list
> > LibreOffice@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/libreoffice
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: Merging feature/commonsallayout branch

2016-10-18 Thread Khaled Hosny
On Tue, Oct 18, 2016 at 09:06:42AM +0200, Milos Sramek wrote:
> Dear Khaled,
> 
> do you think that extensive comparison of rendering of numerous
> documents with and without the new layout engine makes sense?
> If yes, I can run my tests in such a way to see if there are any
> differences.

This would be extremely helpful, and more so if it can run on Windows or
Mac.

> My test documents use latin script except for a few ones in Chinese. So,
> if you happen to have sume documents in Arabic I can add them to my test
> set.

I’ve a random collection of documents somewhere, I’ll clean it up and
send it to you.

Regards,
Khaled


signature.asc
Description: PGP signature
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: Merging feature/commonsallayout branch

2016-10-18 Thread Khaled Hosny
On Tue, Oct 18, 2016 at 12:05:14PM +0200, 'Christian Lohmaier' via Khaled Hosny 
wrote:
> On Mon, Oct 17, 2016 at 9:30 PM, Khaled Hosny  wrote:
> > I believe that feature/commonsallayout (AKA unified text layout) is now
> > feature complete with no known major bugs, and should be ready to be
> > merged on master. I’ll try merge it tomorrow night and hope for the
> > best, unless someone objects loudly.
> 
> Not sure whether the wording is to be taken literally or not.. But I'd
> brefer a non-merge way to add it..
> (aka rebase on top of mater rather than doing a merge)

Sure.

> > There are too main issues with the new code:
> > - Type 1 fonts are not supported. They can be supported with some
> >   effort, but Type 1 fonts have been obsolete for more than 15 years and
> >   I’d like to use this opportunity to drop support for them and cleanup
> >   some of the ugly code we have.
> 
> This is something that should be communitated clearly to QA and
> Marketing projects so they're aware as well..

I’m not very familiar with this, so let me know if there is anything
else I need to.

> > - We use a bit of DirectWrite to load fonts on Windows, so Windows XP is
> >   not supported as well.
> 
> Do you mean just with the new rendering (that could be toggled with
> the env-var), or not supported at all anymore?

I’m not very familiar with how things work on Windows, but we use
DirectWrite library which is available on Vista and higher, and that
code is built unconditional. My understanding is that is means the code
worn’t built on XP, and binaries built on other versions won’t run on it
as well.

Regards,
Khaled
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice


[Libreoffice-commits] core.git: Branch 'feature/commonsallayout' - 130 commits - accessibility/source basctl/source basegfx/source basic/source compilerplugins/clang config_host.mk.in configure.ac con

2016-10-18 Thread Khaled Hosny
Rebased ref, commits from common ancestor:
commit d0b5e1536983dbc1d4eb1b34d9864a0cd6dc1406
Author: Khaled Hosny 
Date:   Mon Oct 17 19:59:23 2016 +0200

Fix debug build and few cleanups

Change-Id: I805962667c3ef2dcaf07a0acebeacca74c74892a

diff --git a/vcl/inc/CommonSalLayout.hxx b/vcl/inc/CommonSalLayout.hxx
index abc5ea7..cd43bec 100644
--- a/vcl/inc/CommonSalLayout.hxx
+++ b/vcl/inc/CommonSalLayout.hxx
@@ -50,9 +50,10 @@ class CommonSalLayout : public GenericSalLayout
 #else
 ServerFont& mrServerFont;
 #endif
-OString mLang;
-hb_feature_t * mpFeatures;
-unsigned int mnFeats;
+
+voidParseFeatures(const OUString& name);
+OString msLanguage;
+std::vector maFeatures;
 
 public:
 #if defined(_WIN32)
@@ -66,7 +67,6 @@ public:
 const ServerFont&   getFontData() const { return mrServerFont; };
 #endif
 
-voidParseFeatures(OUString name);
 voidSetNeedFallback(ImplLayoutArgs&, sal_Int32, bool);
 voidAdjustLayout(ImplLayoutArgs&) override;
 boolLayoutText(ImplLayoutArgs&) override;
diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index 0966b29..f6088b8 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -126,18 +126,16 @@ static hb_unicode_funcs_t* getUnicodeFuncs()
 }
 #endif
 
-void CommonSalLayout::ParseFeatures(OUString name)
+void CommonSalLayout::ParseFeatures(const OUString& name)
 {
-mnFeats = 0;
-mpFeatures = 0;
-mLang = OString("");
+int nFeatures = 0;
 int nStart = name.indexOf(':');
 if (nStart < 0)
 return;
 OString oName = OUStringToOString(name, RTL_TEXTENCODING_ASCII_US);
 for (int nNext = nStart; nNext > 0; nNext = name.indexOf('&', nNext + 1))
 {
-if (name.match("lang=", nNext+1))
+if (name.match("lang=", nNext + 1))
 {
 int endamp = name.indexOf('&', nNext+1);
 int enddelim = name.indexOf(' ', nNext+1);
@@ -151,23 +149,23 @@ void CommonSalLayout::ParseFeatures(OUString name)
 end = endamp;
 else
 end = enddelim;
-mLang = oName.copy(nNext+6, end-nNext-6);
+msLanguage = oName.copy(nNext + 6, end - nNext - 6);
 }
 else
-++mnFeats;
+++nFeatures;
 }
-if (mnFeats == 0)
+if (nFeatures == 0)
 return;
 
-mpFeatures = new hb_feature_t[mnFeats];
-mnFeats = 0;
-for (int nThis = nStart, nNext = name.indexOf('&', nStart+1); nThis > 0; 
nThis = nNext, nNext = name.indexOf('&', nNext + 1))
+maFeatures.reserve(nFeatures);
+for (int nThis = nStart, nNext = name.indexOf('&', nStart + 1); nThis > 0; 
nThis = nNext, nNext = name.indexOf('&', nNext + 1))
 {
-if (!name.match("lang=", nThis+1))
+if (!name.match("lang=", nThis + 1))
 {
 int end = nNext > 0 ? nNext : name.getLength();
-if (hb_feature_from_string(oName.getStr() + nThis + 1, end - nThis 
- 1, &mpFeatures[mnFeats]))
-++mnFeats;
+hb_feature_t aFeature;
+if (hb_feature_from_string(oName.getStr() + nThis + 1, end - nThis 
- 1, &aFeature))
+maFeatures.push_back(aFeature);
 }
 }
 }
@@ -463,9 +461,9 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
 int nRunLen = nEndRunPos - nMinRunPos;
 aHbScript = hb_icu_script_to_script(aScriptRun.maScript);
 
-// hb_language_from_string() accept ISO639-3 language tag except 
for Chinese.
-LanguageTag &rTag = rArgs.maLanguageTag;
-OString sLanguage = mLang.getLength() ? mLang : 
OUStringToOString(rTag.getBcp47(), RTL_TEXTENCODING_ASCII_US);
+OString sLanguage = msLanguage;
+if (sLanguage.isEmpty())
+sLanguage = OUStringToOString(rArgs.maLanguageTag.getBcp47(), 
RTL_TEXTENCODING_ASCII_US);
 
 bool bVertical = false;
 if ((rArgs.mnFlags & SalLayoutFlags::Vertical) &&
@@ -498,7 +496,7 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
 #if HB_VERSION_ATLEAST(0, 9, 42)
 hb_buffer_set_cluster_level(pHbBuffer, 
HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS);
 #endif
-hb_shape(mpHbFont, pHbBuffer, mpFeatures, mnFeats);
+hb_shape(mpHbFont, pHbBuffer, maFeatures.data(), 
maFeatures.size());
 
 int nRunGlyphCount = hb_buffer_get_length(pHbBuffer);
 hb_glyph_info_t *pHbGlyphInfos = 
hb_buffer_get_glyph_infos(pHbBuffer, nullptr);
commit 8b45bb381520bc6990c87966b09dcad90d4f5212
Author: Martin Hosk

[Libreoffice-commits] core.git: 33 commits - config_host.mk.in configure.ac external/harfbuzz RepositoryExternal.mk vcl/CppunitTest_vcl_wmf_test.mk vcl/headless vcl/inc vcl/Library_vcl.mk vcl/quartz v

2016-10-18 Thread Khaled Hosny
 RepositoryExternal.mk  |   20 
 config_host.mk.in  |1 
 configure.ac   |   47 -
 external/harfbuzz/ExternalProject_harfbuzz.mk  |5 
 vcl/CppunitTest_vcl_wmf_test.mk|5 
 vcl/Library_vcl.mk |6 
 vcl/README.vars|1 
 vcl/headless/svptext.cxx   |   10 
 vcl/inc/CommonSalLayout.hxx|   82 ++
 vcl/inc/headless/svpgdi.hxx|3 
 vcl/inc/quartz/ctfonts.hxx |   34 +
 vcl/inc/quartz/salgdi.h|   18 
 vcl/inc/salgdi.hxx |6 
 vcl/inc/sallayout.hxx  |6 
 vcl/inc/scrptrun.h |  160 +
 vcl/inc/textrender.hxx |3 
 vcl/inc/unx/cairotextrender.hxx|2 
 vcl/inc/unx/genpspgraphics.h   |4 
 vcl/inc/unx/glyphcache.hxx |4 
 vcl/inc/unx/salgdi.h   |3 
 vcl/inc/win/salgdi.h   |   11 
 vcl/inc/win/winlayout.hxx  |  519 
 vcl/quartz/ctfonts.cxx |6 
 vcl/quartz/ctfonts.hxx |   34 -
 vcl/quartz/ctlayout.cxx|2 
 vcl/quartz/salgdi.cxx  |  212 +-
 vcl/source/gdi/CommonSalLayout.cxx |  784 +
 vcl/source/gdi/sallayout.cxx   |6 
 vcl/source/gdi/scrptrun.cxx|  234 +++
 vcl/unx/generic/gdi/cairotextrender.cxx|   28 
 vcl/unx/generic/gdi/font.cxx   |   10 
 vcl/unx/generic/glyphs/freetype_glyphcache.cxx |6 
 vcl/unx/generic/glyphs/gcach_layout.cxx|3 
 vcl/unx/generic/glyphs/scrptrun.cxx|  234 ---
 vcl/unx/generic/glyphs/scrptrun.h  |  160 -
 vcl/unx/generic/print/genpspgraphics.cxx   |2 
 vcl/win/gdi/salfont.cxx|   29 
 vcl/win/gdi/winlayout.cxx  |  429 +++--
 vcl/win/gdi/winlayout.hxx  |  240 ---
 39 files changed, 2267 insertions(+), 1102 deletions(-)

New commits:
commit 8b9ec421accf344e0e6921c35ba53d8ff0b2de40
Author: Khaled Hosny 
Date:   Mon Oct 17 19:59:23 2016 +0200

Fix debug build and few cleanups

Change-Id: I805962667c3ef2dcaf07a0acebeacca74c74892a

diff --git a/vcl/inc/CommonSalLayout.hxx b/vcl/inc/CommonSalLayout.hxx
index abc5ea7..cd43bec 100644
--- a/vcl/inc/CommonSalLayout.hxx
+++ b/vcl/inc/CommonSalLayout.hxx
@@ -50,9 +50,10 @@ class CommonSalLayout : public GenericSalLayout
 #else
 ServerFont& mrServerFont;
 #endif
-OString mLang;
-hb_feature_t * mpFeatures;
-unsigned int mnFeats;
+
+voidParseFeatures(const OUString& name);
+OString msLanguage;
+std::vector maFeatures;
 
 public:
 #if defined(_WIN32)
@@ -66,7 +67,6 @@ public:
 const ServerFont&   getFontData() const { return mrServerFont; };
 #endif
 
-voidParseFeatures(OUString name);
 voidSetNeedFallback(ImplLayoutArgs&, sal_Int32, bool);
 voidAdjustLayout(ImplLayoutArgs&) override;
 boolLayoutText(ImplLayoutArgs&) override;
diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index 0966b29..f6088b8 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -126,18 +126,16 @@ static hb_unicode_funcs_t* getUnicodeFuncs()
 }
 #endif
 
-void CommonSalLayout::ParseFeatures(OUString name)
+void CommonSalLayout::ParseFeatures(const OUString& name)
 {
-mnFeats = 0;
-mpFeatures = 0;
-mLang = OString("");
+int nFeatures = 0;
 int nStart = name.indexOf(':');
 if (nStart < 0)
 return;
 OString oName = OUStringToOString(name, RTL_TEXTENCODING_ASCII_US);
 for (int nNext = nStart; nNext > 0; nNext = name.indexOf('&', nNext + 1))
 {
-if (name.match("lang=", nNext+1))
+if (name.match("lang=", nNext + 1))
 {
 int endamp = name.indexOf('&', nNext+1);
 int enddelim = name.indexOf(' ', nNext+1);
@@ -151,23 +149,23 @@ void CommonSalLayout::ParseFeatures(OUString name)
 end = endamp;
 else
 end = enddelim;
-mLang = oName.copy(nNext+6, end-nNext-6);
+msLanguage = oName.copy(nNext + 6, end - nNext - 6);
 }
 else
-++mnFeats;
+++nFeatures;
 }
-if (mnFeats == 0)
+if (nFeatures == 0)
 return;
 
-mpFeatures = new hb_feature_t[mnFeats]

Re: Merging feature/commonsallayout branch

2016-10-18 Thread Khaled Hosny
On Mon, Oct 17, 2016 at 09:30:14PM +0200, Khaled Hosny wrote:
> I believe that feature/commonsallayout (AKA unified text layout) is now
> feature complete with no known major bugs, and should be ready to be
> merged on master. I’ll try merge it tomorrow night and hope for the
> best, unless someone objects loudly.

I just pushed the code into master, here is the summary of changes:

 RepositoryExternal.mk   |  20 +--
 config_host.mk.in   |   1 -
 configure.ac|  47 +++---
 external/harfbuzz/ExternalProject_harfbuzz.mk   |   5 +
 vcl/CppunitTest_vcl_wmf_test.mk |   5 +-
 vcl/Library_vcl.mk  |   6 +-
 vcl/README.vars |   1 +
 vcl/headless/svptext.cxx|  10 +-
 vcl/inc/CommonSalLayout.hxx |  82 +++
 vcl/inc/headless/svpgdi.hxx |   3 +-
 vcl/{ => inc}/quartz/ctfonts.hxx|   6 +-
 vcl/inc/quartz/salgdi.h |  18 ++-
 vcl/inc/salgdi.hxx  |   6 +-
 vcl/inc/sallayout.hxx   |   6 +-
 vcl/{unx/generic/glyphs => inc}/scrptrun.h  |   4 +-
 vcl/inc/textrender.hxx  |   3 +-
 vcl/inc/unx/cairotextrender.hxx |   2 +-
 vcl/inc/unx/genpspgraphics.h|   4 +-
 vcl/inc/unx/glyphcache.hxx  |   4 +
 vcl/inc/unx/salgdi.h|   3 +-
 vcl/inc/win/salgdi.h|  11 +-
 vcl/{win/gdi => inc/win}/winlayout.hxx  | 283 
+++-
 vcl/quartz/ctfonts.cxx  |   6 +-
 vcl/quartz/ctlayout.cxx |   2 +-
 vcl/quartz/salgdi.cxx   | 212 
+++
 vcl/source/gdi/CommonSalLayout.cxx  | 784 
++
 vcl/source/gdi/sallayout.cxx|   6 +
 vcl/{unx/generic/glyphs => source/gdi}/scrptrun.cxx |   0
 vcl/unx/generic/gdi/cairotextrender.cxx |  28 +++-
 vcl/unx/generic/gdi/font.cxx|  10 +-
 vcl/unx/generic/glyphs/freetype_glyphcache.cxx  |   6 +-
 vcl/unx/generic/glyphs/gcach_layout.cxx |   3 +-
 vcl/unx/generic/print/genpspgraphics.cxx|   2 +-
 vcl/win/gdi/salfont.cxx |  29 +++-
 vcl/win/gdi/winlayout.cxx   | 429 
+-
 35 files changed, 1606 insertions(+), 441 deletions(-)

Regards,
Khaled
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice


[Libreoffice-commits] core.git: vcl/Library_vclplug_gen.mk

2016-10-19 Thread Khaled Hosny
 vcl/Library_vclplug_gen.mk |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 66b3aa76b161c4d08e87fbdb19c2b72cc15153cd
Author: Khaled Hosny 
Date:   Wed Oct 19 10:50:18 2016 +0200

Add missing icu_headers dependency

Apparently this was working before by accident since most people have
ICU headers in the system include path on Linux.

Should fix the failing tinderbox.

Change-Id: I796453e66c53b3c64e546c661007a54fa5d866ec

diff --git a/vcl/Library_vclplug_gen.mk b/vcl/Library_vclplug_gen.mk
index c250ca8..f281605 100644
--- a/vcl/Library_vclplug_gen.mk
+++ b/vcl/Library_vclplug_gen.mk
@@ -54,6 +54,7 @@ $(eval $(call gb_Library_use_externals,vclplug_gen,\
glew \
glm_headers \
harfbuzz \
+   icu_headers \
icuuc \
valgrind \
Xrender \
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


Re: Merging feature/commonsallayout branch

2016-10-19 Thread Khaled Hosny
On Wed, Oct 19, 2016 at 03:11:25PM -0700, yphilips wrote:
> So cloph asked in QA about testing SAL_USE_COMMON_LAYOUT on windows XP and i
> did and it crashed on startup, so unless we want to alienate XP users from
> running 5.3, we'd likely need to put in a flag to disable it for XP.

So that is not as bad as I thought it would be. We can have a runtime
check for 5.3 that forces disable CommonSalLayout for Windows XP. We can
then communicate in advance that we are dropping Windows XP support in
5.4 (since we will remove the old code by then).

WDYT?

Regards,
Khaled
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice


[Libreoffice-commits] core.git: 2 commits - vcl/source

2016-10-20 Thread Khaled Hosny
 vcl/source/gdi/CommonSalLayout.cxx |   33 -
 1 file changed, 24 insertions(+), 9 deletions(-)

New commits:
commit d5424208a5b63a9d5ac658279c3f9824aa38a2d6
Author: Khaled Hosny 
Date:   Thu Oct 20 16:37:22 2016 +0200

Reuse the HarfBuzz buffer as much as possible

Less allocations in case we have many sub runs.

Change-Id: I50d4a57702c030c185fc7edef576c64d739a6194

diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index b8f18c4..cdb9b19 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -418,6 +418,13 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
 pTextLayout = pNewScriptRun.get();
 }
 
+hb_buffer_t* pHbBuffer = hb_buffer_create();
+hb_buffer_pre_allocate(pHbBuffer, nGlyphCapacity);
+#if !HB_VERSION_ATLEAST(1, 1, 0)
+static hb_unicode_funcs_t* pHbUnicodeFuncs = getUnicodeFuncs();
+hb_buffer_set_unicode_funcs(pHbBuffer, pHbUnicodeFuncs);
+#endif
+
 Point aCurrPos(0, 0);
 while (true)
 {
@@ -457,6 +464,8 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
 
 for (const auto& aScriptRun : aScriptSubRuns)
 {
+hb_buffer_clear_contents(pHbBuffer);
+
 int nMinRunPos = aScriptRun.mnMin;
 int nEndRunPos = aScriptRun.mnEnd;
 int nRunLen = nEndRunPos - nMinRunPos;
@@ -479,11 +488,6 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
 if (nEndRunPos == nLength)
 nHbFlags |= HB_BUFFER_FLAG_EOT; /* End-of-text */
 
-hb_buffer_t *pHbBuffer = hb_buffer_create();
-#if !HB_VERSION_ATLEAST(1, 1, 0)
-static hb_unicode_funcs_t* pHbUnicodeFuncs = getUnicodeFuncs();
-hb_buffer_set_unicode_funcs(pHbBuffer, pHbUnicodeFuncs);
-#endif
 if (bVertical)
 hb_buffer_set_direction(pHbBuffer, HB_DIRECTION_TTB);
 else
@@ -592,11 +596,11 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
 
 aCurrPos.X() += nAdvance;
 }
-
-hb_buffer_destroy(pHbBuffer);
 }
 }
 
+hb_buffer_destroy(pHbBuffer);
+
 // sort glyphs in visual order
 // and then in logical order (e.g. diacritics after cluster start)
 // XXX: why?
commit 7854d35cd8172b201f1f3ad247860f242e5cb06b
Author: Khaled Hosny 
Date:   Thu Oct 6 04:15:41 2016 +0200

Use HarfBuzz shape plan for a bit more control

This way we control exactly what shapers we use in what order, and as an
extra we can now tell which shaper HarfBuzz ends up using.

Change-Id: Idd303b2a557e16ac86ada0c2006d3e2a052ac489

diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index 527d827..b8f18c4 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -397,6 +397,7 @@ static int GetVerticalFlagsForScript(UScriptCode aScript)
 
 bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
 {
+hb_face_t* pHbFace = hb_font_get_face(mpHbFont);
 hb_script_t aHbScript = HB_SCRIPT_INVALID;
 
 int nGlyphCapacity = 2 * (rArgs.mnEndCharPos - rArgs.mnMinCharPos);
@@ -496,7 +497,18 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
 #if HB_VERSION_ATLEAST(0, 9, 42)
 hb_buffer_set_cluster_level(pHbBuffer, 
HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS);
 #endif
-hb_shape(mpHbFont, pHbBuffer, maFeatures.data(), 
maFeatures.size());
+// The shapers that we want HarfBuzz to use, in the order of
+// preference. The coretext_aat shaper is available only on macOS,
+// but there is no harm in always including it, HarfBuzz will
+// ignore unavailable shapers.
+const char* pHbShapers[] = { "coretext_aat", "graphite2", "ot", 
"fallback", nullptr };
+hb_segment_properties_t aHbProps;
+hb_buffer_get_segment_properties(pHbBuffer, &aHbProps);
+hb_shape_plan_t* pHbPlan = hb_shape_plan_create_cached(pHbFace, 
&aHbProps, maFeatures.data(), maFeatures.size(), pHbShapers);
+bool ok = hb_shape_plan_execute(pHbPlan, mpHbFont, pHbBuffer, 
maFeatures.data(), maFeatures.size());
+assert(ok);
+(void) ok;
+SAL_INFO("vcl.harfbuzz", hb_shape_plan_get_shaper(pHbPlan) << " 
shaper used for " << mrFontSelData.GetFamilyName());
 
 int nRunGlyphCount = hb_buffer_get_length(pHbBuffer);
 hb_glyph_info_t *pHbGlyphInfos = 
hb_buffer_get_glyph_infos(pHbBuffer, nullptr);
@@ -529,7 +541,6 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
 nGlyphFlags |= GlyphItem::IS_IN_CLUSTER;
 
 bool bDiacritic = false;
-hb_face_t* pHbFace = hb_font_get_face(mpHbFont);

[Libreoffice-commits] core.git: 2 commits - vcl/source

2016-10-20 Thread Khaled Hosny
 vcl/source/gdi/CommonSalLayout.cxx |   11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

New commits:
commit 66c1ae50e43f9a738f089356e8225022f776f90b
Author: Khaled Hosny 
Date:   Thu Oct 20 23:22:56 2016 +0200

Typo in commented-out code

Change-Id: I9f276a6de54dd3542249b47986d2ca6b3f27413d

diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index f4fc63f..cd2e91b 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -379,7 +379,7 @@ static int GetVerticalFlagsForScript(UScriptCode aScript)
 nFlag = ??;
 break;
 /* btt -90° */
-case USCRIPT_MONGOLIAN:
+case USCRIPT_OGHAM:
 nFlag = ??;
 break;
 #endif
commit 95c787160448d37e82efe8b7ee2f63bc4eea8541
Author: Khaled Hosny 
Date:   Thu Oct 20 23:04:02 2016 +0200

Vertical Mongolian and Phags-pa seem to work fine

The fonts are designed so that they are rotating 90° is all needed, so
we don’t to rotate them back, unlike CJK.

Change-Id: I0afa4b066257718a5a52eb2e93a18ce839aec2f0

diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index cdb9b19..f4fc63f 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -374,11 +374,6 @@ static int GetVerticalFlagsForScript(UScriptCode aScript)
 nFlag = GF_ROTL;
 break;
 #if 0
-/* ttb 90° */
-case USCRIPT_MONGOLIAN:
-case USCRIPT_PHAGS_PA:
-nFlag = ??;
-break;
 /* ttb -90° */
 case USCRIPT_ORKHON:
 nFlag = ??;
@@ -388,6 +383,10 @@ static int GetVerticalFlagsForScript(UScriptCode aScript)
 nFlag = ??;
 break;
 #endif
+/* ttb 90°, no extra rotation needed */
+case USCRIPT_MONGOLIAN:
+case USCRIPT_PHAGS_PA:
+/* horizontal scripts */
 default:
 break;
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/source

2016-10-20 Thread Khaled Hosny
 vcl/inc/CommonSalLayout.hxx|2 ++
 vcl/source/gdi/CommonSalLayout.cxx |2 ++
 2 files changed, 4 insertions(+)

New commits:
commit da8357463ca088c81774ab6c3ffc6f8b3903ffe7
Author: Khaled Hosny 
Date:   Fri Oct 21 02:30:27 2016 +0200

Add vim modeline to new files

Change-Id: I01cbd3b0698d458d8ba7267f2c70271db14f559f

diff --git a/vcl/inc/CommonSalLayout.hxx b/vcl/inc/CommonSalLayout.hxx
index c16bd87..76eb3eb 100644
--- a/vcl/inc/CommonSalLayout.hxx
+++ b/vcl/inc/CommonSalLayout.hxx
@@ -81,3 +81,5 @@ public:
 };
 
 #endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index cd2e91b..8432e91 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -796,3 +796,5 @@ bool CommonSalLayout::IsKashidaPosValid(int nCharPos) const
 
 return false;
 }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


Re: Merging feature/commonsallayout branch

2016-10-21 Thread Khaled Hosny
On Fri, Oct 21, 2016 at 06:40:08AM -0700, V Stuart Foote wrote:
> On Windows 8.1 & 10 builds (32-bit master TB62) and the Alpha1 build,
> HARFBUZZ unified text is having some issues with OpenGL rendering.  With
> default GPU rendering it is doing pretty well.
> 
> See  tdf#103365 - Text isn't showing in the new commonsallayout if OpenGL is
> on   

https://gerrit.libreoffice.org/#/c/30123/

Regards,
Khaled
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice


[Libreoffice-commits] core.git: vcl/inc vcl/win

2016-10-21 Thread Khaled Hosny
 vcl/inc/win/salgdi.h  |2 +
 vcl/win/gdi/winlayout.cxx |   88 --
 2 files changed, 87 insertions(+), 3 deletions(-)

New commits:
commit 36bafd3d4ad7fa75649eeab0c9cd1b3d6f53d8e8
Author: Khaled Hosny 
Date:   Fri Oct 21 03:01:43 2016 +0200

tdf#103365: Try to fix Windows OpenGL rendering

Essentially an adapted copy of WinLayout::DrawText(). Avoiding code
duplication would have been nicer, but it is going to be too complicated
and the other copy is going away soonish anyway.

Change-Id: I7db4008a0db3d01d71d106e06fe413658f9bf42d
Reviewed-on: https://gerrit.libreoffice.org/30123
Reviewed-by: akash 
Reviewed-by: Khaled Hosny 
Tested-by: Khaled Hosny 

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 9837a06..d694cf6 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -357,6 +357,8 @@ private:
 // get kernign pairs of the current font
 sal_uLong   GetKernPairs();
 
+voidDrawTextLayout(const CommonSalLayout&, HDC);
+
 public:
 static sal_uLongGetTable( const char pTagName[5], const unsigned 
char*&, void*&, IDWriteFontFace*& );
 // public SalGraphics methods, the interface to the independent vcl part
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 8c16b9d..476248e 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -4004,10 +4004,8 @@ LogicalFontInstance* WinFontFace::CreateFontInstance( 
FontSelectPattern& rFSD )
 return pFontInstance;
 }
 
-void WinSalGraphics::DrawSalLayout(const CommonSalLayout& rLayout)
+void WinSalGraphics::DrawTextLayout(const CommonSalLayout& rLayout, HDC hDC)
 {
-HDC hDC = getHDC();
-
 if (getenv("SAL_DWRITE_COMMON_LAYOUT"))
 {
 Point aPos(0, 0);
@@ -4032,4 +4030,88 @@ void WinSalGraphics::DrawSalLayout(const 
CommonSalLayout& rLayout)
 }
 }
 
+void WinSalGraphics::DrawSalLayout(const CommonSalLayout& rLayout)
+{
+HDC hDC = getHDC();
+bool bUseOpenGL = OpenGLHelper::isVCLOpenGLEnabled() && !mbPrinter;
+if (!bUseOpenGL)
+{
+// no OpenGL, just classic rendering
+DrawTextLayout(rLayout, hDC);
+}
+else
+{
+// We have to render the text to a hidden texture, and draw it.
+//
+// Note that Windows GDI does not really support the alpha correctly
+// when drawing - ie. it draws nothing to the alpha channel when
+// rendering the text, even the antialiasing is done as 'real' pixels,
+// not alpha...
+//
+// Luckily, this does not really limit us:
+//
+// To blend properly, we draw the texture, but then use it as an alpha
+// channel for solid color (that will define the text color).  This
+// destroys the subpixel antialiasing - turns it into 'classic'
+// antialiasing - but that is the best we can do, because the subpixel
+// antialiasing needs to know what is in the background: When the
+// background is white, or white-ish, it does the subpixel, but when
+// there is a color, it just darkens the color (and does this even
+// when part of the character is on a colored background, and part on
+// white).  It has to work this way, the results would look strange
+// otherwise.
+//
+// For the GL rendering to work even with the subpixel antialiasing,
+// we would need to get the current texture from the screen, let GDI
+// draw the text to it (so that it can decide well where to use the
+// subpixel and where not), and draw the result - but in that case we
+// don't need alpha anyway.
+//
+// TODO: check the performance of this 2nd approach at some stage and
+// switch to that if it performs well.
+
+Rectangle aRect;
+rLayout.GetBoundRect(*this, aRect);
+
+WinOpenGLSalGraphicsImpl *pImpl = 
dynamic_cast(mpImpl.get());
+
+if (pImpl)
+{
+pImpl->PreDraw();
+
+OpenGLCompatibleDC aDC(*this, aRect.Left(), aRect.Top(), 
aRect.GetWidth(), aRect.GetHeight());
+
+// we are making changes to the DC, make sure we got a new one
+assert(aDC.getCompatibleHDC() != hDC);
+
+RECT aWinRect = { aRect.Left(), aRect.Top(), aRect.Left() + 
aRect.GetWidth(), aRect.Top() + aRect.GetHeight() };
+::FillRect(aDC.getCompatibleHDC(), &aWinRect, 
static_cast(::GetStockObject(WHITE_BRUSH)));
+
+// setup the hidden DC with black color and white background, we 
will
+// use the result of the text drawing later as a mask only
+HFONT hOrigFont = ::SelectFont(aDC.getCompatibleHDC(), 
static_cast(::GetCurrentObject(hDC, OBJ_FONT)));
+
+::SetTextColor(aDC.getCompatibleHDC

[Libreoffice-commits] core.git: vcl/inc vcl/source vcl/win

2016-10-22 Thread Khaled Hosny
 vcl/inc/CommonSalLayout.hxx|6 ---
 vcl/inc/win/salgdi.h   |1 
 vcl/source/gdi/CommonSalLayout.cxx |   65 +
 vcl/win/gdi/salfont.cxx|   18 --
 vcl/win/gdi/winlayout.cxx  |2 -
 5 files changed, 19 insertions(+), 73 deletions(-)

New commits:
commit 2148c853b0d0deea92b97a810950f4d9f0cbb152
Author: Khaled Hosny 
Date:   Fri Oct 21 21:00:21 2016 -0700

Simplify CommonSalLayout constructor on Windows

We can use GDI to load the font tables after all, no need for all the
complications to use DirectWrite to load them. Should also make it work on
Windows XP (untested).

Change-Id: Id49fc524e6da983d76669a078f8b7d624f955703
Reviewed-on: https://gerrit.libreoffice.org/30156
Tested-by: Jenkins 
Reviewed-by: Khaled Hosny 

diff --git a/vcl/inc/CommonSalLayout.hxx b/vcl/inc/CommonSalLayout.hxx
index 76eb3eb..0dd44b2 100644
--- a/vcl/inc/CommonSalLayout.hxx
+++ b/vcl/inc/CommonSalLayout.hxx
@@ -43,9 +43,6 @@ class CommonSalLayout : public GenericSalLayout
 const FontSelectPattern& mrFontSelData;
 css::uno::Reference mxBreak;
 #ifdef _WIN32
-HDC   mhDC;
-HFONT mhFont;
-D2DWriteTextOutRenderer* mpD2DRenderer;
 #elif defined(MACOSX) || defined(IOS)
 const CoreTextStyle&mrCoreTextStyle;
 #else
@@ -58,8 +55,7 @@ class CommonSalLayout : public GenericSalLayout
 
 public:
 #if defined(_WIN32)
-explicitCommonSalLayout(WinSalGraphics*, WinFontInstance&, 
const WinFontFace&);
-voidInitFont() const override;
+explicitCommonSalLayout(HDC, WinFontInstance&, const 
WinFontFace&);
 #elif defined(MACOSX) || defined(IOS)
 explicitCommonSalLayout(const CoreTextStyle&);
 const CoreTextStyle&getFontData() const { return mrCoreTextStyle; };
diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index d694cf6..359c566 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -360,7 +360,6 @@ private:
 voidDrawTextLayout(const CommonSalLayout&, HDC);
 
 public:
-static sal_uLongGetTable( const char pTagName[5], const unsigned 
char*&, void*&, IDWriteFontFace*& );
 // public SalGraphics methods, the interface to the independent vcl part
 
 // get device resolution
diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index 96762f1..0fba16b 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -27,20 +27,6 @@
 #include 
 #include 
 
-#if defined(_WIN32)
-struct WinSalGraphicsWithIDFace
-{
-WinSalGraphics* mpWSL;
-IDWriteFontFace*mpIDFace;
-void*   mpTableContext;
-
-WinSalGraphicsWithIDFace( WinSalGraphics* pWSL, IDWriteFontFace* pIDFace )
-: mpWSL( pWSL ),
-  mpIDFace( pIDFace ),
-  mpTableContext( nullptr )
-{}
-};
-#endif
 
 static hb_blob_t* getFontTable(hb_face_t* /*face*/, hb_tag_t nTableTag, void* 
pUserData)
 {
@@ -53,9 +39,17 @@ static hb_blob_t* getFontTable(hb_face_t* /*face*/, hb_tag_t 
nTableTag, void* pU
 
 sal_uLong nLength = 0;
 #if defined(_WIN32)
-const unsigned char* pBuffer = nullptr;
-WinSalGraphicsWithIDFace* pWSLWithIDFace = 
static_cast(pUserData);
-nLength = WinSalGraphics::GetTable(pTagName, pBuffer, 
pWSLWithIDFace->mpTableContext, pWSLWithIDFace->mpIDFace);
+unsigned char* pBuffer = nullptr;
+HFONT hFont = static_cast(pUserData);
+HDC hDC = GetDC(nullptr);
+SelectObject(hDC, hFont);
+nLength = ::GetFontData(hDC, OSL_NETDWORD(nTableTag), 0, nullptr, 0);
+if (nLength > 0 && nLength != GDI_ERROR)
+{
+pBuffer = new unsigned char[nLength];
+::GetFontData(hDC, OSL_NETDWORD(nTableTag), 0, pBuffer, nLength);
+}
+ReleaseDC(nullptr, hDC);
 #elif defined(MACOSX) || defined(IOS)
 unsigned char* pBuffer = nullptr;
 CoreTextFontFace* pFont = static_cast(pUserData);
@@ -63,8 +57,8 @@ static hb_blob_t* getFontTable(hb_face_t* /*face*/, hb_tag_t 
nTableTag, void* pU
 if (nLength > 0)
 {
 pBuffer = new unsigned char[nLength];
+pFont->GetFontTable(pTagName, pBuffer);
 }
-pFont->GetFontTable(pTagName, pBuffer);
 #else
 const unsigned char* pBuffer = nullptr;
 ServerFont* pFont = static_cast(pUserData);
@@ -73,15 +67,7 @@ static hb_blob_t* getFontTable(hb_face_t* /*face*/, hb_tag_t 
nTableTag, void* pU
 
 hb_blob_t* pBlob = nullptr;
 if (pBuffer != nullptr)
-#if defined(_WIN32)
-pBlob = hb_blob_create(reinterpret_cast(pBuffer), 
nLength, HB_MEMORY_MODE_READONLY, pWSLWithIDFace,
-   [](void* userData)
-   {
-   WinSalGraphicsWithIDFace* pUData = 
static_cast(userData);
-   

Re: Merging feature/commonsallayout branch

2016-10-22 Thread Khaled Hosny
On Mon, Oct 17, 2016 at 09:30:14PM +0200, Khaled Hosny wrote:
> - We use a bit of DirectWrite to load fonts on Windows, so Windows XP is
>   not supported as well. Again it can be fixed with some effort, but I
>   don’t think anyone will miss XP. Ideally we should do a full switch to
>   DirectWrite and modernise our Windows font rendering, but that is
>   another story.

I did some cleanup to the Windows part of the code while working on
other Windows issue, and after [1] the font loading code does not use
DurectWrite anymore. So it should theoretically work on Windows XP now,
untested of course.

1. 
https://gerrit.libreoffice.org/gitweb?p=core.git;a=commitdiff;h=2148c853b0d0deea92b97a810950f4d9f0cbb152
 
Regards,
Khaled
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: testing commonsallayout branch

2016-10-23 Thread Khaled Hosny
Hi,

Things I’d like to test at this point:
* master with and without the new layout code activated on the three
  platforms. To see if we have any regressions or, hopefully, progressions.
* master with the new layout code across platforms (to see if we really
  getting identical results as we hope).

Regards,
Khaled

On Fri, Oct 21, 2016 at 09:18:01PM +0200, Milos Sramek wrote:
> Hi,
> 
> 
> I've changed subject, since the discussion went in a different direction.
> 
> Meanwhile I've discovered, that one can run OSX in a virtual machine :).
> That fits to my environment well.
> 
> I've tested a few random files with a few random version on Linux, Mac
> and Windows. The results:
> http://bender.dam.fmph.uniba.sk/~milos/roundtrip/odttest-mac-win/rslt-web.ods
> 
> Brief explanantion:
> grade 0: pixel level identical
> grade 1: some differences, probably not visible
> ...
> Grade meaning is explained in a comment
> 
> > is a link to pdf:
> column LND: side by side
> column THE: overlay
> column HLPE: vertically aligned lines
> column FDE: vertically and horizontally aligned
> 
> first sheet: print test: printed by tested version (name in header) and
> in reference version (LO43 on Linux) and compared
> second sheet: roundtrip test: saved to odt and printed by the reference
> version. No differences here
> 
> Which versions should I test? The engines can be specified by
> environment variable - I can test that too.
> 
> Is there a way how to install multiple versions in parallel on MAC? I
> can install only production and development one.
> 
> best
> Milos
> 
> 
> On 2016-10-18 18:36, Khaled Hosny wrote:
> > On Tue, Oct 18, 2016 at 09:06:42AM +0200, Milos Sramek wrote:
> >> Dear Khaled,
> >>
> >> do you think that extensive comparison of rendering of numerous
> >> documents with and without the new layout engine makes sense?
> >> If yes, I can run my tests in such a way to see if there are any
> >> differences.
> > This would be extremely helpful, and more so if it can run on Windows or
> > Mac.
> >
> >> My test documents use latin script except for a few ones in Chinese. So,
> >> if you happen to have sume documents in Arabic I can add them to my test
> >> set.
> > I’ve a random collection of documents somewhere, I’ll clean it up and
> > send it to you.
> >
> > Regards,
> > Khaled
> >
> >
> > ___
> > LibreOffice mailing list
> > LibreOffice@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/libreoffice
> 
> 
> -- 
> email & jabber: sramek.mi...@gmail.com
> 
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice


  1   2   3   4   5   6   7   8   9   10   >