Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Side by Side Diff: src/ports/SkFontHost_win.cpp

Issue 213153006: Fix size of rotated text with FreeType. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ports/SkFontHost_FreeType.cpp ('k') | src/utils/SkMatrix22.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkAdvancedTypefaceMetrics.h" 9 #include "SkAdvancedTypefaceMetrics.h"
10 #include "SkBase64.h" 10 #include "SkBase64.h"
11 #include "SkColorPriv.h" 11 #include "SkColorPriv.h"
12 #include "SkData.h" 12 #include "SkData.h"
13 #include "SkDescriptor.h" 13 #include "SkDescriptor.h"
14 #include "SkFontDescriptor.h" 14 #include "SkFontDescriptor.h"
15 #include "SkFontHost.h" 15 #include "SkFontHost.h"
16 #include "SkGlyph.h" 16 #include "SkGlyph.h"
17 #include "SkHRESULT.h" 17 #include "SkHRESULT.h"
18 #include "SkMaskGamma.h" 18 #include "SkMaskGamma.h"
19 #include "SkMatrix22.h"
19 #include "SkOTTable_maxp.h" 20 #include "SkOTTable_maxp.h"
20 #include "SkOTTable_name.h" 21 #include "SkOTTable_name.h"
21 #include "SkOTUtils.h" 22 #include "SkOTUtils.h"
22 #include "SkPath.h" 23 #include "SkPath.h"
23 #include "SkSFNTHeader.h" 24 #include "SkSFNTHeader.h"
24 #include "SkStream.h" 25 #include "SkStream.h"
25 #include "SkString.h" 26 #include "SkString.h"
26 #include "SkTemplates.h" 27 #include "SkTemplates.h"
27 #include "SkThread.h" 28 #include "SkThread.h"
28 #include "SkTypeface_win.h" 29 #include "SkTypeface_win.h"
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 } 630 }
630 SetGraphicsMode(fDDC, GM_ADVANCED); 631 SetGraphicsMode(fDDC, GM_ADVANCED);
631 SetBkMode(fDDC, TRANSPARENT); 632 SetBkMode(fDDC, TRANSPARENT);
632 633
633 SkPoint h = SkPoint::Make(SK_Scalar1, 0); 634 SkPoint h = SkPoint::Make(SK_Scalar1, 0);
634 // A is the total matrix. 635 // A is the total matrix.
635 SkMatrix A; 636 SkMatrix A;
636 fRec.getSingleMatrix(&A); 637 fRec.getSingleMatrix(&A);
637 A.mapPoints(&h, 1); 638 A.mapPoints(&h, 1);
638 639
639 // Find the Given's matrix [[c, -s],[s, c]] which rotates the baseline vecto r h 640 // G is the Givens Matrix for A (rotational matrix where GA[0][1] == 0).
640 // (where the baseline is mapped to) to the positive horizontal axis.
641 const SkScalar& a = h.fX;
642 const SkScalar& b = h.fY;
643 SkScalar c, s;
644 if (0 == b) {
645 c = SkDoubleToScalar(_copysign(SK_Scalar1, a));
646 s = 0;
647 } else if (0 == a) {
648 c = 0;
649 s = SkDoubleToScalar(-_copysign(SK_Scalar1, b));
650 } else if (SkScalarAbs(b) > SkScalarAbs(a)) {
651 SkScalar t = a / b;
652 SkScalar u = SkDoubleToScalar(_copysign(SkScalarSqrt(SK_Scalar1 + t*t), b));
653 s = -1 / u;
654 c = -s * t;
655 } else {
656 SkScalar t = b / a;
657 SkScalar u = SkDoubleToScalar(_copysign(SkScalarSqrt(SK_Scalar1 + t*t), a));
658 c = 1 / u;
659 s = -c * t;
660 }
661
662 // G is the Given's Matrix for A (rotational matrix such that GA[0][1] == 0) .
663 SkMatrix G; 641 SkMatrix G;
664 G.setAll(c, -s, 0, 642 SkComputeGivensRotation(h, &G);
665 s, c, 0,
666 0, 0, SkScalarToPersp(SK_Scalar1));
667 643
668 // GA is the matrix A with rotation removed. 644 // GA is the matrix A with rotation removed.
669 SkMatrix GA(G); 645 SkMatrix GA(G);
670 GA.preConcat(A); 646 GA.preConcat(A);
671 647
672 // realTextSize is the actual device size we want (as opposed to the size th e user requested). 648 // realTextSize is the actual device size we want (as opposed to the size th e user requested).
673 // gdiTextSide is the size we request from GDI. 649 // gdiTextSide is the size we request from GDI.
674 // If the scale is negative, this means the matrix will do the flip anyway. 650 // If the scale is negative, this means the matrix will do the flip anyway.
675 SkScalar realTextSize = SkScalarAbs(GA.get(SkMatrix::kMScaleY)); 651 SkScalar realTextSize = SkScalarAbs(GA.get(SkMatrix::kMScaleY));
676 SkScalar gdiTextSize = SkScalarRoundToScalar(realTextSize); 652 SkScalar gdiTextSize = SkScalarRoundToScalar(realTextSize);
(...skipping 1962 matching lines...) Expand 10 before | Expand all | Expand 10 after
2639 2615
2640 private: 2616 private:
2641 SkTDArray<ENUMLOGFONTEX> fLogFontArray; 2617 SkTDArray<ENUMLOGFONTEX> fLogFontArray;
2642 }; 2618 };
2643 2619
2644 /////////////////////////////////////////////////////////////////////////////// 2620 ///////////////////////////////////////////////////////////////////////////////
2645 2621
2646 SkFontMgr* SkFontMgr_New_GDI() { 2622 SkFontMgr* SkFontMgr_New_GDI() {
2647 return SkNEW(SkFontMgrGDI); 2623 return SkNEW(SkFontMgrGDI);
2648 } 2624 }
OLDNEW
« no previous file with comments | « src/ports/SkFontHost_FreeType.cpp ('k') | src/utils/SkMatrix22.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698