aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2010-05-12 10:13:53 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-05-12 10:13:53 -0700
commitd66241cf69bfb701f19b4c5d3804189dc6454426 (patch)
treec649c52fd3f6b1a59458704cdc45b8e1ad524140
parent74054d95b10bbd34ffbed078b1a673a9622c5281 (diff)
parent4701b5d25c5617888ea754f373946c57534750cb (diff)
downloadskia-d66241cf69bfb701f19b4c5d3804189dc6454426.tar.gz
am 4701b5d2: merge from open-source master
Merge commit '4701b5d25c5617888ea754f373946c57534750cb' into kraken * commit '4701b5d25c5617888ea754f373946c57534750cb': Corrected a bug in SkPaint::breakText. Added GetUnitsPerEM method to SkFontHost
-rw-r--r--include/core/SkFontHost.h10
-rw-r--r--src/core/SkPaint.cpp1
-rw-r--r--src/ports/SkFontHost_FreeType.cpp24
3 files changed, 35 insertions, 0 deletions
diff --git a/include/core/SkFontHost.h b/include/core/SkFontHost.h
index ec345839ad..84e575fec1 100644
--- a/include/core/SkFontHost.h
+++ b/include/core/SkFontHost.h
@@ -266,6 +266,16 @@ public:
static void SetSubpixelOrder(LCDOrder order);
static LCDOrder GetSubpixelOrder();
+
+ ///////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Return the number of font units per em.
+ *
+ * @param fontID the font to query.
+ * @return the number of font units per em or 0 on error.
+ */
+ static uint32_t GetUnitsPerEm(SkFontID fontID);
};
#endif
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index 3d85b8c839..604ed76999 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -906,6 +906,7 @@ size_t SkPaint::breakText(const void* textD, size_t length, SkScalar maxWidth,
if (this->isLinearText())
{
scale = fTextSize / kCanonicalTextSizeForPaths;
+ maxWidth = SkScalarMul(maxWidth, SkScalarDiv(kCanonicalTextSizeForPaths, fTextSize));
// this gets restored by restore
((SkPaint*)this)->setTextSize(SkIntToScalar(kCanonicalTextSizeForPaths));
}
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index 77c379720a..a03e63d9ec 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -227,6 +227,13 @@ static SkFaceRec* ref_ft_face(uint32_t fontID) {
args.stream = &rec->fFTStream;
}
+ if (gFTCount == 0) {
+ if (!InitFreetype()) {
+ return 0;
+ }
+ }
+ ++gFTCount;
+
FT_Error err = FT_Open_Face(gFTLibrary, &args, 0, &rec->fFace);
if (err) { // bad filename, try the default font
@@ -257,6 +264,10 @@ static void unref_ft_face(FT_Face face) {
}
FT_Done_Face(face);
SkDELETE(rec);
+
+ if (--gFTCount == 0) {
+ FT_Done_FreeType(gFTLibrary);
+ }
}
return;
}
@@ -291,6 +302,19 @@ void SkFontHost::FilterRec(SkScalerContext::Rec* rec) {
rec->setHinting(h);
}
+uint32_t SkFontHost::GetUnitsPerEm(SkFontID fontID) {
+ SkAutoMutexAcquire ac(gFTMutex);
+ SkFaceRec *rec = ref_ft_face(fontID);
+ uint16_t unitsPerEm = 0;
+
+ if (rec != NULL && rec->fFace != NULL) {
+ unitsPerEm = rec->fFace->units_per_EM;
+ unref_ft_face(rec->fFace);
+ }
+
+ return (uint32_t)unitsPerEm;
+}
+
SkScalerContext_FreeType::SkScalerContext_FreeType(const SkDescriptor* desc)
: SkScalerContext(desc) {
SkAutoMutexAcquire ac(gFTMutex);