aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2010-05-12 09:31:05 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2010-05-12 09:31:05 -0700
commit4701b5d25c5617888ea754f373946c57534750cb (patch)
tree38239363ca638a7616c164c671eef090a40d273b
parentff1f66966879e612660387285b7ead9c040ff88f (diff)
parentc5875bc07007dd8e8d5e913044b53031ebff8d12 (diff)
downloadskia-4701b5d25c5617888ea754f373946c57534750cb.tar.gz
merge from open-source master
Change-Id: Ic7024b390883841714ac6fb5f6a11f87a9f707a6
-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);