OLD | NEW |
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" |
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 | 832 |
833 if (mx) { | 833 if (mx) { |
834 sk_bzero(mx, sizeof(*mx)); | 834 sk_bzero(mx, sizeof(*mx)); |
835 } | 835 } |
836 if (my) { | 836 if (my) { |
837 sk_bzero(my, sizeof(*my)); | 837 sk_bzero(my, sizeof(*my)); |
838 } | 838 } |
839 | 839 |
840 SkASSERT(fDDC); | 840 SkASSERT(fDDC); |
841 | 841 |
| 842 #ifndef SK_GDI_ALWAYS_USE_TEXTMETRICS_FOR_FONT_METRICS |
842 if (fType == SkScalerContext_Windows::kBitmap_Type) { | 843 if (fType == SkScalerContext_Windows::kBitmap_Type) { |
| 844 #endif |
843 if (mx) { | 845 if (mx) { |
844 mx->fTop = SkIntToScalar(-fTM.tmAscent); | 846 mx->fTop = SkIntToScalar(-fTM.tmAscent); |
845 mx->fAscent = SkIntToScalar(-fTM.tmAscent); | 847 mx->fAscent = SkIntToScalar(-fTM.tmAscent); |
846 mx->fDescent = -SkIntToScalar(fTM.tmDescent); | 848 mx->fDescent = -SkIntToScalar(fTM.tmDescent); |
847 mx->fBottom = SkIntToScalar(fTM.tmDescent); | 849 mx->fBottom = SkIntToScalar(fTM.tmDescent); |
848 mx->fLeading = SkIntToScalar(fTM.tmExternalLeading); | 850 mx->fLeading = SkIntToScalar(fTM.tmExternalLeading); |
849 } | 851 } |
850 | 852 |
851 if (my) { | 853 if (my) { |
852 my->fTop = SkIntToScalar(-fTM.tmAscent); | 854 my->fTop = SkIntToScalar(-fTM.tmAscent); |
853 my->fAscent = SkIntToScalar(-fTM.tmAscent); | 855 my->fAscent = SkIntToScalar(-fTM.tmAscent); |
854 my->fDescent = SkIntToScalar(-fTM.tmDescent); | 856 my->fDescent = SkIntToScalar(-fTM.tmDescent); |
855 my->fBottom = SkIntToScalar(fTM.tmDescent); | 857 my->fBottom = SkIntToScalar(fTM.tmDescent); |
856 my->fLeading = SkIntToScalar(fTM.tmExternalLeading); | 858 my->fLeading = SkIntToScalar(fTM.tmExternalLeading); |
857 my->fAvgCharWidth = SkIntToScalar(fTM.tmAveCharWidth); | 859 my->fAvgCharWidth = SkIntToScalar(fTM.tmAveCharWidth); |
| 860 my->fMaxCharWidth = SkIntToScalar(fTM.tmMaxCharWidth); |
| 861 my->fXMin = 0; |
| 862 my->fXMax = my->fMaxCharWidth; |
| 863 //my->fXHeight = 0; |
858 } | 864 } |
| 865 #ifndef SK_GDI_ALWAYS_USE_TEXTMETRICS_FOR_FONT_METRICS |
859 return; | 866 return; |
860 } | 867 } |
| 868 #endif |
861 | 869 |
862 OUTLINETEXTMETRIC otm; | 870 OUTLINETEXTMETRIC otm; |
863 | 871 |
864 uint32_t ret = GetOutlineTextMetrics(fDDC, sizeof(otm), &otm); | 872 uint32_t ret = GetOutlineTextMetrics(fDDC, sizeof(otm), &otm); |
865 if (GDI_ERROR == ret) { | 873 if (GDI_ERROR == ret) { |
866 LogFontTypeface::EnsureAccessible(this->getTypeface()); | 874 LogFontTypeface::EnsureAccessible(this->getTypeface()); |
867 ret = GetOutlineTextMetrics(fDDC, sizeof(otm), &otm); | 875 ret = GetOutlineTextMetrics(fDDC, sizeof(otm), &otm); |
868 } | 876 } |
869 if (sizeof(otm) != ret) { | 877 if (sizeof(otm) != ret) { |
870 return; | 878 return; |
871 } | 879 } |
872 | 880 |
873 if (mx) { | 881 if (mx) { |
874 mx->fTop = -fScale * otm.otmrcFontBox.left; | 882 mx->fTop = -fScale * otm.otmrcFontBox.left; |
875 mx->fAscent = -fScale * otm.otmAscent; | 883 mx->fAscent = -fScale * otm.otmAscent; |
876 mx->fDescent = -fScale * otm.otmDescent; | 884 mx->fDescent = -fScale * otm.otmDescent; |
877 mx->fBottom = fScale * otm.otmrcFontBox.right; | 885 mx->fBottom = fScale * otm.otmrcFontBox.right; |
878 mx->fLeading = fScale * otm.otmLineGap; | 886 mx->fLeading = fScale * otm.otmLineGap; |
879 } | 887 } |
880 | 888 |
881 if (my) { | 889 if (my) { |
| 890 #ifndef SK_GDI_ALWAYS_USE_TEXTMETRICS_FOR_FONT_METRICS |
882 my->fTop = -fScale * otm.otmrcFontBox.top; | 891 my->fTop = -fScale * otm.otmrcFontBox.top; |
883 my->fAscent = -fScale * otm.otmAscent; | 892 my->fAscent = -fScale * otm.otmAscent; |
884 my->fDescent = -fScale * otm.otmDescent; | 893 my->fDescent = -fScale * otm.otmDescent; |
885 my->fBottom = -fScale * otm.otmrcFontBox.bottom; | 894 my->fBottom = -fScale * otm.otmrcFontBox.bottom; |
886 my->fLeading = fScale * otm.otmLineGap; | 895 my->fLeading = fScale * otm.otmLineGap; |
887 my->fAvgCharWidth = fScale * otm.otmTextMetrics.tmAveCharWidth; | 896 my->fAvgCharWidth = fScale * otm.otmTextMetrics.tmAveCharWidth; |
| 897 my->fMaxCharWidth = fScale * otm.otmTextMetrics.tmMaxCharWidth; |
| 898 my->fXMin = fScale * otm.otmrcFontBox.left; |
| 899 my->fXMax = fScale * otm.otmrcFontBox.right; |
| 900 #endif |
888 my->fXHeight = fScale * otm.otmsXHeight; | 901 my->fXHeight = fScale * otm.otmsXHeight; |
889 } | 902 } |
890 } | 903 } |
891 | 904 |
892 ////////////////////////////////////////////////////////////////////////////////
//////// | 905 ////////////////////////////////////////////////////////////////////////////////
//////// |
893 | 906 |
894 static void build_power_table(uint8_t table[], float ee) { | 907 static void build_power_table(uint8_t table[], float ee) { |
895 for (int i = 0; i < 256; i++) { | 908 for (int i = 0; i < 256; i++) { |
896 float x = i / 255.f; | 909 float x = i / 255.f; |
897 x = sk_float_pow(x, ee); | 910 x = sk_float_pow(x, ee); |
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1903 return this->createFromStream(stream); | 1916 return this->createFromStream(stream); |
1904 } | 1917 } |
1905 | 1918 |
1906 private: | 1919 private: |
1907 SkTDArray<ENUMLOGFONTEX> fLogFontArray; | 1920 SkTDArray<ENUMLOGFONTEX> fLogFontArray; |
1908 }; | 1921 }; |
1909 | 1922 |
1910 SkFontMgr* SkFontMgr::Factory() { | 1923 SkFontMgr* SkFontMgr::Factory() { |
1911 return SkNEW(SkFontMgrGDI); | 1924 return SkNEW(SkFontMgrGDI); |
1912 } | 1925 } |
OLD | NEW |